archive.c: convert to use struct object_id

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Mar 13, 2015 at 23:39 UTC 13609673c4410df754197ec4ae9b57f15bc803d4
1 file changed +11 -11
archive.c
+11 -11
@@ -101,7 +101,7 @@ static void setup_archive_check(struct git_attr_check *check)
101
102 struct directory {
103 struct directory *up;
104 - unsigned char sha1[20];
104 + struct object_id oid;
105 int baselen, len;
106 unsigned mode;
107 int stage;
@@ -177,7 +177,7 @@ static void queue_directory(const unsigned char *sha1,
177 d->stage = stage;
178 c->bottom = d;
179 d->len = sprintf(d->path, "%.*s%s/", (int)base->len, base->buf, filename);
180 - hashcpy(d->sha1, sha1);
180 + hashcpy(d->oid.hash, sha1);
181 }
182
183 static int write_directory(struct archiver_context *c)
@@ -191,7 +191,7 @@ static int write_directory(struct archiver_context *c)
191 d->path[d->len - 1] = '\0'; /* no trailing slash */
192 ret =
193 write_directory(c) ||
194 - write_archive_entry(d->sha1, d->path, d->baselen,
194 + write_archive_entry(d->oid.hash, d->path, d->baselen,
195 d->path + d->baselen, d->mode,
196 d->stage, c) != READ_TREE_RECURSIVE;
197 free(d);
@@ -354,7 +354,7 @@ static void parse_treeish_arg(const char **argv,
354 time_t archive_time;
355 struct tree *tree;
356 const struct commit *commit;
357 - unsigned char sha1[20];
357 + struct object_id oid;
358
359 /* Remotes are only allowed to fetch actual refs */
360 if (remote && !remote_allow_unreachable) {
@@ -362,15 +362,15 @@ static void parse_treeish_arg(const char **argv,
362 const char *colon = strchrnul(name, ':');
363 int refnamelen = colon - name;
364
365 - if (!dwim_ref(name, refnamelen, sha1, &ref))
365 + if (!dwim_ref(name, refnamelen, oid.hash, &ref))
366 die("no such ref: %.*s", refnamelen, name);
367 free(ref);
368 }
369
370 - if (get_sha1(name, sha1))
370 + if (get_sha1(name, oid.hash))
371 die("Not a valid object name");
372
373 - commit = lookup_commit_reference_gently(sha1, 1);
373 + commit = lookup_commit_reference_gently(oid.hash, 1);
374 if (commit) {
375 commit_sha1 = commit->object.sha1;
376 archive_time = commit->date;
@@ -379,21 +379,21 @@ static void parse_treeish_arg(const char **argv,
379 archive_time = time(NULL);
380 }
381
382 - tree = parse_tree_indirect(sha1);
382 + tree = parse_tree_indirect(oid.hash);
383 if (tree == NULL)
384 die("not a tree object");
385
386 if (prefix) {
387 - unsigned char tree_sha1[20];
387 + struct object_id tree_oid;
388 unsigned int mode;
389 int err;
390
391 err = get_tree_entry(tree->object.sha1, prefix,
392 - tree_sha1, &mode);
392 + tree_oid.hash, &mode);
393 if (err || !S_ISDIR(mode))
394 die("current working directory is untracked");
395
396 - tree = parse_tree_indirect(tree_sha1);
396 + tree = parse_tree_indirect(tree_oid.hash);
397 }
398 ar_args->tree = tree;
399 ar_args->commit_sha1 = commit_sha1;