{"thread":{"id":"43415","subject":"Re: [PATCH] Remove uncontested renamed files during merge.","startedAt":"2006-12-13T09:55:40Z","lastAt":"2006-12-13T10:45:38Z","messageCount":4,"participants":["Johannes Schindelin","Shawn O. Pearce","Shawn Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"295346","messageId":"20061213095540.GA25001@spearce.org","threadId":"43415","inReplyTo":null,"subject":"[PATCH] Remove uncontested renamed files during merge.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-12-13T09:55:40Z","receivedAt":"2006-12-13T09:55:40Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Prior to 65ac6e9c3f47807cb603af07a6a9e1a43bc119ae we deleted a\nfile from the working directory during a merge if the file existed\nin the working directory before the merge started but was renamed\nby the branch which is being merged in.  This broke in 65ac63 as\ngit-merge-recursive did not actually update the working directory\non this uncontested rename case.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n\n The same repository that spawned my 'Bug in merge-recursive in\n virtual commit corner case' thread discovered this feature of\n git-merge-recursive today.\n\n I'm not sure this is the right way to fix the issue, but it does\n appear to fix the problem and passes both the existing tests and\n this new one.\n\n merge-recursive.c        |    2 +-\n t/t6024-merge-rename2.sh |   97 ++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 98 insertions(+), 1 deletions(-)\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 9d53bcd..741d17f 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -873,7 +873,7 @@ static int process_renames(struct path_list *a_renames,\n \t\t\tstruct diff_filespec src_other, dst_other;\n \t\t\tint try_merge, stage = a_renames == renames1 ? 3: 2;\n \n-\t\t\tremove_file(1, ren1_src, 1);\n+\t\t\tremove_file(1, ren1_src, 0);\n \n \t\t\thashcpy(src_other.sha1, ren1->src_entry->stages[stage].sha);\n \t\t\tsrc_other.mode = ren1->src_entry->stages[stage].mode;\ndiff --git a/t/t6024-merge-rename2.sh b/t/t6024-merge-rename2.sh\nnew file mode 100755\nindex 0000000..69c66cf\n--- /dev/null\n+++ b/t/t6024-merge-rename2.sh\n@@ -0,0 +1,97 @@\n+#!/bin/sh\n+\n+test_description='Merge-recursive merging renames'\n+. ./test-lib.sh\n+\n+test_expect_success setup \\\n+'\n+cat >A <<\\EOF &&\n+a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n+b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n+c cccccccccccccccccccccccccccccccccccccccccccccccc\n+d dddddddddddddddddddddddddddddddddddddddddddddddd\n+e eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\n+f ffffffffffffffffffffffffffffffffffffffffffffffff\n+g gggggggggggggggggggggggggggggggggggggggggggggggg\n+h hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\n+i iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\n+j jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\n+k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk\n+l llllllllllllllllllllllllllllllllllllllllllllllll\n+m mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm\n+n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn\n+o oooooooooooooooooooooooooooooooooooooooooooooooo\n+EOF\n+\n+cat >M <<\\EOF &&\n+A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n+B BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n+C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\n+D DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD\n+E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n+F FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\n+G GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\n+H HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH\n+I IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\n+J JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ\n+K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK\n+L LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\n+M MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n+N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\n+O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO\n+EOF\n+\n+git add A M &&\n+git commit -m \"initial has A and M\" &&\n+git branch white &&\n+git branch red &&\n+\n+git checkout white &&\n+sed -e \"/^g /s/.*/g : white changes a line/\" <A >B &&\n+sed -e \"/^G /s/.*/G : colored branch changes a line/\" <M >N &&\n+rm -f A M &&\n+git update-index --add --remove A B M N &&\n+git commit -m \"white renames A->B, M->N\" &&\n+\n+git checkout red &&\n+echo created by red >R &&\n+git update-index --add R &&\n+git commit -m \"red creates R\" &&\n+\n+git checkout master'\n+\n+# This test broke in 65ac6e9c3f47807cb603af07a6a9e1a43bc119ae\n+test_expect_success 'merge white into red (A->B,M->N)' \\\n+'\n+\tgit checkout -b red-white red &&\n+\tgit merge white &&\n+\tgit write-tree >/dev/null || {\n+\t\techo \"BAD: merge did not complete\"\n+\t\treturn 1\n+\t}\n+\n+\ttest -f B || {\n+\t\techo \"BAD: B does not exist in working directory\"\n+\t\treturn 1\n+\t}\n+\ttest -f N || {\n+\t\techo \"BAD: N does not exist in working directory\"\n+\t\treturn 1\n+\t}\n+\ttest -f R || {\n+\t\techo \"BAD: R does not exist in working directory\"\n+\t\treturn 1\n+\t}\n+\n+\ttest -f A && {\n+\t\techo \"BAD: A still exists in working directory\"\n+\t\treturn 1\n+\t}\n+\ttest -f M && {\n+\t\techo \"BAD: M still exists in working directory\"\n+\t\treturn 1\n+\t}\n+\treturn 0\n+'\n+\n+test_done\n-- \n"},{"id":"298377","messageId":"Pine.LNX.4.63.0612131129550.3635@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"43415","inReplyTo":"20061213095540.GA25001@spearce.org","subject":"Re: [PATCH] Remove uncontested renamed files during merge.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-13T10:31:25Z","receivedAt":"2006-12-13T10:31:25Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 13 Dec 2006, Shawn O. Pearce wrote:\n\n> Prior to 65ac6e9c3f47807cb603af07a6a9e1a43bc119ae we deleted a\n> file from the working directory during a merge if the file existed\n> in the working directory before the merge started but was renamed\n> by the branch which is being merged in.  This broke in 65ac63 as\n> git-merge-recursive did not actually update the working directory\n> on this uncontested rename case.\n> \n> [...]\n>\n> diff --git a/merge-recursive.c b/merge-recursive.c\n> index 9d53bcd..741d17f 100644\n> --- a/merge-recursive.c\n> +++ b/merge-recursive.c\n> @@ -873,7 +873,7 @@ static int process_renames(struct path_list *a_renames,\n>  \t\t\tstruct diff_filespec src_other, dst_other;\n>  \t\t\tint try_merge, stage = a_renames == renames1 ? 3: 2;\n>  \n> -\t\t\tremove_file(1, ren1_src, 1);\n> +\t\t\tremove_file(1, ren1_src, 0);\n\nI _think_ that the \"0\" should be \"!index_only\". After all, these functions \nare not only called on the virtual merges, but also on the final merge, \nwhich indeed should update the working directory. And since it is a \nrename, the old file has to go.\n\nCiao,\n"},{"id":"295441","messageId":"20061213104244.GA9484@spearce.org","threadId":"43415","inReplyTo":"Pine.LNX.4.63.0612131129550.3635@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Remove uncontested renamed files during merge.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-12-13T10:42:44Z","receivedAt":"2006-12-13T10:42:44Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > diff --git a/merge-recursive.c b/merge-recursive.c\n> > index 9d53bcd..741d17f 100644\n> > --- a/merge-recursive.c\n> > +++ b/merge-recursive.c\n> > @@ -873,7 +873,7 @@ static int process_renames(struct path_list *a_renames,\n> >  \t\t\tstruct diff_filespec src_other, dst_other;\n> >  \t\t\tint try_merge, stage = a_renames == renames1 ? 3: 2;\n> >  \n> > -\t\t\tremove_file(1, ren1_src, 1);\n> > +\t\t\tremove_file(1, ren1_src, 0);\n> \n> I _think_ that the \"0\" should be \"!index_only\".\n\nErr, actually \"index_only\".  Since that's no_wd.  But yea, you are\nright, I didn't consider the index_only mode of operation here.\n\n-->-- corrected patch follows --<--\nRemove uncontested renamed files during merge.\n\nPrior to 65ac6e9c3f47807cb603af07a6a9e1a43bc119ae we deleted a file\nfrom the working directory during a merge if the file existed before\nthe merge started but was renamed by the branch being merged in.\nThis broke in 65ac63 as git-merge-recursive did not actually update\nthe working directory on an uncontested rename.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n merge-recursive.c        |    2 +-\n t/t6024-merge-rename2.sh |   97 ++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 98 insertions(+), 1 deletions(-)\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 9d53bcd..13e96eb 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -873,7 +873,7 @@ static int process_renames(struct path_list *a_renames,\n \t\t\tstruct diff_filespec src_other, dst_other;\n \t\t\tint try_merge, stage = a_renames == renames1 ? 3: 2;\n \n-\t\t\tremove_file(1, ren1_src, 1);\n+\t\t\tremove_file(1, ren1_src, index_only);\n \n \t\t\thashcpy(src_other.sha1, ren1->src_entry->stages[stage].sha);\n \t\t\tsrc_other.mode = ren1->src_entry->stages[stage].mode;\ndiff --git a/t/t6024-merge-rename2.sh b/t/t6024-merge-rename2.sh\nnew file mode 100755\nindex 0000000..69c66cf\n--- /dev/null\n+++ b/t/t6024-merge-rename2.sh\n@@ -0,0 +1,97 @@\n+#!/bin/sh\n+\n+test_description='Merge-recursive merging renames'\n+. ./test-lib.sh\n+\n+test_expect_success setup \\\n+'\n+cat >A <<\\EOF &&\n+a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n+b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n+c cccccccccccccccccccccccccccccccccccccccccccccccc\n+d dddddddddddddddddddddddddddddddddddddddddddddddd\n+e eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\n+f ffffffffffffffffffffffffffffffffffffffffffffffff\n+g gggggggggggggggggggggggggggggggggggggggggggggggg\n+h hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\n+i iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\n+j jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\n+k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk\n+l llllllllllllllllllllllllllllllllllllllllllllllll\n+m mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm\n+n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn\n+o oooooooooooooooooooooooooooooooooooooooooooooooo\n+EOF\n+\n+cat >M <<\\EOF &&\n+A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n+B BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n+C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\n+D DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD\n+E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n+F FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\n+G GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\n+H HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH\n+I IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\n+J JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ\n+K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK\n+L LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\n+M MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n+N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\n+O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO\n+EOF\n+\n+git add A M &&\n+git commit -m \"initial has A and M\" &&\n+git branch white &&\n+git branch red &&\n+\n+git checkout white &&\n+sed -e \"/^g /s/.*/g : white changes a line/\" <A >B &&\n+sed -e \"/^G /s/.*/G : colored branch changes a line/\" <M >N &&\n+rm -f A M &&\n+git update-index --add --remove A B M N &&\n+git commit -m \"white renames A->B, M->N\" &&\n+\n+git checkout red &&\n+echo created by red >R &&\n+git update-index --add R &&\n+git commit -m \"red creates R\" &&\n+\n+git checkout master'\n+\n+# This test broke in 65ac6e9c3f47807cb603af07a6a9e1a43bc119ae\n+test_expect_success 'merge white into red (A->B,M->N)' \\\n+'\n+\tgit checkout -b red-white red &&\n+\tgit merge white &&\n+\tgit write-tree >/dev/null || {\n+\t\techo \"BAD: merge did not complete\"\n+\t\treturn 1\n+\t}\n+\n+\ttest -f B || {\n+\t\techo \"BAD: B does not exist in working directory\"\n+\t\treturn 1\n+\t}\n+\ttest -f N || {\n+\t\techo \"BAD: N does not exist in working directory\"\n+\t\treturn 1\n+\t}\n+\ttest -f R || {\n+\t\techo \"BAD: R does not exist in working directory\"\n+\t\treturn 1\n+\t}\n+\n+\ttest -f A && {\n+\t\techo \"BAD: A still exists in working directory\"\n+\t\treturn 1\n+\t}\n+\ttest -f M && {\n+\t\techo \"BAD: M still exists in working directory\"\n+\t\treturn 1\n+\t}\n+\treturn 0\n+'\n+\n+test_done\n-- \n1.4.4.2.g8662\n"},{"id":"294667","messageId":"Pine.LNX.4.63.0612131144450.3635@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"43415","inReplyTo":"20061213104244.GA9484@spearce.org","subject":"Re: [PATCH] Remove uncontested renamed files during merge.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-13T10:45:38Z","receivedAt":"2006-12-13T10:45:38Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 13 Dec 2006, Shawn Pearce wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > > diff --git a/merge-recursive.c b/merge-recursive.c\n> > > index 9d53bcd..741d17f 100644\n> > > --- a/merge-recursive.c\n> > > +++ b/merge-recursive.c\n> > > @@ -873,7 +873,7 @@ static int process_renames(struct path_list *a_renames,\n> > >  \t\t\tstruct diff_filespec src_other, dst_other;\n> > >  \t\t\tint try_merge, stage = a_renames == renames1 ? 3: 2;\n> > >  \n> > > -\t\t\tremove_file(1, ren1_src, 1);\n> > > +\t\t\tremove_file(1, ren1_src, 0);\n> > \n> > I _think_ that the \"0\" should be \"!index_only\".\n> \n> Err, actually \"index_only\".  Since that's no_wd.\n\nOops. Correct. My memory starts failing me.\n\n> -->-- corrected patch follows --<--\n> Remove uncontested renamed files during merge.\n\nAcked-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nCiao,\nDscho\n"}]}