From 89236e8c29bc5be0cf975610ff39fa05a9f9fafc Mon Sep 17 00:00:00 2001 From: Jan Grodowski Date: Thu, 27 Jun 2024 22:31:53 +0200 Subject: [PATCH] Handle nil merge_base in Changeset --- lib/undercover/changeset.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/undercover/changeset.rb b/lib/undercover/changeset.rb index eac6a95..491a585 100644 --- a/lib/undercover/changeset.rb +++ b/lib/undercover/changeset.rb @@ -74,7 +74,9 @@ def full_diff def compare_base_obj return nil unless compare_base - repo.lookup(repo.merge_base(compare_base.to_s, head)) + merge_base = repo.merge_base(compare_base.to_s, head) + # merge_base may be nil with --depth 1, compare two refs directly + repo.lookup(merge_base || compare_base) end def head