{"thread":{"id":"122","subject":"[PATCH] Automerge fix","startedAt":"2005-04-19T01:02:43Z","lastAt":"2005-04-19T05:26:24Z","messageCount":4,"participants":["Petr Baudis","Linus Torvalds","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"747","messageId":"20050419010242.GS5554@pasky.ji.cz","threadId":"122","inReplyTo":null,"subject":"[PATCH] Automerge fix","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-19T01:02:43Z","receivedAt":"2005-04-19T01:02:43Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Hello,\n\nthis patch fixes git-merge-one-file-script's automerge.\n\nSigned-off-by: Petr Baudis <pasky@ucw.cz>\n\ngit-merge-one-file-script: 7ebf5dac4c69043cd2ff89bf7ee552152802f8d1\n--- a/git-merge-one-file-script\n+++ b/git-merge-one-file-script\n@@ -43,7 +43,7 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n \torig=$(unpack-file $1)\n \tsrc1=$(unpack-file $2)\n \tsrc2=$(unpack-file $3)\n-\tmerge \"$src2\" \"$orig\" \"$src1\" || echo Leaving conflict merge in $src2 && exit 1\n+\tmerge \"$src2\" \"$orig\" \"$src1\" || (echo Leaving conflict merge in $src2 && exit 1)\n \tcp \"$src2\" \"$4\" && update-cache --add -- \"$4\" && exit 0\n \t;;\n \n\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"772","messageId":"Pine.LNX.4.58.0504181945400.15725@ppc970.osdl.org","threadId":"122","inReplyTo":"20050419010242.GS5554@pasky.ji.cz","subject":"Re: [PATCH] Automerge fix","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-19T02:48:09Z","receivedAt":"2005-04-19T02:48:09Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 19 Apr 2005, Petr Baudis wrote:\n> \n> this patch fixes git-merge-one-file-script's automerge.\n\nNope, it doesn't. The original may not have worked, but neither does your \nvesion either: the reason for the exit 1 is that the _script_ should exit, \nbut when you put it in a sub-shell with (..), now only the subshell exits \nwith an error code, and we'll happily continue to do the following line \nwhich we should not do (since the merge failed).\n\n> Signed-off-by: Petr Baudis <pasky@ucw.cz>\n> \n> git-merge-one-file-script: 7ebf5dac4c69043cd2ff89bf7ee552152802f8d1\n> --- a/git-merge-one-file-script\n> +++ b/git-merge-one-file-script\n> @@ -43,7 +43,7 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n>  \torig=$(unpack-file $1)\n>  \tsrc1=$(unpack-file $2)\n>  \tsrc2=$(unpack-file $3)\n> -\tmerge \"$src2\" \"$orig\" \"$src1\" || echo Leaving conflict merge in $src2 && exit 1\n> +\tmerge \"$src2\" \"$orig\" \"$src1\" || (echo Leaving conflict merge in $src2 && exit 1)\n>  \tcp \"$src2\" \"$4\" && update-cache --add -- \"$4\" && exit 0\n\nWhat's the right way?\n\nMaybe\n\n\tif merge \"$src2\" \"$orig\" \"$src1\"\n\tthen \n\t\tcp \"$src2\" \"$4\" && update-cache --add -- \"$4\" && exit 0\n\tfi\n\techo Leaving conflict merge in $src2\n\texit 1\n\nwould work?\n\n\t\tLinus\n"},{"id":"776","messageId":"20050419025726.GA5554@pasky.ji.cz","threadId":"122","inReplyTo":"Pine.LNX.4.58.0504181945400.15725@ppc970.osdl.org","subject":"Re: [PATCH] Automerge fix","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-19T02:57:26Z","receivedAt":"2005-04-19T02:57:26Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Tue, Apr 19, 2005 at 04:48:09AM CEST, I got a letter\nwhere Linus Torvalds <torvalds@osdl.org> told me that...\n> > git-merge-one-file-script: 7ebf5dac4c69043cd2ff89bf7ee552152802f8d1\n> > --- a/git-merge-one-file-script\n> > +++ b/git-merge-one-file-script\n> > @@ -43,7 +43,7 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n> >  \torig=$(unpack-file $1)\n> >  \tsrc1=$(unpack-file $2)\n> >  \tsrc2=$(unpack-file $3)\n> > -\tmerge \"$src2\" \"$orig\" \"$src1\" || echo Leaving conflict merge in $src2 && exit 1\n> > +\tmerge \"$src2\" \"$orig\" \"$src1\" || (echo Leaving conflict merge in $src2 && exit 1)\n> >  \tcp \"$src2\" \"$4\" && update-cache --add -- \"$4\" && exit 0\n> \n> What's the right way?\n> \n> Maybe\n> \n> \tif merge \"$src2\" \"$orig\" \"$src1\"\n> \tthen \n> \t\tcp \"$src2\" \"$4\" && update-cache --add -- \"$4\" && exit 0\n> \tfi\n> \techo Leaving conflict merge in $src2\n> \texit 1\n> \n> would work?\n\nPossibly. Or changing () to {} as suggested by Edgar Toernig.\n\nFWIW, my fragment of this code now looks like:\n\n        ret=0\n        if ! merge \"$src2\" \"$orig\" \"$src1\"; then\n                echo Conflicting merge!\n                cat \"$src2\" >\"$4\"\n                ret=1\n\n        elif ! cat \"$src2\" >\"$4\" && update-cache --add -- \"$4\"; then\n                echo \"Choosing $src2 -> $4 failed\"\n                ret=1\n        fi\n        rm \"$orig\" \"$src1\" \"$src2\"\n        exit $ret\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"783","messageId":"7voecbqqv3.fsf@assigned-by-dhcp.cox.net","threadId":"122","inReplyTo":"Pine.LNX.4.58.0504181945400.15725@ppc970.osdl.org","subject":"Re: [PATCH] Automerge fix","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-19T05:26:24Z","receivedAt":"2005-04-19T05:26:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":">>>>> \"LT\" == Linus Torvalds <torvalds@osdl.org> writes:\n\nLT> What's the right way?\n\nLT> Maybe\n\nLT> \tif merge \"$src2\" \"$orig\" \"$src1\"\nLT> \tthen \nLT> \t\tcp \"$src2\" \"$4\" && update-cache --add -- \"$4\" && exit 0\nLT> \tfi\nLT> \techo Leaving conflict merge in $src2\nLT> \texit 1\n\nLT> would work?\n\nWouldn't this be more readable, short and sweet?\n\n    merge \"$src2\" \"$orig\" \"$src1\" || {\n        echo Leaving conflict merge in $src2 && exit 1\n    }\n    cp \"$src2\" \"$4\" && exec update-cache --add -- \"$4\"\n\nYou did not want subshell so I just changed the () pair to the\n{} pair, and while I was at it I folded the \"&& exit 0\" into the\nlast command before it, which should be better.  You'd want to\nknow if update-cache --add failed for whatever reason.\n\n"}]}