Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 4c732da

Browse files
committed
Merge branch 'jk/maint-push-progress'
"git push" over smart-http lost progress output and this resurrects it. By Jeff King * jk/maint-push-progress: t5541: test more combinations of --progress teach send-pack about --[no-]progress send-pack: show progress when isatty(2)
2 parents f4ed0af + e304aeb commit 4c732da

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

builtin/send-pack.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
410410
const char *receivepack = "git-receive-pack";
411411
int flags;
412412
int nonfastforward = 0;
413+
int progress = -1;
413414

414415
argv++;
415416
for (i = 1; i < argc; i++, argv++) {
@@ -452,6 +453,14 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
452453
args.verbose = 1;
453454
continue;
454455
}
456+
if (!strcmp(arg, "--progress")) {
457+
progress = 1;
458+
continue;
459+
}
460+
if (!strcmp(arg, "--no-progress")) {
461+
progress = 0;
462+
continue;
463+
}
455464
if (!strcmp(arg, "--thin")) {
456465
args.use_thin_pack = 1;
457466
continue;
@@ -492,6 +501,10 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
492501
}
493502
}
494503

504+
if (progress == -1)
505+
progress = !args.quiet && isatty(2);
506+
args.progress = progress;
507+
495508
if (args.stateless_rpc) {
496509
conn = NULL;
497510
fd[0] = 0;

remote-curl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,7 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)
782782
argv[argc++] = "--quiet";
783783
else if (options.verbosity > 1)
784784
argv[argc++] = "--verbose";
785+
argv[argc++] = options.progress ? "--progress" : "--no-progress";
785786
argv[argc++] = url;
786787
for (i = 0; i < nr_spec; i++)
787788
argv[argc++] = specs[i];

t/t5541-http-push.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,36 @@ test_expect_success 'push --mirror to repo with alternates' '
216216
git push --mirror "$HTTPD_URL"/smart/alternates-mirror.git
217217
'
218218

219-
test_expect_success TTY 'quiet push' '
219+
test_expect_success TTY 'push shows progress when stderr is a tty' '
220+
cd "$ROOT_PATH"/test_repo_clone &&
221+
test_commit noisy &&
222+
test_terminal git push >output 2>&1 &&
223+
grep "^Writing objects" output
224+
'
225+
226+
test_expect_success TTY 'push --quiet silences status and progress' '
220227
cd "$ROOT_PATH"/test_repo_clone &&
221228
test_commit quiet &&
222-
test_terminal git push --quiet --no-progress 2>&1 | tee output &&
229+
test_terminal git push --quiet >output 2>&1 &&
223230
test_cmp /dev/null output
224231
'
225232

233+
test_expect_success TTY 'push --no-progress silences progress but not status' '
234+
cd "$ROOT_PATH"/test_repo_clone &&
235+
test_commit no-progress &&
236+
test_terminal git push --no-progress >output 2>&1 &&
237+
grep "^To http" output &&
238+
! grep "^Writing objects"
239+
'
240+
241+
test_expect_success 'push --progress shows progress to non-tty' '
242+
cd "$ROOT_PATH"/test_repo_clone &&
243+
test_commit progress &&
244+
git push --progress >output 2>&1 &&
245+
grep "^To http" output &&
246+
grep "^Writing objects" output
247+
'
248+
226249
test_expect_success 'http push gives sane defaults to reflog' '
227250
cd "$ROOT_PATH"/test_repo_clone &&
228251
test_commit reflog-test &&

0 commit comments

Comments
 (0)