Skip to content

Commit

Permalink
fetch & clone: do not output progress when not on a tty
Browse files Browse the repository at this point in the history
This adds the option "--no-progress" to fetch-pack and upload-pack,
and makes fetch and clone pass this option when stdout is not a tty.

While at documenting that option, also document --strict and --timeout
options for upload-pack.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Feb 20, 2007
1 parent 437b1b2 commit 83a5ad6
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 13 deletions.
5 changes: 4 additions & 1 deletion Documentation/git-fetch-pack.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ git-fetch-pack - Receive missing objects from another repository

SYNOPSIS
--------
'git-fetch-pack' [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [-v] [<host>:]<directory> [<refs>...]
'git-fetch-pack' [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]

DESCRIPTION
-----------
Expand Down Expand Up @@ -63,6 +63,9 @@ OPTIONS
\--depth=<n>::
Limit fetching to ancestor-chains not longer than n.

\--no-progress::
Do not show the progress.

\-v::
Run verbosely.

Expand Down
12 changes: 11 additions & 1 deletion Documentation/git-upload-pack.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ git-upload-pack - Send objects packed back to git-fetch-pack

SYNOPSIS
--------
'git-upload-pack' <directory>
'git-upload-pack' [--strict] [--timeout=<n>] [--no-progress] <directory>

DESCRIPTION
-----------
Expand All @@ -23,6 +23,16 @@ repository. For push operations, see 'git-send-pack'.

OPTIONS
-------

\--strict::
Do not try <directory>/.git/ if <directory> is no git directory.

\--timeout=<n>::
Interrupt transfer after <n> seconds of inactivity.

\--no-progress::
Do not show the progress.

<directory>::
The repository to sync from.

Expand Down
16 changes: 13 additions & 3 deletions fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ static int quiet;
static int verbose;
static int fetch_all;
static int depth;
static int no_progress;
static const char fetch_pack_usage[] =
"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [-v] [<host>:]<directory> [<refs>...]";
"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]";
static const char *uploadpack = "git-upload-pack";

#define COMPLETE (1U << 0)
Expand Down Expand Up @@ -521,7 +522,7 @@ static int get_pack(int xd[2])
if (do_keep) {
*av++ = "index-pack";
*av++ = "--stdin";
if (!quiet)
if (!quiet && !no_progress)
*av++ = "-v";
if (use_thin_pack)
*av++ = "--fix-thin";
Expand Down Expand Up @@ -718,6 +719,10 @@ int main(int argc, char **argv)
st.st_mtime = 0;
continue;
}
if (!strcmp("--no-progress", arg)) {
no_progress = 1;
continue;
}
usage(fetch_pack_usage);
}
dest = arg;
Expand All @@ -727,7 +732,12 @@ int main(int argc, char **argv)
}
if (!dest)
usage(fetch_pack_usage);
pid = git_connect(fd, dest, uploadpack);
if (no_progress) {
char buf[256];
snprintf(buf, sizeof(buf), "%s --no-progress", uploadpack);
pid = git_connect(fd, dest, buf);
} else
pid = git_connect(fd, dest, uploadpack);
if (pid < 0)
return 1;
if (heads && nr_heads)
Expand Down
6 changes: 4 additions & 2 deletions git-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ origin=
origin_override=
use_separate_remote=t
depth=
no_progress=
test -t 1 || no_progress=--no-progress
while
case "$#,$1" in
0,*) break ;;
Expand Down Expand Up @@ -290,8 +292,8 @@ yes,yes)
;;
*)
case "$upload_pack" in
'') git-fetch-pack --all -k $quiet $depth "$repo" ;;
*) git-fetch-pack --all -k $quiet "$upload_pack" $depth "$repo" ;;
'') git-fetch-pack --all -k $quiet $depth $no_progress "$repo";;
*) git-fetch-pack --all -k $quiet "$upload_pack" $depth $no_progress "$repo" ;;
esac >"$GIT_DIR/CLONE_HEAD" ||
die "fetch-pack from '$repo' failed."
;;
Expand Down
5 changes: 4 additions & 1 deletion git-fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ update_head_ok=
exec=
keep=
shallow_depth=
no_progress=
test -t 1 || no_progress=--no-progress
while case "$#" in 0) break ;; esac
do
case "$1" in
Expand Down Expand Up @@ -377,7 +379,8 @@ fetch_main () {
( : subshell because we muck with IFS
IFS=" $LF"
(
git-fetch-pack --thin $exec $keep $shallow_depth "$remote" $rref ||
git-fetch-pack --thin $exec $keep $shallow_depth $no_progress \
"$remote" $rref ||
echo failed "$remote"
) |
(
Expand Down
24 changes: 19 additions & 5 deletions upload-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "revision.h"
#include "list-objects.h"

static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=nn] <dir>";
static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=nn] [--no-progress] <dir>";

/* bits #0..7 in revision.h, #8..10 in commit.c */
#define THEY_HAVE (1u << 11)
Expand All @@ -26,7 +26,7 @@ static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=n
static unsigned long oldest_have;

static int multi_ack, nr_our_refs;
static int use_thin_pack, use_ofs_delta;
static int use_thin_pack, use_ofs_delta, no_progress;
static struct object_array have_obj;
static struct object_array want_obj;
static unsigned int timeout;
Expand Down Expand Up @@ -164,6 +164,9 @@ static void create_pack_file(void)
die("git-upload-pack: unable to fork git-pack-objects");
}
if (!pid_pack_objects) {
const char *argv[10];
int i = 0;

dup2(lp_pipe[0], 0);
dup2(pu_pipe[1], 1);
dup2(pe_pipe[1], 2);
Expand All @@ -174,9 +177,16 @@ static void create_pack_file(void)
close(pu_pipe[1]);
close(pe_pipe[0]);
close(pe_pipe[1]);
execl_git_cmd("pack-objects", "--stdout", "--progress",
use_ofs_delta ? "--delta-base-offset" : NULL,
NULL);

argv[i++] = "pack-objects";
argv[i++] = "--stdout";
if (!no_progress)
argv[i++] = "--progress";
if (use_ofs_delta)
argv[i++] = "--delta-base-offset";
argv[i++] = NULL;

execv_git_cmd(argv);
kill(pid_rev_list, SIGKILL);
die("git-upload-pack: unable to exec git-pack-objects");
}
Expand Down Expand Up @@ -660,6 +670,10 @@ int main(int argc, char **argv)
timeout = atoi(arg+10);
continue;
}
if (!strcmp(arg, "--no-progress")) {
no_progress = 1;
continue;
}
if (!strcmp(arg, "--")) {
i++;
break;
Expand Down

0 comments on commit 83a5ad6

Please sign in to comment.