commit f6343036aa4d7e3805a44832b566b531271c1c6d from: Stefan Sperling date: Tue Jun 22 20:00:44 2021 UTC new -I option for 'got status' to show files which match an ignore pattern commit - bb5126eae54e9983853ff1474cb79031db490c2e commit + f6343036aa4d7e3805a44832b566b531271c1c6d blob - 8e0440ccdc48b95f490d2569a5b63f60004d1480 blob + ea184ea1a744cc0dc2f55f94cb55c6ca80c420f6 --- got/got.1 +++ got/got.1 @@ -672,6 +672,8 @@ The options for .Cm got status are as follows: .Bl -tag -width Ds +.It Fl I +Show unversioned files even if they match an ignore pattern. .It Fl s Ar status-codes Only show files with a modification status matching any of the single-character status codes contained in the blob - 097226da2568c25ff532d61bf72b41de086e3af9 blob + 3af8d5f635cb8536c5f4a4f0f2466edb846ae896 --- got/got.c +++ got/got.c @@ -4430,8 +4430,8 @@ cmd_diff(int argc, char *argv[]) if (error) goto done; - error = got_worktree_status(worktree, &paths, repo, print_diff, - &arg, check_cancelled, NULL); + error = got_worktree_status(worktree, &paths, repo, 0, + print_diff, &arg, check_cancelled, NULL); free(id_str); got_pathlist_free(&paths); goto done; @@ -5119,7 +5119,7 @@ done: __dead static void usage_status(void) { - fprintf(stderr, "usage: %s status [-s status-codes ] [path ...]\n", + fprintf(stderr, "usage: %s status [-I] [-s status-codes ] [path ...]\n", getprogname()); exit(1); } @@ -5157,12 +5157,15 @@ cmd_status(int argc, char *argv[]) char *cwd = NULL, *status_codes = NULL;; struct got_pathlist_head paths; struct got_pathlist_entry *pe; - int ch, i; + int ch, i, no_ignores = 0; TAILQ_INIT(&paths); - while ((ch = getopt(argc, argv, "s:")) != -1) { + while ((ch = getopt(argc, argv, "Is:")) != -1) { switch (ch) { + case 'I': + no_ignores = 1; + break; case 's': for (i = 0; i < strlen(optarg); i++) { switch (optarg[i]) { @@ -5224,8 +5227,8 @@ cmd_status(int argc, char *argv[]) if (error) goto done; - error = got_worktree_status(worktree, &paths, repo, print_status, - status_codes, check_cancelled, NULL); + error = got_worktree_status(worktree, &paths, repo, no_ignores, + print_status, status_codes, check_cancelled, NULL); done: TAILQ_FOREACH(pe, &paths, entry) free((char *)pe->path); @@ -9536,7 +9539,7 @@ cmd_histedit(int argc, char *argv[]) if (error) goto done; error = got_worktree_status(worktree, &paths, - repo, check_local_changes, &have_changes, + repo, 0, check_local_changes, &have_changes, check_cancelled, NULL); got_pathlist_free(&paths); if (error) { @@ -9924,7 +9927,7 @@ cmd_stage(int argc, char *argv[]) goto done; if (list_stage) - error = got_worktree_status(worktree, &paths, repo, + error = got_worktree_status(worktree, &paths, repo, 0, print_stage, NULL, check_cancelled, NULL); else { cpa.patch_script_file = patch_script_file; blob - 9246dbdca16b2907e56bbebc9f597bb7e3e91b10 blob + 5cf85929bb38eed74f828e89ad78c63e26ce9cca --- include/got_worktree.h +++ include/got_worktree.h @@ -171,7 +171,7 @@ typedef const struct got_error *(*got_worktree_status_ * a path, and a corresponding status code. */ const struct got_error *got_worktree_status(struct got_worktree *, - struct got_pathlist_head *, struct got_repository *, + struct got_pathlist_head *, struct got_repository *, int no_ignores, got_worktree_status_cb, void *, got_cancel_cb cancel_cb, void *); /* blob - 8fda1956ff24817df54807e1982ca82da40af38a blob + c6a9ee611f39f7106cbf6b33215f75f9f7a5c715 --- lib/worktree.c +++ lib/worktree.c @@ -3734,7 +3734,7 @@ done: const struct got_error * got_worktree_status(struct got_worktree *worktree, struct got_pathlist_head *paths, struct got_repository *repo, - got_worktree_status_cb status_cb, void *status_arg, + int no_ignores, got_worktree_status_cb status_cb, void *status_arg, got_cancel_cb cancel_cb, void *cancel_arg) { const struct got_error *err = NULL; @@ -3748,7 +3748,8 @@ got_worktree_status(struct got_worktree *worktree, TAILQ_FOREACH(pe, paths, entry) { err = worktree_status(worktree, pe->path, fileindex, repo, - status_cb, status_arg, cancel_cb, cancel_arg, 0, 0); + status_cb, status_arg, cancel_cb, cancel_arg, + no_ignores, 0); if (err) break; } blob - 551a9622836341a7e773fd8bd8c3dbb99188cac8 blob + 8c6c24e701901e9c2ad8922e593794b9365ff248 --- regress/cmdline/status.sh +++ regress/cmdline/status.sh @@ -576,6 +576,33 @@ test_status_cvsignore() { 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 + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 + fi + + cat > $testroot/stdout.expected < $testroot/stdout) + ret="$?" + if [ "$ret" != "0" ]; then + echo "got status failed unexpectedly" >&2 + test_done "$testroot" "1" + return 1 + fi cmp -s $testroot/stdout.expected $testroot/stdout ret="$?" @@ -630,7 +657,34 @@ test_status_gitignore() { ret="$?" if [ "$ret" != "0" ]; then diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 fi + + cat > $testroot/stdout.expected < $testroot/stdout) + ret="$?" + if [ "$ret" != "0" ]; then + echo "got status failed unexpectedly" >&2 + test_done "$testroot" "1" + return 1 + fi + + cmp -s $testroot/stdout.expected $testroot/stdout + ret="$?" + if [ "$ret" != "0" ]; then + diff -u $testroot/stdout.expected $testroot/stdout + fi test_done "$testroot" "$ret" }