commit a78810f8f51f2a0e721f8a34d621802607fc49ac from: Stefan Sperling via: Thomas Adam date: Sun Mar 13 21:25:37 2022 UTC fix 'got status' with an obstructed file given as argument; found by Omar commit - f89c34e12a475ce35580b05957d2abebeff66b23 commit + a78810f8f51f2a0e721f8a34d621802607fc49ac blob - b734a84a9d97091c18294f1ff1dfb7e766cc0e19 blob + fbd962458bb7dd3f9555b846bcc06e955e4eb827 --- lib/worktree.c +++ lib/worktree.c @@ -3642,6 +3642,7 @@ worktree_status(struct got_worktree *worktree, const c struct diff_dir_cb_arg arg; char *ondisk_path = NULL; struct got_pathlist_head ignores; + struct got_fileindex_entry *ie; TAILQ_INIT(&ignores); @@ -3649,6 +3650,14 @@ worktree_status(struct got_worktree *worktree, const c worktree->root_path, path[0] ? "/" : "", path) == -1) return got_error_from_errno("asprintf"); + ie = got_fileindex_entry_get(fileindex, path, strlen(path)); + if (ie) { + err = report_single_file_status(path, ondisk_path, + fileindex, status_cb, status_arg, repo, + report_unchanged, &ignores, no_ignores); + goto done; + } + fd = open(ondisk_path, O_RDONLY | O_NOFOLLOW | O_DIRECTORY | O_CLOEXEC); if (fd == -1) { if (errno != ENOTDIR && errno != ENOENT && errno != EACCES && blob - 8482b39abaec22fd45cad69589613c1baeb685ce blob + 0505a21ded7e746fc0d94090b89d870f9546eda7 --- regress/cmdline/status.sh +++ regress/cmdline/status.sh @@ -147,6 +147,16 @@ test_status_obstructed() { echo '~ epsilon/zeta' > $testroot/stdout.expected (cd $testroot/wt && got status > $testroot/stdout) + + 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 + + (cd $testroot/wt && got status epsilon/zeta > $testroot/stdout) cmp -s $testroot/stdout.expected $testroot/stdout ret="$?"