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

merge recursive and code movement

From
Jay Soffian <jaysoffian@gmail.com>
Date
Mar 24, 2011, 21:18 UTC
Message-ID
<AANLkTi=h6jUsjqXofd0QeWbNBjc9DeodJJ3FN7caW4XC@mail.gmail.com>

There's a use case that merge recursive doesn't seem to handle, and I wonder how difficult it would be to add.

Say you have a merge between OURS and THEIRS, with common ancestor BASE.
Between BASE and THEIRS, a file named header.h has the following changes:
  # Rename header.h to header_new.h
  git mv header.h header_new.h
  # Minor edits to account for the rename such as fixing the
  # include guard:
  perl -pi -e 's/HEADER_H_/HEADER_NEW_H_/' header_new.h
  # Drop a compatibility header.h in place till we can fix all the
  # files which include header.h
  cat > header.h <<-__EOF__
	#ifndef HEADER_H_
	#define HEADER_H_
	#include "header_hew.h"
	#endif // HEADER_H_
  __EOF__
  git add header.h header_new.h
  git commit -m 'rename header.h to header_new.h'

Meanwhile, between BASE and OURS, a few minor changes are made to header.h. This could be as little as a single line change in the middle of the header.h.

Now you merge THEIRS to OURS. Git will just show header.h in conflict. 99% of the time I can do the following:

  git diff MERGE_BASE... header.h | patch header_new.h
  git checkout --theirs header.h
  git add header.h header_new.h

But it would seem like this is something merge recursive should be capable of handling on its own.

j.
Next: Jeff King
Message 1 of 14 in “merge recursive and code movement”
  1. Jay SoffianMar 24, 2011
  2. Jeff KingMar 25, 2011
  3. Jeff KingMar 25, 2011
  4. Jeff KingMar 25, 2011
  5. Jeff KingMar 25, 2011
  6. 1/3 t3030: fix accidental success in symlink renameJeff King, Mar 25, 2011
  7. Junio C HamanoMar 25, 2011
  8. Jeff KingMar 25, 2011
  9. Schalk, KenMar 25, 2011
  10. 2/3 merge: handle renames with replacement contentJeff King, Mar 25, 2011
  11. 3/3 merge: turn on rewrite detectionJeff King, Mar 25, 2011
  12. Jay SoffianMar 25, 2011
  13. Techlive ZhengJul 16, 2012
  14. Jeff KingJul 16, 2012

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.