Subject: Re: [PATCH] 2.36 gitk/diff-tree --stdin regression fix

From: Junio C Hamano <[email-masked]>
Date: Wed, 27 Apr 2022 13:03:41 -0700

René Scharfe <[email-masked]> writes:

>> +	if (prev_options_with_pathspec == options && !options->pathspec.nr)
>> +		BUG("reused struct diff_options, potentially lost pathspec");
>> +	if (options->pathspec.nr)
>> +		prev_options_with_pathspec = options;
>
> This can report a false positive if a diffopt is reused with different
> pathspecs, and one of them is empty (match all).  Which could be countered
> by using a fresh diffopt every time (e.g. pushing it into a loop).

The only use case to reset pathspec of a diffopt during iteration I
can think of is the hacky[*] version of "git log --follow" where the
pathspec is swapped when a rename of a single path being followed is
detected.

    Side note: hacky because the way it swaps a single pathspec upon
    seeing one rename means it does not work in a mergy-branchy
    history where one branch renames and there are still commits
    that need to be explored on the other branch that had the path
    under its original name.