{"thread":{"id":"17633","subject":"[PATCH] rebase: do not fail silently when the HEAD could not be detached","startedAt":"2009-02-07T17:20:09Z","lastAt":"2009-02-08T10:27:45Z","messageCount":5,"participants":["Johannes Schindelin","Junio C Hamano","Björn Steinbrink"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"103637","messageId":"679be9321b4cf4f694917cb9eebba70376a43a0a.1234027102u.git.johannes.schindelin@gmx.de","threadId":"17633","inReplyTo":"cover.1234027102u.git.johannes.schindelin@gmx.de","subject":"[PATCH] rebase: do not fail silently when the HEAD could not be detached","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-02-07T17:20:09Z","receivedAt":"2009-02-07T17:20:09Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Since 6fd2f5e(rebase: operate on a detached HEAD), rebase operates on a\ndetached HEAD.  However, it used \"checkout -q\" to detach the HEAD, which\nhid an error message when, say, an untracked file would have to be\noverwritten to detach the HEAD.\n\nInstead of hiding the output of the checkout in all cases, only hide it\nwhen no error occurred.\n\nWhile at it, add a test that \"rebase\" actually operated on a detached\nHEAD.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n git-rebase.sh     |    2 +-\n t/t3400-rebase.sh |   13 ++++++++++++-\n 2 files changed, 13 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 6d3eddb..1526fcb 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -434,7 +434,7 @@ fi\n \n # Detach HEAD and reset the tree\n echo \"First, rewinding head to replay your work on top of it...\"\n-git checkout -q \"$onto^0\" || die \"could not detach HEAD\"\n+error=$(git checkout \"$onto\" 2>&1) || die \"${error}could not detach HEAD\"\n git update-ref ORIG_HEAD $branch\n \n # If the $onto is a proper descendant of the tip of the branch, then\ndiff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh\nindex b7a670e..8c0c5f5 100755\n--- a/t/t3400-rebase.sh\n+++ b/t/t3400-rebase.sh\n@@ -14,7 +14,8 @@ export GIT_AUTHOR_EMAIL\n \n test_expect_success \\\n     'prepare repository with topic branches' \\\n-    'echo First > A &&\n+    'git config core.logAllRefUpdates true &&\n+     echo First > A &&\n      git update-index --add A &&\n      git commit -m \"Add A.\" &&\n      git checkout -b my-topic-branch &&\n@@ -84,4 +85,14 @@ test_expect_success 'rebase a single mode change' '\n      GIT_TRACE=1 git rebase master\n '\n \n+test_expect_success 'HEAD was detached during rebase' '\n+     test $(git rev-parse HEAD@{1}) != $(git rev-parse modechange@{1})\n+'\n+\n+test_expect_success 'Show verbose error when HEAD could not be detached' '\n+     : > B &&\n+     test_must_fail git rebase topic 2> output.err > output.out &&\n+     grep \"Untracked working tree file .B. would be overwritten\" output.err\n+'\n+\n test_done\n-- \n1.6.1.2.655.g3f285\n"},{"id":"103657","messageId":"7v7i41udij.fsf@gitster.siamese.dyndns.org","threadId":"17633","inReplyTo":"679be9321b4cf4f694917cb9eebba70376a43a0a.1234027102u.git.johannes.schindelin@gmx.de","subject":"Re: [PATCH] rebase: do not fail silently when the HEAD could not be detached","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-07T21:45:56Z","receivedAt":"2009-02-07T21:45:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sounds sensible to be in 1.6.2.\n"},{"id":"103670","messageId":"20090207233524.GD11623@atjola.homenet","threadId":"17633","inReplyTo":"679be9321b4cf4f694917cb9eebba70376a43a0a.1234027102u.git.johannes.schindelin@gmx.de","subject":"Re: [PATCH] rebase: do not fail silently when the HEAD could not be detached","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-02-07T23:35:24Z","receivedAt":"2009-02-07T23:35:24Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.02.07 18:20:09 +0100, Johannes Schindelin wrote:\n> Since 6fd2f5e(rebase: operate on a detached HEAD), rebase operates on a\n> detached HEAD.  However, it used \"checkout -q\" to detach the HEAD, which\n> hid an error message when, say, an untracked file would have to be\n> overwritten to detach the HEAD.\n\nHm, in 324c2c317 \"git-rebase: report checkout failure\", that was\nswitched from a stdout/stderr redirect to -q, so that those error\nmessages are shown. And with a quick test, rebase/checkout complains\njust fine:\n\ndoener@atjola:g (master) $ git checkout -q bar\nerror: Untracked working tree file 'file' would be overwritten by merge.\ndoener@atjola:g (master) $ git rebase bar\nFirst, rewinding head to replay your work on top of it...\nerror: Untracked working tree file 'file' would be overwritten by merge.\ncould not detach HEAD\n\ndoener@atjola:g (master) $ git --version \ngit version 1.6.2.rc0\n\nSame with next and pu.\n\nBjörn\n"},{"id":"103681","messageId":"7v7i414qb9.fsf@gitster.siamese.dyndns.org","threadId":"17633","inReplyTo":"20090207233524.GD11623@atjola.homenet","subject":"Re: [PATCH] rebase: do not fail silently when the HEAD could not be detached","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-08T02:26:18Z","receivedAt":"2009-02-08T02:26:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Björn Steinbrink <B.Steinbrink@gmx.de> writes:\n\n> On 2009.02.07 18:20:09 +0100, Johannes Schindelin wrote:\n>> Since 6fd2f5e(rebase: operate on a detached HEAD), rebase operates on a\n>> detached HEAD.  However, it used \"checkout -q\" to detach the HEAD, which\n>> hid an error message when, say, an untracked file would have to be\n>> overwritten to detach the HEAD.\n>\n> Hm, in 324c2c317 \"git-rebase: report checkout failure\", that was\n> switched from a stdout/stderr redirect to -q, so that those error\n> messages are shown. And with a quick test, rebase/checkout complains\n> just fine:\n\nVery interesting.\n\nDscho, how did you get the \"important part of error information is hidden\"\nfailure that led to this patch?  Did it come from code inspection and\nspeculation alone, or was there an actual failure case?\n\nIf I apply the patch t/t3400-rebase.sh from your message alone to\n'master', it does seem to pass.\n"},{"id":"103716","messageId":"alpine.DEB.1.00.0902081125400.10279@pacific.mpi-cbg.de","threadId":"17633","inReplyTo":"7v7i414qb9.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] rebase: do not fail silently when the HEAD could not be detached","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-02-08T10:27:45Z","receivedAt":"2009-02-08T10:27:45Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 7 Feb 2009, Junio C Hamano wrote:\n\n> Björn Steinbrink <B.Steinbrink@gmx.de> writes:\n> \n> > On 2009.02.07 18:20:09 +0100, Johannes Schindelin wrote:\n> >> Since 6fd2f5e(rebase: operate on a detached HEAD), rebase operates on a\n> >> detached HEAD.  However, it used \"checkout -q\" to detach the HEAD, which\n> >> hid an error message when, say, an untracked file would have to be\n> >> overwritten to detach the HEAD.\n> >\n> > Hm, in 324c2c317 \"git-rebase: report checkout failure\", that was\n> > switched from a stdout/stderr redirect to -q, so that those error\n> > messages are shown. And with a quick test, rebase/checkout complains\n> > just fine:\n> \n> Very interesting.\n> \n> Dscho, how did you get the \"important part of error information is hidden\"\n> failure that led to this patch?  Did it come from code inspection and\n> speculation alone, or was there an actual failure case?\n\nHmm, sorry, I thought I got this with \"my\" Git, but it appears that due to \nsome strange reason I do not understand completely, I was not actually \nusing the Git binary from $HOME/bin/, but /usr/bin/.\n\n> If I apply the patch t/t3400-rebase.sh from your message alone to\n> 'master', it does seem to pass.\n\nWell, please ignore the patch, then.  Or take the test alone.\n\nCiao,\nDscho\n"}]}