{"thread":{"id":"34817","subject":"Bug in git rebase --continue in v1.8.4","startedAt":"2013-08-31T12:49:37Z","lastAt":"2013-09-04T11:56:18Z","messageCount":6,"participants":["Christoph Mallon","Andriy Gapon","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"226416","messageId":"5221E661.1070200@gmx.de","threadId":"34817","inReplyTo":null,"subject":"Bug in git rebase --continue in v1.8.4","fromName":"Christoph Mallon","fromEmail":"christoph.mallon@gmx.de","sentAt":"2013-08-31T12:49:37Z","receivedAt":"2013-08-31T12:49:37Z","isPatch":false,"sender":{"key":"christoph.mallon@gmx.de","avatar":"https://avatars.githubusercontent.com/u/20772248?v=4"},"body":"Hi,\n\nif I run rebase --continue (e.g. after a conflict resolution), then the rebase always ends with this error message:\n\tIt seems that there is already a rebase-apply directory, and\n\tI wonder if you are in the middle of another rebase.  If that is the\n\tcase, please try\n        \tgit rebase (--continue | --abort | --skip)\n\tIf that is not the case, please\n        \trm -fr \"/home/tron/gitRebaseTest/test/.git/rebase-apply\"\n\tand run me again.  I am stopping in case you still have something\n\tvaluable there.\n\nThis happens on git v1.8.4 on FreeBSD. It is fine with v1.8.3.4. It seems to be caused by a1549e1049439386b9fd643fae236ad3ba649650, specifically this hunk:\n\t--- a/git-rebase--am.sh\n\t+++ b/git-rebase--am.sh\n\t@@ -7,12 +7,12 @@ case \"$action\" in\n\t continue)\n\t  git am --resolved --resolvemsg=\"$resolvemsg\" &&\n\t  move_to_original_branch\n\t- exit\n\t+ return\n\t  ;;\n\t skip)\n\t  git am --skip --resolvemsg=\"$resolvemsg\" &&\n\nAttached is a test script for this problem.\n\nRegards\n\tChristoph\n\n\n#! /bin/sh\nset -eux\n\ngit init test\ncd test\n\necho a > file\ngit add .\ngit commit -m a\n\ngit branch -t test\n\necho b > file\ngit add .\ngit commit -m b\n\ngit checkout test\necho c > file\ngit add .\ngit commit -m c\n\n! git rebase\ngit checkout --theirs .\ngit add .\ngit rebase --continue\n"},{"id":"226711","messageId":"5226E8FC.8070208@FreeBSD.org","threadId":"34817","inReplyTo":"5221E661.1070200@gmx.de","subject":"Re: Bug in git rebase --continue in v1.8.4","fromName":"Andriy Gapon","fromEmail":"avg@freebsd.org","sentAt":"2013-09-04T08:02:04Z","receivedAt":"2013-09-04T08:02:04Z","isPatch":false,"sender":{"key":"avg@freebsd.org","avatar":null},"body":"Christoph Mallon said:\n> if I run rebase --continue (e.g. after a conflict resolution), then the rebase always ends with this error message:\n> \tIt seems that there is already a rebase-apply directory, and\n> \tI wonder if you are in the middle of another rebase.  If that is the\n> \tcase, please try\n>         \tgit rebase (--continue | --abort | --skip)\n> \tIf that is not the case, please\n>         \trm -fr \"/home/tron/gitRebaseTest/test/.git/rebase-apply\"\n> \tand run me again.  I am stopping in case you still have something\n> \tvaluable there.\n> \n> This happens on git v1.8.4 on FreeBSD. It is fine with v1.8.3.4.\n\nI observe exactly the same problem.\nI also use FreeBSD and the problem started with 1.8.4.\n\nJudging by the lack of followups, could this be a FreeBSD-specific problem?\nAny thoughts / suggestions?\nThank you!\n\n> It seems to be caused by\n> a1549e1049439386b9fd643fae236ad3ba649650, specifically this hunk:\n> \t--- a/git-rebase--am.sh\n> \t+++ b/git-rebase--am.sh\n> \t <at>  <at>  -7,12 +7,12  <at>  <at>  case \"$action\" in\n> \t continue)\n> \t  git am --resolved --resolvemsg=\"$resolvemsg\" &&\n> \t  move_to_original_branch\n> \t- exit\n> \t+ return\n> \t  ;;\n> \t skip)\n> \t  git am --skip --resolvemsg=\"$resolvemsg\" &&\n\n-- \nAndriy Gapon\n"},{"id":"226713","messageId":"vpqsixl9ezo.fsf@anie.imag.fr","threadId":"34817","inReplyTo":"5226E8FC.8070208@FreeBSD.org","subject":"Re: Bug in git rebase --continue in v1.8.4","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-09-04T08:18:35Z","receivedAt":"2013-09-04T08:18:35Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"[ Cc-ing Ram, as he is the author of the possibly guilty commit. ]\n\nAndriy Gapon <avg@FreeBSD.org> writes:\n\n> Christoph Mallon said:\n>> if I run rebase --continue (e.g. after a conflict resolution), then the rebase always ends with this error message:\n>> \tIt seems that there is already a rebase-apply directory, and\n>> \tI wonder if you are in the middle of another rebase.  If that is the\n>> \tcase, please try\n>>         \tgit rebase (--continue | --abort | --skip)\n>> \tIf that is not the case, please\n>>         \trm -fr \"/home/tron/gitRebaseTest/test/.git/rebase-apply\"\n>> \tand run me again.  I am stopping in case you still have something\n>> \tvaluable there.\n>> \n>> This happens on git v1.8.4 on FreeBSD. It is fine with v1.8.3.4.\n>\n> I observe exactly the same problem.\n> I also use FreeBSD and the problem started with 1.8.4.\n>\n> Judging by the lack of followups, could this be a FreeBSD-specific problem?\n\nI can't reproduce here (Debian GNU/Linux). Do the testsuite pass for\nyou?\n\nIf not, can you write a failing test? A minimalist script outside the\ntestsuite may help too if you're not familiar with Git's testsuite.\n\n> Any thoughts / suggestions?\n> Thank you!\n>\n>> It seems to be caused by\n>> a1549e1049439386b9fd643fae236ad3ba649650, specifically this hunk:\n>> \t--- a/git-rebase--am.sh\n>> \t+++ b/git-rebase--am.sh\n>> \t <at>  <at>  -7,12 +7,12  <at>  <at>  case \"$action\" in\n>> \t continue)\n>> \t  git am --resolved --resolvemsg=\"$resolvemsg\" &&\n>> \t  move_to_original_branch\n>> \t- exit\n>> \t+ return\n>> \t  ;;\n>> \t skip)\n>> \t  git am --skip --resolvemsg=\"$resolvemsg\" &&\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"226717","messageId":"5226F4F8.7090304@FreeBSD.org","threadId":"34817","inReplyTo":"vpqsixl9ezo.fsf@anie.imag.fr","subject":"Re: Bug in git rebase --continue in v1.8.4","fromName":"Andriy Gapon","fromEmail":"avg@freebsd.org","sentAt":"2013-09-04T08:53:12Z","receivedAt":"2013-09-04T08:53:12Z","isPatch":false,"sender":{"key":"avg@freebsd.org","avatar":null},"body":"on 04/09/2013 11:18 Matthieu Moy said the following:\n> [ Cc-ing Ram, as he is the author of the possibly guilty commit. ]\n> \n> Andriy Gapon <avg@FreeBSD.org> writes:\n>> Judging by the lack of followups, could this be a FreeBSD-specific problem?\n> \n> I can't reproduce here (Debian GNU/Linux). Do the testsuite pass for\n> you?\n> \n> If not, can you write a failing test? A minimalist script outside the\n> testsuite may help too if you're not familiar with Git's testsuite.\n\nThank you for the suggestion.\nI've just tried it and it failed here:\n\n*** t3403-rebase-skip.sh ***\nok 1 - setup\nok 2 - rebase with git am -3 (default)\nok 3 - rebase --skip can not be used with other options\nnot ok 4 - rebase --skip with am -3\n#\n#               git rebase --skip\n#\nnot ok 5 - rebase moves back to skip-reference\n#\n#               test refs/heads/skip-reference = $(git symbolic-ref HEAD) &&\n#               git branch post-rebase &&\n#               git reset --hard pre-rebase &&\n#               test_must_fail git rebase master &&\n#               echo \"hello\" > hello &&\n#               git add hello &&\n#               git rebase --continue &&\n#               test refs/heads/skip-reference = $(git symbolic-ref HEAD) &&\n#               git reset --hard post-rebase\n#\nok 6 - checkout skip-merge\nok 7 - rebase with --merge\nnot ok 8 - rebase --skip with --merge\n#\n#               git rebase --skip\n#\nok 9 - merge and reference trees equal\nnot ok 10 - moved back to branch correctly\n#\n#               test refs/heads/skip-merge = $(git symbolic-ref HEAD)\n#\n# failed 4 among 10 test(s)\n\n\nChristoph has also suggested a small test script in his original email that\nstarted this thread:\nhttp://thread.gmane.org/gmane.comp.version-control.git/233516\n\n-- \nAndriy Gapon\n"},{"id":"226719","messageId":"5226FA92.5060709@FreeBSD.org","threadId":"34817","inReplyTo":"5226F4F8.7090304@FreeBSD.org","subject":"Re: Bug in git rebase --continue in v1.8.4","fromName":"Andriy Gapon","fromEmail":"avg@freebsd.org","sentAt":"2013-09-04T09:17:06Z","receivedAt":"2013-09-04T09:17:06Z","isPatch":false,"sender":{"key":"avg@freebsd.org","avatar":null},"body":"\nThis looks like bug in FreeBSD shell indeed.\nIf a script is sourced within a function scope, then 'return' in the script\ncauses the function to return.  But it should cause the sourced script to return.\n\nI'll see what we can do about this.\nSorry for distracting you.\nAnd thank you for the help!\n-- \nAndriy Gapon\n"},{"id":"226724","messageId":"vpq61ug6brx.fsf@anie.imag.fr","threadId":"34817","inReplyTo":"5226FA92.5060709@FreeBSD.org","subject":"Re: Bug in git rebase --continue in v1.8.4","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-09-04T11:56:18Z","receivedAt":"2013-09-04T11:56:18Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Andriy Gapon <avg@FreeBSD.org> writes:\n\n> This looks like bug in FreeBSD shell indeed.\n\nYes: the testsuite would have caught it otherwise.\n\n> If a script is sourced within a function scope, then 'return' in the script\n> causes the function to return.  But it should cause the sourced script to return.\n\nOK, so this is FreeBSD's fault. But that should not prevent us from\nfixing Git to make it work with FreeBSD.\n\nDoes the patch below fix the testsuite for you?\n\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -167,13 +167,22 @@ You can run \"git stash pop\" or \"git stash drop\" at any time.\n        rm -rf \"$state_dir\"\n }\n \n-run_specific_rebase () {\n+run_specific_rebase_internal () {\n        if [ \"$interactive_rebase\" = implied ]; then\n                GIT_EDITOR=:\n                export GIT_EDITOR\n                autosquash=\n        fi\n+       # On FreeBSD, the shell's \"return\" returns from the current\n+       # function, not from the current file inclusion.\n+       # run_specific_rebase_internal has the file inclusion as a\n+       # last statement, so POSIX and FreeBSD's return will do the\n+       # same thing.\n        . git-rebase--$type\n+}\n+\n+run_specific_rebase () {\n+       run_specific_rebase_internal\n        ret=$?\n        if test $ret -eq 0\n        then\n\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}