diff options
author | Jeff King <peff@peff.net> | 2016-10-12 16:10:40 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-10-12 14:30:16 -0700 |
commit | 4f21454b55f4237b7d0487ad5099c9edf4fc3967 (patch) | |
tree | 823ab289135da04b10f02367e2e73777e83cb54f /builtin | |
parent | 0b65a8dbdb38962e700ee16776a3042beb489060 (diff) | |
download | git-4f21454b55f4237b7d0487ad5099c9edf4fc3967.tar.gz git-4f21454b55f4237b7d0487ad5099c9edf4fc3967.tar.xz |
merge-base: handle --fork-point without reflog
The --fork-point option looks in the reflog to try to find
where a derived branch forked from a base branch. However,
if the reflog for the base branch is totally empty (as it
commonly is right after cloning, which does not write a
reflog entry), then our for_each_reflog call will not find
any entries, and we will come up with no merge base, even
though there may be one with the current tip of the base.
We can fix this by just adding the current tip to
our list of collected entries.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/merge-base.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin/merge-base.c b/builtin/merge-base.c index c0d1822eb..b572a37c2 100644 --- a/builtin/merge-base.c +++ b/builtin/merge-base.c @@ -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; |