commit b80270a75026f6a3e46594ecdd024b6f9e77a368 from: Stefan Sperling date: Thu Aug 08 22:12:00 2019 UTC make 'got status' find top-level .cvsignore when invoked from a subdir commit - 6841da0026bfd0be124721da859278eff7353c4f commit + b80270a75026f6a3e46594ecdd024b6f9e77a368 blob - 61c82088a8a2401eae516229118fdc49eac21432 blob + 58f47bcb9d3d140efc6e5e0e4ddcfc432387e204 --- lib/worktree.c +++ lib/worktree.c @@ -2433,15 +2433,16 @@ match_ignores(struct got_pathlist_head *ignores, const } static const struct got_error * -add_ignores(struct got_pathlist_head *ignores, const char *path) +add_ignores(struct got_pathlist_head *ignores, const char *root_path, + const char *path) { const struct got_error *err = NULL; char *ignorespath; FILE *ignoresfile = NULL; /* TODO: read .gitignores as well... */ - if (asprintf(&ignorespath, "%s%s.cvsignore", path, path[0] ? "/" : "") - == -1) + if (asprintf(&ignorespath, "%s/%s%s.cvsignore", root_path, path, + path[0] ? "/" : "") == -1) return got_error_from_errno("asprintf"); ignoresfile = fopen(ignorespath, "r"); @@ -2480,7 +2481,7 @@ status_new(void *arg, struct dirent *de, const char *p } if (de->d_type == DT_DIR) - err = add_ignores(&a->ignores, path); + err = add_ignores(&a->ignores, a->worktree->root_path, path); else if (got_path_is_child(path, a->status_path, a->status_path_len) && !match_ignores(&a->ignores, path)) err = (*a->status_cb)(a->status_arg, GOT_STATUS_UNVERSIONED, @@ -2553,7 +2554,7 @@ worktree_status(struct got_worktree *worktree, const c arg.cancel_cb = cancel_cb; arg.cancel_arg = cancel_arg; TAILQ_INIT(&arg.ignores); - err = add_ignores(&arg.ignores, ""); + err = add_ignores(&arg.ignores, worktree->root_path, path); if (err == NULL) err = got_fileindex_diff_dir(fileindex, workdir, worktree->root_path, path, repo, &fdiff_cb, &arg); blob - e4d71a97459fd79e1edfb492c0b395452e70e44a blob + 99766ac88326608f2b27f3b5c8415b095b11073c --- regress/cmdline/status.sh +++ regress/cmdline/status.sh @@ -504,7 +504,21 @@ function test_status_cvsignore { echo '? epsilon/boo' >> $testroot/stdout.expected echo '? foop' >> $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 + echo '? .cvsignore' > $testroot/stdout.expected + echo '? epsilon/.cvsignore' >> $testroot/stdout.expected + echo '? epsilon/boo' >> $testroot/stdout.expected + echo '? foop' >> $testroot/stdout.expected + (cd $testroot/wt/gamma && got status > $testroot/stdout) + cmp -s $testroot/stdout.expected $testroot/stdout ret="$?" if [ "$ret" != "0" ]; then