add suppress status-code selection to got status. this allows for a quick way to clean output without the use of ignore files. ok stsp
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
diff --git a/got/got.1 b/got/got.1
index 5625716..c36aa31 100644
--- a/got/got.1
+++ b/got/got.1
@@ -658,7 +658,7 @@ Silence progress output.
.It Cm up
Short alias for
.Cm update .
-.It Cm status Oo Fl I Oc Oo Fl s Ar status-codes Oc Op Ar path ...
+.It Cm status Oo Fl I Oc Oo Fl s Ar status-codes Oc Oo Fl q Oc Op Ar path ...
Show the current modification status of files in a work tree,
using the following status codes:
.Bl -column YXZ description
@@ -711,6 +711,14 @@ argument.
Any combination of codes from the above list of possible status codes
may be specified.
For staged files, status codes displayed in either column will be matched.
+.It Fl S Ar status-codes
+Suppress the output of files with a modification status matching any of the
+single-character status codes contained in the
+.Ar status-codes
+argument.
+Any combination of codes from the above list of possible status codes
+may be specified.
+For staged files, status codes displayed in either column will be matched.
.El
.Pp
For compatibility with
diff --git a/got/got.c b/got/got.c
index e0fa212..319269c 100644
--- a/got/got.c
+++ b/got/got.c
@@ -5224,31 +5224,51 @@ done:
__dead static void
usage_status(void)
{
- fprintf(stderr, "usage: %s status [-I] [-s status-codes ] [path ...]\n",
- getprogname());
+ fprintf(stderr, "usage: %s status [-I] [-s status-codes ] "
+ "[-S status-codes] [path ...]\n", getprogname());
exit(1);
}
+struct got_status_arg {
+ char *status_codes;
+ int suppress;
+};
+
static const struct got_error *
print_status(void *arg, unsigned char status, unsigned char staged_status,
const char *path, struct got_object_id *blob_id,
struct got_object_id *staged_blob_id, struct got_object_id *commit_id,
int dirfd, const char *de_name)
{
+ struct got_status_arg *st = arg;
+
if (status == staged_status && (status == GOT_STATUS_DELETE))
status = GOT_STATUS_NO_CHANGE;
- if (arg) {
- char *status_codes = arg;
- size_t ncodes = strlen(status_codes);
- int i;
+ if (st != NULL && st->status_codes) {
+ size_t ncodes = strlen(st->status_codes);
+ int i, j = 0;
+
for (i = 0; i < ncodes ; i++) {
- if (status == status_codes[i] ||
- staged_status == status_codes[i])
- break;
+ if (st->suppress) {
+ if (status == st->status_codes[i] ||
+ staged_status == st->status_codes[i]) {
+ j++;
+ continue;
+ }
+ } else {
+ if (status == st->status_codes[i] ||
+ staged_status == st->status_codes[i])
+ break;
+ }
}
+
+ if (st->suppress && j == 0)
+ goto print;
+
if (i == ncodes)
return NULL;
}
+print:
printf("%c%c %s\n", status, staged_status, path);
return NULL;
}
@@ -5259,14 +5279,19 @@ cmd_status(int argc, char *argv[])
const struct got_error *error = NULL;
struct got_repository *repo = NULL;
struct got_worktree *worktree = NULL;
- char *cwd = NULL, *status_codes = NULL;;
+ struct got_status_arg st;
+ char *cwd = NULL;
struct got_pathlist_head paths;
struct got_pathlist_entry *pe;
int ch, i, no_ignores = 0;
TAILQ_INIT(&paths);
- while ((ch = getopt(argc, argv, "Is:")) != -1) {
+ memset(&st, 0, sizeof(st));
+ st.status_codes = NULL;
+ st.suppress = 0;
+
+ while ((ch = getopt(argc, argv, "Is:S:")) != -1) {
switch (ch) {
case 'I':
no_ignores = 1;
@@ -5289,7 +5314,11 @@ cmd_status(int argc, char *argv[])
optarg[i]);
}
}
- status_codes = optarg;
+ st.status_codes = optarg;
+ break;
+ case 'S':
+ st.status_codes = optarg;
+ st.suppress = 1;
break;
default:
usage_status();
@@ -5333,7 +5362,7 @@ cmd_status(int argc, char *argv[])
goto done;
error = got_worktree_status(worktree, &paths, repo, no_ignores,
- print_status, status_codes, check_cancelled, NULL);
+ print_status, &st, check_cancelled, NULL);
done:
TAILQ_FOREACH(pe, &paths, entry)
free((char *)pe->path);