Skip to content

Commit 3ddad98

Browse files
author
Junio C Hamano
committed
Merge branch 'js/fetch-progress' (early part)
* 'js/fetch-progress' (early part): Fixup no-progress for fetch & clone fetch & clone: do not output progress when not on a tty Conflicts: git-fetch.sh
2 parents e6f9511 + b0e9089 commit 3ddad98

File tree

6 files changed

+47
-14
lines changed

6 files changed

+47
-14
lines changed

Documentation/git-fetch-pack.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-fetch-pack - Receive missing objects from another repository
88

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

1313
DESCRIPTION
1414
-----------
@@ -63,6 +63,9 @@ OPTIONS
6363
\--depth=<n>::
6464
Limit fetching to ancestor-chains not longer than n.
6565

66+
\--no-progress::
67+
Do not show the progress.
68+
6669
\-v::
6770
Run verbosely.
6871

Documentation/git-upload-pack.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-upload-pack - Send objects packed back to git-fetch-pack
88

99
SYNOPSIS
1010
--------
11-
'git-upload-pack' <directory>
11+
'git-upload-pack' [--strict] [--timeout=<n>] <directory>
1212

1313
DESCRIPTION
1414
-----------
@@ -23,6 +23,13 @@ repository. For push operations, see 'git-send-pack'.
2323

2424
OPTIONS
2525
-------
26+
27+
\--strict::
28+
Do not try <directory>/.git/ if <directory> is no git directory.
29+
30+
\--timeout=<n>::
31+
Interrupt transfer after <n> seconds of inactivity.
32+
2633
<directory>::
2734
The repository to sync from.
2835

fetch-pack.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ static int quiet;
1515
static int verbose;
1616
static int fetch_all;
1717
static int depth;
18+
static int no_progress;
1819
static const char fetch_pack_usage[] =
19-
"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [-v] [<host>:]<directory> [<refs>...]";
20+
"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]";
2021
static const char *uploadpack = "git-upload-pack";
2122

2223
#define COMPLETE (1U << 0)
@@ -173,12 +174,13 @@ static int find_common(int fd[2], unsigned char *result_sha1,
173174
}
174175

175176
if (!fetching)
176-
packet_write(fd[1], "want %s%s%s%s%s%s\n",
177+
packet_write(fd[1], "want %s%s%s%s%s%s%s\n",
177178
sha1_to_hex(remote),
178179
(multi_ack ? " multi_ack" : ""),
179180
(use_sideband == 2 ? " side-band-64k" : ""),
180181
(use_sideband == 1 ? " side-band" : ""),
181182
(use_thin_pack ? " thin-pack" : ""),
183+
(no_progress ? " no-progress" : ""),
182184
" ofs-delta");
183185
else
184186
packet_write(fd[1], "want %s\n", sha1_to_hex(remote));
@@ -521,7 +523,7 @@ static int get_pack(int xd[2])
521523
if (do_keep) {
522524
*av++ = "index-pack";
523525
*av++ = "--stdin";
524-
if (!quiet)
526+
if (!quiet && !no_progress)
525527
*av++ = "-v";
526528
if (use_thin_pack)
527529
*av++ = "--fix-thin";
@@ -718,6 +720,10 @@ int main(int argc, char **argv)
718720
st.st_mtime = 0;
719721
continue;
720722
}
723+
if (!strcmp("--no-progress", arg)) {
724+
no_progress = 1;
725+
continue;
726+
}
721727
usage(fetch_pack_usage);
722728
}
723729
dest = arg;

git-clone.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ origin=
7979
origin_override=
8080
use_separate_remote=t
8181
depth=
82+
no_progress=
83+
test -t 1 || no_progress=--no-progress
8284
while
8385
case "$#,$1" in
8486
0,*) break ;;
@@ -290,8 +292,8 @@ yes,yes)
290292
;;
291293
*)
292294
case "$upload_pack" in
293-
'') git-fetch-pack --all -k $quiet $depth "$repo" ;;
294-
*) git-fetch-pack --all -k $quiet "$upload_pack" $depth "$repo" ;;
295+
'') git-fetch-pack --all -k $quiet $depth $no_progress "$repo";;
296+
*) git-fetch-pack --all -k $quiet "$upload_pack" $depth $no_progress "$repo" ;;
295297
esac >"$GIT_DIR/CLONE_HEAD" ||
296298
die "fetch-pack from '$repo' failed."
297299
;;
@@ -393,7 +395,7 @@ then
393395

394396
case "$no_checkout" in
395397
'')
396-
test "z$quiet" = z && v=-v || v=
398+
test "z$quiet" = z -a "z$no_progress" = z && v=-v || v=
397399
git-read-tree -m -u $v HEAD HEAD
398400
esac
399401
fi

git-fetch.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ update_head_ok=
2424
exec=
2525
keep=
2626
shallow_depth=
27+
no_progress=
28+
test -t 1 || no_progress=--no-progress
2729
while case "$#" in 0) break ;; esac
2830
do
2931
case "$1" in
@@ -392,7 +394,8 @@ fetch_main () {
392394
git-bundle unbundle "$remote" $rref ||
393395
echo failed "$remote"
394396
else
395-
git-fetch-pack --thin $exec $keep $shallow_depth "$remote" $rref ||
397+
git-fetch-pack --thin $exec $keep $shallow_depth $no_progress \
398+
"$remote" $rref ||
396399
echo failed "$remote"
397400
fi
398401
) |

upload-pack.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=n
2626
static unsigned long oldest_have;
2727

2828
static int multi_ack, nr_our_refs;
29-
static int use_thin_pack, use_ofs_delta;
29+
static int use_thin_pack, use_ofs_delta, no_progress;
3030
static struct object_array have_obj;
3131
static struct object_array want_obj;
3232
static unsigned int timeout;
@@ -164,6 +164,9 @@ static void create_pack_file(void)
164164
die("git-upload-pack: unable to fork git-pack-objects");
165165
}
166166
if (!pid_pack_objects) {
167+
const char *argv[10];
168+
int i = 0;
169+
167170
dup2(lp_pipe[0], 0);
168171
dup2(pu_pipe[1], 1);
169172
dup2(pe_pipe[1], 2);
@@ -174,9 +177,16 @@ static void create_pack_file(void)
174177
close(pu_pipe[1]);
175178
close(pe_pipe[0]);
176179
close(pe_pipe[1]);
177-
execl_git_cmd("pack-objects", "--stdout", "--progress",
178-
use_ofs_delta ? "--delta-base-offset" : NULL,
179-
NULL);
180+
181+
argv[i++] = "pack-objects";
182+
argv[i++] = "--stdout";
183+
if (!no_progress)
184+
argv[i++] = "--progress";
185+
if (use_ofs_delta)
186+
argv[i++] = "--delta-base-offset";
187+
argv[i++] = NULL;
188+
189+
execv_git_cmd(argv);
180190
kill(pid_rev_list, SIGKILL);
181191
die("git-upload-pack: unable to exec git-pack-objects");
182192
}
@@ -537,6 +547,8 @@ static void receive_needs(void)
537547
use_sideband = LARGE_PACKET_MAX;
538548
else if (strstr(line+45, "side-band"))
539549
use_sideband = DEFAULT_PACKET_MAX;
550+
if (strstr(line+45, "no-progress"))
551+
no_progress = 1;
540552

541553
/* We have sent all our refs already, and the other end
542554
* should have chosen out of them; otherwise they are
@@ -605,7 +617,7 @@ static void receive_needs(void)
605617
static int send_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
606618
{
607619
static const char *capabilities = "multi_ack thin-pack side-band"
608-
" side-band-64k ofs-delta shallow";
620+
" side-band-64k ofs-delta shallow no-progress";
609621
struct object *o = parse_object(sha1);
610622

611623
if (!o)

0 commit comments

Comments
 (0)