git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] rebase: Squelch the "fatal: Not an error." message
@ 2010-03-24  0:03 Kevin Ballard
  2010-03-25 21:24 ` Kevin Ballard
  2010-03-26 19:25 ` Junio C Hamano
  0 siblings, 2 replies; 6+ messages in thread
From: Kevin Ballard @ 2010-03-24  0:03 UTC (permalink / raw
  To: git

[-- Attachment #1: Type: text/plain, Size: 1081 bytes --]

When `git rebase --onto newbase upstream` is executed with
upstream being equal to the current commit, `git rebase` will
call `git format-patch` with "upstream..upstream" as the commits
to generate patches for. This causes a spurious error message to
be thrown which should be squelched.

Signed-off-by: Kevin Ballard <kevin@sb.org>
---
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.

git-rebase.sh |    2 +-
1 files changed, 1 insertions(+), 1 deletions(-)


[-- Attachment #2: 0001-rebase-Squelch-the-fatal-Not-an-error.-message.patch --]
[-- Type: text/x-patch, Size: 403 bytes --]

diff --git a/git-rebase.sh b/git-rebase.sh
index e0eb956..8868dee 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -544,7 +544,7 @@ fi
 if test -z "$do_merge"
 then
 	git format-patch -k --stdout --full-index --ignore-if-in-upstream \
-		$root_flag "$revisions" |
+		$root_flag "$revisions" 2>/dev/null |
 	git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" &&
 	move_to_original_branch
 	ret=$?

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] rebase: Squelch the "fatal: Not an error." message
  2010-03-24  0:03 [PATCH] rebase: Squelch the "fatal: Not an error." message Kevin Ballard
@ 2010-03-25 21:24 ` Kevin Ballard
  2010-03-26 19:25 ` Junio C Hamano
  1 sibling, 0 replies; 6+ messages in thread
From: Kevin Ballard @ 2010-03-25 21:24 UTC (permalink / raw
  To: git

Aww crud, I just realized I titled this patch wrong. It was supposed to be

rebase: Squelch the "fatal: Not a range." error

Should I send out a new patch?

-Kevin Ballard

On Mar 23, 2010, at 5:03 PM, Kevin Ballard wrote:

> When `git rebase --onto newbase upstream` is executed with
> upstream being equal to the current commit, `git rebase` will
> call `git format-patch` with "upstream..upstream" as the commits
> to generate patches for. This causes a spurious error message to
> be thrown which should be squelched.
> 
> Signed-off-by: Kevin Ballard <kevin@sb.org>
> ---
> 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.
> 
> git-rebase.sh |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
> 
> <0001-rebase-Squelch-the-fatal-Not-an-error.-message.patch>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] rebase: Squelch the "fatal: Not an error." message
  2010-03-24  0:03 [PATCH] rebase: Squelch the "fatal: Not an error." message Kevin Ballard
  2010-03-25 21:24 ` Kevin Ballard
@ 2010-03-26 19:25 ` Junio C Hamano
  2010-03-26 23:31   ` Kevin Ballard
  1 sibling, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2010-03-26 19:25 UTC (permalink / raw
  To: Kevin Ballard; +Cc: git

Kevin Ballard <kevin@sb.org> writes:

> ... 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.

Hmm, since "git format-patch HEAD" simply exits with success, I am
inclined to think that we should fix "format-patch HEAD..HEAD" to do the
same instead.  I didn't check how involved such a change might be,
though.

>
> git-rebase.sh |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
>
> diff --git a/git-rebase.sh b/git-rebase.sh
> index e0eb956..8868dee 100755
> --- a/git-rebase.sh
> +++ b/git-rebase.sh
> @@ -544,7 +544,7 @@ fi
>  if test -z "$do_merge"
>  then
>  	git format-patch -k --stdout --full-index --ignore-if-in-upstream \
> -		$root_flag "$revisions" |
> +		$root_flag "$revisions" 2>/dev/null |
>  	git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" &&
>  	move_to_original_branch
>  	ret=$?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] rebase: Squelch the "fatal: Not an error." message
  2010-03-26 19:25 ` Junio C Hamano
@ 2010-03-26 23:31   ` Kevin Ballard
  2010-03-27  0:08     ` Kevin Ballard
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Ballard @ 2010-03-26 23:31 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 633 bytes --]

On Mar 26, 2010, at 12:25 PM, Junio C Hamano wrote:

> Hmm, since "git format-patch HEAD" simply exits with success, I am
> inclined to think that we should fix "format-patch HEAD..HEAD" to do the
> same instead.  I didn't check how involved such a change might be,
> though.

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.

-Kevin Ballard

-- 
Kevin Ballard
http://kevin.sb.org
kevin@sb.org
http://www.tildesoft.com




[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2432 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] rebase: Squelch the "fatal: Not an error." message
  2010-03-26 23:31   ` Kevin Ballard
@ 2010-03-27  0:08     ` Kevin Ballard
  2010-03-30  2:46       ` [PATCH] format-patch: Squelch 'fatal: Not a range." error Kevin Ballard
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Ballard @ 2010-03-27  0:08 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Git Mailing List

[-- Attachment #1: Type: text/plain, Size: 1383 bytes --]

On Mar 26, 2010, at 4:31 PM, Kevin Ballard wrote:

> On Mar 26, 2010, at 12:25 PM, Junio C Hamano wrote:
> 
>> Hmm, since "git format-patch HEAD" simply exits with success, I am
>> inclined to think that we should fix "format-patch HEAD..HEAD" to do the
>> same instead.  I didn't check how involved such a change might be,
>> though.
> 
> 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.

Hmm, 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):

	if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))
		die("Not a range.");

Without 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).

-Kevin Ballard

-- 
Kevin Ballard
http://kevin.sb.org
kevin@sb.org
http://www.tildesoft.com




[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2432 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] format-patch: Squelch 'fatal: Not a range." error
  2010-03-27  0:08     ` Kevin Ballard
@ 2010-03-30  2:46       ` Kevin Ballard
  0 siblings, 0 replies; 6+ messages in thread
From: Kevin Ballard @ 2010-03-30  2:46 UTC (permalink / raw
  To: git; +Cc: Kevin Ballard, Junio C Hamano

Don't output an error on `git format-patch --ignore-if-in-upstream HEAD`.
This matches the behavior of `git format-patch HEAD`.

Signed-off-by: Kevin Ballard <kevin@sb.org>
---
This seems like a safer change than just deleting the die("Not a range.").
The conditional here is copied from cmd_cherry().
 builtin/log.c           |    9 ++++++++-
 t/t4014-format-patch.sh |    4 ++++
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/builtin/log.c b/builtin/log.c
index 0cb4d5a..362dd42 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1179,8 +1179,15 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 			return 0;
 	}
 
-	if (ignore_if_in_upstream)
+	if (ignore_if_in_upstream) {
+		/* Don't say anything if head and upstream are the same. */
+		if (rev.pending.nr == 2) {
+			struct object_array_entry *o = rev.pending.objects;
+			if (hashcmp(o[0].item->sha1, o[1].item->sha1) == 0)
+				return 0;
+		}
 		get_patch_ids(&rev, &ids, prefix);
+	}
 
 	if (!use_stdout)
 		realstdout = xfdopen(xdup(1), "w");
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index c7b6256..d21c37f 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -609,4 +609,8 @@ test_expect_success 'format-patch -- <path>' '
 	! grep "Use .--" error
 '
 
+test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
+	git format-patch --ignore-if-in-upstream HEAD
+'
+
 test_done
-- 
1.7.0.3.436.g3ff98

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-03-30  2:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-24  0:03 [PATCH] rebase: Squelch the "fatal: Not an error." message Kevin Ballard
2010-03-25 21:24 ` Kevin Ballard
2010-03-26 19:25 ` Junio C Hamano
2010-03-26 23:31   ` Kevin Ballard
2010-03-27  0:08     ` Kevin Ballard
2010-03-30  2:46       ` [PATCH] format-patch: Squelch 'fatal: Not a range." error Kevin Ballard

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).