git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* calling git rebase with invalid onto-ref exits with wrong error message
@ 2012-05-30  9:02 Manuela Hutter
  2012-05-30  9:27 ` Erik Faye-Lund
  0 siblings, 1 reply; 5+ messages in thread
From: Manuela Hutter @ 2012-05-30  9:02 UTC (permalink / raw)
  To: git

Just noticed a small bug (in git version 1.7.10.msysgit.1):

calling
   git rebase --onto <onto-ref> <base-ref> <branch-ref>

with an unknown <onto-ref> reports:
   fatal: Needed a single revision
   Does not point to a valid commit: <branch-ref>

Expected:
   fatal: Needed a single revision
   Does not point to a valid commit: <onto-ref>

Cheers,
Manuela

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

* Re: calling git rebase with invalid onto-ref exits with wrong error message
  2012-05-30  9:02 calling git rebase with invalid onto-ref exits with wrong error message Manuela Hutter
@ 2012-05-30  9:27 ` Erik Faye-Lund
  2012-05-30 15:37   ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Erik Faye-Lund @ 2012-05-30  9:27 UTC (permalink / raw)
  To: manuelah; +Cc: git

On Wed, May 30, 2012 at 11:02 AM, Manuela Hutter <manuelah@opera.com> wrote:
> Just noticed a small bug (in git version 1.7.10.msysgit.1):
>
> calling
>   git rebase --onto <onto-ref> <base-ref> <branch-ref>
>
> with an unknown <onto-ref> reports:
>   fatal: Needed a single revision
>   Does not point to a valid commit: <branch-ref>
>
> Expected:
>   fatal: Needed a single revision
>   Does not point to a valid commit: <onto-ref>
>

Indeed. This looks like the result of a bad merge-resolution, but I
could be mistaken. This looks like the correct solution to me:

diff --git a/git-rebase.sh b/git-rebase.sh
index 24a2840..3267c92 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -423,7 +423,7 @@ case "$onto_name" in
 	;;
 *)
 	onto=$(git rev-parse --verify "${onto_name}^0") ||
-	die "Does not point to a valid commit: $1"
+	die "Does not point to a valid commit: $onto_name"
 	;;
 esac

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

* Re: calling git rebase with invalid onto-ref exits with wrong error message
  2012-05-30  9:27 ` Erik Faye-Lund
@ 2012-05-30 15:37   ` Junio C Hamano
  2012-05-30 16:39     ` [PATCH] rebase: report invalid commit correctly Erik Faye-Lund
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2012-05-30 15:37 UTC (permalink / raw)
  To: kusmabite; +Cc: manuelah, git

Erik Faye-Lund <kusmabite@gmail.com> writes:

> Indeed. This looks like the result of a bad merge-resolution, but I
> could be mistaken.

It looks like 9765b6a (rebase: align variable content, 2011-02-06)
originally botched it, which propagated to 71786f5 (rebase: factor
out reference parsing, 2011-02-06) in the series, and finally merged
at 78c6e0f (Merge branch 'mz/rebase', 2011-04-28).

> This looks like the correct solution to me:
>
> diff --git a/git-rebase.sh b/git-rebase.sh
> index 24a2840..3267c92 100755
> --- a/git-rebase.sh
> +++ b/git-rebase.sh
> @@ -423,7 +423,7 @@ case "$onto_name" in
>  	;;
>  *)
>  	onto=$(git rev-parse --verify "${onto_name}^0") ||
> -	die "Does not point to a valid commit: $1"
> +	die "Does not point to a valid commit: $onto_name"
>  	;;
>  esac

Yes, it does.

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

* [PATCH] rebase: report invalid commit correctly
  2012-05-30 15:37   ` Junio C Hamano
@ 2012-05-30 16:39     ` Erik Faye-Lund
  2012-05-30 21:11       ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Erik Faye-Lund @ 2012-05-30 16:39 UTC (permalink / raw)
  To: git; +Cc: manuelah, gitster

In 9765b6a (rebase: align variable content, 2011-02-06), the code
to error out was moved up one level. Unfortunately, one reference
to a function parameter wasn't rewritten as it should, leading to
the wrong parameter being errored on.

This error was propagated by 71786f5 (rebase: factor out reference
parsing, 2011-02-06) and merged in 78c6e0f (Merge branch
'mz/rebase', 2011-04-28).

Correct this by reporting $onto_name istead.

Reported-By: Manuela Hutter <manuelah@opera.com>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---

Here's a proper patch, I guess.

On Wed, May 30, 2012 at 5:37 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Erik Faye-Lund <kusmabite@gmail.com> writes:
>
>> Indeed. This looks like the result of a bad merge-resolution, but I
>> could be mistaken.
>
> It looks like 9765b6a (rebase: align variable content, 2011-02-06)
> originally botched it, which propagated to 71786f5 (rebase: factor
> out reference parsing, 2011-02-06) in the series, and finally merged
> at 78c6e0f (Merge branch 'mz/rebase', 2011-04-28).
>

Thanks for digging, this was very helpful for the commit message.

 git-rebase.sh             | 2 +-
 t/t3406-rebase-message.sh | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/git-rebase.sh b/git-rebase.sh
index 24a2840..3267c92 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -423,7 +423,7 @@ case "$onto_name" in
 	;;
 *)
 	onto=$(git rev-parse --verify "${onto_name}^0") ||
-	die "Does not point to a valid commit: $1"
+	die "Does not point to a valid commit: $onto_name"
 	;;
 esac
 
diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh
index fe5f936..6898377 100755
--- a/t/t3406-rebase-message.sh
+++ b/t/t3406-rebase-message.sh
@@ -62,4 +62,9 @@ test_expect_success 'rebase -n overrides config rebase.stat config' '
         ! grep "^ fileX |  *1 +$" diffstat.txt
 '
 
+test_expect_success 'rebase --onto outputs the invalid ref' '
+	test_must_fail git rebase --onto invalid-ref HEAD HEAD 2>err &&
+	grep "invalid-ref" err
+'
+
 test_done
-- 
1.7.10.msysgit.1.1147.g20e60f3

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

* Re: [PATCH] rebase: report invalid commit correctly
  2012-05-30 16:39     ` [PATCH] rebase: report invalid commit correctly Erik Faye-Lund
@ 2012-05-30 21:11       ` Junio C Hamano
  0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2012-05-30 21:11 UTC (permalink / raw)
  To: Erik Faye-Lund; +Cc: git, manuelah

Erik Faye-Lund <kusmabite@gmail.com> writes:

> In 9765b6a (rebase: align variable content, 2011-02-06), the code
> to error out was moved up one level. Unfortunately, one reference
> to a function parameter wasn't rewritten as it should, leading to
> the wrong parameter being errored on.
>
> This error was propagated by 71786f5 (rebase: factor out reference
> parsing, 2011-02-06) and merged in 78c6e0f (Merge branch
> 'mz/rebase', 2011-04-28).
>
> Correct this by reporting $onto_name istead.
>
> Reported-By: Manuela Hutter <manuelah@opera.com>
> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
> ---
>
> Here's a proper patch, I guess.

Thanks.

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

end of thread, other threads:[~2012-05-30 21:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-30  9:02 calling git rebase with invalid onto-ref exits with wrong error message Manuela Hutter
2012-05-30  9:27 ` Erik Faye-Lund
2012-05-30 15:37   ` Junio C Hamano
2012-05-30 16:39     ` [PATCH] rebase: report invalid commit correctly Erik Faye-Lund
2012-05-30 21:11       ` Junio C Hamano

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 NNTP newsgroup(s).