2 * Copyright (c) 2005, 2006 Rene Scharfe
11 static const char tar_tree_usage[] =
12 "git-tar-tree [--remote=<repo>] <tree-ish> [basedir]\n"
13 "*** Note that this command is now deprecated; use git-archive instead.";
15 int cmd_tar_tree(int argc, const char **argv, const char *prefix)
18 * git-tar-tree is now a wrapper around git-archive --format=tar
20 * $0 --remote=<repo> arg... ==>
21 * git-archive --format=tar --remote=<repo> arg...
23 * git-archive --format=tar tree-ish
24 * $0 tree-ish basedir ==>
25 * git-archive --format-tar --prefix=basedir tree-ish
28 const char **nargv = xcalloc(sizeof(*nargv), argc + 2);
32 nargv[nargc++] = "git-archive";
33 nargv[nargc++] = "--format=tar";
35 if (2 <= argc && !strncmp("--remote=", argv[1], 9)) {
36 nargv[nargc++] = argv[1];
42 usage(tar_tree_usage);
46 basedir_arg = xmalloc(strlen(argv[2]) + 11);
47 sprintf(basedir_arg, "--prefix=%s/", argv[2]);
48 nargv[nargc++] = basedir_arg;
52 nargv[nargc++] = argv[1];
57 "*** git-tar-tree is now deprecated.\n"
58 "*** Running git-archive instead.\n***");
59 for (i = 0; i < nargc; i++) {
61 sq_quote_print(stderr, nargv[i]);
64 return cmd_archive(nargc, nargv, prefix);
67 /* ustar header + extended global header content */
68 #define RECORDSIZE (512)
69 #define HEADERSIZE (2 * RECORDSIZE)
71 int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)
73 char buffer[HEADERSIZE];
74 struct ustar_header *header = (struct ustar_header *)buffer;
75 char *content = buffer + RECORDSIZE;
78 n = xread(0, buffer, HEADERSIZE);
80 die("git-get-tar-commit-id: read error");
81 if (header->typeflag[0] != 'g')
83 if (memcmp(content, "52 comment=", 11))
86 n = xwrite(1, content + 11, 41);
88 die("git-get-tar-commit-id: write error");