Skip to content

Commit 8bb2e03

Browse files
author
Junio C Hamano
committed
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>
1 parent b92b2ce commit 8bb2e03

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ls-files.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ static int show_unmerged = 0;
2020
static int show_modified = 0;
2121
static int show_killed = 0;
2222
static int show_other_directories = 0;
23+
static int show_valid_bit = 0;
2324
static int line_terminator = '\n';
2425

2526
static int prefix_len = 0, prefix_offset = 0;
@@ -447,7 +448,8 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
447448
if (pathspec && !match(pathspec, ce->name, len))
448449
return;
449450

450-
if (tag && *tag && (ce->ce_flags & htons(CE_VALID))) {
451+
if (tag && *tag && show_valid_bit &&
452+
(ce->ce_flags & htons(CE_VALID))) {
451453
static char alttag[4];
452454
memcpy(alttag, tag, 3);
453455
if (isalpha(tag[0]))
@@ -592,7 +594,7 @@ static void verify_pathspec(void)
592594
}
593595

594596
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])* "
596598
"[ --ignored ] [--exclude=<pattern>] [--exclude-from=<file>] "
597599
"[ --exclude-per-directory=<filename> ] [--full-name] [--] [<file>]*";
598600

@@ -617,13 +619,15 @@ int main(int argc, const char **argv)
617619
line_terminator = 0;
618620
continue;
619621
}
620-
if (!strcmp(arg, "-t")) {
622+
if (!strcmp(arg, "-t") || !strcmp(arg, "-v")) {
621623
tag_cached = "H ";
622624
tag_unmerged = "M ";
623625
tag_removed = "R ";
624626
tag_modified = "C ";
625627
tag_other = "? ";
626628
tag_killed = "K ";
629+
if (arg[1] == 'v')
630+
show_valid_bit = 1;
627631
continue;
628632
}
629633
if (!strcmp(arg, "-c") || !strcmp(arg, "--cached")) {

0 commit comments

Comments
 (0)