]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t5703-upload-pack-ref-in-want.sh
t5703: stop losing return codes of git commands
[thirdparty/git.git] / t / t5703-upload-pack-ref-in-want.sh
index 88338c4e099a6302680faca254999cc7ab1c02a2..1424fabd4aa5585f6eb8129dd48468dcab35753b 100755 (executable)
@@ -18,14 +18,16 @@ get_actual_commits () {
                p
                }' <out | test-tool pkt-line unpack-sideband >o.pack &&
        git index-pack o.pack &&
-       git verify-pack -v o.idx | grep commit | cut -c-40 | sort >actual_commits
+       git verify-pack -v o.idx >objs &&
+       grep commit objs | cut -c-40 | sort >actual_commits
 }
 
 check_output () {
        get_actual_refs &&
        test_cmp expected_refs actual_refs &&
        get_actual_commits &&
-       test_cmp expected_commits actual_commits
+       sort expected_commits >sorted_commits &&
+       test_cmp sorted_commits actual_commits
 }
 
 # c(o/foo) d(o/bar)
@@ -75,17 +77,19 @@ test_expect_success 'invalid want-ref line' '
 '
 
 test_expect_success 'basic want-ref' '
+       oid=$(git rev-parse f) &&
        cat >expected_refs <<-EOF &&
-       $(git rev-parse f) refs/heads/master
+       $oid refs/heads/master
        EOF
-       git rev-parse f | sort >expected_commits &&
+       git rev-parse f >expected_commits &&
 
+       oid=$(git rev-parse a) &&
        test-tool pkt-line pack >in <<-EOF &&
        command=fetch
        0001
        no-progress
        want-ref refs/heads/master
-       have $(git rev-parse a)
+       have $oid
        done
        0000
        EOF
@@ -95,19 +99,22 @@ test_expect_success 'basic want-ref' '
 '
 
 test_expect_success 'multiple want-ref lines' '
+       oid_c=$(git rev-parse c) &&
+       oid_d=$(git rev-parse d) &&
        cat >expected_refs <<-EOF &&
-       $(git rev-parse c) refs/heads/o/foo
-       $(git rev-parse d) refs/heads/o/bar
+       $oid_c refs/heads/o/foo
+       $oid_d refs/heads/o/bar
        EOF
-       git rev-parse c d | sort >expected_commits &&
+       git rev-parse c d >expected_commits &&
 
+       oid=$(git rev-parse b) &&
        test-tool pkt-line pack >in <<-EOF &&
        command=fetch
        0001
        no-progress
        want-ref refs/heads/o/foo
        want-ref refs/heads/o/bar
-       have $(git rev-parse b)
+       have $oid
        done
        0000
        EOF
@@ -117,10 +124,11 @@ test_expect_success 'multiple want-ref lines' '
 '
 
 test_expect_success 'mix want and want-ref' '
+       oid=$(git rev-parse f) &&
        cat >expected_refs <<-EOF &&
-       $(git rev-parse f) refs/heads/master
+       $oid refs/heads/master
        EOF
-       git rev-parse e f | sort >expected_commits &&
+       git rev-parse e f >expected_commits &&
 
        test-tool pkt-line pack >in <<-EOF &&
        command=fetch
@@ -138,17 +146,19 @@ test_expect_success 'mix want and want-ref' '
 '
 
 test_expect_success 'want-ref with ref we already have commit for' '
+       oid=$(git rev-parse c) &&
        cat >expected_refs <<-EOF &&
-       $(git rev-parse c) refs/heads/o/foo
+       $oid refs/heads/o/foo
        EOF
        >expected_commits &&
 
+       oid=$(git rev-parse c) &&
        test-tool pkt-line pack >in <<-EOF &&
        command=fetch
        0001
        no-progress
        want-ref refs/heads/o/foo
-       have $(git rev-parse c)
+       have $oid
        done
        0000
        EOF
@@ -211,13 +221,14 @@ test_expect_success 'fetching with exact OID' '
 
        rm -rf local &&
        cp -r "$LOCAL_PRISTINE" local &&
+       oid=$(git -C "$REPO" rev-parse d) &&
        GIT_TRACE_PACKET="$(pwd)/log" git -C local fetch origin \
-               $(git -C "$REPO" rev-parse d):refs/heads/actual &&
+               "$oid":refs/heads/actual &&
 
        git -C "$REPO" rev-parse "d" >expected &&
        git -C local rev-parse refs/heads/actual >actual &&
        test_cmp expected actual &&
-       grep "want $(git -C "$REPO" rev-parse d)" log
+       grep "want $oid" log
 '
 
 test_expect_success 'fetching multiple refs' '
@@ -239,13 +250,14 @@ test_expect_success 'fetching ref and exact OID' '
 
        rm -rf local &&
        cp -r "$LOCAL_PRISTINE" local &&
+       oid=$(git -C "$REPO" rev-parse b) &&
        GIT_TRACE_PACKET="$(pwd)/log" git -C local fetch origin \
-               master $(git -C "$REPO" rev-parse b):refs/heads/actual &&
+               master "$oid":refs/heads/actual &&
 
        git -C "$REPO" rev-parse "master" "b" >expected &&
        git -C local rev-parse refs/remotes/origin/master refs/heads/actual >actual &&
        test_cmp expected actual &&
-       grep "want $(git -C "$REPO" rev-parse b)" log &&
+       grep "want $oid" log &&
        grep "want-ref refs/heads/master" log
 '