{"thread":{"id":"14420","subject":"git-new-workdir should not share .git/rr-cache/MERGE_RR","startedAt":"2008-07-12T11:27:07Z","lastAt":"2008-07-13T08:58:33Z","messageCount":5,"participants":["Kalle Olavi Niemitalo","Johannes Schindelin","Shawn O. Pearce","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"83073","messageId":"87skufmjg4.fsf@Astalo.kon.iki.fi","threadId":"14420","inReplyTo":null,"subject":"git-new-workdir should not share .git/rr-cache/MERGE_RR","fromName":"Kalle Olavi Niemitalo","fromEmail":"kon@iki.fi","sentAt":"2008-07-12T11:27:07Z","receivedAt":"2008-07-12T11:27:07Z","isPatch":false,"sender":{"key":"kon@iki.fi","avatar":null},"body":"The contrib/workdir/git-new-workdir script makes .git/rr-cache in\neach workdir a symlink to the shared .git/rr-cache directory.\nThis lets git-rerere share conflict resolutions between workdirs.\nHowever, that directory also contains .git/rr-cache/MERGE_RR,\nwhich lists the files for which conflict resolutions should be\nsaved in the next commit.  It is thus possible that git-merge in\none workdir records conflicts to the shared MERGE_RR file, and\ngit-commit in another workdir saves the staged files to rr-cache\nas conflict resolutions, even though those files are from a\ndifferent branch and never saw the merge.  Such invalid conflict\nresolutions need then be separately deleted.  This happened to\nme, with git version 1.5.6.\n\nI don't see any way to modify the symlinks made by\ngit-new-workdir so that new SHA-1 directories in .git/rr-cache\nwould be shared but .git/rr-cache/MERGE_RR would not.  On IRC,\n\"gitte\" suggested changing Git to use $GIT_DIR/MERGE_RR instead\nof $GIT_DIR/rr-cache/MERGE_RR.  I suppose compatibility with\npeople's existing repositories would require the modified Git to\nkeep reading $GIT_DIR/rr-cache/MERGE_RR too, so that Git could be\npainlessly upgraded during a merge, but it is not obvious to me\nhow lock files should then work.\n\nAlternatively, the SHA-1 directories in .git/rr-cache could be\nmoved to a subdirectory; then git-new-workdir could be changed to\nsymlink only that subdirectory.\n"},{"id":"83081","messageId":"alpine.DEB.1.00.0807121553120.8950@racer","threadId":"14420","inReplyTo":"87skufmjg4.fsf@Astalo.kon.iki.fi","subject":"[PATCH 1/2] Move MERGE_RR from .git/rr-cache/ into .git/","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-12T14:56:19Z","receivedAt":"2008-07-12T14:56:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nIf you want to reuse the rerere cache in another repository, and set\na symbolic link to it, you do not want to have the two repositories\ninterfer with each other by accessing the _same_ MERGE_RR.\n\nFor example, if you use contrib/git-new-workdir to set up a second\nworking directory, and you have a conflict in one working directory,\nbut commit in the other working directory first, the wrong \"resolution\"\nwill be recorded.\n\nThe easy solution is to move MERGE_RR out of the rr-cache/ directory,\nwhich also corresponds with the notion that rr-cache/ contains cached\nresolutions, not some intermediate temporary states.\n\nNoticed by Kalle Olavi Niemitalo.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tShawn, I Cc:ed you because of 2/2.\n\n\tOn Sat, 12 Jul 2008, Kalle Olavi Niemitalo wrote:\n\n\t> I don't see any way to modify the symlinks made by \n\t> git-new-workdir so that new SHA-1 directories in .git/rr-cache\n\t> would be shared but .git/rr-cache/MERGE_RR would not.  On IRC, \n\t> \"gitte\" suggested changing Git to use $GIT_DIR/MERGE_RR instead of \n\t> $GIT_DIR/rr-cache/MERGE_RR.\n\n\t\"gitte\" actually expected that a patch would not be that hard.\n\n\t> I suppose compatibility with people's existing repositories \n\t> would require the modified Git to keep reading \n\t> $GIT_DIR/rr-cache/MERGE_RR too, so that Git could be painlessly \n\t> upgraded during a merge, but it is not obvious to me how lock files \n\t> should then work.\n\n\t\"rerere\" is not perfect.  Thus, I suspect that we can just leave \n\tan existing MERGE_RR alone, and the user just has to record the \n\tresolution another time.  Too bad.\n\n branch.c          |    2 +-\n builtin-rerere.c  |    2 +-\n t/t4200-rerere.sh |    6 +++---\n 3 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 56e9492..b1e59f2 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -166,7 +166,7 @@ void create_branch(const char *head,\n void remove_branch_state(void)\n {\n \tunlink(git_path(\"MERGE_HEAD\"));\n-\tunlink(git_path(\"rr-cache/MERGE_RR\"));\n+\tunlink(git_path(\"MERGE_RR\"));\n \tunlink(git_path(\"MERGE_MSG\"));\n \tunlink(git_path(\"SQUASH_MSG\"));\n }\ndiff --git a/builtin-rerere.c b/builtin-rerere.c\nindex 69c3a52..1db2e0c 100644\n--- a/builtin-rerere.c\n+++ b/builtin-rerere.c\n@@ -429,7 +429,7 @@ static int setup_rerere(struct path_list *merge_rr)\n \tif (!is_rerere_enabled())\n \t\treturn -1;\n \n-\tmerge_rr_path = xstrdup(git_path(\"rr-cache/MERGE_RR\"));\n+\tmerge_rr_path = xstrdup(git_path(\"MERGE_RR\"));\n \tfd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1);\n \tread_rr(merge_rr);\n \treturn fd;\ndiff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh\nindex cf10557..b5a4202 100755\n--- a/t/t4200-rerere.sh\n+++ b/t/t4200-rerere.sh\n@@ -57,7 +57,7 @@ test_expect_success 'conflicting merge' '\n \t! git merge first\n '\n \n-sha1=$(sed -e 's/\t.*//' .git/rr-cache/MERGE_RR)\n+sha1=$(sed -e 's/\t.*//' .git/MERGE_RR)\n rr=.git/rr-cache/$sha1\n test_expect_success 'recorded preimage' \"grep ^=======$ $rr/preimage\"\n \n@@ -143,7 +143,7 @@ test_expect_success 'rerere kicked in' \"! grep ^=======$ a1\"\n test_expect_success 'rerere prefers first change' 'test_cmp a1 expect'\n \n rm $rr/postimage\n-echo \"$sha1\ta1\" | perl -pe 'y/\\012/\\000/' > .git/rr-cache/MERGE_RR\n+echo \"$sha1\ta1\" | perl -pe 'y/\\012/\\000/' > .git/MERGE_RR\n \n test_expect_success 'rerere clear' 'git rerere clear'\n \n@@ -190,7 +190,7 @@ test_expect_success 'file2 added differently in two branches' '\n \tgit add file2 &&\n \tgit commit -m version2 &&\n \t! git merge fourth &&\n-\tsha1=$(sed -e \"s/\t.*//\" .git/rr-cache/MERGE_RR) &&\n+\tsha1=$(sed -e \"s/\t.*//\" .git/MERGE_RR) &&\n \trr=.git/rr-cache/$sha1 &&\n \techo Cello > file2 &&\n \tgit add file2 &&\n-- \n1.5.6.2.511.ge432a\n"},{"id":"83082","messageId":"alpine.DEB.1.00.0807121556480.8950@racer","threadId":"14420","inReplyTo":"alpine.DEB.1.00.0807121553120.8950@racer","subject":"[PATCH 2/2 (for GIT-GUI)] git-gui: MERGE_RR lives in .git/ directly with newer Git versions","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-12T14:56:59Z","receivedAt":"2008-07-12T14:56:59Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nNow that MERGE_RR was moved out of .git/rr-cache/, we have to delete\nit somewhere else.  Just in case somebody wants to use a newer git-gui\nwith an older Git, the file .git/rr-cache/MERGE_RR is removed, too (if\nit exists).\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n git-gui/lib/merge.tcl |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/lib/merge.tcl b/lib/merge.tcl\nindex cc26b07..5c01875 100644\n--- a/lib/merge.tcl\n+++ b/lib/merge.tcl\n@@ -257,6 +257,7 @@ proc _reset_wait {fd} {\n \n \t\tcatch {file delete [gitdir MERGE_HEAD]}\n \t\tcatch {file delete [gitdir rr-cache MERGE_RR]}\n+\t\tcatch {file delete [gitdir MERGE_RR]}\n \t\tcatch {file delete [gitdir SQUASH_MSG]}\n \t\tcatch {file delete [gitdir MERGE_MSG]}\n \t\tcatch {file delete [gitdir GITGUI_MSG]}\n-- \n1.5.6.2.511.ge432a\n"},{"id":"83118","messageId":"20080713011623.GC31050@spearce.org","threadId":"14420","inReplyTo":"alpine.DEB.1.00.0807121556480.8950@racer","subject":"Re: [PATCH 2/2 (for GIT-GUI)] git-gui: MERGE_RR lives in .git/ directly with newer Git versions","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-07-13T01:16:23Z","receivedAt":"2008-07-13T01:16:23Z","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> \n> Now that MERGE_RR was moved out of .git/rr-cache/, we have to delete\n> it somewhere else.  Just in case somebody wants to use a newer git-gui\n> with an older Git, the file .git/rr-cache/MERGE_RR is removed, too (if\n> it exists).\n> \n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nAck, I can pull this into git-gui.git.  But I want to make sure\nJunio is going to take 1/2 into git.git.\n\n\n>  git-gui/lib/merge.tcl |    1 +\n>  1 files changed, 1 insertions(+), 0 deletions(-)\n> \n> diff --git a/lib/merge.tcl b/lib/merge.tcl\n> index cc26b07..5c01875 100644\n> --- a/lib/merge.tcl\n> +++ b/lib/merge.tcl\n> @@ -257,6 +257,7 @@ proc _reset_wait {fd} {\n>  \n>  \t\tcatch {file delete [gitdir MERGE_HEAD]}\n>  \t\tcatch {file delete [gitdir rr-cache MERGE_RR]}\n> +\t\tcatch {file delete [gitdir MERGE_RR]}\n>  \t\tcatch {file delete [gitdir SQUASH_MSG]}\n>  \t\tcatch {file delete [gitdir MERGE_MSG]}\n>  \t\tcatch {file delete [gitdir GITGUI_MSG]}\n> -- \n\n-- \nShawn.\n"},{"id":"83131","messageId":"7vvdzatb2e.fsf@gitster.siamese.dyndns.org","threadId":"14420","inReplyTo":"20080713011623.GC31050@spearce.org","subject":"Re: [PATCH 2/2 (for GIT-GUI)] git-gui: MERGE_RR lives in .git/ directly with newer Git versions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-13T08:58:33Z","receivedAt":"2008-07-13T08:58:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>> \n>> Now that MERGE_RR was moved out of .git/rr-cache/, we have to delete\n>> it somewhere else.  Just in case somebody wants to use a newer git-gui\n>> with an older Git, the file .git/rr-cache/MERGE_RR is removed, too (if\n>> it exists).\n>> \n>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n>\n> Ack, I can pull this into git-gui.git.  But I want to make sure\n> Junio is going to take 1/2 into git.git.\n\nWill do.\n"}]}