git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Previous: Johannes Schindelin via GitGitGadgetNext: Johannes Schindelin via GitGitGadget
Message 4 of 10 in “Allow passing pathspecs to git range-diff”
  1. 0/2 Allow passing pathspecs to git range-diffJohannes Schindelin via GitGitGadget, Aug 23, 2022
  2. 1/2 range-diff: reorder argument handlingJohannes Schindelin via GitGitGadget, Aug 23, 2022
  3. 2/2 range-diff: optionally accept a pathspecJohannes Schindelin via GitGitGadget, Aug 23, 2022
  4. Junio C HamanoAug 24, 2022
  5. 0/3 Allow passing pathspecs to git range-diffJohannes Schindelin via GitGitGadget, Aug 26, 2022
  6. 1/3 range-diff: reorder argument handlingJohannes Schindelin via GitGitGadget, Aug 26, 2022
  7. 2/3 range-diff: consistently validate the argumentsJohannes Schindelin via GitGitGadget, Aug 26, 2022
  8. Junio C HamanoAug 26, 2022
  9. 3/3 range-diff: optionally accept pathspecsJohannes Schindelin via GitGitGadget, Aug 26, 2022
  10. Junio C HamanoAug 26, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.