git-clone: always keep pack sent from remote.
This deprecates --keep and -q flags and always keeps the pack sent from the remote site. Corresponding configuration variables are also removed. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
49bb805e69
commit
e1c7ada6dd
72
clone-pack.c
72
clone-pack.c
@ -3,10 +3,8 @@
|
|||||||
#include "pkt-line.h"
|
#include "pkt-line.h"
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
static int quiet;
|
|
||||||
static int keep_pack;
|
|
||||||
static const char clone_pack_usage[] =
|
static const char clone_pack_usage[] =
|
||||||
"git-clone-pack [-q] [--keep] [--exec=<git-upload-pack>] [<host>:]<directory> [<heads>]*";
|
"git-clone-pack [--exec=<git-upload-pack>] [<host>:]<directory> [<heads>]*";
|
||||||
static const char *exec = "git-upload-pack";
|
static const char *exec = "git-upload-pack";
|
||||||
|
|
||||||
static void clone_handshake(int fd[2], struct ref *ref)
|
static void clone_handshake(int fd[2], struct ref *ref)
|
||||||
@ -114,41 +112,6 @@ static void write_refs(struct ref *ref)
|
|||||||
free(head_path);
|
free(head_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int clone_by_unpack(int fd[2])
|
|
||||||
{
|
|
||||||
int status;
|
|
||||||
pid_t pid;
|
|
||||||
|
|
||||||
pid = fork();
|
|
||||||
if (pid < 0)
|
|
||||||
die("git-clone-pack: unable to fork off git-unpack-objects");
|
|
||||||
if (!pid) {
|
|
||||||
dup2(fd[0], 0);
|
|
||||||
close(fd[0]);
|
|
||||||
close(fd[1]);
|
|
||||||
execlp("git-unpack-objects", "git-unpack-objects",
|
|
||||||
quiet ? "-q" : NULL, NULL);
|
|
||||||
die("git-unpack-objects exec failed");
|
|
||||||
}
|
|
||||||
close(fd[0]);
|
|
||||||
close(fd[1]);
|
|
||||||
while (waitpid(pid, &status, 0) < 0) {
|
|
||||||
if (errno != EINTR)
|
|
||||||
die("waiting for git-unpack-objects: %s", strerror(errno));
|
|
||||||
}
|
|
||||||
if (WIFEXITED(status)) {
|
|
||||||
int code = WEXITSTATUS(status);
|
|
||||||
if (code)
|
|
||||||
die("git-unpack-objects died with error code %d", code);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (WIFSIGNALED(status)) {
|
|
||||||
int sig = WTERMSIG(status);
|
|
||||||
die("git-unpack-objects died of signal %d", sig);
|
|
||||||
}
|
|
||||||
die("Sherlock Holmes! git-unpack-objects died of unnatural causes %d!", status);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int finish_pack(const char *pack_tmp_name)
|
static int finish_pack(const char *pack_tmp_name)
|
||||||
{
|
{
|
||||||
int pipe_fd[2];
|
int pipe_fd[2];
|
||||||
@ -294,35 +257,13 @@ static int clone_pack(int fd[2], int nr_match, char **match)
|
|||||||
}
|
}
|
||||||
clone_handshake(fd, refs);
|
clone_handshake(fd, refs);
|
||||||
|
|
||||||
if (keep_pack)
|
status = clone_without_unpack(fd);
|
||||||
status = clone_without_unpack(fd);
|
|
||||||
else
|
|
||||||
status = clone_by_unpack(fd);
|
|
||||||
|
|
||||||
if (!status)
|
if (!status)
|
||||||
write_refs(refs);
|
write_refs(refs);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int clone_options(const char *var, const char *value)
|
|
||||||
{
|
|
||||||
if (!strcmp("clone.keeppack", var)) {
|
|
||||||
keep_pack = git_config_bool(var, value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!strcmp("clone.quiet", var)) {
|
|
||||||
quiet = git_config_bool(var, value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Put other local option parsing for this program
|
|
||||||
* here ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Fall back on the default ones */
|
|
||||||
return git_default_config(var, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i, ret, nr_heads;
|
int i, ret, nr_heads;
|
||||||
@ -330,25 +271,20 @@ int main(int argc, char **argv)
|
|||||||
int fd[2];
|
int fd[2];
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
git_config(clone_options);
|
|
||||||
nr_heads = 0;
|
nr_heads = 0;
|
||||||
heads = NULL;
|
heads = NULL;
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
char *arg = argv[i];
|
char *arg = argv[i];
|
||||||
|
|
||||||
if (*arg == '-') {
|
if (*arg == '-') {
|
||||||
if (!strcmp("-q", arg)) {
|
if (!strcmp("-q", arg))
|
||||||
quiet = 1;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
if (!strncmp("--exec=", arg, 7)) {
|
if (!strncmp("--exec=", arg, 7)) {
|
||||||
exec = arg + 7;
|
exec = arg + 7;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp("--keep", arg)) {
|
if (!strcmp("--keep", arg))
|
||||||
keep_pack = 1;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
usage(clone_pack_usage);
|
usage(clone_pack_usage);
|
||||||
}
|
}
|
||||||
dest = arg;
|
dest = arg;
|
||||||
|
Loading…
Reference in New Issue
Block a user