{"thread":{"id":"24035","subject":"Merging a commit from a distant branch, cherry-pick seems to fail","startedAt":"2010-06-07T22:46:10Z","lastAt":"2010-06-08T11:58:29Z","messageCount":4,"participants":["Sjors Gielen","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"143193","messageId":"4C1009EE-3A67-4DF9-9F45-493CD463AEF9@dazjorz.com","threadId":"24035","inReplyTo":null,"subject":"Merging a commit from a distant branch, cherry-pick seems to fail","fromName":"Sjors Gielen","fromEmail":"dazjorz@dazjorz.com","sentAt":"2010-06-07T22:46:10Z","receivedAt":"2010-06-07T22:46:10Z","isPatch":false,"sender":{"key":"dazjorz@dazjorz.com","avatar":null},"body":"Hi list,\n\nI'm one of the lead developers for KMess. Recently, I've been doing some work regarding KMess on Mac, in a branch called 'noknotify' (because knotify works like shit on Mac). This branch was branched off of the master branch a few days ago. The master branch has had major development activity in the last half year, as the KMess version that will eventually be 2.1 or so. Before that, we released a kmess-2.0.x branch; this branch has been relatively silent since branching off from master.\n\nNow, after those changes in noknotify, I want to merge them back into kmess-2.0.x. However, the two branches noknotify and kmess-2.0.x are hugely apart. The changes in the commit I want to merge are to files which haven't changed a lot (apart from the ChangeLog and CMakeLists.txt) and should apply somewhat cleanly.\n\nSo I switched branches, made sure my branch was clean, made sure I was taking the right commit, and cherry-picked the interesting commit from the other branch.\n\n<<<<<<\nsjors@smbp:~/Projecten/kmess/git$ git checkout kmess-2.0.x\nSwitched to branch 'kmess-2.0.x'\nsjors@smbp:~/Projecten/kmess/git$ git status\n# On branch kmess-2.0.x\nnothing to commit (working directory clean)\nsjors@smbp:~/Projecten/kmess/git$ git log -1 --name-only --oneline f9380fd43a2c1\nf9380fd 2010-06-03 (Sjors) (noknotify branch)\nChangeLog\nsrc/CMakeLists.txt\nsrc/notification/macnotification.cpp\nsrc/notification/macnotification.h\nsrc/notification/notificationmanager.cpp\nsrc/notification/notificationmanager.h\nsjors@smbp:~/Projecten/kmess/git$ git cherry-pick -n f9380fd43a2c1cb75d97c7a667d652195e674824\nAutomatic cherry-pick failed.  After resolving the conflicts,\nmark the corrected paths with 'git add <paths>' or 'git rm <paths>'\nand commit the result with: \n\n        git commit -c f9380fd43a2c1cb75d97c7a667d652195e674824\n<<<<<<<\n\nApparantly, this failed. The reason why: Instead of changing just those few files in the commit, git was apparantly trying to merge a lot more, see:\n\n<<<<<<<\nsjors@smbp:~/Projecten/kmess/git$ git status\n# On branch kmess-2.0.x\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#\tmodified:   src/CMakeLists.txt\n#\tnew file:   src/notification/macnotification.cpp\n#\tnew file:   src/notification/macnotification.h\n#\tmodified:   src/notification/notificationmanager.cpp\n#\n# Unmerged paths:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#   (use \"git add/rm <file>...\" as appropriate to mark resolution)\n#\n#\tboth modified:      ChangeLog\n#\tadded by us:        contrib/isf-qt\n#\tboth modified:      src/notification/notificationmanager.h\n#\nsjors@smbp:~/Projecten/kmess/git$ git diff ChangeLog | head -n 20\ndiff --cc ChangeLog\nindex ef7223f,ca14ce8..0000000\n--- a/ChangeLog\n+++ b/ChangeLog\n@@@ -1,134 -1,101 +1,148 @@@\n++<<<<<<< HEAD\n +2010-05-31 (Adam)\n + * Fix bug in chatwindow.ui: use the global include for IsfInkCanvas.\n++=======\n+ \n+ 2010-06-03 (Sjors) (noknotify branch)\n+  * Added MacNotification class, which currently makes the KMess icon in the\n+    Dock 'jump' when its method is called.\n+  * Made the NotificationManager use MacNotification instead when doing\n+    notifications on the Mac.\n+ \n+ 2010-05-29 (Adam)\n+  * Update the use of the MsnSession API (no more \"get\" prefix).\n+  * Disable meeting/invite/send file buttons if chatting to a Yahoo! contact\n+  * Handle YahooMessage in Chat\n<<<<<<<<\n\nThe lines added starting with \"2010-05-29 (Adam)\" are not from kmess-2.0.x, but from 'master' - the lines are also present in the snapshot of noknotify after commit f9380fd43, but weren't changed in that commit.\n\nI'd have expected git cherry-pick to simply take the changes in commit f9380fd43 and apply them to kmess-2.0.x, without pulling along history in 'master'. Testing and debugging in the #git channel on Freenode didn't show what I was doing wrong (<http://git.pastebin.com/dUntbHDV>). Now I could just take the patch with 'git show' and use 'git apply' to apply it, but that doesn't seem like the Git way to do this. So the question is: does any of you know why this is happening, what I'm doing wrong, and what I should do instead?\n\nBTW: my repository is a synchronised clone of http://gitorious.org/kmess/kmess, so you can all try stuff yourself :)\n\nThank you,\nSjors"},{"id":"143206","messageId":"4C0DDBC8.9030909@viscovery.net","threadId":"24035","inReplyTo":"4C1009EE-3A67-4DF9-9F45-493CD463AEF9@dazjorz.com","subject":"Re: Merging a commit from a distant branch, cherry-pick seems to fail","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-06-08T05:57:28Z","receivedAt":"2010-06-08T05:57:28Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 6/8/2010 0:46, schrieb Sjors Gielen:\n> sjors@smbp:~/Projecten/kmess/git$ git log -1 --name-only --oneline f9380fd43a2c1\n> f9380fd 2010-06-03 (Sjors) (noknotify branch)\n> ChangeLog\n> src/CMakeLists.txt\n> src/notification/macnotification.cpp\n> src/notification/macnotification.h\n> src/notification/notificationmanager.cpp\n> src/notification/notificationmanager.h\n...\n> sjors@smbp:~/Projecten/kmess/git$ git status\n> # On branch kmess-2.0.x\n> # Changes to be committed:\n> #   (use \"git reset HEAD <file>...\" to unstage)\n> #\n> #\tmodified:   src/CMakeLists.txt\n> #\tnew file:   src/notification/macnotification.cpp\n> #\tnew file:   src/notification/macnotification.h\n> #\tmodified:   src/notification/notificationmanager.cpp\n> #\n> # Unmerged paths:\n> #   (use \"git reset HEAD <file>...\" to unstage)\n> #   (use \"git add/rm <file>...\" as appropriate to mark resolution)\n> #\n> #\tboth modified:      ChangeLog\n> #\tadded by us:        contrib/isf-qt\n> #\tboth modified:      src/notification/notificationmanager.h\n> #\n...\n> I'd have expected git cherry-pick to simply take the changes in commit\n> f9380fd43 and apply them to kmess-2.0.x, without pulling along history\n> in 'master'. Testing and debugging in the #git channel on Freenode didn't\n> show what I was doing wrong (<http://git.pastebin.com/dUntbHDV>). Now I\n> could just take the patch with 'git show' and use 'git apply' to apply it,\n> but that doesn't seem like the Git way to do this. So the question is:\n> does any of you know why this is happening, what I'm doing wrong, and what\n> I should do instead?\n\nYou did nothing wrong. If at all, there is a bug in git.\n\nThe *only* curious thing after your cherry-pick is this:\n\n> #\tadded by us:        contrib/isf-qt\n\nbecause contrib/isf-qt is not touched by the commit that you are\ncherry-picking.\n\ncontrib/isf-qt is a submodule on branch kmess-2.0.x, but it is a regular\ndirectory on master. I don't think that git should report it as a conflict.\n\nTo go ahead, simply resolve the conflicts in ChangeLog and\nnotificationmanager.h, and make sure that you do not have staged any\nchanges to contrib/isf-qt before you commit.\n\n-- Hannes\n"},{"id":"143223","messageId":"4C0E2AB4.2010008@viscovery.net","threadId":"24035","inReplyTo":"4C0DDBC8.9030909@viscovery.net","subject":"[PATCH] merge-recursive: demonstrate an incorrect conflict with submodule","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-06-08T11:34:12Z","receivedAt":"2010-06-08T11:34:12Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Sixt <j6t@kdbg.org>\n\nWhen one side of a merge turns a directory into a submodule, and the other\nside does not touch that directory (but has other non-conflicting changes),\nthen a merge should succeed. But currently, it does not; it rather fails\nwith a file/directory conflict.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\nAm 6/8/2010 7:57, schrieb Johannes Sixt:\n> The *only* curious thing after your cherry-pick is this:\n> \n>> #\tadded by us:        contrib/isf-qt\n> \n> because contrib/isf-qt is not touched by the commit that you are\n> cherry-picking.\n\nHere's a test case that exhibits the bug in merge-recursive;\nat least, I think it is a bug.\n\n-- Hannes\n\n t/t3030-merge-recursive.sh |   29 +++++++++++++++++++++++++++++\n 1 files changed, 29 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh\nindex 9929f82..9eae6e9 100755\n--- a/t/t3030-merge-recursive.sh\n+++ b/t/t3030-merge-recursive.sh\n@@ -22,6 +22,7 @@ test_expect_success 'setup 1' '\n \tgit branch df-2 &&\n \tgit branch df-3 &&\n \tgit branch remove &&\n+\tgit branch submod &&\n \n \techo hello >>a &&\n \tcp a d/e &&\n@@ -236,6 +237,17 @@ test_expect_success 'setup 6' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'setup 7' '\n+\n+\tgit checkout submod &&\n+\tgit rm d/e &&\n+\ttest_tick &&\n+\tgit commit -m \"remove d/e\" &&\n+\tgit update-index --add --cacheinfo 160000 $c1 d &&\n+\ttest_tick &&\n+\tgit commit -m \"make d/ a submodule\"\n+'\n+\n test_expect_success 'merge-recursive simple' '\n \n \trm -fr [abcd] &&\n@@ -551,4 +563,21 @@ test_expect_success 'merge removes empty directories' '\n \ttest_must_fail test -d d\n '\n \n+test_expect_failure 'merge-recursive simple w/submodule' '\n+\n+\tgit checkout submod &&\n+\tgit merge remove\n+'\n+\n+test_expect_failure 'merge-recursive simple w/submodule result' '\n+\n+\tgit ls-files -s >actual &&\n+\t(\n+\t\techo \"100644 $o5 0\ta\"\n+\t\techo \"100644 $o0 0\tc\"\n+\t\techo \"100644 $c1 0\td\"\n+\t) >expected &&\n+\ttest_cmp expected actual\n+'\n+\n test_done\n-- \n1.7.1.75.g68e2c\n"},{"id":"143226","messageId":"4C0E3065.5070401@viscovery.net","threadId":"24035","inReplyTo":"4C0E2AB4.2010008@viscovery.net","subject":"Re: [PATCH] merge-recursive: demonstrate an incorrect conflict with submodule","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-06-08T11:58:29Z","receivedAt":"2010-06-08T11:58:29Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 6/8/2010 13:34, schrieb Johannes Sixt:\n> +test_expect_failure 'merge-recursive simple w/submodule result' '\n> +\n> +\tgit ls-files -s >actual &&\n> +\t(\n> +\t\techo \"100644 $o5 0\ta\"\n> +\t\techo \"100644 $o0 0\tc\"\n> +\t\techo \"100644 $c1 0\td\"\n\nMake this line\n\t\techo \"160000 $c1 0\td\"\nSorry!\n\n> +\t) >expected &&\n> +\ttest_cmp expected actual\n\n-- Hannes\n"}]}