Subject: [PATCH 14/14] index-pack: silently assume missing objects are promisor

From: Jeff Hostetler <[email-masked]>
Date: Thu, 2 Nov 2017 20:31:29 +0000

From: Jeff Hostetler <[email-masked]>

Teach index-pack to not complain about missing objects
when the --promisor flag is given.  The assumption is that
index-pack is currently building the idx and promisor data
and the is_promisor_object() query would fail anyway.

Signed-off-by: Jeff Hostetler <[email-masked]>
---
 builtin/index-pack.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 31cd5ba..51693dc 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -82,6 +82,7 @@ static int verbose;
 static int show_resolving_progress;
 static int show_stat;
 static int check_self_contained_and_connected;
+static int arg_promisor_given;
 
 static struct progress *progress;
 
@@ -223,10 +224,11 @@ static unsigned check_object(struct object *obj)
 		unsigned long size;
 		int type = sha1_object_info(obj->oid.hash, &size);
 
-		if (type <= 0) {
+		if (type <= 0 && arg_promisor_given) {
 			/*
-			 * TODO Use the promisor code to conditionally
-			 * try to fetch this object -or- assume it is ok.
+			 * Assume this missing object is promised.  We can't
+			 * confirm it because we are indexing the packfile
+			 * that omitted it.
 			 */
 			obj->flags |= FLAG_CHECKED;
 			return 0;
@@ -1717,8 +1719,10 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
 				keep_msg = arg + 7;
 			} else if (!strcmp(arg, "--promisor")) {
 				promisor_msg = "";
+				arg_promisor_given = 1;
 			} else if (starts_with(arg, "--promisor=")) {
 				promisor_msg = arg + strlen("--promisor=");
+				arg_promisor_given = 1;
 			} else if (starts_with(arg, "--threads=")) {
 				char *end;
 				nr_threads = strtoul(arg+10, &end, 0);
-- 
2.9.3