{"thread":{"id":"33","subject":"[PATCH] trivial argument parsing patches","startedAt":"2005-04-15T11:28:01Z","lastAt":"2005-04-15T11:28:01Z","messageCount":1,"participants":["Paul Mackerras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"206","messageId":"16991.42305.118284.139777@cargo.ozlabs.ibm.com","threadId":"33","inReplyTo":null,"subject":"[PATCH] trivial argument parsing patches","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2005-04-15T11:28:01Z","receivedAt":"2005-04-15T11:28:01Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"In perusing the git code, I noticed some errors in argument parsing,\nwhich the patch below fixes.  The show-diff error (checking argv[1]\neach time around the loop) probably doesn't actually cause any real\nproblem, but it could be confusing for a novice if \"show-diff x\"\nproduces an error but \"show-diff -s x\" doesn't (and ignores the extra\nargument).\n\nSigned-off-by: Paul Mackerras <paulus@samba.org>\n\nrev-tree.c:  7bf9e9a92f528485360f374239809714ce7a19f5\n--- rev-tree.c\n+++ rev-tree.c\t2005-04-15 21:17:16.000000000 +1000\n@@ -189,8 +189,8 @@\n \t\tchar *arg = argv[i];\n \n \t\tif (!strcmp(arg, \"--cache\")) {\n-\t\t\tread_cache_file(argv[2]);\n \t\t\ti++;\n+\t\t\tread_cache_file(argv[i]);\n \t\t\tcontinue;\n \t\t}\n \nshow-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n--- show-diff.c\n+++ show-diff.c\t2005-04-15 21:22:28.000000000 +1000\n@@ -61,12 +61,10 @@\n \tint entries = read_cache();\n \tint i;\n \n-\twhile (argc-- > 1) {\n-\t\tif (!strcmp(argv[1], \"-s\")) {\n-\t\t\tsilent = 1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tusage(\"show-diff [-s]\");\n+\tif (argc > 1) {\n+\t\tif (argc > 2 || strcmp(argv[1], \"-s\"))\n+\t\t\tusage(\"show-diff [-s]\");\n+\t\tsilent = 1;\n \t}\n \n \tif (entries < 0) {\n"}]}