mirror of
https://github.com/git/git.git
synced 2025-01-22 07:24:10 +08:00
Implement -v (verbose) option for pull methods other than local transport.
This moves the private "say()" function to pull.c, renames it to "pull_say()", and introduces a global variable "get_verbosely" that makes the pull backends report what they fetch. The -v option is added to git-rpull and git-http-pull to match git-local-pull. The documentation is updated to describe these pull commands. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
cc167ccaeb
commit
e78d97723c
@ -568,14 +568,35 @@ git-init-db won't hurt an existing repository.
|
||||
################################################################
|
||||
git-http-pull
|
||||
|
||||
git-http-pull [-c] [-t] [-a] [-v] commit-id url
|
||||
|
||||
Downloads a remote GIT repository via HTTP protocol.
|
||||
|
||||
-c
|
||||
Get the commit objects.
|
||||
-t
|
||||
Get trees associated with the commit objects.
|
||||
-a
|
||||
Get all the objects.
|
||||
-v
|
||||
Report what is downloaded.
|
||||
|
||||
|
||||
################################################################
|
||||
git-local-pull
|
||||
|
||||
git-local-pull [-c] [-t] [-a] [-l] [-s] [-n] [-v] commit-id path
|
||||
|
||||
Downloads another GIT repository on a local system.
|
||||
|
||||
-c
|
||||
Get the commit objects.
|
||||
-t
|
||||
Get trees associated with the commit objects.
|
||||
-a
|
||||
Get all the objects.
|
||||
-v
|
||||
Report what is downloaded.
|
||||
|
||||
################################################################
|
||||
git-ls-tree
|
||||
@ -888,9 +909,20 @@ think.)
|
||||
################################################################
|
||||
git-rpull
|
||||
|
||||
git-rpull [-c] [-t] [-a] [-v] commit-id url
|
||||
|
||||
Pulls from a remote repository over ssh connection, invoking git-rpush on
|
||||
the other end.
|
||||
|
||||
-c
|
||||
Get the commit objects.
|
||||
-t
|
||||
Get trees associated with the commit objects.
|
||||
-a
|
||||
Get all the objects.
|
||||
-v
|
||||
Report what is downloaded.
|
||||
|
||||
|
||||
################################################################
|
||||
git-rpush
|
||||
|
@ -79,8 +79,6 @@ int fetch(unsigned char *sha1)
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
|
||||
/*printf("Getting %s\n", hex);*/
|
||||
|
||||
if (curl_easy_perform(curl))
|
||||
return error("Couldn't get %s for %s\n", url, hex);
|
||||
|
||||
@ -96,6 +94,7 @@ int fetch(unsigned char *sha1)
|
||||
return error("File %s has bad hash\n", hex);
|
||||
}
|
||||
|
||||
pull_say("got %s\n", hex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -114,11 +113,13 @@ int main(int argc, char **argv)
|
||||
get_all = 1;
|
||||
get_tree = 1;
|
||||
get_history = 1;
|
||||
} else if (argv[arg][1] == 'v') {
|
||||
get_verbosely = 1;
|
||||
}
|
||||
arg++;
|
||||
}
|
||||
if (argc < arg + 2) {
|
||||
usage("http-pull [-c] [-t] [-a] commit-id url");
|
||||
usage("git-http-pull [-c] [-t] [-a] [-v] commit-id url");
|
||||
return 1;
|
||||
}
|
||||
commit_id = argv[arg];
|
||||
|
14
local-pull.c
14
local-pull.c
@ -14,15 +14,9 @@
|
||||
static int use_link = 0;
|
||||
static int use_symlink = 0;
|
||||
static int use_filecopy = 1;
|
||||
static int verbose = 0;
|
||||
|
||||
static char *path;
|
||||
|
||||
static void say(const char *fmt, const char *hex) {
|
||||
if (verbose)
|
||||
fprintf(stderr, fmt, hex);
|
||||
}
|
||||
|
||||
int fetch(unsigned char *sha1)
|
||||
{
|
||||
static int object_name_start = -1;
|
||||
@ -41,7 +35,7 @@ int fetch(unsigned char *sha1)
|
||||
strcpy(filename + object_name_start + 3, hex + 2);
|
||||
if (use_link) {
|
||||
if (!link(filename, dest_filename)) {
|
||||
say("link %s\n", hex);
|
||||
pull_say("link %s\n", hex);
|
||||
return 0;
|
||||
}
|
||||
/* If we got ENOENT there is no point continuing. */
|
||||
@ -51,7 +45,7 @@ int fetch(unsigned char *sha1)
|
||||
}
|
||||
}
|
||||
if (use_symlink && !symlink(filename, dest_filename)) {
|
||||
say("symlink %s\n", hex);
|
||||
pull_say("symlink %s\n", hex);
|
||||
return 0;
|
||||
}
|
||||
if (use_filecopy) {
|
||||
@ -79,7 +73,7 @@ int fetch(unsigned char *sha1)
|
||||
fprintf(stderr, "cannot write %s (%ld bytes)\n",
|
||||
dest_filename, st.st_size);
|
||||
else
|
||||
say("copy %s\n", hex);
|
||||
pull_say("copy %s\n", hex);
|
||||
return status;
|
||||
}
|
||||
fprintf(stderr, "failed to copy %s with given copy methods.\n", hex);
|
||||
@ -117,7 +111,7 @@ int main(int argc, char **argv)
|
||||
else if (argv[arg][1] == 'n')
|
||||
use_filecopy = 0;
|
||||
else if (argv[arg][1] == 'v')
|
||||
verbose = 1;
|
||||
get_verbosely = 1;
|
||||
else
|
||||
usage(local_pull_usage);
|
||||
arg++;
|
||||
|
6
pull.c
6
pull.c
@ -7,12 +7,18 @@
|
||||
int get_tree = 0;
|
||||
int get_history = 0;
|
||||
int get_all = 0;
|
||||
int get_verbosely = 0;
|
||||
static unsigned char current_commit_sha1[20];
|
||||
|
||||
static const char commitS[] = "commit";
|
||||
static const char treeS[] = "tree";
|
||||
static const char blobS[] = "blob";
|
||||
|
||||
void pull_say(const char *fmt, const char *hex) {
|
||||
if (get_verbosely)
|
||||
fprintf(stderr, fmt, hex);
|
||||
}
|
||||
|
||||
static void report_missing(const char *what, const unsigned char *missing)
|
||||
{
|
||||
char missing_hex[41];
|
||||
|
6
pull.h
6
pull.h
@ -13,6 +13,12 @@ extern int get_history;
|
||||
/** Set to fetch the trees in the commit history. **/
|
||||
extern int get_all;
|
||||
|
||||
/* Set to be verbose */
|
||||
extern int get_verbosely;
|
||||
|
||||
/* Report what we got under get_verbosely */
|
||||
extern void pull_say(const char *, const char *);
|
||||
|
||||
extern int pull(char *target);
|
||||
|
||||
#endif /* PULL_H */
|
||||
|
10
rpull.c
10
rpull.c
@ -14,8 +14,12 @@ static int fd_out;
|
||||
|
||||
int fetch(unsigned char *sha1)
|
||||
{
|
||||
int ret;
|
||||
write(fd_out, sha1, 20);
|
||||
return write_sha1_from_fd(sha1, fd_in);
|
||||
ret = write_sha1_from_fd(sha1, fd_in);
|
||||
if (!ret)
|
||||
pull_say("got %s\n", sha1_to_hex(sha1));
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
@ -33,11 +37,13 @@ int main(int argc, char **argv)
|
||||
get_all = 1;
|
||||
get_tree = 1;
|
||||
get_history = 1;
|
||||
} else if (argv[arg][1] == 'v') {
|
||||
get_verbosely = 1;
|
||||
}
|
||||
arg++;
|
||||
}
|
||||
if (argc < arg + 2) {
|
||||
usage("rpull [-c] [-t] [-a] commit-id url");
|
||||
usage("git-rpull [-c] [-t] [-a] [-v] commit-id url");
|
||||
return 1;
|
||||
}
|
||||
commit_id = argv[arg];
|
||||
|
Loading…
Reference in New Issue
Block a user