new -I option for 'got status' to show files which match an ignore pattern
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
diff --git a/got/got.1 b/got/got.1
index 8e0440c..ea184ea 100644
--- a/got/got.1
+++ b/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
diff --git a/got/got.c b/got/got.c
index 097226d..3af8d5f 100644
--- a/got/got.c
+++ b/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;
diff --git a/include/got_worktree.h b/include/got_worktree.h
index 9246dbd..5cf8592 100644
--- a/include/got_worktree.h
+++ b/include/got_worktree.h
@@ -171,7 +171,7 @@ typedef const struct got_error *(*got_worktree_status_cb)(void *,
* 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 *);
/*
diff --git a/lib/worktree.c b/lib/worktree.c
index 8fda195..c6a9ee6 100644
--- a/lib/worktree.c
+++ b/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;
}
diff --git a/regress/cmdline/status.sh b/regress/cmdline/status.sh
index 551a962..8c6c24e 100755
--- a/regress/cmdline/status.sh
+++ b/regress/cmdline/status.sh
@@ -581,6 +581,33 @@ test_status_cvsignore() {
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ cat > $testroot/stdout.expected <<EOF
+? .cvsignore
+? epsilon/.cvsignore
+? epsilon/bar
+? epsilon/boo
+? epsilon/foo
+? epsilon/moo
+? epsilon/new/foo
+? foo
+? foop
+EOF
+ (cd $testroot/wt && got status -I > $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"
}
@@ -630,6 +657,33 @@ 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 <<EOF
+? .gitignore
+? a/b/c/foo
+? a/b/c/zoo
+? barp
+? epsilon/bar
+? epsilon/boo
+? epsilon/moo
+? foo
+? foop
+EOF
+ (cd $testroot/wt && got status -I > $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"
}