Commit Diff


commit - c957ebaceccd668eeb87e51c9e323b983af2e79f
commit + a914c6bf9a936469678bf7398b2a02bfc4107d75
blob - 512ee415f0d588088b9c8b8480666c26b5097909
blob + 408d6c2eca222e770eac22fefded31612c59a877
--- got/got.c
+++ got/got.c
@@ -3452,7 +3452,7 @@ wrap_not_worktree_error(const struct got_error *orig_e
 	err = got_error_msg(GOT_ERR_NOT_WORKTREE, msg);
 	if (repo) {
 		const struct got_error *close_err = got_repo_close(repo);
-		if (close_err == NULL)
+		if (err == NULL)
 			err = close_err;
 	}
 	if (pack_fds) {
blob - 282f6198ef06d3c01364dc6a50d274ad0a31821e
blob + 28da1dacd8934b690da5ceef71b0f51b9bcb8c87
--- regress/cmdline/status.sh
+++ regress/cmdline/status.sh
@@ -1075,6 +1075,25 @@ test_status_empty_file() {
 	ret=$?
 	if [ $ret -ne 0 ]; then
 		diff -u $testroot/stdout.expected $testroot/stdout
+	fi
+	test_done "$testroot" "$ret"
+}
+
+test_status_in_repo() {
+	local testroot=`test_init status_in_repo`
+
+	(cd $testroot/repo && got status > $testroot/stdout \
+		2> $testroot/stderr)
+
+	cat > $testroot/stderr.expected <<EOF
+got: 'got status' needs a work tree in addition to a git repository
+Work trees can be checked out from this Git repository with 'got checkout'.
+The got(1) manual page contains more information.
+EOF
+	cmp -s $testroot/stderr.expected $testroot/stderr
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		diff -u $testroot/stderr.expected $testroot/stderr
 	fi
 	test_done "$testroot" "$ret"
 }
@@ -1098,3 +1117,4 @@ run_test test_status_gitignore_trailing_slashes
 run_test test_status_status_code
 run_test test_status_suppress
 run_test test_status_empty_file
+run_test test_status_in_repo