Re: [PATCH 13/27] t5703: stop losing return codes of git commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 14, 2019 at 8:01 PM Denton Liu <liu.denton@xxxxxxxxx> wrote:
> Signed-off-by: Denton Liu <liu.denton@xxxxxxxxx>
> ---
> diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh
> @@ -312,9 +324,11 @@ inconsistency () {
> +       oid1=$(git -C "$REPO" rev-parse $1) &&
> +       oid2=$(git -C "$REPO" rev-parse $2) &&
>         printf "s/%s/%s/" \
> -              $(git -C "$REPO" rev-parse $1 | tr -d "\n") \
> -              $(git -C "$REPO" rev-parse $2 | tr -d "\n") \
> +              $(echo "$oid1" | tr -d "\n") \
> +              $(echo "$oid2" | tr -d "\n") \
>                >"$HTTPD_ROOT_PATH/one-time-sed"

This code is rather odd. The $(...) substitution already takes care of
stripping out newlines, so the 'tr' invocations in both the original
and the revised code are superfluous. As this patch series
incorporates various other cleanups, it would not be inappropriate to
create a patch which removes the unnecessary 'tr' invocations
preparatory to this patch. The final result should be a simple:

    printf "s/%s/%s/" $oid1 $oid2 >"$HTTPD_ROOT_PATH/one-time-sed"

or even simpler:

    printf "s/$oid1/$oid2/" >"$HTTPD_ROOT_PATH/one-time-sed"

In fact, given the way the tests actually employ "one-time-sed" via
$(cat one-time-sed) in t/lib-httpd/apply-one-time-sed.sh, it could
even be as simple as:

    echo "s/$oid1/$oid2/" >"$HTTPD_ROOT_PATH/one-time-sed"

which makes it consistent with the final "server loses a ref - ref in
want" test, which does use 'echo' rather than 'printf'. (That change
might also deserve its own patch.)



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux