Skip to contentSkip to conversation

git-tar-tree: Move code for git-archive --format=tar to archive-tar.c

PATCH In review Rene Scharfe 2 participants 3 messages Jun 15, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 git-tar-tree: Move code for git-archive --format=tar to archive-tar.c

This patch doesn't change any functionality, it only moves code around. It makes seeing the few remaining lines of git-tar-tree code easier. ;-)

---

 Makefile           |    2 
 archive-tar.c      |  325 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 builtin-tar-tree.c |  313 --------------------------------------------------
 3 files changed, 326 insertions(+), 314 deletions(-)
Makefile +1 -1
index 739d7e3..d4f6e01 100644
@@ -254,7 +254,7 @@ LIB_OBJS = \
 	fetch-clone.o revision.o pager.o tree-walk.o xdiff-interface.o \
 	write_or_die.o trace.o list-objects.o \
 	alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \
-	color.o wt-status.o archive-zip.o
+	color.o wt-status.o archive-zip.o archive-tar.o
 
 BUILTIN_OBJS = \
 	builtin-add.o \
archive-tar.c new file +325 -0

325 lines not on this page · raw message

builtin-tar-tree.c +0 -313

331 lines not on this page · raw message

#1 lore raw
Quoted 4 lines · Rene Scharfe

This patch doesn't change any functionality, it only moves code around. It makes seeing the few remaining lines of git-tar-tree code easier. ;-)

Thanks. And here is an obvious follow-up to it.

-- >8 --
[PATCH] Remove upload-tar and make git-tar-tree a thin wrapper to git-archive

---

.gitignore +0 -1
index 3ca66e4..284db5d 100644
@@ -122,7 +122,6 @@ git-update-ref
 git-update-server-info
 git-upload-archive
 git-upload-pack
-git-upload-tar
 git-var
 git-verify-pack
 git-verify-tag
Documentation/git-tar-tree.txt +3 -0
index 1e1c7fa..74a6fdd 100644
@@ -12,6 +12,9 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
+THIS COMMAND IS DEPRECATED.  Use `git-archive` with `--format=tar`
+option instead.
+
 Creates a tar archive containing the tree structure for the named tree.
 When <base> is specified it is added as a leading path to the files in the
 generated tar archive.
Documentation/git-upload-tar.txt deleted +0 -39
deleted file mode 100644
index 394af62..0000000
@@ -1,39 +0,0 @@
-git-upload-tar(1)
-=================
-
-NAME
-----
-git-upload-tar - Send tar archive
-
-
-SYNOPSIS
---------
-'git-upload-tar' <directory>
-
-DESCRIPTION
------------
-Invoked by 'git-tar-tree --remote' and sends a generated tar archive
-to the other end over the git protocol.
-
-This command is usually not invoked directly by the end user.
-The UI for the protocol is on the 'git-tar-tree' side, and the
-program pair is meant to be used to get a tar archive from a
-remote repository.
-
-
-OPTIONS
--------
-<directory>::
-	The repository to get a tar archive from.
-
-Author
-------
-Written by Junio C Hamano <[email protected]>
-
-Documentation
---------------
-Documentation by Junio C Hamano.
-
-GIT
----
-Part of the gitlink:git[7] suite
Documentation/git.txt +0 -4
index 744c38d..1bf5ef5 100644
@@ -247,10 +247,6 @@ gitlink:git-upload-pack[1]::
 	Invoked by 'git-fetch-pack' to push
 	what are asked for.
 
-gitlink:git-upload-tar[1]::
-	Invoked by 'git-tar-tree --remote' to return the tar
-	archive the other end asked for.
-
 
 High-level commands (porcelain)
 -------------------------------
Makefile +0 -1
index d4f6e01..35de011 100644
@@ -298,7 +298,6 @@ BUILTIN_OBJS = \
 	builtin-update-index.o \
 	builtin-update-ref.o \
 	builtin-upload-archive.o \
-	builtin-upload-tar.o \
 	builtin-verify-pack.o \
 	builtin-write-tree.o
 
builtin-tar-tree.c +50 -78

144 lines not on this page · raw message

builtin-upload-tar.c deleted +0 -74

74 lines not on this page · raw message

git.c +0 -1
index 1686220..ae80e78 100644
@@ -263,7 +263,6 @@ static void handle_internal_command(int 
 		{ "update-index", cmd_update_index, RUN_SETUP },
 		{ "update-ref", cmd_update_ref, RUN_SETUP },
 		{ "upload-archive", cmd_upload_archive },
-		{ "upload-tar", cmd_upload_tar },
 		{ "version", cmd_version },
 		{ "whatchanged", cmd_whatchanged, RUN_SETUP | USE_PAGER },
 		{ "write-tree", cmd_write_tree, RUN_SETUP },
#2 lore raw
Quoted 11 lines · Junio C Hamano
Quoted 4 lines · Rene Scharfe

This patch doesn't change any functionality, it only moves code around. It makes seeing the few remaining lines of git-tar-tree code easier. ;-)

Thanks. And here is an obvious follow-up to it.

-- >8 --
[PATCH] Remove upload-tar and make git-tar-tree a thin wrapper to git-archive

OK.

builtin-tar-tree.c #include "tar.h" · line 10

Quoted 8 lines
builtin-tar-tree.c +0 -0
index aa370e3..5d2bec0 100644
@@ -8,94 +8,66 @@ #include "tar.h"
 #include "builtin.h"
 #include "pkt-line.h"
 #include "archive.h"

At least the last two header references aren't needed any more.

Quoted 6 lines
builtin-tar-tree.c +0 -6
-	if (argc == 3) {
-		int baselen = strlen(argv[2]);
-		base = xmalloc(baselen + 2);
-		memcpy(base, argv[2], baselen);
-		base[baselen] = '/';
-		base[baselen + 1] = '\0';

[...]

builtin-tar-tree.c #include "tar.h" · line 50

Quoted 5 lines
builtin-tar-tree.c +5 -0
+	case 3:
+		/* base-path */ 
+		basedir_arg = xmalloc(strlen(argv[2]) + 10);
+		sprintf(basedir_arg, "--prefix=%s", argv[2]);
+		nargv[nargc++] = basedir_arg;

Traditionally we always added a slash to the git-tar-tree base parameter, forcing it to always be a base _directory_. git-archive in contrast to that simply adds the prefix to the paths; users have to provide their own slash. This is consistent with how we handle --prefix parameters elsewhere. It also means that the sprintf format string here should be "--prefix=%s/" (and allocate one more byte the line before).

builtin-tar-tree.c #include "tar.h" · line 65

Quoted 8 lines
builtin-tar-tree.c +8 -0
+	fprintf(stderr,
+		"*** git-tar-tree is now deprecated.\n"
+		"*** Running git-archive instead.\n***");
+	for (i = 0; i < nargc; i++) {
+		fputc(' ', stderr);
+		sq_quote_print(stderr, nargv[i]);
+	}
+	fputc('\n', stderr);

Hey, scary message. ;-) It certainly will aid the re-education of our users, so I think it's OK.

Thanks,
René