gitweb: Separate printing difftree in git_commit into git_difftree_body
[gitweb.git] / builtin-tar-tree.c
index e5aaded820bddfe2d5175508cc9c422b55a66eec..215892b6967ab3b42ef3826e3e934001de1f5162 100644 (file)
@@ -308,18 +308,18 @@ int git_tar_config(const char *var, const char *value)
        return git_default_config(var, value);
 }
 
-static int generate_tar(int argc, const char **argv, char** envp)
+static int generate_tar(int argc, const char **argv, const char *prefix)
 {
        unsigned char sha1[20], tree_sha1[20];
        struct commit *commit;
        struct tree_desc tree;
        struct strbuf current_path;
+       void *buffer;
 
        current_path.buf = xmalloc(PATH_MAX);
        current_path.alloc = PATH_MAX;
        current_path.len = current_path.eof = 0;
 
-       setup_git_directory();
        git_config(git_tar_config);
 
        switch (argc) {
@@ -342,8 +342,8 @@ static int generate_tar(int argc, const char **argv, char** envp)
        } else
                archive_time = time(NULL);
 
-       tree.buf = read_object_with_reference(sha1, tree_type, &tree.size,
-                                             tree_sha1);
+       tree.buf = buffer = read_object_with_reference(sha1, tree_type,
+                                                      &tree.size, tree_sha1);
        if (!tree.buf)
                die("not a reference to a tag, commit or tree object: %s",
                    sha1_to_hex(sha1));
@@ -352,6 +352,7 @@ static int generate_tar(int argc, const char **argv, char** envp)
                write_entry(tree_sha1, &current_path, 040777, NULL, 0);
        traverse_tree(&tree, &current_path);
        write_trailer();
+       free(buffer);
        free(current_path.buf);
        return 0;
 }
@@ -402,19 +403,19 @@ static int remote_tar(int argc, const char **argv)
        return !!ret;
 }
 
-int cmd_tar_tree(int argc, const char **argv, char **envp)
+int cmd_tar_tree(int argc, const char **argv, const char *prefix)
 {
        if (argc < 2)
                usage(tar_tree_usage);
        if (!strncmp("--remote=", argv[1], 9))
                return remote_tar(argc, argv);
-       return generate_tar(argc, argv, envp);
+       return generate_tar(argc, argv, prefix);
 }
 
 /* ustar header + extended global header content */
 #define HEADERSIZE (2 * RECORDSIZE)
 
-int cmd_get_tar_commit_id(int argc, const char **argv, char **envp)
+int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)
 {
        char buffer[HEADERSIZE];
        struct ustar_header *header = (struct ustar_header *)buffer;