Use OPT_BIT in builtin-for-each-ref
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pierre Habouzit committed
Nov 7, 2007 at 11:20 UTC
9fac800cae287256cea0512f5c5effae7a7aa784
1 file changed
+10
-9
builtin-for-each-ref.c
+10
-9
@@ -833,16 +833,19 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
833
int i, num_refs;
834
const char *format = "%(objectname) %(objecttype)\t%(refname)";
835
struct ref_sort *sort = NULL, **sort_tail = &sort;
836
- int maxcount = 0, quote_style;
837
- int quote_shell = 0, quote_perl = 0, quote_python = 0, quote_tcl = 0;
836
+ int maxcount = 0, quote_style = 0;
837
struct refinfo **refs;
838
struct grab_ref_cbdata cbdata;
839
840
struct option opts[] = {
842
- OPT_BOOLEAN('s', "shell", "e_shell, "quote placeholders suitably for shells"),
843
- OPT_BOOLEAN('p', "perl", "e_perl, "quote placeholders suitably for perl"),
844
- OPT_BOOLEAN( 0 , "python", "e_python, "quote placeholders suitably for python"),
845
- OPT_BOOLEAN( 0 , "tcl", "e_tcl, "quote placeholders suitably for tcl"),
841
+ OPT_BIT('s', "shell", "e_style,
842
+ "quote placeholders suitably for shells", QUOTE_SHELL),
843
+ OPT_BIT('p', "perl", "e_style,
844
+ "quote placeholders suitably for perl", QUOTE_PERL),
845
+ OPT_BIT(0 , "python", "e_style,
846
+ "quote placeholders suitably for python", QUOTE_PYTHON),
847
+ OPT_BIT(0 , "tcl", "e_style,
848
+ "quote placeholders suitably for tcl", QUOTE_TCL),
849
850
OPT_GROUP(""),
851
OPT_INTEGER( 0 , "count", &maxcount, "show only <n> matched refs"),
@@ -857,15 +860,13 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
860
error("invalid --count argument: `%d'", maxcount);
861
usage_with_options(for_each_ref_usage, opts);
862
}
860
- if (quote_shell + quote_perl + quote_python + quote_tcl > 1) {
863
+ if (HAS_MULTI_BITS(quote_style)) {
864
error("more than one quoting style ?");
865
usage_with_options(for_each_ref_usage, opts);
866
}
867
if (verify_format(format))
868
usage_with_options(for_each_ref_usage, opts);
869
867
- quote_style = QUOTE_SHELL * quote_shell + QUOTE_PERL * quote_perl +
868
- QUOTE_PYTHON * quote_python + QUOTE_TCL * quote_tcl;
870
if (!sort)
871
sort = default_sort();
872
sort_atom_limit = used_atom_cnt;