threads / bug / 49305

Fwd: [Possible GIT Bug]

Subject: Fwd: [Possible GIT Bug]

## tl;dr

6 messages between Sep 9, 2018 and Sep 10, 2018.

replies: 5people: 5as markdown or json

Dylan Young· Sep 9, 2018, 13:30 UTC · lore
Works:
git show -C --find-copies-harder  055f6c89fa4506037d1621761f13430f469b8029

git show -C --find-copies-harder 055f6c89fa4506037d1621761f13430f469b8029 --name-status

Doesn’t Work:

git show -C --find-copies-harder 055f6c89fa4506037d1621761f13430f469b8029 -- PATH_TO_MY_COPIED_FILE

i.e.
--- /dev/null
+++ b/ PATH_TO_MY_COPIED_FILE





Hope that’s self-explanatory!!!



Best,





Casey Meijer
Bryan Turner· Sep 9, 2018, 19:04 UTC · re: Dylan Young · lore

Re: [Possible GIT Bug]

On Sun, Sep 9, 2018 at 6:31 AM Dylan Young <dylanyoungmeijer@gmail.com> wrote:
Show 7 quoted lines
>
> Works:
>
> git show -C --find-copies-harder  055f6c89fa4506037d1621761f13430f469b8029
>
> git show -C --find-copies-harder
> 055f6c89fa4506037d1621761f13430f469b8029 --name-status

Here, because you didn't provide _any_ paths, Git is allowed to consider all of the paths modified in the commit and, because you specified --find-copies-harder, it's allowed to consider paths that _weren't_ modified too. That means it can "see" both the source and destination for the copy, and it detects the copy as you're expecting.

Show 5 quoted lines
>
> Doesn’t Work:
>
> git show -C --find-copies-harder
> 055f6c89fa4506037d1621761f13430f469b8029  --  PATH_TO_MY_COPIED_FILE

Here, though, you've _explicitly limited_ Git to only the copied file. It's not allowed to consider any others, which means it can't "see" the source path anymore. As a result, the copy is detected as a straight add. Note that --find-copies-harder means the diff machinery is allowed to consider files that weren't modified in the commit as possible sources for copies, but that's still subject to your explicit filtering. In other words, if PATH_TO_SOURCE_FILE wasn't modified, running this would _not_ see a copy:

git show -C 055f6c89fa4506037d1621761f13430f469b8029 -- PATH_TO_MY_COPIED_FILE PATH_TO_SOURCE_FILE

But running this would:

git show -C -C 055f6c89fa4506037d1621761f13430f469b8029 -- PATH_TO_MY_COPIED_FILE PATH_TO_SOURCE_FILE

No bugs here. Everything is working as intended, if not, perhaps, as you expected.

Hope this helps, Bryan

Show 11 quoted lines
>
> i.e.
>
> --- /dev/null
>
> +++ b/ PATH_TO_MY_COPIED_FILE
>
> Hope that’s self-explanatory!!!
>
> Best,
> Casey Meijer
Jeff King· Sep 10, 2018, 13:24 UTC · re: Bryan Turner · lore

Re: [Possible GIT Bug]

On Sun, Sep 09, 2018 at 12:04:58PM -0700, Bryan Turner wrote:
Show 19 quoted lines
> Here, though, you've _explicitly limited_ Git to only the copied file.
> It's not allowed to consider any others, which means it can't "see"
> the source path anymore. As a result, the copy is detected as a
> straight add. Note that --find-copies-harder means the diff machinery
> is allowed to consider files that weren't modified in the commit as
> possible sources for copies, but that's still subject to your explicit
> filtering. In other words, if PATH_TO_SOURCE_FILE wasn't modified,
> running this would _not_ see a copy:
> 
> git show -C 055f6c89fa4506037d1621761f13430f469b8029  --
> PATH_TO_MY_COPIED_FILE PATH_TO_SOURCE_FILE
> 
> But running this would:
> 
> git show -C -C 055f6c89fa4506037d1621761f13430f469b8029  --
> PATH_TO_MY_COPIED_FILE PATH_TO_SOURCE_FILE
> 
> No bugs here. Everything is working as intended, if not, perhaps, as
> you expected.

Your explanation is correct. To be fair, though, it seems like --find-copies-harder is made a lot less useful by the not considering the larger set of sources, since that's kind of its point. I'm not sure if this behavior actually is intentional, or simply what happens to occur based on the combination of features.

You can do:
  git log -C C --full-diff $commit -- $path

to limit a traversal to commits touching $path, but still see the full diff (including possible copy sources). But AFAIK there's no option to limit the diff, but include extra copy sources.

I'd be tempted to say we should do that automatically when --find-copies-harder is in effect, but it's possible that some people actually do want the current behavior. For a single path it's silly, but if you did something like this:

  git show -C -C $commit -- foo/

that would find differences in the foo/ directory, and find copies only from sources in foo/. That limits the result, but also limits the effort, which can be important given the cost of copy detection.

-Peff
Junio C Hamano· Sep 10, 2018, 16:03 UTC · re: Jeff King · lore

Re: [Possible GIT Bug]

Jeff King <peff@peff.net> writes:
Show 5 quoted lines
> Your explanation is correct. To be fair, though, it seems like
> --find-copies-harder is made a lot less useful by the not considering
> the larger set of sources, since that's kind of its point. I'm not sure
> if this behavior actually is intentional, or simply what happens to
> occur based on the combination of features.

It is neither but if I have to pick one between the two, it is much closer to the former than the latter. The primary source of this is that we have only *one* pathspec given to the diff machinery, but in order to implement your ideal "find harder", you'd need *two*. That is, one set of paths for which you are interested in their origin, and the other set that you allow the machinery to consider as possible origins. Since we can only give one pathspec machinery, that one pathspec is used to specify both of these sets.

Eckhard Maaß· Sep 10, 2018, 17:35 UTC · re: Junio C Hamano · lore

Re: [Possible GIT Bug]

On Mon, Sep 10, 2018 at 09:03:10AM -0700, Junio C Hamano wrote:
Show 8 quoted lines
> It is neither but if I have to pick one between the two, it is much
> closer to the former than the latter.  The primary source of this is
> that we have only *one* pathspec given to the diff machinery, but in
> order to implement your ideal "find harder", you'd need *two*.  That
> is, one set of paths for which you are interested in their origin,
> and the other set that you allow the machinery to consider as possible
> origins.  Since we can only give one pathspec machinery, that one
> pathspec is used to specify both of these sets.

How does tihs compare to `--follow`? With that knob active the machinery indeed uses the whole repository for finding renames and/or copies. Is this the only exception then?

Take care, Eckhard

Junio C Hamano· Sep 10, 2018, 18:37 UTC · re: Eckhard Maaß · lore

Re: [Possible GIT Bug]

"Eckhard Maaß" <eckhard.s.maass@googlemail.com> writes:
Show 13 quoted lines
> On Mon, Sep 10, 2018 at 09:03:10AM -0700, Junio C Hamano wrote:
>> It is neither but if I have to pick one between the two, it is much
>> closer to the former than the latter.  The primary source of this is
>> that we have only *one* pathspec given to the diff machinery, but in
>> order to implement your ideal "find harder", you'd need *two*.  That
>> is, one set of paths for which you are interested in their origin,
>> and the other set that you allow the machinery to consider as possible
>> origins.  Since we can only give one pathspec machinery, that one
>> pathspec is used to specify both of these sets.
>
> How does tihs compare to `--follow`? With that knob active the machinery
> indeed uses the whole repository for finding renames and/or copies. Is
> this the only exception then?

'--follow' is a checkbox hack that is not even properly integrated with the diff machinery (it only exists on the "log" side of the tool), so I do not think it is productive to find a comparison.

← back to recent threads