Thread (181 messages) 181 messages, 7 authors, 2021-01-20

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

From: Eric Sunshine <hidden>
Date: 2019-11-16 10:11:53

On Thu, Nov 14, 2019 at 8:01 PM Denton Liu [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Signed-off-by: Denton Liu <redacted>
---
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.)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help