Skip to content

Commit fd88d9c

Browse files
author
Junio C Hamano
committed
Remove upload-tar and make git-tar-tree a thin wrapper to git-archive
The command now issues a big deprecation warning message and runs git-archive command with appropriate arguments. git-tar-tree $tree_ish $base always forces $base to be the leading directory name, so the --prefix parameter passed internally to git-archive is a slash appended to it, i.e. "--prefix=$base/". Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 3d74982 commit fd88d9c

File tree

8 files changed

+53
-200
lines changed

8 files changed

+53
-200
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ git-update-ref
122122
git-update-server-info
123123
git-upload-archive
124124
git-upload-pack
125-
git-upload-tar
126125
git-var
127126
git-verify-pack
128127
git-verify-tag

Documentation/git-tar-tree.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ SYNOPSIS
1212

1313
DESCRIPTION
1414
-----------
15+
THIS COMMAND IS DEPRECATED. Use `git-archive` with `--format=tar`
16+
option instead.
17+
1518
Creates a tar archive containing the tree structure for the named tree.
1619
When <base> is specified it is added as a leading path to the files in the
1720
generated tar archive.

Documentation/git-upload-tar.txt

Lines changed: 0 additions & 39 deletions
This file was deleted.

Documentation/git.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,6 @@ gitlink:git-upload-pack[1]::
247247
Invoked by 'git-fetch-pack' to push
248248
what are asked for.
249249

250-
gitlink:git-upload-tar[1]::
251-
Invoked by 'git-tar-tree --remote' to return the tar
252-
archive the other end asked for.
253-
254250

255251
High-level commands (porcelain)
256252
-------------------------------

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ BUILTIN_OBJS = \
300300
builtin-update-index.o \
301301
builtin-update-ref.o \
302302
builtin-upload-archive.o \
303-
builtin-upload-tar.o \
304303
builtin-verify-pack.o \
305304
builtin-write-tree.o
306305

builtin-tar-tree.c

Lines changed: 50 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -6,96 +6,66 @@
66
#include "commit.h"
77
#include "tar.h"
88
#include "builtin.h"
9-
#include "pkt-line.h"
10-
#include "archive.h"
11-
12-
#define RECORDSIZE (512)
13-
#define BLOCKSIZE (RECORDSIZE * 20)
9+
#include "quote.h"
1410

1511
static const char tar_tree_usage[] =
16-
"git-tar-tree [--remote=<repo>] <tree-ish> [basedir]";
12+
"git-tar-tree [--remote=<repo>] <tree-ish> [basedir]\n"
13+
"*** Note that this command is now deprecated; use git-archive instead.";
1714

18-
static int generate_tar(int argc, const char **argv, const char *prefix)
15+
int cmd_tar_tree(int argc, const char **argv, const char *prefix)
1916
{
20-
struct archiver_args args;
21-
int result;
22-
char *base = NULL;
23-
24-
memset(&args, 0, sizeof(args));
25-
if (argc != 2 && argc != 3)
26-
usage(tar_tree_usage);
27-
if (argc == 3) {
28-
int baselen = strlen(argv[2]);
29-
base = xmalloc(baselen + 2);
30-
memcpy(base, argv[2], baselen);
31-
base[baselen] = '/';
32-
base[baselen + 1] = '\0';
17+
/*
18+
* git-tar-tree is now a wrapper around git-archive --format=tar
19+
*
20+
* $0 --remote=<repo> arg... ==>
21+
* git-archive --format=tar --remote=<repo> arg...
22+
* $0 tree-ish ==>
23+
* git-archive --format=tar tree-ish
24+
* $0 tree-ish basedir ==>
25+
* git-archive --format-tar --prefix=basedir tree-ish
26+
*/
27+
int i;
28+
const char **nargv = xcalloc(sizeof(*nargv), argc + 2);
29+
char *basedir_arg;
30+
int nargc = 0;
31+
32+
nargv[nargc++] = "git-archive";
33+
nargv[nargc++] = "--format=tar";
34+
35+
if (2 <= argc && !strncmp("--remote=", argv[1], 9)) {
36+
nargv[nargc++] = argv[1];
37+
argv++;
38+
argc--;
3339
}
34-
args.base = base;
35-
parse_treeish_arg(argv + 1, &args, NULL);
36-
37-
result = write_tar_archive(&args);
38-
free(base);
39-
40-
return result;
41-
}
42-
43-
static const char *exec = "git-upload-tar";
44-
45-
static int remote_tar(int argc, const char **argv)
46-
{
47-
int fd[2], ret, len;
48-
pid_t pid;
49-
char buf[1024];
50-
char *url;
51-
52-
if (argc < 3 || 4 < argc)
40+
switch (argc) {
41+
default:
5342
usage(tar_tree_usage);
54-
55-
/* --remote=<repo> */
56-
url = xstrdup(argv[1]+9);
57-
pid = git_connect(fd, url, exec);
58-
if (pid < 0)
59-
return 1;
60-
61-
packet_write(fd[1], "want %s\n", argv[2]);
62-
if (argv[3])
63-
packet_write(fd[1], "base %s\n", argv[3]);
64-
packet_flush(fd[1]);
65-
66-
len = packet_read_line(fd[0], buf, sizeof(buf));
67-
if (!len)
68-
die("git-tar-tree: expected ACK/NAK, got EOF");
69-
if (buf[len-1] == '\n')
70-
buf[--len] = 0;
71-
if (strcmp(buf, "ACK")) {
72-
if (5 < len && !strncmp(buf, "NACK ", 5))
73-
die("git-tar-tree: NACK %s", buf + 5);
74-
die("git-tar-tree: protocol error");
43+
break;
44+
case 3:
45+
/* base-path */
46+
basedir_arg = xmalloc(strlen(argv[2]) + 11);
47+
sprintf(basedir_arg, "--prefix=%s/", argv[2]);
48+
nargv[nargc++] = basedir_arg;
49+
/* fallthru */
50+
case 2:
51+
/* tree-ish */
52+
nargv[nargc++] = argv[1];
7553
}
76-
/* expect a flush */
77-
len = packet_read_line(fd[0], buf, sizeof(buf));
78-
if (len)
79-
die("git-tar-tree: expected a flush");
80-
81-
/* Now, start reading from fd[0] and spit it out to stdout */
82-
ret = copy_fd(fd[0], 1);
83-
close(fd[0]);
84-
85-
ret |= finish_connect(pid);
86-
return !!ret;
87-
}
88-
89-
int cmd_tar_tree(int argc, const char **argv, const char *prefix)
90-
{
91-
if (argc < 2)
92-
usage(tar_tree_usage);
93-
if (!strncmp("--remote=", argv[1], 9))
94-
return remote_tar(argc, argv);
95-
return generate_tar(argc, argv, prefix);
54+
nargv[nargc] = NULL;
55+
56+
fprintf(stderr,
57+
"*** git-tar-tree is now deprecated.\n"
58+
"*** Running git-archive instead.\n***");
59+
for (i = 0; i < nargc; i++) {
60+
fputc(' ', stderr);
61+
sq_quote_print(stderr, nargv[i]);
62+
}
63+
fputc('\n', stderr);
64+
return cmd_archive(nargc, nargv, prefix);
9665
}
9766

9867
/* ustar header + extended global header content */
68+
#define RECORDSIZE (512)
9969
#define HEADERSIZE (2 * RECORDSIZE)
10070

10171
int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)

builtin-upload-tar.c

Lines changed: 0 additions & 74 deletions
This file was deleted.

git.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
263263
{ "update-index", cmd_update_index, RUN_SETUP },
264264
{ "update-ref", cmd_update_ref, RUN_SETUP },
265265
{ "upload-archive", cmd_upload_archive },
266-
{ "upload-tar", cmd_upload_tar },
267266
{ "version", cmd_version },
268267
{ "whatchanged", cmd_whatchanged, RUN_SETUP | USE_PAGER },
269268
{ "write-tree", cmd_write_tree, RUN_SETUP },

0 commit comments

Comments
 (0)