Merge branch 'jk/push-progress'
* jk/push-progress: push: pass --progress down to git-pack-objects t5523-push-upstream: test progress messages t5523-push-upstream: add function to ensure fresh upstream repo test_terminal: ensure redirections work reliably test_terminal: catch use without TTY prerequisite test-lib: allow test code to check the list of declared prerequisites tests: test terminal output to both stdout and stderr tests: factor out terminal handling from t7006maint
commit
0510480510
|
@ -48,6 +48,7 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
NULL,
|
||||||
};
|
};
|
||||||
struct child_process po;
|
struct child_process po;
|
||||||
int i;
|
int i;
|
||||||
|
@ -59,6 +60,8 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext
|
||||||
argv[i++] = "--delta-base-offset";
|
argv[i++] = "--delta-base-offset";
|
||||||
if (args->quiet)
|
if (args->quiet)
|
||||||
argv[i++] = "-q";
|
argv[i++] = "-q";
|
||||||
|
if (args->progress)
|
||||||
|
argv[i++] = "--progress";
|
||||||
memset(&po, 0, sizeof(po));
|
memset(&po, 0, sizeof(po));
|
||||||
po.argv = argv;
|
po.argv = argv;
|
||||||
po.in = -1;
|
po.in = -1;
|
||||||
|
|
|
@ -5,6 +5,7 @@ struct send_pack_args {
|
||||||
unsigned verbose:1,
|
unsigned verbose:1,
|
||||||
quiet:1,
|
quiet:1,
|
||||||
porcelain:1,
|
porcelain:1,
|
||||||
|
progress:1,
|
||||||
send_mirror:1,
|
send_mirror:1,
|
||||||
force_update:1,
|
force_update:1,
|
||||||
use_thin_pack:1,
|
use_thin_pack:1,
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
test_expect_success 'set up terminal for tests' '
|
||||||
|
if
|
||||||
|
test_have_prereq PERL &&
|
||||||
|
"$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl \
|
||||||
|
sh -c "test -t 1 && test -t 2"
|
||||||
|
then
|
||||||
|
test_set_prereq TTY &&
|
||||||
|
test_terminal () {
|
||||||
|
if ! test_declared_prereq TTY
|
||||||
|
then
|
||||||
|
echo >&4 "test_terminal: need to declare TTY prerequisite"
|
||||||
|
return 127
|
||||||
|
fi
|
||||||
|
"$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl "$@"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
'
|
|
@ -2,9 +2,14 @@
|
||||||
|
|
||||||
test_description='push with --set-upstream'
|
test_description='push with --set-upstream'
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
. "$TEST_DIRECTORY"/lib-terminal.sh
|
||||||
|
|
||||||
|
ensure_fresh_upstream() {
|
||||||
|
rm -rf parent && git init --bare parent
|
||||||
|
}
|
||||||
|
|
||||||
test_expect_success 'setup bare parent' '
|
test_expect_success 'setup bare parent' '
|
||||||
git init --bare parent &&
|
ensure_fresh_upstream &&
|
||||||
git remote add upstream parent
|
git remote add upstream parent
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -66,4 +71,41 @@ test_expect_success 'push -u HEAD' '
|
||||||
check_config headbranch upstream refs/heads/headbranch
|
check_config headbranch upstream refs/heads/headbranch
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success TTY 'progress messages go to tty' '
|
||||||
|
ensure_fresh_upstream &&
|
||||||
|
|
||||||
|
test_terminal git push -u upstream master >out 2>err &&
|
||||||
|
grep "Writing objects" err
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'progress messages do not go to non-tty' '
|
||||||
|
ensure_fresh_upstream &&
|
||||||
|
|
||||||
|
# skip progress messages, since stderr is non-tty
|
||||||
|
git push -u upstream master >out 2>err &&
|
||||||
|
! grep "Writing objects" err
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'progress messages go to non-tty (forced)' '
|
||||||
|
ensure_fresh_upstream &&
|
||||||
|
|
||||||
|
# force progress messages to stderr, even though it is non-tty
|
||||||
|
git push -u --progress upstream master >out 2>err &&
|
||||||
|
grep "Writing objects" err
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success TTY 'push -q suppresses progress' '
|
||||||
|
ensure_fresh_upstream &&
|
||||||
|
|
||||||
|
test_terminal git push -u -q upstream master >out 2>err &&
|
||||||
|
! grep "Writing objects" err
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_failure TTY 'push --no-progress suppresses progress' '
|
||||||
|
ensure_fresh_upstream &&
|
||||||
|
|
||||||
|
test_terminal git push -u --no-progress upstream master >out 2>err &&
|
||||||
|
! grep "Writing objects" err
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
|
@ -4,42 +4,13 @@ test_description='Test automatic use of a pager.'
|
||||||
|
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
. "$TEST_DIRECTORY"/lib-pager.sh
|
. "$TEST_DIRECTORY"/lib-pager.sh
|
||||||
|
. "$TEST_DIRECTORY"/lib-terminal.sh
|
||||||
|
|
||||||
cleanup_fail() {
|
cleanup_fail() {
|
||||||
echo >&2 cleanup failed
|
echo >&2 cleanup failed
|
||||||
(exit 1)
|
(exit 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
test_expect_success 'set up terminal for tests' '
|
|
||||||
rm -f stdout_is_tty ||
|
|
||||||
cleanup_fail &&
|
|
||||||
|
|
||||||
if test -t 1
|
|
||||||
then
|
|
||||||
>stdout_is_tty
|
|
||||||
elif
|
|
||||||
test_have_prereq PERL &&
|
|
||||||
"$PERL_PATH" "$TEST_DIRECTORY"/t7006/test-terminal.perl \
|
|
||||||
sh -c "test -t 1"
|
|
||||||
then
|
|
||||||
>test_terminal_works
|
|
||||||
fi
|
|
||||||
'
|
|
||||||
|
|
||||||
if test -e stdout_is_tty
|
|
||||||
then
|
|
||||||
test_terminal() { "$@"; }
|
|
||||||
test_set_prereq TTY
|
|
||||||
elif test -e test_terminal_works
|
|
||||||
then
|
|
||||||
test_terminal() {
|
|
||||||
"$PERL_PATH" "$TEST_DIRECTORY"/t7006/test-terminal.perl "$@"
|
|
||||||
}
|
|
||||||
test_set_prereq TTY
|
|
||||||
else
|
|
||||||
say "# no usable terminal, so skipping some tests"
|
|
||||||
fi
|
|
||||||
|
|
||||||
test_expect_success 'setup' '
|
test_expect_success 'setup' '
|
||||||
unset GIT_PAGER GIT_PAGER_IN_USE;
|
unset GIT_PAGER GIT_PAGER_IN_USE;
|
||||||
test_might_fail git config --unset core.pager &&
|
test_might_fail git config --unset core.pager &&
|
||||||
|
@ -213,11 +184,6 @@ test_expect_success 'color when writing to a file intended for a pager' '
|
||||||
colorful colorful.log
|
colorful colorful.log
|
||||||
'
|
'
|
||||||
|
|
||||||
if test_have_prereq SIMPLEPAGER && test_have_prereq TTY
|
|
||||||
then
|
|
||||||
test_set_prereq SIMPLEPAGERTTY
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use this helper to make it easy for the caller of your
|
# Use this helper to make it easy for the caller of your
|
||||||
# terminal-using function to specify whether it should fail.
|
# terminal-using function to specify whether it should fail.
|
||||||
# If you write
|
# If you write
|
||||||
|
@ -253,7 +219,7 @@ parse_args() {
|
||||||
test_default_pager() {
|
test_default_pager() {
|
||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
|
|
||||||
$test_expectation SIMPLEPAGERTTY "$cmd - default pager is used by default" "
|
$test_expectation SIMPLEPAGER,TTY "$cmd - default pager is used by default" "
|
||||||
unset PAGER GIT_PAGER;
|
unset PAGER GIT_PAGER;
|
||||||
test_might_fail git config --unset core.pager &&
|
test_might_fail git config --unset core.pager &&
|
||||||
rm -f default_pager_used ||
|
rm -f default_pager_used ||
|
||||||
|
|
|
@ -366,6 +366,15 @@ test_have_prereq () {
|
||||||
test $total_prereq = $ok_prereq
|
test $total_prereq = $ok_prereq
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_declared_prereq () {
|
||||||
|
case ",$test_prereq," in
|
||||||
|
*,$1,*)
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# You are not expected to call test_ok_ and test_failure_ directly, use
|
# You are not expected to call test_ok_ and test_failure_ directly, use
|
||||||
# the text_expect_* functions instead.
|
# the text_expect_* functions instead.
|
||||||
|
|
||||||
|
@ -418,17 +427,17 @@ test_skip () {
|
||||||
break
|
break
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
if test -z "$to_skip" && test -n "$prereq" &&
|
if test -z "$to_skip" && test -n "$test_prereq" &&
|
||||||
! test_have_prereq "$prereq"
|
! test_have_prereq "$test_prereq"
|
||||||
then
|
then
|
||||||
to_skip=t
|
to_skip=t
|
||||||
fi
|
fi
|
||||||
case "$to_skip" in
|
case "$to_skip" in
|
||||||
t)
|
t)
|
||||||
of_prereq=
|
of_prereq=
|
||||||
if test "$missing_prereq" != "$prereq"
|
if test "$missing_prereq" != "$test_prereq"
|
||||||
then
|
then
|
||||||
of_prereq=" of $prereq"
|
of_prereq=" of $test_prereq"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
say_color skip >&3 "skipping test: $@"
|
say_color skip >&3 "skipping test: $@"
|
||||||
|
@ -442,9 +451,10 @@ test_skip () {
|
||||||
}
|
}
|
||||||
|
|
||||||
test_expect_failure () {
|
test_expect_failure () {
|
||||||
test "$#" = 3 && { prereq=$1; shift; } || prereq=
|
test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
|
||||||
test "$#" = 2 ||
|
test "$#" = 2 ||
|
||||||
error "bug in the test script: not 2 or 3 parameters to test-expect-failure"
|
error "bug in the test script: not 2 or 3 parameters to test-expect-failure"
|
||||||
|
export test_prereq
|
||||||
if ! test_skip "$@"
|
if ! test_skip "$@"
|
||||||
then
|
then
|
||||||
say >&3 "checking known breakage: $2"
|
say >&3 "checking known breakage: $2"
|
||||||
|
@ -460,9 +470,10 @@ test_expect_failure () {
|
||||||
}
|
}
|
||||||
|
|
||||||
test_expect_success () {
|
test_expect_success () {
|
||||||
test "$#" = 3 && { prereq=$1; shift; } || prereq=
|
test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
|
||||||
test "$#" = 2 ||
|
test "$#" = 2 ||
|
||||||
error "bug in the test script: not 2 or 3 parameters to test-expect-success"
|
error "bug in the test script: not 2 or 3 parameters to test-expect-success"
|
||||||
|
export test_prereq
|
||||||
if ! test_skip "$@"
|
if ! test_skip "$@"
|
||||||
then
|
then
|
||||||
say >&3 "expecting success: $2"
|
say >&3 "expecting success: $2"
|
||||||
|
@ -504,11 +515,12 @@ test_expect_code () {
|
||||||
# Usage: test_external description command arguments...
|
# Usage: test_external description command arguments...
|
||||||
# Example: test_external 'Perl API' perl ../path/to/test.pl
|
# Example: test_external 'Perl API' perl ../path/to/test.pl
|
||||||
test_external () {
|
test_external () {
|
||||||
test "$#" = 4 && { prereq=$1; shift; } || prereq=
|
test "$#" = 4 && { test_prereq=$1; shift; } || test_prereq=
|
||||||
test "$#" = 3 ||
|
test "$#" = 3 ||
|
||||||
error >&5 "bug in the test script: not 3 or 4 parameters to test_external"
|
error >&5 "bug in the test script: not 3 or 4 parameters to test_external"
|
||||||
descr="$1"
|
descr="$1"
|
||||||
shift
|
shift
|
||||||
|
export test_prereq
|
||||||
if ! test_skip "$descr" "$@"
|
if ! test_skip "$descr" "$@"
|
||||||
then
|
then
|
||||||
# Announce the script to reduce confusion about the
|
# Announce the script to reduce confusion about the
|
||||||
|
|
|
@ -5,14 +5,15 @@ use warnings;
|
||||||
use IO::Pty;
|
use IO::Pty;
|
||||||
use File::Copy;
|
use File::Copy;
|
||||||
|
|
||||||
# Run @$argv in the background with stdout redirected to $out.
|
# Run @$argv in the background with stdio redirected to $out and $err.
|
||||||
sub start_child {
|
sub start_child {
|
||||||
my ($argv, $out) = @_;
|
my ($argv, $out, $err) = @_;
|
||||||
my $pid = fork;
|
my $pid = fork;
|
||||||
if (not defined $pid) {
|
if (not defined $pid) {
|
||||||
die "fork failed: $!"
|
die "fork failed: $!"
|
||||||
} elsif ($pid == 0) {
|
} elsif ($pid == 0) {
|
||||||
open STDOUT, ">&", $out;
|
open STDOUT, ">&", $out;
|
||||||
|
open STDERR, ">&", $err;
|
||||||
close $out;
|
close $out;
|
||||||
exec(@$argv) or die "cannot exec '$argv->[0]': $!"
|
exec(@$argv) or die "cannot exec '$argv->[0]': $!"
|
||||||
}
|
}
|
||||||
|
@ -48,12 +49,28 @@ sub xsendfile {
|
||||||
copy($in, $out, 4096) or $!{EIO} or die "cannot copy from child: $!";
|
copy($in, $out, 4096) or $!{EIO} or die "cannot copy from child: $!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub copy_stdio {
|
||||||
|
my ($out, $err) = @_;
|
||||||
|
my $pid = fork;
|
||||||
|
defined $pid or die "fork failed: $!";
|
||||||
|
if (!$pid) {
|
||||||
|
close($out);
|
||||||
|
xsendfile(\*STDERR, $err);
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
close($err);
|
||||||
|
xsendfile(\*STDOUT, $out);
|
||||||
|
finish_child($pid) == 0
|
||||||
|
or exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
if ($#ARGV < 1) {
|
if ($#ARGV < 1) {
|
||||||
die "usage: test-terminal program args";
|
die "usage: test-terminal program args";
|
||||||
}
|
}
|
||||||
my $master = new IO::Pty;
|
my $master_out = new IO::Pty;
|
||||||
my $slave = $master->slave;
|
my $master_err = new IO::Pty;
|
||||||
my $pid = start_child(\@ARGV, $slave);
|
my $pid = start_child(\@ARGV, $master_out->slave, $master_err->slave);
|
||||||
close $slave;
|
close $master_out->slave;
|
||||||
xsendfile(\*STDOUT, $master);
|
close $master_err->slave;
|
||||||
|
copy_stdio($master_out, $master_err);
|
||||||
exit(finish_child($pid));
|
exit(finish_child($pid));
|
|
@ -789,6 +789,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
|
||||||
args.use_thin_pack = data->options.thin;
|
args.use_thin_pack = data->options.thin;
|
||||||
args.verbose = (transport->verbose > 0);
|
args.verbose = (transport->verbose > 0);
|
||||||
args.quiet = (transport->verbose < 0);
|
args.quiet = (transport->verbose < 0);
|
||||||
|
args.progress = transport->progress;
|
||||||
args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);
|
args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);
|
||||||
args.porcelain = !!(flags & TRANSPORT_PUSH_PORCELAIN);
|
args.porcelain = !!(flags & TRANSPORT_PUSH_PORCELAIN);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue