Skip to contentSkip to conversation

calling git rebase with invalid onto-ref exits with wrong error message

PATCH In review Manuela Hutter 3 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 5 lines · Manuela Hutter

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

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

Quoted 8 lines

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:

git-rebase.sh +1 -1
index 24a2840..3267c92 100755
@@ -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
#2 lore raw
Quoted 2 lines · Erik Faye-Lund

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

Quoted 7 lines

This looks like the correct solution to me:

git-rebase.sh +0 -0
index 24a2840..3267c92 100755

git-rebase.sh case "$onto_name" in · line 428

Quoted 7 lines
git-rebase.sh +1 -1
@@ -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.

#3 lore raw

PATCH 1/1 rebase: report invalid commit correctly

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.

---

Here's a proper patch, I guess.

Quoted 10 lines · Junio C Hamano
Quoted 2 lines · Erik Faye-Lund

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(-)
git-rebase.sh +1 -1
index 24a2840..3267c92 100755
@@ -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
 
t/t3406-rebase-message.sh +5 -0
index fe5f936..6898377 100755
@@ -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
Signature · 1 line
1.7.10.msysgit.1.1147.g20e60f3
#4 lore raw

Re: [PATCH] rebase: report invalid commit correctly

Quoted 9 lines · Erik Faye-Lund

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

Quoted 7 lines

Correct this by reporting $onto_name istead.

---

Here's a proper patch, I guess.

Thanks.