@matheusbsbs / matheus-bagliano / commits / 2c6df2d5d1
Fork 0

tar-tree: Use SHA1 of root tree for the basedir

... instead of the made-up "0". Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <junkio@cox.net>

Rene Scharfe committed Mar 25, 2006 at 23:21 UTC 2c6df2d5d1894d8951895334d80735868c6ac253
1 file changed +4 -3
tar-tree.c
+4 -3
@@ -375,7 +375,7 @@ static void traverse_tree(struct tree_desc *tree,
375
376 int main(int argc, char **argv)
377 {
378 - unsigned char sha1[20];
378 + unsigned char sha1[20], tree_sha1[20];
379 struct commit *commit;
380 struct tree_desc tree;
381
@@ -398,14 +398,15 @@ int main(int argc, char **argv)
398 write_global_extended_header(commit->object.sha1);
399 archive_time = commit->date;
400 }
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);
403 if (!tree.buf)
404 die("not a reference to a tag, commit or tree object: %s",
405 sha1_to_hex(sha1));
406 if (!archive_time)
407 archive_time = time(NULL);
408 if (basedir)
408 - write_header((unsigned char *)"0", TYPEFLAG_DIR, NULL, NULL,
409 + write_header(tree_sha1, TYPEFLAG_DIR, NULL, NULL,
410 basedir, 040777, NULL, 0);
411 traverse_tree(&tree, NULL);
412 write_trailer();