6
#include "repository.h"
7
#include "commit-graph.h"
8
#include "object-store.h"
9
+#include "progress.h"
10
11
static char const * const builtin_commit_graph_usage[] = {
12
N_("git commit-graph verify [--object-dir <objdir>] [--shallow] [--[no-]progress]"),
139
return 0;
140
}
141
141
-static int read_one_commit(struct oidset *commits, const char *hash)
142
+static int read_one_commit(struct oidset *commits, struct progress *progress,
143
+ const char *hash)
144
{
145
+ struct commit *result;
146
struct object_id oid;
147
const char *end;
148
149
if (parse_oid_hex(hash, &oid, &end))
150
return error(_("unexpected non-hex object ID: %s"), hash);
151
149
- oidset_insert(commits, &oid);
152
+ result = lookup_commit_reference_gently(the_repository, &oid, 1);
153
+ if (result)
154
+ oidset_insert(commits, &result->object.oid);
155
+ else
156
+ return error(_("invalid commit object id: %s"), hash);
157
+
158
+ display_progress(progress, oidset_size(commits));
159
+
160
return 0;
161
}
162
168
struct object_directory *odb = NULL;
169
int result = 0;
170
enum commit_graph_write_flags flags = 0;
171
+ struct progress *progress = NULL;
172
173
static struct option builtin_commit_graph_write_options[] = {
174
OPT_STRING(0, "object-dir", &opts.obj_dir,
239
} else if (opts.stdin_commits) {
240
oidset_init(&commits, 0);
241
flags |= COMMIT_GRAPH_WRITE_CHECK_OIDS;
242
+ if (opts.progress)
243
+ progress = start_delayed_progress(
244
+ _("Collecting commits from input"), 0);
245
246
while (strbuf_getline(&buf, stdin) != EOF) {
233
- if (read_one_commit(&commits, buf.buf)) {
247
+ if (read_one_commit(&commits, progress, buf.buf)) {
248
result = 1;
249
goto cleanup;
250
}
251
}
252
+
253
+
254
}
255
256
if (write_commit_graph(odb,
263
cleanup:
264
string_list_clear(&pack_indexes, 0);
265
strbuf_release(&buf);
266
+ if (progress)
267
+ stop_progress(&progress);
268
return result;
269
}
270