[PATCH] add short options to show-files

The show-files long options are cumbersome to type.  This patch adds
equivalent short options.

Also add missing "unmerged" to usage string.

Finally reduce the number of lines for argument parsing in half.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Nicolas Pitre 2005-04-28 15:06:25 -07:00 коммит произвёл Linus Torvalds
Родитель 0cc087e304
Коммит cf9a113d35
1 изменённых файлов: 16 добавлений и 37 удалений

Просмотреть файл

@ -206,6 +206,10 @@ static void show_files(void)
} }
} }
static const char *show_files_usage =
"show-files [-z] (--[cached|deleted|others|stage|unmerged])* "
"[ --ignored [--exclude=<pattern>] [--exclude-from=<file>) ]";
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int i; int i;
@ -215,55 +219,30 @@ int main(int argc, char **argv)
if (!strcmp(arg, "-z")) { if (!strcmp(arg, "-z")) {
line_terminator = 0; line_terminator = 0;
continue; } else if (!strcmp(arg, "-c") || !strcmp(arg, "--cached")) {
}
if (!strcmp(arg, "--cached")) {
show_cached = 1; show_cached = 1;
continue; } else if (!strcmp(arg, "-d") || !strcmp(arg, "--deleted")) {
}
if (!strcmp(arg, "--deleted")) {
show_deleted = 1; show_deleted = 1;
continue; } else if (!strcmp(arg, "-o") || !strcmp(arg, "--others")) {
}
if (!strcmp(arg, "--others")) {
show_others = 1; show_others = 1;
continue; } else if (!strcmp(arg, "-i") || !strcmp(arg, "--ignored")) {
}
if (!strcmp(arg, "--ignored")) {
show_ignored = 1; show_ignored = 1;
continue; } else if (!strcmp(arg, "-s") || !strcmp(arg, "--stage")) {
}
if (!strcmp(arg, "--stage")) {
show_stage = 1; show_stage = 1;
continue; } else if (!strcmp(arg, "-u") || !strcmp(arg, "--unmerged")) {
}
if (!strcmp(arg, "--unmerged")) {
// There's no point in showing unmerged unless you also show the stage information // There's no point in showing unmerged unless you also show the stage information
show_stage = 1; show_stage = 1;
show_unmerged = 1; show_unmerged = 1;
continue; } else if (!strcmp(arg, "-x") && i+1 < argc) {
}
if (!strcmp(arg, "-x") && i+1 < argc) {
add_exclude(argv[++i]); add_exclude(argv[++i]);
continue; } else if (!strncmp(arg, "--exclude=", 10)) {
}
if (!strncmp(arg, "--exclude=", 10)) {
add_exclude(arg+10); add_exclude(arg+10);
continue; } else if (!strcmp(arg, "-X") && i+1 < argc) {
}
if (!strcmp(arg, "-X") && i+1 < argc) {
add_excludes_from_file(argv[++i]); add_excludes_from_file(argv[++i]);
continue; } else if (!strncmp(arg, "--exclude-from=", 15)) {
}
if (!strncmp(arg, "--exclude-from=", 15)) {
add_excludes_from_file(arg+15); add_excludes_from_file(arg+15);
continue; } else
} usage(show_files_usage);
usage("show-files [-z] (--[cached|deleted|others|stage])* "
"[ --ignored [--exclude=<pattern>] [--exclude-from=<file>) ]");
} }
if (show_ignored && !nr_excludes) { if (show_ignored && !nr_excludes) {