Commit 2c201a36298b33cae3e3f1e94d7f30c20ac8d140

Stefan Sperling 2019-02-10T16:41:44

make 'got status' ignore symlinks, for now

diff --git a/lib/worktree.c b/lib/worktree.c
index cd4a548..9a55298 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -1212,6 +1212,10 @@ status_new(void *arg, struct dirent *de, const char *parent_path)
 	if (de->d_type == DT_DIR)
 		return NULL;
 
+	/* XXX ignore symlinks for now */
+	if (de->d_type == DT_LNK)
+		return NULL;
+
 	if (parent_path[0]) {
 		if (asprintf(&path, "%s/%s", parent_path, de->d_name) == -1)
 			return got_error_from_errno();
diff --git a/regress/cmdline/status.sh b/regress/cmdline/status.sh
index e1df9d4..da1fdae 100755
--- a/regress/cmdline/status.sh
+++ b/regress/cmdline/status.sh
@@ -250,9 +250,40 @@ function test_status_unversioned_subdirs {
 	test_done "$testroot" "$ret"
 }
 
+# 'got status' ignores symlinks at present; this might change eventually
+function test_status_ignores_symlink {
+	local testroot=`test_init status_ignores_symlink 1`
+
+	mkdir $testroot/repo/ramdisk/
+	touch $testroot/repo/ramdisk/Makefile
+	(cd $testroot/repo && git add .)
+	git_commit $testroot/repo -m "first commit"
+
+	got checkout $testroot/repo $testroot/wt > /dev/null
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	ln -s /usr/obj/distrib/i386/ramdisk $testroot/wt/ramdisk/obj
+
+	echo -n > $testroot/stdout.expected
+
+	(cd $testroot/wt && got status > $testroot/stdout)
+
+	cmp $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+	fi
+	test_done "$testroot" "$ret"
+}
+
 run_test test_status_basic
 run_test test_status_subdir_no_mods
 run_test test_status_subdir_no_mods2
 run_test test_status_obstructed
 run_test test_status_shows_local_mods_after_update
 run_test test_status_unversioned_subdirs
+run_test test_status_ignores_symlink