Subject: Re: [PATCH 2/2] range-diff: optionally accept a pathspec

From: Junio C Hamano <[email-masked]>
Date: Wed, 24 Aug 2022 14:00:11 -0700

"Johannes Schindelin via GitGitGadget" <[email-masked]>
writes:

> From: Johannes Schindelin <[email-masked]>
>
> 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 <[email-masked]>
> ---

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.

> 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.