15
#include "progress.h"
16
#include "reflog-walk.h"
17
#include "oidset.h"
18
+#include "packfile.h"
19
20
static const char rev_list_usage[] =
21
"git rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
68
MA_ERROR = 0, /* fail if any missing objects are encountered */
69
MA_ALLOW_ANY, /* silently allow ALL missing objects */
70
MA_PRINT, /* print ALL missing objects in special section */
71
+ MA_ALLOW_PROMISOR, /* silently allow all missing PROMISOR objects */
72
};
73
static enum missing_action arg_missing_action;
74
199
200
static inline void finish_object__ma(struct object *obj)
201
{
202
+ /*
203
+ * Whether or not we try to dynamically fetch missing objects
204
+ * from the server, we currently DO NOT have the object. We
205
+ * can either print, allow (ignore), or conditionally allow
206
+ * (ignore) them.
207
+ */
208
switch (arg_missing_action) {
209
case MA_ERROR:
210
die("missing blob object '%s'", oid_to_hex(&obj->oid));
217
oidset_insert(&missing_objects, &obj->oid);
218
return;
219
220
+ case MA_ALLOW_PROMISOR:
221
+ if (is_promisor_object(&obj->oid))
222
+ return;
223
+ die("unexpected missing blob object '%s'",
224
+ oid_to_hex(&obj->oid));
225
+ return;
226
+
227
default:
228
BUG("unhandled missing_action");
229
return;
230
}
231
}
232
218
-static void finish_object(struct object *obj, const char *name, void *cb_data)
233
+static int finish_object(struct object *obj, const char *name, void *cb_data)
234
{
235
struct rev_list_info *info = cb_data;
221
- if (obj->type == OBJ_BLOB && !has_object_file(&obj->oid))
236
+ if (obj->type == OBJ_BLOB && !has_object_file(&obj->oid)) {
237
finish_object__ma(obj);
238
+ return 1;
239
+ }
240
if (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)
241
parse_object(&obj->oid);
242
+ return 0;
243
}
244
245
static void show_object(struct object *obj, const char *name, void *cb_data)
246
{
247
struct rev_list_info *info = cb_data;
230
- finish_object(obj, name, cb_data);
248
+ if (finish_object(obj, name, cb_data))
249
+ return;
250
display_progress(progress, ++progress_counter);
251
if (info->flags & REV_LIST_QUIET)
252
return;
334
335
if (!strcmp(value, "allow-any")) {
336
arg_missing_action = MA_ALLOW_ANY;
337
+ fetch_if_missing = 0;
338
return 1;
339
}
340
341
if (!strcmp(value, "print")) {
342
arg_missing_action = MA_PRINT;
343
+ fetch_if_missing = 0;
344
+ return 1;
345
+ }
346
+
347
+ if (!strcmp(value, "allow-promisor")) {
348
+ arg_missing_action = MA_ALLOW_PROMISOR;
349
+ fetch_if_missing = 0;
350
return 1;
351
}
352
371
init_revisions(&revs, prefix);
372
revs.abbrev = DEFAULT_ABBREV;
373
revs.commit_format = CMIT_FMT_UNSPECIFIED;
374
+
375
+ /*
376
+ * Scan the argument list before invoking setup_revisions(), so that we
377
+ * know if fetch_if_missing needs to be set to 0.
378
+ *
379
+ * "--exclude-promisor-objects" acts as a pre-filter on missing objects
380
+ * by not crossing the boundary from realized objects to promisor
381
+ * objects.
382
+ *
383
+ * Let "--missing" to conditionally set fetch_if_missing.
384
+ */
385
+ for (i = 1; i < argc; i++) {
386
+ const char *arg = argv[i];
387
+ if (!strcmp(arg, "--exclude-promisor-objects")) {
388
+ fetch_if_missing = 0;
389
+ revs.exclude_promisor_objects = 1;
390
+ break;
391
+ }
392
+ }
393
+ for (i = 1; i < argc; i++) {
394
+ const char *arg = argv[i];
395
+ if (skip_prefix(arg, "--missing=", &arg)) {
396
+ if (revs.exclude_promisor_objects)
397
+ die(_("cannot combine --exclude-promisor-objects and --missing"));
398
+ if (parse_missing_action_value(arg))
399
+ break;
400
+ }
401
+ }
402
+
403
argc = setup_revisions(argc, argv, &revs, NULL);
404
405
memset(&info, 0, sizeof(info));
468
continue;
469
}
470
415
- if (skip_prefix(arg, "--missing=", &arg) &&
416
- parse_missing_action_value(arg))
417
- continue;
471
+ if (!strcmp(arg, "--exclude-promisor-objects"))
472
+ continue; /* already handled above */
473
+ if (skip_prefix(arg, "--missing=", &arg))
474
+ continue; /* already handled above */
475
476
usage(rev_list_usage);
477