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

correct git merge behavior or corner case?

From
FBFrançois Beausoleil <francois@teksol.info>
Date
Apr 20, 2009, 14:50 UTC
Message-ID
<2FE32A75-C0D9-4156-B5D2-61AC6C086E5F@teksol.info>
Hi all,
I'm the author of http://blog.teksol.info/2009/04/15/beware-of-gits-content-tracking.html

In http://article.gmane.org/gmane.comp.version-control.git/116954, Johannes was very critical of me, so here's the full story.

I cloned the repository and branched master to do some integration work. On the integration branch, I created an empty file. At one point, I merged from master and had some conflicts. While resolving the conflicts, I happened to notice a file that didn't exist on master had been modified.

Full transcript follows:

$ git checkout -b merge-tracking-reproduce 5b8520419833635c61bdfb9abbbdc086df512388 # integration branch $ git merge 5ed60ecabd585972003084e07401f598d00f5a1d # master branch

$ git status # On branch merge-tracking-reproduce # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # ... # modified: vendor/plugins/acts_as_money/LICENSE # # Changed but not updated: # (use "git add <file>..." to update what will be committed) # ... a couple of conflicts, they don't matter

$ git diff --cached vendor/plugins/acts_as_money/LICENSE
diff --git a/vendor/plugins/acts_as_money/LICENSE b/vendor/plugins/ 
acts_as_money/LICENSE
index e69de29..a273c73 100644
--- a/vendor/plugins/acts_as_money/LICENSE
+++ b/vendor/plugins/acts_as_money/LICENSE
@@ -0,0 +1,4 @@
+one:
+  user: active
+  name: name
+  description: description

$ git log 5b8520419833635c61bdfb9abbbdc086df512388 -- vendor/plugins/ 
acts_as_money/LICENSE # on integration branch
commit c25787637b6ac5d8f0783cf1688c9ce6fb135659
Author: François Beausoleil <francois@teksol.info>
Date:   Thu Apr 9 14:15:03 2009 -0400

     Added Quirky dependencies

$ git log 5ed60ecabd585972003084e07401f598d00f5a1d -- vendor/plugins/ 
acts_as_money/LICENSE # on master branch
# empty, no file by that name on master

$ git log "-Sdescription: description"  
5b8520419833635c61bdfb9abbbdc086df512388 # on integration branch

$ git log "-Sdescription: description"  
5ed60ecabd585972003084e07401f598d00f5a1d # on master branch
commit 36d2a29d0c3c3a2a51db5f3be9faea7cea7ff3c1
Author: Michael Lacy <mike@kluster.com>
Date:   Tue Apr 14 10:16:50 2009 -0400

     quirky voting

$ git diff 36d2a29d0c3c3a2a51db5f3be9faea7cea7ff3c1^.. 
36d2a29d0c3c3a2a51db5f3be9faea7cea7ff3c1 -- vendor/gems/thoughtbot- 
shoulda-2.10.1/test/fixtures/products.yml
diff --git a/vendor/gems/thoughtbot-shoulda-2.10.1/test/fixtures/ 
products.yml b/vendor/gems/thoughtbot-shoulda-2.10.1/test/fixtures/
index e69de29..a273c73 100644
--- a/vendor/gems/thoughtbot-shoulda-2.10.1/test/fixtures/products.yml
+++ b/vendor/gems/thoughtbot-shoulda-2.10.1/test/fixtures/products.yml
@@ -0,0 +1,4 @@
+one:
+  user: active
+  name: name
+  description: description

Regarding Anders reproduction recipe, no file was deleted.  I'm trying  
to write a reproduction script, but haven't managed to reproduce it  
just yet.  The steps I *think* happened are thus:

cd $(mktemp -d repo.XXXXXX)
git init
touch README
git add README
git commit --message "First commit"
git checkout -b integration
mkdir -p vendor/a
touch vendor/a/LICENSE
git add vendor/a/LICENSE
git commit --message "Adding LICENSE"
git checkout master
mkdir -p vendor/b
touch vendor/b/COPYING
git add vendor/b/COPYING
git commit --message "Adding COPYING"
echo "adding some content" > vendor/b/COPYING
git commit --all --message "Updated COPYING"
git checkout integration
git merge master
git diff HEAD^..HEAD

But the bug isn't reproduced with these steps.  If you want access to  
the repository, please contact me privately and I'll give you access.

Johannes, you were right: I should have found the right avenue for  
posting this question and done so.  If not immediately, at least the  
next day.  It was late, I had other things to do, I just decided to  
post a quick note.  Call me lazy, yes.  Incompetent, that's going a  
bit too far.  I hope my competence can be redeemed in your eyes.

Have a nice day!
--
François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/
Next: Jeff King
Message 1 of 2 in “correct git merge behavior or corner case?”
  1. François BeausoleilApr 20, 2009
  2. Jeff KingApr 21, 2009

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.