Commit 54817d72bf743bcd8d0313b5af1bd9899bbda5e9

Stefan Sperling 2019-07-27T12:40:05

fix a status bug exposed by test_update_conflict_wt_rm_vs_repo_rm

diff --git a/lib/worktree.c b/lib/worktree.c
index 4101d79..697a915 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -2263,18 +2263,9 @@ worktree_status(struct got_worktree *worktree, const char *path,
 	workdir = opendir(ondisk_path);
 	if (workdir == NULL) {
 		if (errno == ENOTDIR || errno == ENOENT) {
-			struct got_fileindex_entry *ie;
-			ie = got_fileindex_entry_get(fileindex, path);
-			if (ie == NULL)
-				err = (*status_cb)(status_arg,
-				    GOT_STATUS_UNVERSIONED, path, NULL, NULL);
-			else
-				err = report_file_status(ie, ondisk_path,
-				    status_cb, status_arg, repo);
-			if (err)
-				goto done;
-			err = report_file_status(ie, ondisk_path,
-			    status_cb, status_arg, repo);
+			err = report_file_status(
+			    got_fileindex_entry_get(fileindex, path),
+			    ondisk_path, status_cb, status_arg, repo);
 			goto done;
 		} else {
 			err = got_error_from_errno2("opendir", ondisk_path);
diff --git a/regress/cmdline/update.sh b/regress/cmdline/update.sh
index ce179b0..e3be1a7 100755
--- a/regress/cmdline/update.sh
+++ b/regress/cmdline/update.sh
@@ -1052,8 +1052,17 @@ function test_update_conflict_wt_rm_vs_repo_rm {
 	fi
 
 	# beta is now gone... we don't flag tree conflicts yet
-	echo 'got: bad path' > $testroot/stderr.expected
-	(cd $testroot/wt && got status beta 2> $testroot/stderr)
+	echo -n > $testroot/stdout.expected
+	echo -n > $testroot/stderr.expected
+	(cd $testroot/wt && got status beta > $testroot/stdout \
+		2> $testroot/stderr)
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
 	cmp -s $testroot/stderr.expected $testroot/stderr
 	ret="$?"
 	if [ "$ret" != "0" ]; then