@matheusbsbs / matheus-bagliano / commits / 9b5a9fa60a
Fork 0

t0090: stop losing return codes of git commands

In generate_expected_cache_tree_rec(), there are currently two instances of `git ls-files` in the upstream of a pipe. In the case where the upstream git command fails, its return code will be lost. Extract the `git ls-files` into its own call so that if it ever fails, its return code is not lost. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Denton Liu committed Nov 27, 2019 at 11:53 UTC 9b5a9fa60a444058c07c6f8df08fd779aaebfaae
1 file changed +3 -2
t/t0090-cache-tree.sh
+3 -2
@@ -21,9 +21,10 @@ generate_expected_cache_tree_rec () {
21 parent="$2" &&
22 # ls-files might have foo/bar, foo/bar/baz, and foo/bar/quux
23 # We want to count only foo because it's the only direct child
24 - subtrees=$(git ls-files|grep /|cut -d / -f 1|uniq) &&
24 + git ls-files >files &&
25 + subtrees=$(grep / files|cut -d / -f 1|uniq) &&
26 subtree_count=$(echo "$subtrees"|awk -v c=0 '$1 != "" {++c} END {print c}') &&
26 - entries=$(git ls-files|wc -l) &&
27 + entries=$(wc -l <files) &&
28 printf "SHA $dir (%d entries, %d subtrees)\n" "$entries" "$subtree_count" &&
29 for subtree in $subtrees
30 do