-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This command implements the git archive protocol on the server side. This command is not intended to be used by the end user. Underlying git-archive command line options are sent over the protocol from "git-archive --remote=...", just like upload-tar currently does with "git-tar-tree=...". As for "git-archive" command implementation, this new command does not execute any existing "git-{tar,zip}-tree" but rely on the archive API defined by "git-archive" patch. Hence we get 2 good points: - "git-archive" and "git-upload-archive" share all option parsing code. - All kind of git-upload-{tar,zip} can be deprecated. Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
- Loading branch information
Franck Bui-Huu
authored and
Junio C Hamano
committed
Sep 9, 2006
1 parent
ec06bff
commit 39345a2
Showing
7 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
git-upload-archive(1) | ||
==================== | ||
|
||
NAME | ||
---- | ||
git-upload-archive - Send archive | ||
|
||
|
||
SYNOPSIS | ||
-------- | ||
'git-upload-archive' <directory> | ||
|
||
DESCRIPTION | ||
----------- | ||
Invoked by 'git-archive --remote' and sends a generated 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-archive' side, and the program pair | ||
is meant to be used to get an archive from a remote repository. | ||
|
||
OPTIONS | ||
------- | ||
<directory>:: | ||
The repository to get a tar archive from. | ||
|
||
Author | ||
------ | ||
Written by Franck Bui-Huu. | ||
|
||
Documentation | ||
-------------- | ||
Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>. | ||
|
||
GIT | ||
--- | ||
Part of the gitlink:git[7] suite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) 2006 Franck Bui-Huu | ||
*/ | ||
#include <time.h> | ||
#include "cache.h" | ||
#include "builtin.h" | ||
#include "archive.h" | ||
#include "pkt-line.h" | ||
|
||
static const char upload_archive_usage[] = | ||
"git-upload-archive <repo>"; | ||
|
||
|
||
int cmd_upload_archive(int argc, const char **argv, const char *prefix) | ||
{ | ||
struct archiver ar; | ||
const char *sent_argv[MAX_ARGS]; | ||
const char *arg_cmd = "argument "; | ||
char *p, buf[4096]; | ||
int treeish_idx; | ||
int sent_argc; | ||
int len; | ||
|
||
if (argc != 2) | ||
usage(upload_archive_usage); | ||
|
||
if (strlen(argv[1]) > sizeof(buf)) | ||
die("insanely long repository name"); | ||
|
||
strcpy(buf, argv[1]); /* enter-repo smudges its argument */ | ||
|
||
if (!enter_repo(buf, 0)) | ||
die("not a git archive"); | ||
|
||
/* put received options in sent_argv[] */ | ||
sent_argc = 1; | ||
sent_argv[0] = "git-upload-archive"; | ||
for (p = buf;;) { | ||
/* This will die if not enough free space in buf */ | ||
len = packet_read_line(0, p, (buf + sizeof buf) - p); | ||
if (len == 0) | ||
break; /* got a flush */ | ||
if (sent_argc > MAX_ARGS - 2) | ||
die("Too many options (>29)"); | ||
|
||
if (p[len-1] == '\n') { | ||
p[--len] = 0; | ||
} | ||
if (len < strlen(arg_cmd) || | ||
strncmp(arg_cmd, p, strlen(arg_cmd))) | ||
die("'argument' token or flush expected"); | ||
|
||
len -= strlen(arg_cmd); | ||
memmove(p, p + strlen(arg_cmd), len); | ||
sent_argv[sent_argc++] = p; | ||
p += len; | ||
*p++ = 0; | ||
} | ||
sent_argv[sent_argc] = NULL; | ||
|
||
/* parse all options sent by the client */ | ||
treeish_idx = parse_archive_args(sent_argc, sent_argv, &ar); | ||
|
||
parse_treeish_arg(sent_argv + treeish_idx, &ar.args, prefix); | ||
parse_pathspec_arg(sent_argv + treeish_idx + 1, &ar.args); | ||
|
||
packet_write(1, "ACK\n"); | ||
packet_flush(1); | ||
|
||
return ar.write_archive(&ar.args); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters