summaryrefslogtreecommitdiff
path: root/t/t5703-upload-pack-ref-in-want.sh
diff options
context:
space:
mode:
authorDenton Liu <liu.denton@gmail.com>2019-11-27 19:53:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-11-29 21:20:15 (GMT)
commit763b47bafab6f781dc52461985b3300d447d1332 (patch)
tree7b8d8c808406aedce8c04446fe9fd212d6e647f6 /t/t5703-upload-pack-ref-in-want.sh
parenteacaa1c18096e96c391c1246e91c43f35834e49e (diff)
downloadgit-763b47bafab6f781dc52461985b3300d447d1332.zip
git-763b47bafab6f781dc52461985b3300d447d1332.tar.gz
git-763b47bafab6f781dc52461985b3300d447d1332.tar.bz2
t5703: stop losing return codes of git commands
Currently, there are two ways where the return codes of git commands are lost. The first way is when a command is in the upstream of a pipe. In a pipe, only the return code of the last command is used. Thus, all other commands will have their return codes masked. Rewrite pipes so that there are no git commands upstream. The other way is when a command is in a non-assignment command substitution. The return code will be lost in favour of the surrounding command's. Rewrite instances of this such that git commands are in an assignment-only command substitution. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5703-upload-pack-ref-in-want.sh')
-rwxr-xr-xt/t5703-upload-pack-ref-in-want.sh46
1 files changed, 29 insertions, 17 deletions
diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh
index 88338c4..1424fab 100755
--- a/t/t5703-upload-pack-ref-in-want.sh
+++ b/t/t5703-upload-pack-ref-in-want.sh
@@ -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
'