2018-08-13 14:33:04 +03:00
|
|
|
#ifndef RANGE_DIFF_H
|
|
|
|
#define RANGE_DIFF_H
|
|
|
|
|
range-diff: also show the diff between patches
Just like tbdiff, we now show the diff between matching patches. This is
a "diff of two diffs", so it can be a bit daunting to read for the
beginner.
An alternative would be to display an interdiff, i.e. the hypothetical
diff which is the result of first reverting the old diff and then
applying the new diff.
Especially when rebasing frequently, an interdiff is often not feasible,
though: if the old diff cannot be applied in reverse (due to a moving
upstream), an interdiff can simply not be inferred.
This commit brings `range-diff` closer to feature parity with regard
to tbdiff.
To make `git range-diff` respect e.g. color.diff.* settings, we have
to adjust git_branch_config() accordingly.
Note: while we now parse diff options such as --color, the effect is not
yet the same as in tbdiff, where also the commit pairs would be colored.
This is left for a later commit.
Note also: while tbdiff accepts the `--no-patches` option to suppress
these diffs between patches, we prefer the `-s` (or `--no-patch`) option
that is automatically supported via our use of diff_opt_parse().
And finally note: to support diff options, we have to call
`parse_options()` such that it keeps unknown options, and then loop over
those and let `diff_opt_parse()` handle them. After that loop, we have
to call `parse_options()` again, to make sure that no unknown options
are left.
Helped-by: Thomas Gummerer <t.gummerer@gmail.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-13 14:33:07 +03:00
|
|
|
#include "diff.h"
|
2020-07-28 23:23:39 +03:00
|
|
|
#include "strvec.h"
|
range-diff: also show the diff between patches
Just like tbdiff, we now show the diff between matching patches. This is
a "diff of two diffs", so it can be a bit daunting to read for the
beginner.
An alternative would be to display an interdiff, i.e. the hypothetical
diff which is the result of first reverting the old diff and then
applying the new diff.
Especially when rebasing frequently, an interdiff is often not feasible,
though: if the old diff cannot be applied in reverse (due to a moving
upstream), an interdiff can simply not be inferred.
This commit brings `range-diff` closer to feature parity with regard
to tbdiff.
To make `git range-diff` respect e.g. color.diff.* settings, we have
to adjust git_branch_config() accordingly.
Note: while we now parse diff options such as --color, the effect is not
yet the same as in tbdiff, where also the commit pairs would be colored.
This is left for a later commit.
Note also: while tbdiff accepts the `--no-patches` option to suppress
these diffs between patches, we prefer the `-s` (or `--no-patch`) option
that is automatically supported via our use of diff_opt_parse().
And finally note: to support diff options, we have to call
`parse_options()` such that it keeps unknown options, and then loop over
those and let `diff_opt_parse()` handle them. After that loop, we have
to call `parse_options()` again, to make sure that no unknown options
are left.
Helped-by: Thomas Gummerer <t.gummerer@gmail.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-13 14:33:07 +03:00
|
|
|
|
2018-07-22 12:57:11 +03:00
|
|
|
#define RANGE_DIFF_CREATION_FACTOR_DEFAULT 60
|
|
|
|
|
2021-02-05 17:46:11 +03:00
|
|
|
struct range_diff_options {
|
|
|
|
int creation_factor;
|
|
|
|
unsigned dual_color:1;
|
2021-02-05 17:46:13 +03:00
|
|
|
unsigned left_only:1, right_only:1;
|
2021-02-05 17:46:11 +03:00
|
|
|
const struct diff_options *diffopt; /* may be NULL */
|
|
|
|
const struct strvec *other_arg; /* may be NULL */
|
|
|
|
};
|
|
|
|
|
2018-11-30 07:27:11 +03:00
|
|
|
/*
|
2021-02-05 17:46:11 +03:00
|
|
|
* Compare series of commits in `range1` and `range2`, and emit to the
|
|
|
|
* standard output.
|
2018-11-30 07:27:11 +03:00
|
|
|
*/
|
2018-08-13 14:33:04 +03:00
|
|
|
int show_range_diff(const char *range1, const char *range2,
|
2021-02-05 17:46:11 +03:00
|
|
|
struct range_diff_options *opts);
|
2018-08-13 14:33:04 +03:00
|
|
|
|
2021-01-27 19:37:22 +03:00
|
|
|
/*
|
|
|
|
* Determine whether the given argument is usable as a range argument of `git
|
2021-02-05 17:44:48 +03:00
|
|
|
* range-diff`, e.g. A..B.
|
2021-01-27 19:37:22 +03:00
|
|
|
*/
|
|
|
|
int is_range_diff_range(const char *arg);
|
|
|
|
|
2018-08-13 14:33:04 +03:00
|
|
|
#endif
|