commit 9628f36dac5ed5319b482a020f06ff9737a0c1f0 from: Stefan Sperling date: Mon Jun 19 21:02:30 2023 UTC make 'got tree /' succeed in a work tree Previously, this command would trigger an error: got: /: bad path commit - ce986f226790f56efc0cbece296c912d25385599 commit + 9628f36dac5ed5319b482a020f06ff9737a0c1f0 blob - b713aa2e5f2e3920e0055fb2366825c0e1487eff blob + a14b71c8099e53f924c43a9d3f6a90a70ffe1449 --- got/got.c +++ got/got.c @@ -6150,7 +6150,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() {