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

Cumulative "git read-tree -m" rejected with overwriting warning

From
Marcin Owsiany <marcin@owsiany.pl>
Date
Feb 13, 2013, 23:02 UTC
Message-ID
<20130213230213.GT20333@localhost>
Hello,
Consider the following use case:
  git init
  seq 0 9 > f
  git add f
  git commit -m start
  
  git checkout -b b1
  perl -pi -e 's,0,b1,' f
  git commit -a -m b1
  
  git checkout -b b2
  perl -pi -e 's,9,b2,' f
  git commit -a -m b2
  
  git checkout master
  git merge b1 b1

As the changes to "f" don't conflict, the octopus merge deals with them just fine, and I get a merge in a single commit object.

Now, let's say my b1 and b2 branches are a bit more special, and apart from the main contents (i.e. the "f" file), each branch contains a couple of files with branch-specific metadata. The names of those files are the same in each branch. (People familiar with topgit can probably guess I'm talking about topgit branches here.)

I'd like to merge all such branches into "master" in one octopus-like commit, but the metadata files introduce a conflict during simple octopus merge. However I don't care about that metadata when the branches are merged into "master", so I'm trying to write a script which would do such merge while discarding the metadata files.

The problem is, I cannot get it to work, when two branches modify the same file (like "f" above), even if the changes don't conflict. I get either:

error: Entry 'f' would be overwritten by merge. Cannot merge.
 - when trying to use the two-arg form of "git read-tree -m -i"
or:
f: needs merge
 - when trying to use the three-arg form
Attached is the minimal test case that reproduces the problem.

It might just be that git-read-tree cannot do what I need, and I'm just misinterpreting the meaning of:

 "the index file saves and restores with all this information, so you
 can merge things incrementally,"

which I took to mean that I can read from multiple trees one by one before writing the tree.

Could anyone give me some hints?
-- 
Marcin Owsiany <marcin@owsiany.pl>              http://marcin.owsiany.pl/
GnuPG: 2048R/02F946FC  35E9 1344 9F77 5F43 13DD  6423 DBF4 80C6 02F9 46FC

"Every program in development at MIT expands until it can read mail."
                                                              -- Unknown
Next: Junio C Hamano
Message 1 of 2 in “Cumulative "git read-tree -m" rejected with overwriting warning”
  1. Marcin OwsianyFeb 13, 2013
  2. Junio C HamanoFeb 13, 2013

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.