Merge branch 'jc/merge-bases'
authorJunio C Hamano <gitster@pobox.com>
Tue, 11 Sep 2012 18:35:26 +0000 (11:35 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Sep 2012 18:36:05 +0000 (11:36 -0700)
Optimise the "merge-base" computation a bit, and also update its
users that do not need the full merge-base information to call a
cheaper subset.

* jc/merge-bases:
  reduce_heads(): reimplement on top of remove_redundant()
  merge-base: "--is-ancestor A B"
  get_merge_bases_many(): walk from many tips in parallel
  in_merge_bases(): use paint_down_to_common()
  merge_bases_many(): split out the logic to paint history
  in_merge_bases(): omit unnecessary redundant common ancestor reduction
  http-push: use in_merge_bases() for fast-forward check
  receive-pack: use in_merge_bases() for fast-forward check
  in_merge_bases(): support only one "other" commit

1  2 
builtin/branch.c
builtin/fetch.c
builtin/merge-base.c
builtin/receive-pack.c
commit.c
commit.h
contrib/examples/builtin-fetch--tool.c
fast-import.c
http-push.c
submodule.c

Simple merge
diff --cc builtin/fetch.c
Simple merge
index 2f223a66462c5e6014c8608cd3c50ef243e8668a,0568b07e1d010c0a39fe5a9868ac87c0e0f1a593..1bc79910481e6ee04b470620da5609c1c6fbcac4
@@@ -23,9 -23,10 +23,10 @@@ static int show_merge_base(struct commi
  }
  
  static const char * const merge_base_usage[] = {
 -      "git merge-base [-a|--all] <commit> <commit>...",
 -      "git merge-base [-a|--all] --octopus <commit>...",
 -      "git merge-base --independent <commit>...",
 -      "git merge-base --is-ancestor <commit> <commit>",
 +      N_("git merge-base [-a|--all] <commit> <commit>..."),
 +      N_("git merge-base [-a|--all] --octopus <commit>..."),
 +      N_("git merge-base --independent <commit>..."),
++      N_("git merge-base --is-ancestor <commit> <commit>"),
        NULL
  };
  
@@@ -77,11 -92,14 +92,14 @@@ int cmd_merge_base(int argc, const cha
        int show_all = 0;
        int octopus = 0;
        int reduce = 0;
+       int is_ancestor = 0;
  
        struct option options[] = {
 -              OPT_BOOLEAN('a', "all", &show_all, "output all common ancestors"),
 -              OPT_BOOLEAN(0, "octopus", &octopus, "find ancestors for a single n-way merge"),
 -              OPT_BOOLEAN(0, "independent", &reduce, "list revs not reachable from others"),
 +              OPT_BOOLEAN('a', "all", &show_all, N_("output all common ancestors")),
 +              OPT_BOOLEAN(0, "octopus", &octopus, N_("find ancestors for a single n-way merge")),
 +              OPT_BOOLEAN(0, "independent", &reduce, N_("list revs not reachable from others")),
+               OPT_BOOLEAN(0, "is-ancestor", &is_ancestor,
 -                          "is the first one ancestor of the other?"),
++                          N_("is the first one ancestor of the other?")),
                OPT_END()
        };
  
Simple merge
diff --cc commit.c
Simple merge
diff --cc commit.h
Simple merge
diff --cc fast-import.c
Simple merge
diff --cc http-push.c
Simple merge
diff --cc submodule.c
index 19dc6a6c0d5cf7d9a4c80c61e160290b4462665d,8fc974d1cbb8901f6653335f046d33c944d48d2c..d133796c9ca6ef1018b23d7b0379d7ed71e846ee
@@@ -788,10 -738,9 +788,10 @@@ static int find_first_merges(struct obj
                die("revision walk setup failed");
        while ((commit = get_revision(&revs)) != NULL) {
                struct object *o = &(commit->object);
-               if (in_merge_bases(b, &commit, 1))
+               if (in_merge_bases(b, commit))
                        add_object_array(o, NULL, &merges);
        }
 +      reset_revision_walk();
  
        /* Now we've got all merges that contain a and b. Prune all
         * merges that contain another found merge and save them in