diff mbox series

[12/12] paint_down_to_common(): special-case shallow/partial clones

Message ID 33894600ae77156ba022ebba6cec4f2b24c77cd2.1707813709.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series The merge-base logic vs missing commit objects | expand

Commit Message

Johannes Schindelin Feb. 13, 2024, 8:41 a.m. UTC
From: Johannes Schindelin <johannes.schindelin@gmx.de>

In shallow/partial clones, we _expect_ commits to be missing. Let's
teach the merge-base logic to ignore those and simply go ahead and
treat the involved commit histories as cut off at that point.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 commit-reach.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/commit-reach.c b/commit-reach.c
index 25b39c302a8..4af60c2501d 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -10,6 +10,8 @@ 
 #include "tag.h"
 #include "commit-reach.h"
 #include "ewah/ewok.h"
+#include "shallow.h"
+#include "promisor-remote.h"
 
 /* Remember to update object flag allocation in object.h */
 #define PARENT1		(1u<<16)
@@ -115,7 +117,9 @@  static int paint_down_to_common(struct repository *r,
 				 * dispatched with a `die()`.
 				 */
 				free_commit_list(*result);
-				if (ignore_missing_commits)
+				if (ignore_missing_commits ||
+				    is_repository_shallow(r) ||
+				    repo_has_promisor_remote(r))
 					return 0;
 				return error(_("could not parse commit %s"),
 					     oid_to_hex(&p->object.oid));