Commit Diff


commit - 844dda16b0ff0b9351544d7d94bd2d299be509c6
commit + 9fecc8d045c7fbacd561ecfc5a39f8e163299496
blob - ec4f8ac963eafff2950257bc022d8c5ab5f86a99
blob + 97bf12ffc17a365ba3d293d7fdface5dbae61368
--- got/got.c
+++ got/got.c
@@ -6149,7 +6149,7 @@ cmd_tree(int argc, char *argv[])
 		const char *prefix = got_worktree_get_path_prefix(worktree);
 		char *p;
 
-		if (path == NULL)
+		if (path == NULL || got_path_is_root_dir(path))
 			path = "";
 		error = got_worktree_resolve_path(&p, worktree, path);
 		if (error)
blob - 5499391aa37047d50dfd1ab7501e0772654e8b4f
blob + 5fa15d25ce341431bf7f64d2a7236abc04edb893
--- regress/cmdline/tree.sh
+++ regress/cmdline/tree.sh
@@ -32,15 +32,18 @@ test_tree_basic() {
 	echo 'foo' >> $testroot/stdout.expected
 	echo 'gamma/' >> $testroot/stdout.expected
 
-	(cd $testroot/wt && got tree > $testroot/stdout)
+	for p in "" "." "/"; do
+		(cd $testroot/wt && got tree $p > $testroot/stdout)
+		cmp -s $testroot/stdout.expected $testroot/stdout
+		ret=$?
+		if [ $ret -ne 0 ]; then
+			diff -u $testroot/stdout.expected $testroot/stdout
+			test_done "$testroot" "$ret"
+			return 1
+		fi
+	done
 
-	cmp -s $testroot/stdout.expected $testroot/stdout
-	ret=$?
-	if [ $ret -ne 0 ]; then
-		diff -u $testroot/stdout.expected $testroot/stdout
-	fi
-
-	test_done "$testroot" "$ret"
+	test_done "$testroot" "0"
 }
 
 test_tree_branch() {