for-each-ref: Fix quoting style constants.
for-each-ref can accept only one quoting style. For this reason it uses OPT_BIT for the quoting style switches so that it is easy to check for more than one bit being set. However, not all symbolic constants were actually single bit values. In particular: $ git for-each-ref --python error: more than one quoting style ? This fixes it. While we are here, let's also remove the space before the question mark. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Sixt committed
Dec 6, 2007 at 13:24 UTC
c9ecf4f12aecabfad87507ebd133476ea99fe4cb
2 files changed
+42
-3
builtin-for-each-ref.c
+3
-3
@@ -13,8 +13,8 @@
13
#define QUOTE_NONE 0
14
#define QUOTE_SHELL 1
15
#define QUOTE_PERL 2
16
-#define QUOTE_PYTHON 3
17
-#define QUOTE_TCL 4
16
+#define QUOTE_PYTHON 4
17
+#define QUOTE_TCL 8
18
19
typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type;
20
@@ -861,7 +861,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
861
usage_with_options(for_each_ref_usage, opts);
862
}
863
if (HAS_MULTI_BITS(quote_style)) {
864
- error("more than one quoting style ?");
864
+ error("more than one quoting style?");
865
usage_with_options(for_each_ref_usage, opts);
866
}
867
if (verify_format(format))
t/t6300-for-each-ref.sh
+39
@@ -169,5 +169,44 @@ test_expect_success 'Verify descending sort' '
169
git diff expected actual
170
'
171
172
+cat >expected <<\EOF
173
+'refs/heads/master'
174
+'refs/tags/testtag'
175
+EOF
176
+
177
+test_expect_success 'Quoting style: shell' '
178
+ git for-each-ref --shell --format="%(refname)" >actual &&
179
+ git diff expected actual
180
+'
181
+
182
+test_expect_success 'Quoting style: perl' '
183
+ git for-each-ref --perl --format="%(refname)" >actual &&
184
+ git diff expected actual
185
+'
186
+
187
+test_expect_success 'Quoting style: python' '
188
+ git for-each-ref --python --format="%(refname)" >actual &&
189
+ git diff expected actual
190
+'
191
+
192
+cat >expected <<\EOF
193
+"refs/heads/master"
194
+"refs/tags/testtag"
195
+EOF
196
+
197
+test_expect_success 'Quoting style: tcl' '
198
+ git for-each-ref --tcl --format="%(refname)" >actual &&
199
+ git diff expected actual
200
+'
201
+
202
+for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
203
+ test_expect_success "more than one quoting style: $i" "
204
+ git for-each-ref $i 2>&1 | (read line &&
205
+ case \$line in
206
+ \"error: more than one quoting style\"*) : happy;;
207
+ *) false
208
+ esac)
209
+ "
210
+done
211
212
test_done