Skip to content

Commit 2c6df2d

Browse files
Rene ScharfeJunio C Hamano
Rene Scharfe
authored and
Junio C Hamano
committed
tar-tree: Use SHA1 of root tree for the basedir
... instead of the made-up "0". Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c150462 commit 2c6df2d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tar-tree.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ static void traverse_tree(struct tree_desc *tree,
375375

376376
int main(int argc, char **argv)
377377
{
378-
unsigned char sha1[20];
378+
unsigned char sha1[20], tree_sha1[20];
379379
struct commit *commit;
380380
struct tree_desc tree;
381381

@@ -398,14 +398,15 @@ int main(int argc, char **argv)
398398
write_global_extended_header(commit->object.sha1);
399399
archive_time = commit->date;
400400
}
401-
tree.buf = read_object_with_reference(sha1, "tree", &tree.size, NULL);
401+
tree.buf = read_object_with_reference(sha1, "tree", &tree.size,
402+
tree_sha1);
402403
if (!tree.buf)
403404
die("not a reference to a tag, commit or tree object: %s",
404405
sha1_to_hex(sha1));
405406
if (!archive_time)
406407
archive_time = time(NULL);
407408
if (basedir)
408-
write_header((unsigned char *)"0", TYPEFLAG_DIR, NULL, NULL,
409+
write_header(tree_sha1, TYPEFLAG_DIR, NULL, NULL,
409410
basedir, 040777, NULL, 0);
410411
traverse_tree(&tree, NULL);
411412
write_trailer();

0 commit comments

Comments
 (0)