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

Re: Merge after directory rename ?

From
Michael Witten <mfwitten@gmail.com>
Date
Aug 21, 2011, 23:45 UTC
Message-ID
<CAMOZ1BukGPZt8gJh0J4EHRrPHv5teAdnkNT+gZJa9mX=2ohFOw@mail.gmail.com>
In-Reply-To
<j2ru2h$cd$1@dough.gmane.org>
2011/8/21 Marcin Wiśnicki <mwisnicki@gmail.com>:
Show 14 quoted lines
> Is it possible to merge files after performing directory renames in such
> way that new files will end up in renamed directories ?
>
> For example:
> 1. [master]  add dir1/file1
> 2. [branch1] branch from master
> 3. [branch1] add dir1/file2
> 4. [master]  rename dir1 to dir2
> 5. [master]  merge branch1
>
> Where it should notice that dir1=>dir2 and therefore {dir1=>dir2}/file2.
>
> Currently I end up with dir1/file2 which is undesirable as it breaks
> refactorings and requires a lot of manual effort to clean-up.

Part of the assumption for someone working on `branch1' might be that `dir1/file2' is in fact in `dir1'. The rename via `master' conflicts with that assumption. In this case, a full-blown conflict might be useful.

However, suppose that the author who is working with `master' doesn't need `dir1', but the author who is working with `branch1' does need it INDEPENDENTLY:

  1. [master]  add dir2/file1
  2. [branch1] branch from master
  3. [branch1] add dir1/file2
  4. [master]  add dir1/file3
  5. [master]  rename dir1/file3 to dir3/file3
  6. [master]  merge branch1

In that case, you'd want `dir1/file2' from the `branch1' work to be silently created rather than automatically renamed to `dir3/file3'. This should not result in a conflict or a rename.

So, from your grievance, I suppose that git currently assumes the latter case (and hence, gives no indication of a possible conflict). Perhaps git could be improved here at least in terms of a warning. Perhaps the merger could request that directory renames be considered conflicts or enforced, but this would have to involve the intent of the merger me thinks (using command line flags).

Previous: Marcin WiśnickiNext: Michael Witten
Message 2 of 8 in “Merge after directory rename ?”
  1. Marcin WiśnickiAug 21, 2011
  2. Michael WittenAug 21, 2011
  3. Michael WittenAug 21, 2011
  4. Marcin WiśnickiAug 22, 2011
  5. Michael WittenAug 22, 2011
  6. Marcin WiśnickiAug 22, 2011
  7. Michael WittenAug 23, 2011
  8. Jeff KingAug 23, 2011

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.