Re: [PATCH 2/2] range-diff: optionally accept a pathspec
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 24, 2022, 21:00 UTC
- Message-ID
- <xmqqh7215pd0.fsf@gitster.g>
- In-Reply-To
- <064b147451b04051a413b532cd97ae764ba68027.1661258122.git.gitgitgadget@gmail.com>
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 32 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de> > > The `git range-diff` command can be quite expensive, which is not a > surprise given that the underlying algorithm to match up pairs of > commits between the provided two commit ranges has a cubic runtime. > > Therefore it makes sense to restrict the commit ranges as much as > possible, to reduce the amount of input to that O(N^3) algorithm. > > In chatty repositories with wide trees, this is not necessarily > possible merely by choosing commit ranges wisely. > > Let's give users another option to restrict the commit ranges: by > providing a pathspec. That helps in repositories with wide trees because > it is likely that the user has a good idea which subset of the tree they > are actually interested in. > > Example: > > git range-diff upstream/main upstream/seen HEAD -- range-diff.c > > This shows commits that are either in the local branch or in `seen`, but > not in `main`, skipping all commits that do not touch `range-diff.c`. > > Note: Since we piggy-back the pathspecs onto the `other_arg` mechanism > that was introduced to be able to pass through the `--notes` option to > the revision machinery, we must now ensure that the `other_arg` array is > appended at the end (the revision range must come before the pathspecs, > if any). > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > ---
It is excellent that this now takes pathspec to sparsify the history.
The implementation looks, eh, a bit dirty with obvious repetitions in the "..." case and two-ranges cases. Three-arg cases sort-of looks different but that is because the original one does not even bother to ensure argv[0] and argv[1] are objects, while the new one does, so they are essentially doing the same things.
Show 9 quoted lines
> diff --git a/Documentation/git-range-diff.txt b/Documentation/git-range-diff.txt > index fe350d7f405..0b393715d70 100644 > --- a/Documentation/git-range-diff.txt > +++ b/Documentation/git-range-diff.txt > @@ -12,6 +12,7 @@ SYNOPSIS > [--no-dual-color] [--creation-factor=<factor>] > [--left-only | --right-only] > ( <range1> <range2> | <rev1>...<rev2> | <base> <rev1> <rev2> ) > + [[--] <path>...]
OK.