{"thread":{"id":"14415","subject":"[PATCH] git-rebase.sh: Display error output from git-checkout when detaching HEAD fails.","startedAt":"2008-07-11T21:26:59Z","lastAt":"2008-07-15T15:22:25Z","messageCount":4,"participants":["Robert Shearman","Junio C Hamano","Rob Shearman"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"83015","messageId":"1215811619-28512-1-git-send-email-robertshearman@gmail.com","threadId":"14415","inReplyTo":null,"subject":"[PATCH] git-rebase.sh: Display error output from git-checkout when detaching HEAD fails.","fromName":"Robert Shearman","fromEmail":"robertshearman@gmail.com","sentAt":"2008-07-11T21:26:59Z","receivedAt":"2008-07-11T21:26:59Z","isPatch":true,"sender":{"key":"robertshearman@gmail.com","avatar":null},"body":"The \"git checkout\" command executed could fail if, for example, upstream contains a file that would overrwrite a local, untracked file. The output redirection didn't work as stderr was redirected to /dev/null, as was stdout. This appears to be not what was intended so the order of redirections is fixed so that stderr is redirected to stdout instead.\n---\n git-rebase.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex e2d85ee..0da2210 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -376,7 +376,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 \"$onto^0\" >/dev/null 2>&1 ||\n+git checkout \"$onto^0\" 2>&1 >/dev/null ||\n \tdie \"could not detach HEAD\"\n # git reset --hard \"$onto^0\"\n \n-- \n1.5.6.2.225.g4596.dirty\n"},{"id":"83033","messageId":"7vr6a0hvvu.fsf@gitster.siamese.dyndns.org","threadId":"14415","inReplyTo":"1215811619-28512-1-git-send-email-robertshearman@gmail.com","subject":"Re: [PATCH] git-rebase.sh: Display error output from git-checkout when detaching HEAD fails.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-11T22:57:25Z","receivedAt":"2008-07-11T22:57:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Robert Shearman <robertshearman@gmail.com> writes:\n\n> The \"git checkout\" command executed could fail if, for example, upstream contains a file that would overrwrite a local, untracked file. The output redirection didn't work as stderr was redirected to /dev/null, as was stdout. This appears to be not what was intended so the order of redirections is fixed so that stderr is redirected to stdout instead.\n\nVery long lines, lacks sign-off.\n\n> ---\n>  git-rebase.sh |    2 +-\n>  1 files changed, 1 insertions(+), 1 deletions(-)\n>\n> diff --git a/git-rebase.sh b/git-rebase.sh\n> index e2d85ee..0da2210 100755\n> --- a/git-rebase.sh\n> +++ b/git-rebase.sh\n> @@ -376,7 +376,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 \"$onto^0\" >/dev/null 2>&1 ||\n\nI think this very much is done deliberately by somebody who knows the\nshell to discard everything.\n\n> +git checkout \"$onto^0\" 2>&1 >/dev/null ||\n\nAnd if it is beneficial to show the error, you just do not touch fd #2,\nlike this:\n\n\tgit checkout \"$onto^0\" >/dev/null\n\nAs I do not see any reason to send the error message to stdout like you\ndid.\n\nI also suspect that this part of the script predates 6124aee (add a quiet\noption to git-checkout, 2007-02-01) where the command learned to be more\nquiet during the normal operation.  Perhaps you can replace the line with\n\n\tgit checkout -q \"$onto^0\"\n\nand be done with it.  I haven't tested it, though.\n"},{"id":"83300","messageId":"1096648c0807141257i76f70322p5a16c86c1c826a66@mail.gmail.com","threadId":"14415","inReplyTo":"7vr6a0hvvu.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-rebase.sh: Display error output from git-checkout when detaching HEAD fails.","fromName":"Rob Shearman","fromEmail":"robertshearman@gmail.com","sentAt":"2008-07-14T19:57:17Z","receivedAt":"2008-07-14T19:57:17Z","isPatch":true,"sender":{"key":"robertshearman@gmail.com","avatar":null},"body":"2008/7/11 Junio C Hamano <gitster@pobox.com>:\n> Robert Shearman <robertshearman@gmail.com> writes:\n>> diff --git a/git-rebase.sh b/git-rebase.sh\n>> index e2d85ee..0da2210 100755\n>> --- a/git-rebase.sh\n>> +++ b/git-rebase.sh\n>> @@ -376,7 +376,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 \"$onto^0\" >/dev/null 2>&1 ||\n>\n> I think this very much is done deliberately by somebody who knows the\n> shell to discard everything.\n\nWhy wasn't \"git checkout \"$onto^0\" &> /dev/null\" used then? Then only\nreason I can come up with would be portability, but it seems\nsurprising to me.\n\n>> +git checkout \"$onto^0\" 2>&1 >/dev/null ||\n>\n> And if it is beneficial to show the error, you just do not touch fd #2,\n> like this:\n>\n>        git checkout \"$onto^0\" >/dev/null\n\nAbsolutely. I was just trying to fix the statement to what I thought\nwas the original intent.\n\n> As I do not see any reason to send the error message to stdout like you\n> did.\n>\n> I also suspect that this part of the script predates 6124aee (add a quiet\n> option to git-checkout, 2007-02-01) where the command learned to be more\n> quiet during the normal operation.  Perhaps you can replace the line with\n>\n>        git checkout -q \"$onto^0\"\n>\n> and be done with it.  I haven't tested it, though.\n\nI just tested it and it solves the original issue whilst not\ndisplaying unnecessary messages during a rebase. For reference, the\nattached script reproduces the issue that I was trying to solve.\n\nShould I resend the patch (like the following) now that it is\neffectively completely your work?\n\n-git checkout \"$onto^0\" >/dev/null 2>&1 ||\n+git checkout -q \"$onto^0\" ||\n\n-- \nRob Shearman\n"},{"id":"83403","messageId":"7vmykj2mvi.fsf@gitster.siamese.dyndns.org","threadId":"14415","inReplyTo":"1096648c0807141257i76f70322p5a16c86c1c826a66@mail.gmail.com","subject":"Re: [PATCH] git-rebase.sh: Display error output from git-checkout when detaching HEAD fails.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-15T15:22:25Z","receivedAt":"2008-07-15T15:22:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Rob Shearman\" <robertshearman@gmail.com> writes:\n\n> 2008/7/11 Junio C Hamano <gitster@pobox.com>:\n> ...\n>> I think this very much is done deliberately by somebody who knows the\n>> shell to discard everything.\n>\n> Why wasn't \"git checkout \"$onto^0\" &> /dev/null\" used then? Then only\n> reason I can come up with would be portability,...\n\nYes, we are quite old fashioned when it comes to shell scripting.\n\n>> ...  Perhaps you can replace the line with\n>>\n>>        git checkout -q \"$onto^0\"\n>>\n>> and be done with it.  I haven't tested it, though.\n>\n> I just tested it and it solves the original issue whilst not\n> displaying unnecessary messages during a rebase. For reference, the\n> attached script reproduces the issue that I was trying to solve.\n>\n> Should I resend the patch (like the following) now that it is\n> effectively completely your work?\n\nYour choice.\n\nThe issues you might want to consider when making that choice are:\n\n - Resending something that is trivial may seem waste of time on your\n   part;\n\n - Bringing the issue up is more than half of solving it, and you deserve\n   the credit.  By resending with a clear commit log message you assure\n   this;\n\n - I am handling many patches for git.git that are readily applicable\n   immediately after I read them in my mbox, while creating a commit out\n   of this discussion is something I need to \"work on\".  When I get around\n   to do some git work tonight, I may not even recall this dialogue, and\n   the solution may be forgotten.\n\n - I am lazy and may forget to pass --author=\"Rob Shearman <your@email>\"\n   even if I remember this conversation and when I make a commit myself;\n\nI just made a commit out of this discussion before I forget, so no need to\nresend for this one, but in general I'd appreciate a resend in general ;-)\n\n-- >8 --\nFrom: Junio C Hamano <gitster@pobox.com>\nDate: Mon, 14 Jul 2008 14:05:35 -0700\nSubject: [PATCH] git-rebase: report checkout failure\n\nWhen detaching the HEAD to the base commit, the \"git checkout\" command\ncould fail if, for example, upstream contains a file that would overrwrite\na local, untracked file.  Unconditionally discarding the standard error\nstream was done to squelch the progress and notices back when checkout\ndid not have -q option, but there is no reason to keep doing it anymore.\n\nNoticed by Robert Shearman.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-rebase.sh |    4 +---\n 1 files changed, 1 insertions(+), 3 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex e2d85ee..7825f88 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -376,9 +376,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 \"$onto^0\" >/dev/null 2>&1 ||\n-\tdie \"could not detach HEAD\"\n-# git reset --hard \"$onto^0\"\n+git checkout -q \"$onto^0\" || die \"could not detach HEAD\"\n \n # If the $onto is a proper descendant of the tip of the branch, then\n # we just fast forwarded.\n-- \n1.5.6.3.473.gc658e\n"}]}