builtin/fetch: rewrite to take an object_id argument
[gitweb.git] / builtin / show-branch.c
index f3fb5fb2bf28019dafcbd2bfbd6b1a024aa6da2f..cf918f46e2f72b61ade391dda3379d8df09b27d4 100644 (file)
@@ -466,12 +466,18 @@ static void snarf_refs(int head, int remotes)
 {
        if (head) {
                int orig_cnt = ref_name_cnt;
-               for_each_ref(append_head_ref, NULL);
+               struct each_ref_fn_sha1_adapter wrapped_append_head_ref =
+                       {append_head_ref, NULL};
+
+               for_each_ref(each_ref_fn_adapter, &wrapped_append_head_ref);
                sort_ref_range(orig_cnt, ref_name_cnt);
        }
        if (remotes) {
                int orig_cnt = ref_name_cnt;
-               for_each_ref(append_remote_ref, NULL);
+               struct each_ref_fn_sha1_adapter wrapped_append_remote_ref =
+                       {append_remote_ref, NULL};
+
+               for_each_ref(each_ref_fn_adapter, &wrapped_append_remote_ref);
                sort_ref_range(orig_cnt, ref_name_cnt);
        }
 }
@@ -538,9 +544,12 @@ static void append_one_rev(const char *av)
        if (strchr(av, '*') || strchr(av, '?') || strchr(av, '[')) {
                /* glob style match */
                int saved_matches = ref_name_cnt;
+               struct each_ref_fn_sha1_adapter wrapped_append_matching_ref =
+                       {append_matching_ref, NULL};
+
                match_ref_pattern = av;
                match_ref_slash = count_slash(av);
-               for_each_ref(append_matching_ref, NULL);
+               for_each_ref(each_ref_fn_adapter, &wrapped_append_matching_ref);
                if (saved_matches == ref_name_cnt &&
                    ref_name_cnt < MAX_REVS)
                        error("no matching refs with %s", av);
@@ -718,7 +727,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
        }
 
        /* If nothing is specified, show all branches by default */
-       if (ac + all_heads + all_remotes == 0)
+       if (ac <= topics && all_heads + all_remotes == 0)
                all_heads = 1;
 
        if (reflog) {
@@ -785,13 +794,13 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
                }
                free(ref);
        }
-       else if (all_heads + all_remotes)
-               snarf_refs(all_heads, all_remotes);
        else {
                while (0 < ac) {
                        append_one_rev(*av);
                        ac--; av++;
                }
+               if (all_heads + all_remotes)
+                       snarf_refs(all_heads, all_remotes);
        }
 
        head_p = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,