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

Re: [Possible GIT Bug]

From
Bryan Turner <bturner@atlassian.com>
Date
Sep 9, 2018, 19:04 UTC
Message-ID
<CAGyf7-EFiZ7ouUPDMtv3eb57QEiM2pkavyKQe7iNO7+eBeuZ9w@mail.gmail.com>
In-Reply-To
<CAPGJNu5=GkiALR1=RYgHLv3NDrycqv13jpU5_=SOW-yWtRXduw@mail.gmail.com>
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
Previous: Dylan YoungNext: Jeff King
Message 2 of 6 in “Fwd: [Possible GIT Bug]”
  1. Dylan YoungSep 9, 2018
  2. Bryan TurnerSep 9, 2018
  3. Jeff KingSep 10, 2018
  4. Junio C HamanoSep 10, 2018
  5. Eckhard MaaßSep 10, 2018
  6. Junio C HamanoSep 10, 2018

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.