{"thread":{"id":"382","subject":"[PATCH] add short options to show-files","startedAt":"2005-04-28T21:48:34Z","lastAt":"2005-04-28T21:48:34Z","messageCount":1,"participants":["Nicolas Pitre"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"2092","messageId":"Pine.LNX.4.62.0504281742580.14033@localhost.localdomain","threadId":"382","inReplyTo":null,"subject":"[PATCH] add short options to show-files","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2005-04-28T21:48:34Z","receivedAt":"2005-04-28T21:48:34Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"\nThe show-files long options are cumbersome to type.  This patch adds \nequivalent short options.\n\nAlso add missing \"unmerged\" to usage string.\n\nFinally reduce the number of lines for argument parsing in half.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n\n--- k/show-files.c\n+++ l/show-files.c\n@@ -206,6 +206,10 @@ static void show_files(void)\n \t}\n }\n \n+static const char *show_files_usage =\n+\t\"show-files [-z] (--[cached|deleted|others|stage|unmerged])* \"\n+\t\"[ --ignored [--exclude=<pattern>] [--exclude-from=<file>) ]\";\n+\n int main(int argc, char **argv)\n {\n \tint i;\n@@ -215,55 +219,30 @@ int main(int argc, char **argv)\n \n \t\tif (!strcmp(arg, \"-z\")) {\n \t\t\tline_terminator = 0;\n-\t\t\tcontinue;\n-\t\t}\n-\n-\t\tif (!strcmp(arg, \"--cached\")) {\n+\t\t} else if (!strcmp(arg, \"-c\") || !strcmp(arg, \"--cached\")) {\n \t\t\tshow_cached = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"--deleted\")) {\n+\t\t} else if (!strcmp(arg, \"-d\") || !strcmp(arg, \"--deleted\")) {\n \t\t\tshow_deleted = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"--others\")) {\n+\t\t} else if (!strcmp(arg, \"-o\") || !strcmp(arg, \"--others\")) {\n \t\t\tshow_others = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"--ignored\")) {\n+\t\t} else if (!strcmp(arg, \"-i\") || !strcmp(arg, \"--ignored\")) {\n \t\t\tshow_ignored = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"--stage\")) {\n+\t\t} else if (!strcmp(arg, \"-s\") || !strcmp(arg, \"--stage\")) {\n \t\t\tshow_stage = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"--unmerged\")) {\n+\t\t} else if (!strcmp(arg, \"-u\") || !strcmp(arg, \"--unmerged\")) {\n \t\t\t// There's no point in showing unmerged unless you also show the stage information\n \t\t\tshow_stage = 1;\n \t\t\tshow_unmerged = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\n-\t\tif (!strcmp(arg, \"-x\") && i+1 < argc) {\n+\t\t} else if (!strcmp(arg, \"-x\") && i+1 < argc) {\n \t\t\tadd_exclude(argv[++i]);\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strncmp(arg, \"--exclude=\", 10)) {\n+\t\t} else if (!strncmp(arg, \"--exclude=\", 10)) {\n \t\t\tadd_exclude(arg+10);\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strcmp(arg, \"-X\") && i+1 < argc) {\n+\t\t} else if (!strcmp(arg, \"-X\") && i+1 < argc) {\n \t\t\tadd_excludes_from_file(argv[++i]);\n-\t\t\tcontinue;\n-\t\t}\n-\t\tif (!strncmp(arg, \"--exclude-from=\", 15)) {\n+\t\t} else if (!strncmp(arg, \"--exclude-from=\", 15)) {\n \t\t\tadd_excludes_from_file(arg+15);\n-\t\t\tcontinue;\n-\t\t}\n-\n-\t\tusage(\"show-files [-z] (--[cached|deleted|others|stage])* \"\n-\t\t      \"[ --ignored [--exclude=<pattern>] [--exclude-from=<file>) ]\");\n+\t\t} else\n+\t\t\tusage(show_files_usage);\n \t}\n \n \tif (show_ignored && !nr_excludes) {\n"}]}