git-check-attr: Introduce a new variable
Avoid reusing variable "doubledash" to mean something other than the expected "position of a double-dash, if any". Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Aug 4, 2011 at 06:36 UTC
d6541bb1ac753a3cc0b92021cf82b07cf459cb28
1 file changed
+7
-6
builtin/check-attr.c
+7
-6
@@ -71,7 +71,7 @@ static void check_attr_stdin_paths(int cnt, struct git_attr_check *check)
71
int cmd_check_attr(int argc, const char **argv, const char *prefix)
72
{
73
struct git_attr_check *check;
74
- int cnt, i, doubledash;
74
+ int cnt, i, doubledash, filei;
75
const char *errstr = NULL;
76
77
argc = parse_options(argc, argv, prefix, check_attr_options,
@@ -92,14 +92,15 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
92
/* If there is no double dash, we handle only one attribute */
93
if (doubledash < 0) {
94
cnt = 1;
95
- doubledash = 0;
96
- } else
95
+ filei = 1;
96
+ } else {
97
cnt = doubledash;
98
- doubledash++;
98
+ filei = doubledash + 1;
99
+ }
100
101
if (cnt <= 0)
102
errstr = "No attribute specified";
102
- else if (stdin_paths && doubledash < argc)
103
+ else if (stdin_paths && filei < argc)
104
errstr = "Can't specify files with --stdin";
105
if (errstr) {
106
error("%s", errstr);
@@ -120,7 +121,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
121
if (stdin_paths)
122
check_attr_stdin_paths(cnt, check);
123
else {
123
- for (i = doubledash; i < argc; i++)
124
+ for (i = filei; i < argc; i++)
125
check_attr(cnt, check, argv[i]);
126
maybe_flush_or_die(stdout, "attribute to stdout");
127
}