Commit df3ed485f4148d31d1b555abb99fcba42c1a49b7

Stefan Sperling 2021-01-31T11:57:10

simplify the error message shown when 'got rebase' has nothing to do

diff --git a/got/got.c b/got/got.c
index 7a85d64..9a5559d 100644
--- a/got/got.c
+++ b/got/got.c
@@ -7918,9 +7918,12 @@ cmd_rebase(int argc, char *argv[])
 				goto done;
 			error = NULL;
 		} else {
-			error = got_error_msg(GOT_ERR_SAME_BRANCH,
-			    "specified branch resolves to a commit which "
-			    "is already contained in work tree's branch");
+			static char msg[128];
+			snprintf(msg, sizeof(msg),
+			    "%s is already based on %s",
+			    got_ref_get_name(branch),
+			    got_worktree_get_head_ref_name(worktree));
+			error = got_error_msg(GOT_ERR_SAME_BRANCH, msg);
 			goto done;
 		}
 		error = got_worktree_rebase_prepare(&new_base_branch,
diff --git a/regress/cmdline/rebase.sh b/regress/cmdline/rebase.sh
index f521fb1..5bf2ae4 100755
--- a/regress/cmdline/rebase.sh
+++ b/regress/cmdline/rebase.sh
@@ -173,10 +173,8 @@ test_rebase_ancestry_check() {
 		return 1
 	fi
 
-	echo -n "got: specified branch resolves to a commit " \
+	echo "got: refs/heads/newbranch is already based on refs/heads/master" \
 		> $testroot/stderr.expected
-	echo "which is already contained in work tree's branch" \
-		>> $testroot/stderr.expected
 	cmp -s $testroot/stderr.expected $testroot/stderr
 	ret="$?"
 	if [ "$ret" != "0" ]; then