Re: [PATCH v4 1/2] t6400: preserve git ls-files exit status code

From
Eric Sunshine <hidden>
Date
2021-06-29 14:11:37
Reply to
Đoàn Trần Công Danh, 2021-06-29
On Tue, Jun 29, 2021 at 9:57 AM Đoàn Trần Công Danh
[off-list ref] wrote:
In t6400, we're checking number of files in the index and the working
tree by piping the output of "git ls-files" to "wc -l", thus losing the
exit status code of git.

Let's write the output of "git ls-files" to a temporary file, in order
to check exit status code of "git ls-files" properly.
Thanks, the simplicity of this version over the previous attempts is appealing.

Just a few extremely minor style nits below; don't know if any of them
are worth a re-roll.
quoted hunk ↗ jump to hunk
Signed-off-by: Đoàn Trần Công Danh <redacted>
---
diff --git a/t/t6400-merge-df.sh b/t/t6400-merge-df.sh
@@ -9,6 +9,20 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

 . ./test-lib.sh

+check_ls_files_count() {
style: funcname () {
+       local ops val
+       if test "$#" -le 2
I also &&-chain the `local` declaration:

    local ops val &&
    if test "$#" -le 2

By making it easy to see the `&&` upfront, when new code is inserted,
there is a better chance that the &&-chain will be kept intact:

    local ops val &&
    my new code &&
    if test "$#" -le 2
quoted hunk ↗ jump to hunk
+       then
+               BUG "Expect 2 or more arguments"
+       fi &&
A quick grep of the tests indicates that they are consistent about
using lowercase for the first word in a BUG():

    BUG "expect 2 or more arguments"
quoted hunk ↗ jump to hunk
+       ops="$1" &&
+       val="$2" &&
+       shift 2 &&
+       mkdir -p .git/trash &&
+       git ls-files "$@" >.git/trash/output &&
+       test_line_count "$ops" "$val" .git/trash/output
+}
Thread (29 messages) 29 messages, 5 authors, last reply 2021-07-04
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help