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

RE: [BUG] All files in folder are moved when cherry-picking commit that moves fewer files

From
LNLinus Nilsson <linus.nilsson@trimma.se>
Date
Feb 28, 2019, 08:16 UTC
Message-ID
<67C5CE5D6EC13D4DB8FC51E2F9BD262F022B8B3599@Triton.ad.trimma.se>
In-Reply-To
<CABPp-BGOqQ0P8ywCK_sybPOeASxPnkTq7NXW8678f=345=68-Q@mail.gmail.com>
Thanks for the answers. So it seems it's not a bug, but may lead to new merge options. I worked around it anyway, so it was not a real problem.

Med vänlig hälsning Linus Nilsson

-----Original Message-----
From: Elijah Newren <newren@gmail.com> 
Sent: Wednesday, 27 February 2019 18:32
To: Jeff King <peff@peff.net>
Cc: Phillip Wood <phillip.wood@dunelm.org.uk>; Linus Nilsson <Linus.Nilsson@trimma.se>; git@vger.kernel.org
Subject: Re: [BUG] All files in folder are moved when cherry-picking commit that moves fewer files
On Wed, Feb 27, 2019 at 8:40 AM Jeff King <peff@peff.net> wrote:
Show 25 quoted lines
>
> On Wed, Feb 27, 2019 at 08:02:35AM -0800, Elijah Newren wrote:
>
> > > > I have found what I suspect to be a bug, or at least not 
> > > > desirable behavior in my case. In one branch, I have moved all 
> > > > files in a directory to another directory. The first directory 
> > > > is now empty in this branch (I haven't tested whether this is significant).
> > >
> > > I suspect that because you've moved all the files git thinks the 
> > > directory has been renamed and that's why it moves a/file2 when 
> > > fix is cherry-picked in the example below. I've cc'd Elijah as he 
> > > knows more about how the directory rename detection works.
> >
> > Yes, Phillip is correct.  If the branch you were 
> > merging/cherry-picking still had any files at all in the original 
> > directory, then no directory rename would be detected.  You can read 
> > up more details about how it works at 
> > https://git.kernel.org/pub/scm/git/git.git/tree/Documentation/techni
> > cal/directory-rename-detection.txt
>
> Is there a way to disable it (either by config, or for a single run)? 
> I know there's merge.renames, but it's plausible somebody might want 
> file-level renames but not directory-level ones.
>
> -Peff

Not yet. Adding such an option, similar in nature to the flags for turning off renaming detection entirely (merge.renames, diff.renames, -Xno-renames) would probably make sense (I don't see an analogy to -Xrename-threshold=, though). It might make sense as just an alternate setting of merge.renames or diff.renames, though it's possible that could get confusing with "copy" being an option. #leftoverbits for someone that wants to figure out what the option names and values should be?

Previous: Elijah NewrenNext: Junio C Hamano
Message 6 of 49 in “[BUG] All files in folder are moved when cherry-picking commit that moves fewer files”
  1. Linus NilssonFeb 27, 2019
  2. Phillip WoodFeb 27, 2019
  3. Elijah NewrenFeb 27, 2019
  4. Jeff KingFeb 27, 2019
  5. Elijah NewrenFeb 27, 2019
  6. Linus NilssonFeb 28, 2019
  7. Junio C HamanoMar 1, 2019
  8. Elijah NewrenMar 2, 2019
  9. Junio C HamanoMar 3, 2019
  10. Elijah NewrenMar 6, 2019
  11. Junio C HamanoMar 6, 2019
  12. Elijah NewrenMar 7, 2019
  13. Junio C HamanoMar 7, 2019
  14. Junio C HamanoMar 7, 2019
  15. 00/15 Switch directory rename detection defaultElijah Newren, Mar 30, 2019
  16. 08/15 merge-recursive: remove ren[12]_other fields from rename_conflict_infoElijah Newren, Mar 30, 2019
  17. 10/15 merge-recursive: cleanup handle_rename_* function signaturesElijah Newren, Mar 30, 2019
  18. 01/15 Use 'unsigned short' for mode, like diff_filespec doesElijah Newren, Mar 30, 2019
  19. 04/15 merge-recursive: rename locals 'o' and 'a' to 'obuf' and 'abuf'Elijah Newren, Mar 30, 2019
  20. 14/15 merge-recursive: give callers of handle_content_merge() access to contentsElijah Newren, Mar 30, 2019
  21. 11/15 merge-recursive: switch from (oid,mode) pairs to a diff_filespecElijah Newren, Mar 30, 2019
  22. 07/15 merge-recursive: shrink rename_conflict_infoElijah Newren, Mar 30, 2019
  23. 12/15 t6043: fix copied test description to match its purposeElijah Newren, Mar 30, 2019
  24. 09/15 merge-recursive: track branch where rename occurred in rename structElijah Newren, Mar 30, 2019
  25. 13/15 merge-recursive: track information associated with directory renamesElijah Newren, Mar 30, 2019
  26. 15/15 merge-recursive: switch directory rename detection defaultElijah Newren, Mar 30, 2019
  27. Ævar Arnfjörð BjarmasonMar 30, 2019
  28. Elijah NewrenApr 1, 2019
  29. 02/15 merge-recursive: rename merge_options argument from 'o' to 'opt'Elijah Newren, Mar 30, 2019
  30. 05/15 merge-recursive: use 'ci' for rename_conflict_info variable nameElijah Newren, Mar 30, 2019
  31. 03/15 merge-recursive: rename diff_filespec 'one' to 'o'Elijah Newren, Mar 30, 2019
  32. 06/15 merge-recursive: move some struct declarations togetherElijah Newren, Mar 30, 2019
  33. 00/15 Switch directory rename detection defaultElijah Newren, Apr 5, 2019
  34. 03/15 merge-recursive: rename diff_filespec 'one' to 'o'Elijah Newren, Apr 5, 2019
  35. 05/15 merge-recursive: use 'ci' for rename_conflict_info variable nameElijah Newren, Apr 5, 2019
  36. 09/15 merge-recursive: track branch where rename occurred in rename structElijah Newren, Apr 5, 2019
  37. 06/15 merge-recursive: move some struct declarations togetherElijah Newren, Apr 5, 2019
  38. 07/15 merge-recursive: shrink rename_conflict_infoElijah Newren, Apr 5, 2019
  39. 08/15 merge-recursive: remove ren[12]_other fields from rename_conflict_infoElijah Newren, Apr 5, 2019
  40. 04/15 merge-recursive: rename locals 'o' and 'a' to 'obuf' and 'abuf'Elijah Newren, Apr 5, 2019
  41. 15/15 merge-recursive: switch directory rename detection defaultElijah Newren, Apr 5, 2019
  42. 14/15 merge-recursive: give callers of handle_content_merge() access to contentsElijah Newren, Apr 5, 2019
  43. 12/15 t6043: fix copied test description to match its purposeElijah Newren, Apr 5, 2019
  44. 13/15 merge-recursive: track information associated with directory renamesElijah Newren, Apr 5, 2019
  45. 02/15 merge-recursive: rename merge_options argument from 'o' to 'opt'Elijah Newren, Apr 5, 2019
  46. 10/15 merge-recursive: cleanup handle_rename_* function signaturesElijah Newren, Apr 5, 2019
  47. 01/15 Use 'unsigned short' for mode, like diff_filespec doesElijah Newren, Apr 5, 2019
  48. 11/15 merge-recursive: switch from (oid,mode) pairs to a diff_filespecElijah Newren, Apr 5, 2019
  49. Jacob KellerApr 5, 2019

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.