Commit Diff


commit - 22403ab7111504d4c33872ec85a46d2eaf21a95b
commit + 9e822917b02cb36e8dd86a73a51ddfd57baa6c25
blob - 28c535ec25b39ce9be78c197d5c2a4e393907add
blob + 5d1639cc92038e9f33eb3ea515cd83b8469b4fb0
--- got/got.c
+++ got/got.c
@@ -7923,6 +7923,7 @@ list_backup_refs(const char *backup_ref_prefix, const 
 	char *branch_name = NULL;
 	struct got_commit_object *old_commit = NULL;
 	struct got_reflist_object_id_map *refs_idmap = NULL;
+	int wanted_branch_found = 0;
 
 	TAILQ_INIT(&refs);
 	TAILQ_INIT(&backup_refs);
@@ -7978,6 +7979,7 @@ list_backup_refs(const char *backup_ref_prefix, const 
 
 		if (wanted_branch_name == NULL ||
 		    strcmp(wanted_branch_name, branch_name) == 0) {
+			wanted_branch_found = 1;
 			err = print_backup_ref(branch_name, refname,
 			   old_commit_id, old_commit, refs_idmap, repo);
 			if (err)
@@ -7991,6 +7993,11 @@ list_backup_refs(const char *backup_ref_prefix, const 
 		got_object_commit_close(old_commit);
 		old_commit = NULL;
 	}
+
+	if (wanted_branch_name && !wanted_branch_found) {
+		err = got_error_fmt(GOT_ERR_NOT_REF,
+		    "%s/%s/", backup_ref_prefix, wanted_branch_name);
+	}
 done:
 	if (refs_idmap)
 		got_reflist_object_id_map_free(refs_idmap);
blob - f972bece510f4dafdcb5218eae89fbaa86daef0c
blob + 432e94f7e99b6fbf303f9d9ec0b7e9656d912a6a
--- regress/cmdline/rebase.sh
+++ regress/cmdline/rebase.sh
@@ -172,7 +172,26 @@ EOF
 	ret="$?"
 	if [ "$ret" != "0" ]; then
 		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
 	fi
+
+	# Asking for backups of a branch which has none should yield an error
+	(cd $testroot/repo && got rebase -l master \
+		> $testroot/stdout 2> $testroot/stderr)
+	echo -n > $testroot/stdout.expected
+	echo "got: refs/got/backup/rebase/master/: no such reference found" \
+		> $testroot/stderr.expected
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+	fi
+	cmp -s $testroot/stderr.expected $testroot/stderr
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stderr.expected $testroot/stderr
+	fi
 	test_done "$testroot" "$ret"
 }