Merge branch 'jk/merge-base-fork-point-without-reflog' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 28 Oct 2016 16:01:17 +0000 (09:01 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 28 Oct 2016 16:01:17 +0000 (09:01 -0700)
"git rebase" immediately after "git clone" failed to find the fork
point from the upstream.

* jk/merge-base-fork-point-without-reflog:
merge-base: handle --fork-point without reflog

builtin/merge-base.c
t/t6010-merge-base.sh
index c0d1822eb3ad371b9ab0b830aed2cc2741a978bd..b572a37c2611b2a8c20b1db7edac68623d371a38 100644 (file)
@@ -173,6 +173,9 @@ static int handle_fork_point(int argc, const char **argv)
        revs.initial = 1;
        for_each_reflog_ent(refname, collect_one_reflog_ent, &revs);
 
+       if (!revs.nr && !get_sha1(refname, sha1))
+               add_one_commit(sha1, &revs);
+
        for (i = 0; i < revs.nr; i++)
                revs.commit[i]->object.flags &= ~TMP_MARK;
 
index e0c5f44cac0290c6e15c5360b0cc7c1f4d486614..31db7b5f9125ed346450d7bfe29d8bb5fac0460a 100755 (executable)
@@ -260,6 +260,12 @@ test_expect_success 'using reflog to find the fork point' '
        test_cmp expect3 actual
 '
 
+test_expect_success '--fork-point works with empty reflog' '
+       git -c core.logallrefupdates=false branch no-reflog base &&
+       git merge-base --fork-point no-reflog derived &&
+       test_cmp expect3 actual
+'
+
 test_expect_success 'merge-base --octopus --all for complex tree' '
        # Best common ancestor for JE, JAA and JDD is JC
        #             JE