git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Hakim Cassimally <hakim.cassimally@gmail.com>
Cc: git@vger.kernel.org, Sam Vilain <sam@vilain.net>
Subject: Re: git-cherry-pick problem - directory not touched by commit is  marked "added by us"
Date: Wed, 06 Jan 2010 19:30:46 -0800	[thread overview]
Message-ID: <7v4omyfv6h.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <82cfa8031001060328r21aa8de3s5c2dd5dac005b679@mail.gmail.com> (Hakim Cassimally's message of "Wed\, 6 Jan 2010 11\:28\:44 +0000")

Hakim Cassimally <hakim.cassimally@gmail.com> writes:

>>>     (stable) $ git cherry-pick 301afce1
>>>     Finished one cherry-pick.
>>>     www/client/css/admin.css: needs merge
>>>         <...snip>
>>>     www/client/css/admin.css: unmerged (8e7cd850bf40d1a921b1f62ce0945abd374fa55d)
>>>         <...snip>
>>>     ...
>>>     error: Error building trees
>>
>  $ git ls-files -s -u www/client/css/admin.css # only staged/unmerged
>   100755 8e7cd850bf40d1a921b1f62ce0945abd374fa55d 2
> www/client/css/admin.css
>
> (i.e. when run after the failed cherry-pick)
>
>> Also take the 'git ls-tree -r HEAD', 'git ls-tree -r 301afce1' and 'git
>> ls-tree -r 301afce1^' output, and grep for the files in question.  The
>> answer (or at least a bug triage) should be in the output of those
>> commands.
>
>   $ git ls-tree HEAD | grep www/client/css/admin.css
>   100755 blob 8e7cd850bf40d1a921b1f62ce0945abd374fa55d
> www/client/css/admin.css
>
> There's no entry in git ls-tree 301afce1 or 301afce1^1 though.  I'd
> guess that's significant, but I don't know what answer it suggests...
>
> (However the file exists in both (stable) and (experimental)...
> and is identical in both).
> ....

So in short:

 * commit 301a added a new path bin/upload_module.pl;

 * the state you cherry-picked this commit to was clean (i.e. before
   running cherry-pick, "git status" reported no local changes to the
   index nor to the work tree);

 * the commit, the index, and the work tree before running this
   cherry-pick had www/client/css/admin.css file, which also existed in
   301a and 301a^, but all of these three commits had the same contents.

A simple minded attempt to reproduce this (attached below) by preparing a
commit that adds one new file and attempting to transplant to an unrelated
commit that doesn't have the file didn't work; I have been scratching my
head.

What "cherry-pick" internally does is to run:

    git merge-recursive 301a^ -- HEAD 301a

That is, "We are at HEAD; consolidate the change since 301a^ to 301a into
our state, and leave the result in the index and the work tree".  Then it
commits the result.  One thing to try is to see if this gives the same
kind of breakage.

The only other thing that _may_ be involved is if there are paths that
turned between directories and files on the two histories, or perhaps
there are paths like "www-frotz", "www.frotz", etc (i.e. "www" followed by
a byte whose ASCII value comes before '/') involved, and unpack_trees()
machinery the merge-recursive internally uses are getting confused about
D/F conflicts.  To diagnose it, it would be helpful to get the full output
from these two commands:

    git ls-tree -r -t HEAD (before cherry-pick)
    git ls-tree -r -t 301a (the commit you are transplanting)

Thanks

---

diff --git a/t/t3506-cherry-pick-addremove.sh b/t/t3506-cherry-pick-addremove.sh
new file mode 100755
index 0000000..e7dcd77
--- /dev/null
+++ b/t/t3506-cherry-pick-addremove.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+test_description='unrelated files added by our side'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+	test_commit A &&
+	git branch side &&
+	test_commit B &&
+	test_commit C &&
+
+	git checkout side &&
+	test_commit D &&
+	test_commit E &&
+
+	git checkout master
+'
+
+test_expect_success 'cherry-pick' '
+	git reset --hard C &&
+	git cherry-pick side &&
+	git grep E E.t
+'
+
+test_done

  reply	other threads:[~2010-01-07  3:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-05 12:33 git-cherry-pick problem - directory not touched by commit is marked "added by us" Hakim Cassimally
2010-01-05 21:37 ` Sam Vilain
2010-01-06 11:28   ` Hakim Cassimally
2010-01-07  3:30     ` Junio C Hamano [this message]
2010-01-07  3:35       ` Junio C Hamano
2010-01-08 22:29         ` Hakim Cassimally

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v4omyfv6h.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=hakim.cassimally@gmail.com \
    --cc=sam@vilain.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).