Merge branch 'mg/doc-remote-tags-or-not' into maint
[gitweb.git] / builtin / merge-base.c
index a2923235e1024e554b0dc937c8222282d1855065..fdebef6fa157e920a4560e68c1215665f1e20baf 100644 (file)
@@ -10,7 +10,7 @@ static int show_merge_base(struct commit **rev, int rev_nr, int show_all)
 {
        struct commit_list *result;
 
-       result = get_merge_bases_many(rev[0], rev_nr - 1, rev + 1, 0);
+       result = get_merge_bases_many_dirty(rev[0], rev_nr - 1, rev + 1);
 
        if (!result)
                return 1;
@@ -48,19 +48,36 @@ static struct commit *get_commit_reference(const char *arg)
        return r;
 }
 
-static int handle_octopus(int count, const char **args, int reduce, int show_all)
+static int handle_independent(int count, const char **args)
 {
        struct commit_list *revs = NULL;
        struct commit_list *result;
        int i;
 
-       if (reduce)
-               show_all = 1;
+       for (i = count - 1; i >= 0; i--)
+               commit_list_insert(get_commit_reference(args[i]), &revs);
+
+       result = reduce_heads(revs);
+       if (!result)
+               return 1;
+
+       while (result) {
+               printf("%s\n", sha1_to_hex(result->item->object.sha1));
+               result = result->next;
+       }
+       return 0;
+}
+
+static int handle_octopus(int count, const char **args, int show_all)
+{
+       struct commit_list *revs = NULL;
+       struct commit_list *result;
+       int i;
 
        for (i = count - 1; i >= 0; i--)
                commit_list_insert(get_commit_reference(args[i]), &revs);
 
-       result = reduce ? reduce_heads(revs) : get_octopus_merge_bases(revs);
+       result = reduce_heads(get_octopus_merge_bases(revs));
 
        if (!result)
                return 1;
@@ -159,7 +176,7 @@ static int handle_fork_point(int argc, const char **argv)
        for (i = 0; i < revs.nr; i++)
                revs.commit[i]->object.flags &= ~TMP_MARK;
 
-       bases = get_merge_bases_many(derived, revs.nr, revs.commit, 0);
+       bases = get_merge_bases_many_dirty(derived, revs.nr, revs.commit);
 
        /*
         * There should be one and only one merge base, when we found
@@ -220,8 +237,11 @@ int cmd_merge_base(int argc, const char **argv, const char *prefix)
        if (cmdmode == 'r' && show_all)
                die("--independent cannot be used with --all");
 
-       if (cmdmode == 'r' || cmdmode == 'o')
-               return handle_octopus(argc, argv, cmdmode == 'r', show_all);
+       if (cmdmode == 'o')
+               return handle_octopus(argc, argv, show_all);
+
+       if (cmdmode == 'r')
+               return handle_independent(argc, argv);
 
        if (cmdmode == 'f') {
                if (argc < 1 || 2 < argc)