1. 30 Nov, 2018 1 commit
    • Junio C Hamano's avatar
      format-patch: do not let its diff-options affect --range-diff · d8981c3f
      Junio C Hamano authored
      Stop leaking how the primary output of format-patch is customized to
      the range-diff machinery and instead let the latter use its own
      "reasonable default", in order to correct the breakage introduced by
      a5170794 ("Merge branch 'ab/range-diff-no-patch'", 2018-11-18) on
      the 'master' front.  "git format-patch --range-diff..." without any
      weird diff option started to include the "range-diff --stat" output,
      which is rather useless right now, that made the whole thing
      unusable and this is probably the least disruptive way to whip the
      codebase into a shippable shape.
      
      We may want to later make the range-diff driven by format-patch more
      configurable, but that would have to wait until we have a good
      design.
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      d8981c3f
  2. 14 Nov, 2018 1 commit
    • Ævar Arnfjörð Bjarmason's avatar
      range-diff: make diff option behavior (e.g. --stat) consistent · a48e12ef
      Ævar Arnfjörð Bjarmason authored
      Make the behavior when diff options (e.g. "--stat") are passed
      consistent with how "diff" behaves.
      
      Before 73a834e9 ("range-diff: relieve callers of low-level
      configuration burden", 2018-07-22) running range-diff with "--stat"
      would produce stat output and the diff output, as opposed to how
      "diff" behaves where once "--stat" is specified "--patch" also needs
      to be provided to emit the patch output.
      
      As noted in a previous change ("range-diff doc: add a section about
      output stability", 2018-11-07) the "--stat" output with "range-diff"
      is useless at the moment.
      
      But we should behave consistently with "diff" in anticipation of such
      output being useful in the future, because it would make for confusing
      UI if "diff" and "range-diff" behaved differently when it came to how
      they interpret diff options.
      
      The new behavior is also consistent with the existing documentation
      added in ba931edd ("range-diff: populate the man page",
      2018-08-13). See "[...]also accepts the regular diff options[...]" in
      git-range-diff(1).
      Signed-off-by: Ævar Arnfjörð Bjarmason's avatarÆvar Arnfjörð Bjarmason <avarab@gmail.com>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      a48e12ef
  3. 12 Nov, 2018 1 commit
  4. 05 Nov, 2018 1 commit
    • Jeff King's avatar
      range-diff: use a hunk callback · d2eb8093
      Jeff King authored
      When we count the lines in a diff, we don't actually care about the
      contents of each line. By using a hunk callback, we tell xdiff that it
      does not need to even bother generating a hunk header line, saving a
      small amount of work.
      
      Arguably we could even ignore the hunk headers completely, since we're
      just computing a cost function between patches. But doing it this way
      maintains the exact same behavior before and after.
      Signed-off-by: 's avatarJeff King <peff@peff.net>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      d2eb8093
  5. 02 Nov, 2018 1 commit
    • Jeff King's avatar
      xdiff-interface: provide a separate consume callback for hunks · 9346d6d1
      Jeff King authored
      The previous commit taught xdiff to optionally provide the hunk header
      data to a specialized callback. But most users of xdiff actually use our
      more convenient xdi_diff_outf() helper, which ensures that our callbacks
      are always fed whole lines.
      
      Let's plumb the special hunk-callback through this interface, too. It
      will follow the same rule as xdiff when the hunk callback is NULL (i.e.,
      continue to pass a stringified hunk header to the line callback). Since
      we add NULL to each caller, there should be no behavior change yet.
      Signed-off-by: 's avatarJeff King <peff@peff.net>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      9346d6d1
  6. 25 Oct, 2018 1 commit
    • Lucas De Marchi's avatar
      range-diff: allow to diff files regardless of submodule config · 0e573e8f
      Lucas De Marchi authored
      If we have `submodule.diff = log' in the configuration file
      or `--submodule=log' is given as argument, range-diff fails
      to compare both diffs and we only get the following output:
      
          Submodule a 0000000...0000000 (new submodule)
      
      Even if the repository doesn't have any submodule.
      
      That's because the mode in diff_filespec is not correct and when
      flushing the diff, down in builtin_diff() we will enter the condition:
      
      	if (o->submodule_format == DIFF_SUBMODULE_LOG &&
      	    (!one->mode || S_ISGITLINK(one->mode)) &&
      	    (!two->mode || S_ISGITLINK(two->mode))) {
      		show_submodule_summary(o, one->path ? one->path : two->path,
      				&one->oid, &two->oid,
      				two->dirty_submodule);
      		return;
      
      It turns out that S_ISGITLINK will return true (mode == 0160000 here).
      Similar thing happens if submodule.diff is "diff".
      
      Do like it's done in grep.c when calling fill_filespec() and force it to
      be recognized as a file by adding S_IFREG to the mode.
      Signed-off-by: 's avatarLucas De Marchi <lucas.demarchi@intel.com>
      Acked-by: Johannes Schindelin's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      0e573e8f
  7. 20 Aug, 2018 2 commits
    • Stefan Beller's avatar
      range-diff: indent special lines as context · 2543a641
      Stefan Beller authored
      The range-diff coloring is a bit fuzzy when it comes to special lines of
      a diff, such as indicating new and old files with +++ and ---, as it
      would pickup the first character and interpret it for its coloring, which
      seems annoying as in regular diffs, these lines are colored bold via
      DIFF_METAINFO.
      
      By indenting these lines by a white space, they will be treated as context
      which is much more useful, an example [1] on the range diff series itself:
      
      [...]
          + diff --git a/Documentation/git-range-diff.txt b/Documentation/git-range-diff.txt
          + new file mode 100644
          + --- /dev/null
          + +++ b/Documentation/git-range-diff.txt
          +@@
          ++git-range-diff(1)
      [...]
          +
            diff --git a/Makefile b/Makefile
            --- a/Makefile
            +++ b/Makefile
      [...]
      
      The first lines that introduce the new file for the man page will have the
      '+' sign colored and the rest of the line will be bold.
      
      The later lines that indicate a change to the Makefile will be treated as
      context both in the outer and inner diff, such that those lines stay
      regular color.
      
      [1] ./git-range-diff pr-1/dscho/branch-diff-v3...pr-1/dscho/branch-diff-v4
          These tags are found at https://github.com/gitgitgadget/gitSigned-off-by: Stefan Beller's avatarStefan Beller <sbeller@google.com>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      2543a641
    • Stefan Beller's avatar
      range-diff: make use of different output indicators · 8d5ccb59
      Stefan Beller authored
      This change itself only changes the internal communication and should
      have no visible effect to the user. We instruct the diff code that
      produces the inner diffs to use other markers instead of the
      usual markers for new, old and context lines.
      Signed-off-by: Stefan Beller's avatarStefan Beller <sbeller@google.com>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      8d5ccb59
  8. 14 Aug, 2018 2 commits
  9. 13 Aug, 2018 8 commits
    • Johannes Schindelin's avatar
      range-diff: left-pad patch numbers · d1f87a2d
      Johannes Schindelin authored
      As pointed out by Elijah Newren, tbdiff has this neat little alignment
      trick where it outputs the commit pairs with patch numbers that are
      padded to the maximal patch number's width:
      
      	  1: cafedead =   1: acefade first patch
      	[...]
      	314: beefeada < 314: facecab up to PI!
      
      Let's do the same in range-diff, too.
      Signed-off-by: Johannes Schindelin's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      d1f87a2d
    • Johannes Schindelin's avatar
      range-diff: use color for the commit pairs · faa1df86
      Johannes Schindelin authored
      Arguably the most important part of `git range-diff`'s output is the
      list of commits in the two branches, together with their relationships.
      
      For that reason, tbdiff introduced color-coding that is pretty
      intuitive, especially for unchanged patches (all dim yellow, like the
      first line in `git show`'s output) vs modified patches (old commit is
      red, new commit is green). Let's imitate that color scheme.
      Signed-off-by: Johannes Schindelin's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      faa1df86
    • Johannes Schindelin's avatar
      range-diff: do not show "function names" in hunk headers · 4eba1fe6
      Johannes Schindelin authored
      We are comparing complete, formatted commit messages with patches. There
      are no function names here, so stop looking for them.
      Signed-off-by: Johannes Schindelin's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      4eba1fe6
    • Johannes Schindelin's avatar
      range-diff: adjust the output of the commit pairs · eb0be38c
      Johannes Schindelin authored
      This not only uses "dashed stand-ins" for "pairs" where one side is
      missing (i.e. unmatched commits that are present only in one of the two
      commit ranges), but also adds onelines for the reader's pleasure.
      
      This change brings `git range-diff` yet another step closer to
      feature parity with tbdiff: it now shows the oneline, too, and indicates
      with `=` when the commits have identical diffs.
      Signed-off-by: Johannes Schindelin's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      eb0be38c
    • Johannes Schindelin's avatar
      range-diff: right-trim commit messages · a142f978
      Johannes Schindelin authored
      When comparing commit messages, we need to keep in mind that they are
      indented by four spaces. That is, empty lines are no longer empty, but
      have "trailing whitespace". When displaying them in color, that results
      in those nagging red lines.
      
      Let's just right-trim the lines in the commit message, it's not like
      trailing white-space in the commit messages are important enough to care
      about in `git range-diff`.
      Signed-off-by: Johannes Schindelin's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      a142f978
    • Johannes Schindelin's avatar
      range-diff: also show the diff between patches · c8c5e43a
      Johannes Schindelin authored
      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: 's avatarThomas Gummerer <t.gummerer@gmail.com>
      Helped-by: Eric Sunshine's avatarEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: Johannes Schindelin's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      c8c5e43a
    • Johannes Schindelin's avatar
      range-diff: improve the order of the shown commits · 9dc46e02
      Johannes Schindelin authored
      This patch lets `git range-diff` use the same order as tbdiff.
      
      The idea is simple: for left-to-right readers, it is natural to assume
      that the `git range-diff` is performed between an older vs a newer
      version of the branch. As such, the user is probably more interested in
      the question "where did this come from?" rather than "where did that one
      go?".
      
      To that end, we list the commits in the order of the second commit range
      ("the newer version"), inserting the unmatched commits of the first
      commit range as soon as all their predecessors have been shown.
      Signed-off-by: Johannes Schindelin's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      9dc46e02
    • Johannes Schindelin's avatar
      range-diff: first rudimentary implementation · d9c66f0b
      Johannes Schindelin authored
      At this stage, `git range-diff` can determine corresponding commits
      of two related commit ranges. This makes use of the recently introduced
      implementation of the linear assignment algorithm.
      
      The core of this patch is a straight port of the ideas of tbdiff, the
      apparently dormant project at https://github.com/trast/tbdiff.
      
      The output does not at all match `tbdiff`'s output yet, as this patch
      really concentrates on getting the patch matching part right.
      
      Note: due to differences in the diff algorithm (`tbdiff` uses the Python
      module `difflib`, Git uses its xdiff fork), the cost matrix calculated
      by `range-diff` is different (but very similar) to the one calculated
      by `tbdiff`. Therefore, it is possible that they find different matching
      commits in corner cases (e.g. when a patch was split into two patches of
      roughly equal length).
      Signed-off-by: Johannes Schindelin's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      d9c66f0b