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

Re: Re: git log -M -- filename is not working?

From
Jeff King <peff@peff.net>
Date
May 14, 2010, 04:55 UTC
Message-ID
<20100514045522.GE6075@coredump.intra.peff.net>
In-Reply-To
<19434.48308.815673.263230@winooski.ccs.neu.edu>
On Wed, May 12, 2010 at 10:35:32AM -0400, Eli Barzilay wrote:
Show 7 quoted lines
> But with `-p' it was doing something confusing: I used two files that
> were recently renamed, and the result was the correct log history, but
> the first patch that was shown (the rename) showed the two files as
> added.  (That's even when I added `-C' and `-M'.)  This happens even
> with a single path.  OTOH, using `--follow' with `-p' and a single
> path without your patch produces the expected result where the first
> patch is a rename (even without `-C'/`-M').
Ah, yeah, I see. The problem is that my code is doing something like:
  1. Do a sha1-only diff with our current path list.
  2. If there were any created files, they might be renames.
     Put aside the old diff results. Do a new diff, looking for renames.
  3. If there are renames, add them to our path list.
  4. Restore the old diff results.
  5. Proceed with other desired diff options (rename detection, showing
     patches, etc).

But the during step (5), remember that we are still working with the old diff results, which will not include the expanded path. Thus we won't consider the new path as a rename source, and will fail to find the rename.

The naive right way would be to re-do step (1) with the expanded path. But there is an optimization, since we can use the diff results from (2) directly, including avoiding re-doing the rename detection.

The only "downside" is that it means --follow actually impacts the diff generation by implying --find-copies-harder. And I put downside in quotes because it is probably not a big deal. We have already spent the CPU time to find the answer, so it is silly not to show it. I can't imagine why somebody would want --follow, but would _not_ want rename detection in the resulting diff.

Bo's version of the patch does that optimization. When I clean up the patch (probably sometime next week), I'll take those changes.

-Peff
Previous: Eli BarzilayNext: Eli Barzilay
Message 21 of 26 in “git log -M -- filename is not working?”
  1. Eugene SajineMay 7, 2010
  2. Jacob HelwigMay 7, 2010
  3. Eugene SajineMay 7, 2010
  4. Eli BarzilayMay 7, 2010
  5. Matthieu MoyMay 7, 2010
  6. Jakub NarebskiMay 7, 2010
  7. Jeff KingMay 8, 2010
  8. Eli BarzilayMay 8, 2010
  9. Jeff KingMay 8, 2010
  10. Junio C HamanoMay 8, 2010
  11. Eli BarzilayMay 8, 2010
  12. Jeff KingMay 12, 2010
  13. Eli BarzilayMay 12, 2010
  14. Jeff KingMay 12, 2010
  15. Jeff KingMay 12, 2010
  16. Eli BarzilayMay 12, 2010
  17. Bo YangMay 12, 2010
  18. Jeff KingMay 12, 2010
  19. Bo YangMay 13, 2010
  20. Eli BarzilayMay 13, 2010
  21. Jeff KingMay 14, 2010
  22. Eli BarzilayMay 14, 2010
  23. Bo YangMay 12, 2010
  24. Jeff KingMay 12, 2010
  25. Eli BarzilayMay 12, 2010
  26. Bo YangMay 12, 2010

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.