Junio C Hamano <gitster@xxxxxxxxx> 于2020年11月10日周二 上午4:59写道: > > > @@ -166,6 +177,8 @@ int cmd__proc_receive(int argc, const char **argv) > > fprintf(stderr, "proc-receive> %s\n", item->string); > > } > > > > + if (die_report) > > + die("die with the --die-report option"); > > And at this point we have already read everything the other end > said (if so, there is no need for the artificial "read everything > before we die")? In patch v3, will use "gently" forms of packet_write_fmt() and packet_flush(), and it is no necessary to read everything before die. And will add more "--die-*" option in test helper. > > diff --git a/t/t5411/test-0013-bad-protocol.sh b/t/t5411/test-0013-bad-protocol.sh > > index c5fe4cb37b..5c5241bc95 100644 > > --- a/t/t5411/test-0013-bad-protocol.sh > > +++ b/t/t5411/test-0013-bad-protocol.sh > > @@ -55,19 +55,16 @@ test_expect_success "proc-receive: bad protocol (hook --die-version, $PROTOCOL)" > > test_must_fail git -C workbench push origin \ > > HEAD:refs/for/master/topic \ > > >out 2>&1 && > > Are these expected to conflict with Dscho's changes to move 'master' > around? See topic "gitster/js/default-branch-name-adjust-t5411" has been merge to master branch already. Will rebase on it. > > - make_user_friendly_and_stable_output <out >actual && > > - > > + make_user_friendly_and_stable_output <out | > > + sed -n \ > > + -e "/^To / { s/ */ /g; p; }" \ > > + -e "/^ ! / { s/ */ /g; p; }" \ > > + >actual && > > It's the same thing but I somehow find "s/ */ /g" easier to read. > The comparison is between "there may be two things or more---squish > them down to one" and "After one thing, there may be any number of > things---remove all the extra ones". > > Makes me wonder if make_user_friendly should optionally have an > option to do something like this for us. I doubt it that it is > worth to do something like the attached patch. > > > t/t5411/common-functions.sh | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git c/t/t5411/common-functions.sh w/t/t5411/common-functions.sh > index 6580bebd8e..6919639c60 100644 > --- c/t/t5411/common-functions.sh > +++ w/t/t5411/common-functions.sh > @@ -40,7 +40,9 @@ create_commits_in () { > # `GIT_TEST_GETTEXT_POISON=true` in order to test unintentional translations > # on plumbing commands. > make_user_friendly_and_stable_output () { > - sed \ > + local en= > + case "$#" in 0) ;; *) en=-n ;; esac > + sed $en \ > -e "s/ *\$//" \ > -e "s/ */ /g" \ > -e "s/'/\"/g" \ > @@ -52,5 +54,6 @@ make_user_friendly_and_stable_output () { > -e "s/$(echo $A | cut -c1-7)[0-9a-f]*/<OID-A>/g" \ > -e "s/$(echo $B | cut -c1-7)[0-9a-f]*/<OID-B>/g" \ > -e "s#To $URL_PREFIX/upstream.git#To <URL/of/upstream.git>#" \ > - -e "/^error: / d" > + -e "/^error: / d" \ > + ${1+"$@"} > } If we call make_user_friendly_and_stable_output like this: make_user_friendly_and_stable_output \ -e "/^To / { p; n; p; n; p; } Text lines next to "^To " will not be formatted by the built-in sed's arguments. So will write like this: -- snip -- diff --git a/t/t5411/common-functions.sh b/t/t5411/common-functions.sh index 521a347710..b7cca2d8fb 100644 --- a/t/t5411/common-functions.sh +++ b/t/t5411/common-functions.sh @@ -42,7 +42,7 @@ create_commits_in () { make_user_friendly_and_stable_output () { sed \ -e "s/ *\$//" \ - -e "s/ */ /g" \ + -e "s/ */ /g" \ -e "s/'/\"/g" \ -e "s/ / /g" \ -e "s/$A/<COMMIT-A>/g" \ @@ -52,5 +52,11 @@ make_user_friendly_and_stable_output () { -e "s/$(echo $A | cut -c1-7)[0-9a-f]*/<OID-A>/g" \ -e "s/$(echo $B | cut -c1-7)[0-9a-f]*/<OID-B>/g" \ -e "s#To $URL_PREFIX/upstream.git#To <URL/of/upstream.git>#" \ - -e "/^error: / d" + -e "/^error: / d" | \ + if test $# -eq 0 + then + cat + else + sed ${1+"$@"} + fi } -- snap --