554
return 0;
555
}
556
557
+static void handle_ref_opt(const char *pattern, const char *prefix)
558
+{
559
+ if (pattern)
560
+ for_each_glob_ref_in(show_reference, pattern, prefix, NULL);
561
+ else
562
+ for_each_ref_in(prefix, show_reference, NULL);
563
+ clear_ref_exclusion(&ref_excludes);
564
+}
565
+
566
int cmd_rev_parse(int argc, const char **argv, const char *prefix)
567
{
568
int i, as_is = 0, verify = 0, quiet = 0, revs_count = 0, type = 0;
755
for_each_ref_in("refs/bisect/good", anti_reference, NULL);
756
continue;
757
}
749
- if (skip_prefix(arg, "--branches=", &arg)) {
750
- for_each_glob_ref_in(show_reference, arg,
751
- "refs/heads/", NULL);
752
- clear_ref_exclusion(&ref_excludes);
753
- continue;
754
- }
755
- if (!strcmp(arg, "--branches")) {
756
- for_each_branch_ref(show_reference, NULL);
757
- clear_ref_exclusion(&ref_excludes);
758
- continue;
759
- }
760
- if (skip_prefix(arg, "--tags=", &arg)) {
761
- for_each_glob_ref_in(show_reference, arg,
762
- "refs/tags/", NULL);
763
- clear_ref_exclusion(&ref_excludes);
758
+ if (opt_with_value(arg, "--branches", &arg)) {
759
+ handle_ref_opt(arg, "refs/heads/");
760
continue;
761
}
766
- if (!strcmp(arg, "--tags")) {
767
- for_each_tag_ref(show_reference, NULL);
768
- clear_ref_exclusion(&ref_excludes);
762
+ if (opt_with_value(arg, "--tags", &arg)) {
763
+ handle_ref_opt(arg, "refs/tags/");
764
continue;
765
}
766
if (skip_prefix(arg, "--glob=", &arg)) {
772
- for_each_glob_ref(show_reference, arg, NULL);
773
- clear_ref_exclusion(&ref_excludes);
774
- continue;
775
- }
776
- if (skip_prefix(arg, "--remotes=", &arg)) {
777
- for_each_glob_ref_in(show_reference, arg,
778
- "refs/remotes/", NULL);
779
- clear_ref_exclusion(&ref_excludes);
767
+ handle_ref_opt(arg, NULL);
768
continue;
769
}
782
- if (!strcmp(arg, "--remotes")) {
783
- for_each_remote_ref(show_reference, NULL);
784
- clear_ref_exclusion(&ref_excludes);
770
+ if (opt_with_value(arg, "--remotes", &arg)) {
771
+ handle_ref_opt(arg, "refs/remotes/");
772
continue;
773
}
774
if (skip_prefix(arg, "--exclude=", &arg)) {