{"thread":{"id":"23157","subject":"[PATCH] rebase: Squelch the \"fatal: Not an error.\" message","startedAt":"2010-03-24T00:03:05Z","lastAt":"2010-03-30T02:46:38Z","messageCount":6,"participants":["Kevin Ballard","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"137678","messageId":"C07F26A5-6BAD-433D-B1FF-A08DC8E0EA74@sb.org","threadId":"23157","inReplyTo":null,"subject":"[PATCH] rebase: Squelch the \"fatal: Not an error.\" message","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2010-03-24T00:03:05Z","receivedAt":"2010-03-24T00:03:05Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"When `git rebase --onto newbase upstream` is executed with\nupstream being equal to the current commit, `git rebase` will\ncall `git format-patch` with \"upstream..upstream\" as the commits\nto generate patches for. This causes a spurious error message to\nbe thrown which should be squelched.\n\nSigned-off-by: Kevin Ballard <kevin@sb.org>\n---\nThis patch was inspired by a common error encountered when using `git pull --rebase`, particularly in the case where there are no local commits that need rebasing and the fetched head was a force-pushed history modification (e.g. from git filter-branch). The error itself is actually caused by running `git rebase --onto newbase upstream` where upstream is the same commit as HEAD. This causes `git format-patch` to be called with \"upstream..upstream\" as the range and it complains. My solution was to squelch all errors from `git format-patch`, though I am unsure if the \"fatal: Not a range.\" error is the only error that can be raised in this situation.\n\ngit-rebase.sh |    2 +-\n1 files changed, 1 insertions(+), 1 deletions(-)\n\n\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex e0eb956..8868dee 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -544,7 +544,7 @@ fi\n if test -z \"$do_merge\"\n then\n \tgit format-patch -k --stdout --full-index --ignore-if-in-upstream \\\n-\t\t$root_flag \"$revisions\" |\n+\t\t$root_flag \"$revisions\" 2>/dev/null |\n \tgit am $git_am_opt --rebasing --resolvemsg=\"$RESOLVEMSG\" &&\n \tmove_to_original_branch\n \tret=$?\n"},{"id":"137815","messageId":"AB91AF2A-E6ED-4C4F-8B99-4A9CFA591C29@sb.org","threadId":"23157","inReplyTo":"C07F26A5-6BAD-433D-B1FF-A08DC8E0EA74@sb.org","subject":"Re: [PATCH] rebase: Squelch the \"fatal: Not an error.\" message","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2010-03-25T21:24:44Z","receivedAt":"2010-03-25T21:24:44Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"Aww crud, I just realized I titled this patch wrong. It was supposed to be\n\nrebase: Squelch the \"fatal: Not a range.\" error\n\nShould I send out a new patch?\n\n-Kevin Ballard\n\nOn Mar 23, 2010, at 5:03 PM, Kevin Ballard wrote:\n\n> When `git rebase --onto newbase upstream` is executed with\n> upstream being equal to the current commit, `git rebase` will\n> call `git format-patch` with \"upstream..upstream\" as the commits\n> to generate patches for. This causes a spurious error message to\n> be thrown which should be squelched.\n> \n> Signed-off-by: Kevin Ballard <kevin@sb.org>\n> ---\n> This patch was inspired by a common error encountered when using `git pull --rebase`, particularly in the case where there are no local commits that need rebasing and the fetched head was a force-pushed history modification (e.g. from git filter-branch). The error itself is actually caused by running `git rebase --onto newbase upstream` where upstream is the same commit as HEAD. This causes `git format-patch` to be called with \"upstream..upstream\" as the range and it complains. My solution was to squelch all errors from `git format-patch`, though I am unsure if the \"fatal: Not a range.\" error is the only error that can be raised in this situation.\n> \n> git-rebase.sh |    2 +-\n> 1 files changed, 1 insertions(+), 1 deletions(-)\n> \n> <0001-rebase-Squelch-the-fatal-Not-an-error.-message.patch>\n"},{"id":"137881","messageId":"7vy6helwbq.fsf@alter.siamese.dyndns.org","threadId":"23157","inReplyTo":"C07F26A5-6BAD-433D-B1FF-A08DC8E0EA74@sb.org","subject":"Re: [PATCH] rebase: Squelch the \"fatal: Not an error.\" message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-26T19:25:13Z","receivedAt":"2010-03-26T19:25:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kevin Ballard <kevin@sb.org> writes:\n\n> ... The error itself is\n> actually caused by running `git rebase --onto newbase upstream` where\n> upstream is the same commit as HEAD. This causes `git format-patch` to\n> be called with \"upstream..upstream\" as the range and it complains. My\n> solution was to squelch all errors from `git format-patch`, though I am\n> unsure if the \"fatal: Not a range.\" error is the only error that can be\n> raised in this situation.\n\nHmm, since \"git format-patch HEAD\" simply exits with success, I am\ninclined to think that we should fix \"format-patch HEAD..HEAD\" to do the\nsame instead.  I didn't check how involved such a change might be,\nthough.\n\n>\n> git-rebase.sh |    2 +-\n> 1 files changed, 1 insertions(+), 1 deletions(-)\n>\n>\n> diff --git a/git-rebase.sh b/git-rebase.sh\n> index e0eb956..8868dee 100755\n> --- a/git-rebase.sh\n> +++ b/git-rebase.sh\n> @@ -544,7 +544,7 @@ fi\n>  if test -z \"$do_merge\"\n>  then\n>  \tgit format-patch -k --stdout --full-index --ignore-if-in-upstream \\\n> -\t\t$root_flag \"$revisions\" |\n> +\t\t$root_flag \"$revisions\" 2>/dev/null |\n>  \tgit am $git_am_opt --rebasing --resolvemsg=\"$RESOLVEMSG\" &&\n>  \tmove_to_original_branch\n>  \tret=$?\n"},{"id":"137916","messageId":"F8E395F5-C248-4A95-B2EF-A36E941FFDCF@sb.org","threadId":"23157","inReplyTo":"7vy6helwbq.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] rebase: Squelch the \"fatal: Not an error.\" message","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2010-03-26T23:31:13Z","receivedAt":"2010-03-26T23:31:13Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"On Mar 26, 2010, at 12:25 PM, Junio C Hamano wrote:\n\n> Hmm, since \"git format-patch HEAD\" simply exits with success, I am\n> inclined to think that we should fix \"format-patch HEAD..HEAD\" to do the\n> same instead.  I didn't check how involved such a change might be,\n> though.\n\nActually it doesn't. The line `git format-patch --ignore-if-in-upstream HEAD` gives the same error (the flag seems to be necessary to get the error in the first place). In any case, I'll see if I can't figure out why it's giving that error.\n\n-Kevin Ballard\n\n-- \nKevin Ballard\nhttp://kevin.sb.org\nkevin@sb.org\nhttp://www.tildesoft.com\n\n\n\n"},{"id":"137921","messageId":"46BEF37C-3E3F-4490-9CE6-C0109438C181@sb.org","threadId":"23157","inReplyTo":"F8E395F5-C248-4A95-B2EF-A36E941FFDCF@sb.org","subject":"Re: [PATCH] rebase: Squelch the \"fatal: Not an error.\" message","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2010-03-27T00:08:20Z","receivedAt":"2010-03-27T00:08:20Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"On Mar 26, 2010, at 4:31 PM, Kevin Ballard wrote:\n\n> On Mar 26, 2010, at 12:25 PM, Junio C Hamano wrote:\n> \n>> Hmm, since \"git format-patch HEAD\" simply exits with success, I am\n>> inclined to think that we should fix \"format-patch HEAD..HEAD\" to do the\n>> same instead.  I didn't check how involved such a change might be,\n>> though.\n> \n> Actually it doesn't. The line `git format-patch --ignore-if-in-upstream HEAD` gives the same error (the flag seems to be necessary to get the error in the first place). In any case, I'll see if I can't figure out why it's giving that error.\n\nHmm, it seems like the easiest fix is just to comment out the following block in log.c (in get_patch_ids, line 645 on current next):\n\n\tif ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))\n\t\tdie(\"Not a range.\");\n\nWithout that line, `git format-patch --ignore-if-in-upstream HEAD` returns the expected empty output. I also ran the complete test suite (excluding SVN tests) and there were no breakages. However I don't understand the purpose behind that assertion in the first place (as I am not familiar with the workings of rev_info or patch_ids) so I don't know if this change is really appropriate (though I would assume that if it wasn't, a test somewhere would break).\n\n-Kevin Ballard\n\n-- \nKevin Ballard\nhttp://kevin.sb.org\nkevin@sb.org\nhttp://www.tildesoft.com\n\n\n\n"},{"id":"138150","messageId":"1269917198-58320-1-git-send-email-kevin@sb.org","threadId":"23157","inReplyTo":"46BEF37C-3E3F-4490-9CE6-C0109438C181@sb.org","subject":"[PATCH] format-patch: Squelch 'fatal: Not a range.\" error","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2010-03-30T02:46:38Z","receivedAt":"2010-03-30T02:46:38Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"Don't output an error on `git format-patch --ignore-if-in-upstream HEAD`.\nThis matches the behavior of `git format-patch HEAD`.\n\nSigned-off-by: Kevin Ballard <kevin@sb.org>\n---\nThis seems like a safer change than just deleting the die(\"Not a range.\").\nThe conditional here is copied from cmd_cherry().\n builtin/log.c           |    9 ++++++++-\n t/t4014-format-patch.sh |    4 ++++\n 2 files changed, 12 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 0cb4d5a..362dd42 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1179,8 +1179,15 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t\treturn 0;\n \t}\n \n-\tif (ignore_if_in_upstream)\n+\tif (ignore_if_in_upstream) {\n+\t\t/* Don't say anything if head and upstream are the same. */\n+\t\tif (rev.pending.nr == 2) {\n+\t\t\tstruct object_array_entry *o = rev.pending.objects;\n+\t\t\tif (hashcmp(o[0].item->sha1, o[1].item->sha1) == 0)\n+\t\t\t\treturn 0;\n+\t\t}\n \t\tget_patch_ids(&rev, &ids, prefix);\n+\t}\n \n \tif (!use_stdout)\n \t\trealstdout = xfdopen(xdup(1), \"w\");\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex c7b6256..d21c37f 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -609,4 +609,8 @@ test_expect_success 'format-patch -- <path>' '\n \t! grep \"Use .--\" error\n '\n \n+test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '\n+\tgit format-patch --ignore-if-in-upstream HEAD\n+'\n+\n test_done\n-- \n1.7.0.3.436.g3ff98\n"}]}