@matheusbsbs / matheus-bagliano / commits / 8bb2e03b9d
Fork 0

ls-files: split "show-valid-bit" into a different option.

To preserve compatibility with scripts that expect uppercase letters to be shown, do not make '-t' to unconditionally show the valid bit. Introduce '-v' option for that. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Feb 12, 2006 at 01:47 UTC 8bb2e03b9d47d87657b67ddfaf712e736cf3db8f
1 file changed +7 -3
ls-files.c
+7 -3
@@ -20,6 +20,7 @@ static int show_unmerged = 0;
20 static int show_modified = 0;
21 static int show_killed = 0;
22 static int show_other_directories = 0;
23 +static int show_valid_bit = 0;
24 static int line_terminator = '\n';
25
26 static int prefix_len = 0, prefix_offset = 0;
@@ -447,7 +448,8 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
448 if (pathspec && !match(pathspec, ce->name, len))
449 return;
450
450 - if (tag && *tag && (ce->ce_flags & htons(CE_VALID))) {
451 + if (tag && *tag && show_valid_bit &&
452 + (ce->ce_flags & htons(CE_VALID))) {
453 static char alttag[4];
454 memcpy(alttag, tag, 3);
455 if (isalpha(tag[0]))
@@ -592,7 +594,7 @@ static void verify_pathspec(void)
594 }
595
596 static const char ls_files_usage[] =
595 - "git-ls-files [-z] [-t] (--[cached|deleted|others|stage|unmerged|killed|modified])* "
597 + "git-ls-files [-z] [-t] [-v] (--[cached|deleted|others|stage|unmerged|killed|modified])* "
598 "[ --ignored ] [--exclude=<pattern>] [--exclude-from=<file>] "
599 "[ --exclude-per-directory=<filename> ] [--full-name] [--] [<file>]*";
600
@@ -617,13 +619,15 @@ int main(int argc, const char **argv)
619 line_terminator = 0;
620 continue;
621 }
620 - if (!strcmp(arg, "-t")) {
622 + if (!strcmp(arg, "-t") || !strcmp(arg, "-v")) {
623 tag_cached = "H ";
624 tag_unmerged = "M ";
625 tag_removed = "R ";
626 tag_modified = "C ";
627 tag_other = "? ";
628 tag_killed = "K ";
629 + if (arg[1] == 'v')
630 + show_valid_bit = 1;
631 continue;
632 }
633 if (!strcmp(arg, "-c") || !strcmp(arg, "--cached")) {