Skip to content

Commit 1360967

Browse files
bk2204gitster
authored andcommitted
archive.c: convert to use struct object_id
Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3c5ff99 commit 1360967

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

archive.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static void setup_archive_check(struct git_attr_check *check)
101101

102102
struct directory {
103103
struct directory *up;
104-
unsigned char sha1[20];
104+
struct object_id oid;
105105
int baselen, len;
106106
unsigned mode;
107107
int stage;
@@ -177,7 +177,7 @@ static void queue_directory(const unsigned char *sha1,
177177
d->stage = stage;
178178
c->bottom = d;
179179
d->len = sprintf(d->path, "%.*s%s/", (int)base->len, base->buf, filename);
180-
hashcpy(d->sha1, sha1);
180+
hashcpy(d->oid.hash, sha1);
181181
}
182182

183183
static int write_directory(struct archiver_context *c)
@@ -191,7 +191,7 @@ static int write_directory(struct archiver_context *c)
191191
d->path[d->len - 1] = '\0'; /* no trailing slash */
192192
ret =
193193
write_directory(c) ||
194-
write_archive_entry(d->sha1, d->path, d->baselen,
194+
write_archive_entry(d->oid.hash, d->path, d->baselen,
195195
d->path + d->baselen, d->mode,
196196
d->stage, c) != READ_TREE_RECURSIVE;
197197
free(d);
@@ -354,23 +354,23 @@ static void parse_treeish_arg(const char **argv,
354354
time_t archive_time;
355355
struct tree *tree;
356356
const struct commit *commit;
357-
unsigned char sha1[20];
357+
struct object_id oid;
358358

359359
/* Remotes are only allowed to fetch actual refs */
360360
if (remote && !remote_allow_unreachable) {
361361
char *ref = NULL;
362362
const char *colon = strchrnul(name, ':');
363363
int refnamelen = colon - name;
364364

365-
if (!dwim_ref(name, refnamelen, sha1, &ref))
365+
if (!dwim_ref(name, refnamelen, oid.hash, &ref))
366366
die("no such ref: %.*s", refnamelen, name);
367367
free(ref);
368368
}
369369

370-
if (get_sha1(name, sha1))
370+
if (get_sha1(name, oid.hash))
371371
die("Not a valid object name");
372372

373-
commit = lookup_commit_reference_gently(sha1, 1);
373+
commit = lookup_commit_reference_gently(oid.hash, 1);
374374
if (commit) {
375375
commit_sha1 = commit->object.sha1;
376376
archive_time = commit->date;
@@ -379,21 +379,21 @@ static void parse_treeish_arg(const char **argv,
379379
archive_time = time(NULL);
380380
}
381381

382-
tree = parse_tree_indirect(sha1);
382+
tree = parse_tree_indirect(oid.hash);
383383
if (tree == NULL)
384384
die("not a tree object");
385385

386386
if (prefix) {
387-
unsigned char tree_sha1[20];
387+
struct object_id tree_oid;
388388
unsigned int mode;
389389
int err;
390390

391391
err = get_tree_entry(tree->object.sha1, prefix,
392-
tree_sha1, &mode);
392+
tree_oid.hash, &mode);
393393
if (err || !S_ISDIR(mode))
394394
die("current working directory is untracked");
395395

396-
tree = parse_tree_indirect(tree_sha1);
396+
tree = parse_tree_indirect(tree_oid.hash);
397397
}
398398
ar_args->tree = tree;
399399
ar_args->commit_sha1 = commit_sha1;

0 commit comments

Comments
 (0)