]> git.ipfire.org Git - thirdparty/git.git/commitdiff
apply-one-time-sed.sh: modernize style
authorDenton Liu <liu.denton@gmail.com>
Wed, 27 Nov 2019 19:53:06 +0000 (11:53 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Nov 2019 21:20:14 +0000 (13:20 -0800)
Convert `[ ... ]` to use `test` and test for the existence of a regular
file (`-f`) instead of any file (`-e`).

Move the `then`s onto their own lines so that it conforms with the
general test style.

Instead of redirecting input into sed, allow it to open its own input.

Use `cmp -s` instead of `diff` since we only care about whether the two
files are equal and `diff` is overkill for this.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-httpd/apply-one-time-sed.sh

index fcef72892547c70af0b33bdf96f0c5acb793ea9b..bf7689d0202f9fcef7798c0c122e217e98f12606 100644 (file)
@@ -7,11 +7,13 @@
 #
 # This can be used to simulate the effects of the repository changing in
 # between HTTP request-response pairs.
-if [ -e one-time-sed ]; then
+if test -f one-time-sed
+then
        "$GIT_EXEC_PATH/git-http-backend" >out
-       sed "$(cat one-time-sed)" <out >out_modified
+       sed "$(cat one-time-sed)" out >out_modified
 
-       if diff out out_modified >/dev/null; then
+       if cmp -s out out_modified
+       then
                cat out
        else
                cat out_modified