Skip to contentSkip to conversation

cherry-pick fail when a symbolic link has been changed into a file or directory

DISCUSSION Camille Moncelier 3 participants 10 messages Jun 15, 2016 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

I'm reposting this since I didn't get any responses and I think my message didn't contained enought context.

I think I may have spotted a bug, or a unhandled case when doing a cherry-pick

Consider a repository like this:

# Initialize a dummy repository
mkdir -p repo1 ; cd repo1
git init .

# Create a new directory dir1' and a link to it dir2'
mkdir dir1
echo file1 > dir1/file1
ln -s dir1 dir2
git add dir1 dir2
git commit -m "Initial status: dir2 -> dir1"

# Create a branch named test1' remove the dir2' link and

# replace it by a new directory
    git checkout -b test1
    git rm dir2
    mkdir dir2
    touch file2 > dir2/file1
    git add dir2/file1
    git commit -m "Removing link: dir1/ and dir2/"

# Now create a new file in `test1' branch
message="New file in test1"
echo $message > new_file_test1
git add new_file_test1
git commit -m "$message"

# Now try to cherry-pick last commit from `test1' into master
git co master
git cherry-pick test1

The cherry-pick fails saying if failed to merge dir2' despite the fact that the commit doesn't affect dir2' and

git diff test1~..test1 | git apply

is working. Am I doing something wrong ?

Signature · 2 lines
Camille Moncelier
http://devlife.org
#1 lore raw

Could you try to cherry-pick with other strategies? For example with:

git cherry-pick --strategy resolve test1

I remember there were some problems with the default "recursive" strategy and I am not sure they were fixed.
By the way could you tell which version of git you are using?

Thanks,
Christian.

Quoted 54 lines · Camille Moncelier

I'm reposting this since I didn't get any responses and I think my message didn't contained enought context.

I think I may have spotted a bug, or a unhandled case when doing a cherry-pick

Consider a repository like this:

# Initialize a dummy repository
   mkdir -p repo1 ; cd repo1
   git init .

# Create a new directory dir1' and a link to it dir2' mkdir dir1
   echo file1 > dir1/file1
   ln -s dir1 dir2
   git add dir1 dir2
   git commit -m "Initial status: dir2 -> dir1"

# Create a branch named test1' remove the dir2' link and

# replace it by a new directory
   git checkout -b test1
   git rm dir2
   mkdir dir2
   touch file2 > dir2/file1
   git add dir2/file1
   git commit -m "Removing link: dir1/ and dir2/"

# Now create a new file in `test1' branch
   message="New file in test1"
   echo $message > new_file_test1
   git add new_file_test1
   git commit -m "$message"

# Now try to cherry-pick last commit from `test1' into master git co master
   git cherry-pick test1

The cherry-pick fails saying if failed to merge dir2' despite the fact that the commit doesn't affect dir2' and

git diff test1~..test1 | git apply

is working. Am I doing something wrong ?

--
Camille Moncelier
http://devlife.org

--
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 4 lines · On Thu, 4 Nov 2010 14:55:12 +0100 Christian Couder…

Could you try to cherry-pick with other strategies? For example with:

git cherry-pick --strategy resolve test1

~/repo1$ git --version
git version 1.7.3.1

~/repo1$ git cherry-pick --strategy resolve test1
Trying simple merge.
Simple merge failed, trying Automatic merge.
[master da2d5bf] New file in test1

 1 files changed, 1 insertions(+), 
 create mode 100644 new_file_test1

Seems it is working using the resolve strategy. I may have found a message on this list posted a while ago:

"cherry-picking a commit clobbers a file which is a directory in the target commit"

Which seems to deal with the same kind of problems maybe something is missing in the patch in order to handle this particular case.

Quoted 3 lines

I remember there were some problems with the default "recursive" strategy and I am not sure they were fixed.
By the way could you tell which version of git you are using?

I'm using ubuntu's 1.7.1 version on my laptop which doesn't support --strategy and a v1.7.3.1 on another computer, both expose the same problem.

Quoted 3 lines

Thanks,
Christian.

--
Camille Moncelier
http://devlife.org

#3 lore raw
Quoted 18 lines · Camille Moncelier
Quoted 4 lines · On Thu, 4 Nov 2010 14:55:12 +0100 Christian Couder…

Could you try to cherry-pick with other strategies? For example with:

git cherry-pick --strategy resolve test1

~/repo1$ git --version
git version 1.7.3.1

~/repo1$ git cherry-pick --strategy resolve test1
Trying simple merge.
Simple merge failed, trying Automatic merge.
[master da2d5bf] New file in test1

 1 files changed, 1 insertions(+),

 create mode 100644 new_file_test1

Quoted 8 lines

Seems it is working using the resolve strategy. I may have found a message on this list posted a while ago:

"cherry-picking a commit clobbers a file which is a directory in the target commit"

Which seems to deal with the same kind of problems maybe something is missing in the patch in order to handle this particular case.

Please reply not only to me but also to the list and add relevant people in Cc: like I did.

Elijah Newren sent a patch series around September the 20th but I did not check to see if this series was merged into pu, next or master. And I don't know if it fixes your problem.
Could you have a look?

Thanks,
Christian.

#4 lore raw
Quoted 2 lines · On Thu, 4 Nov 2010 18:03:39 +0100 Christian Couder…

Please reply not only to me but also to the list and add relevant people in Cc: like I did.

It replied to the list[1] and CC'ed you. I use claws mail + gmane NNTP gateway. Maybe I did something wrong but it seems that the message has been successfully delivered to the list.

[1] http://article.gmane.org/gmane.comp.version-control.git/160722

Quoted 5 lines

Elijah Newren sent a patch series around September the 20th but I did not check to see if this series was merged into pu, next or master. And I don't know if it fixes your problem.
Could you have a look?

I think I already took a look last week, and I think they were merged in 1.7.1 or 1.7.2 although I'm not sure. I'll take another look. This evening or maybe tomorrow.

Quoted 3 lines

Thanks,
Christian.

#5 lore raw
Quoted 10 lines · Camille Moncelier
Quoted 2 lines · On Thu, 4 Nov 2010 18:03:39 +0100 Christian Couder…

Please reply not only to me but also to the list and add relevant people in Cc: like I did.

It replied to the list[1] and CC'ed you. I use claws mail + gmane NNTP gateway. Maybe I did something wrong but it seems that the message has been successfully delivered to the list.

[1] http://article.gmane.org/gmane.comp.version-control.git/160722

Yeah, sorry, I use gmail and I don't know why but it doesn't show the list in "To:" or "Cc:".

Regards,
Christian.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 16 lines · Elijah Newren

Hi,

Sorry, I've been missing in action for about a month, but I'll have some time this weekend to catch back up on git stuff...

Quoted 9 lines · Camille Moncelier
Quoted 4 lines · On Thu, 4 Nov 2010 18:03:39 +0100 Christian Couder…

Elijah Newren sent a patch series around September the 20th but I did not check to see if this series was merged into pu, next or master. And I don't know if it fixes your problem.
Could you have a look?

I think I already took a look last week, and I think they were merged in 1.7.1 or 1.7.2 although I'm not sure. I'll take another look. This evening or maybe tomorrow.

Great!

Quoted 7 lines

The patch series I posted in late September post-dates the related series of mine that were merged in 1.7.3.

I'd also be happy to take a look and see if my newer merge-recursive series fixes your case (or whether one of my other improvements to that series since my September posting does).  If not, I'll track it down and fix it and add that fix to the series.

Great!

Thanks both,
Christian.

#8 lore raw
Quoted 8 lines
Quoted 7 lines

The patch series I posted in late September post-dates the related series of mine that were merged in 1.7.3.

I'd also be happy to take a look and see if my newer merge-recursive series fixes your case (or whether one of my other improvements to that series since my September posting does).  If not, I'll track it down and fix it and add that fix to the series.

It's strange I've just tested on my laptop and it seems fixed in v1.7.3. I'll redo the test this week on the repository I've first experienced the problem, just to see if the problem is really gone or my testcase isn't sufficient.

I've tried to use git bisect to check the patch which fixed the problem but, I didn't succeed.

BTW, Is there a way using git bisect to find the "last bad commit", or maybe the "first good one" ?

Quoted 4 lines

Great!

Thanks both,
Christian.

#9 lore raw
Quoted 2 lines · Camille Moncelier

BTW, Is there a way using git bisect to find the "last bad commit", or maybe the "first good one" ?

It works the same as "find first bad one", you just have to exchange "good" and "bad" (they really mean "before" and "after").

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#10 lore raw
In reply to Christian Couder
Quoted 8 lines · Christian Couder

Could you try to cherry-pick with other strategies? For example with:

git cherry-pick --strategy resolve test1

I remember there were some problems with the default "recursive" strategy and I am not sure they were fixed.
By the way could you tell which version of git you are using?

PS: Sorry for top-posting. Please don't answer like I just did.

Quoted 57 lines
Quoted 54 lines · Camille Moncelier

I'm reposting this since I didn't get any responses and I think my message didn't contained enought context.

I think I may have spotted a bug, or a unhandled case when doing a cherry-pick

Consider a repository like this:

# Initialize a dummy repository
   mkdir -p repo1 ; cd repo1
   git init .

# Create a new directory dir1' and a link to it dir2' mkdir dir1
   echo file1 > dir1/file1
   ln -s dir1 dir2
   git add dir1 dir2
   git commit -m "Initial status: dir2 -> dir1"

# Create a branch named test1' remove the dir2' link and

# replace it by a new directory
   git checkout -b test1
   git rm dir2
   mkdir dir2
   touch file2 > dir2/file1
   git add dir2/file1
   git commit -m "Removing link: dir1/ and dir2/"

# Now create a new file in `test1' branch
   message="New file in test1"
   echo $message > new_file_test1
   git add new_file_test1
   git commit -m "$message"

# Now try to cherry-pick last commit from `test1' into master git co master
   git cherry-pick test1

The cherry-pick fails saying if failed to merge dir2' despite the fact that the commit doesn't affect dir2' and

git diff test1~..test1 | git apply

is working. Am I doing something wrong ?

--
Camille Moncelier
http://devlife.org

--
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html