Skip to content

Commit

Permalink
t4012-diff-binary.sh: use the $( ... ) construct for command substitu…
Browse files Browse the repository at this point in the history
…tion

The Git CodingGuidelines prefer the $(...) construct for command
substitution instead of using the backquotes `...`.

The backquoted form is the traditional method for command
substitution, and is supported by POSIX.  However, all but the
simplest uses become complicated quickly.  In particular, embedded
command substitutions and/or the use of double quotes require
careful escaping with the backslash character.

The patch was generated by:

for _f in $(find . -name "*.sh")
do
   sed -i 's@`\(.*\)`@$(\1)@g' ${_f}
done

and then carefully proof-read.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Elia Pinto authored and Junio C Hamano committed Apr 30, 2014
1 parent 38b2e5d commit e6ce6f4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions t/t4012-diff-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ test_expect_success C_LOCALE_OUTPUT 'apply detecting corrupt patch correctly' '
git diff >output &&
sed -e "s/-CIT/xCIT/" <output >broken &&
test_must_fail git apply --stat --summary broken 2>detected &&
detected=`cat detected` &&
detected=`expr "$detected" : "fatal.*at line \\([0-9]*\\)\$"` &&
detected=`sed -ne "${detected}p" broken` &&
detected=$(cat detected) &&
detected=$(expr "$detected" : "fatal.*at line \\([0-9]*\\)\$") &&
detected=$(sed -ne "${detected}p" broken) &&
test "$detected" = xCIT
'

test_expect_success C_LOCALE_OUTPUT 'apply detecting corrupt patch correctly' '
git diff --binary | sed -e "s/-CIT/xCIT/" >broken &&
test_must_fail git apply --stat --summary broken 2>detected &&
detected=`cat detected` &&
detected=`expr "$detected" : "fatal.*at line \\([0-9]*\\)\$"` &&
detected=`sed -ne "${detected}p" broken` &&
detected=$(cat detected) &&
detected=$(expr "$detected" : "fatal.*at line \\([0-9]*\\)\$") &&
detected=$(sed -ne "${detected}p" broken) &&
test "$detected" = xCIT
'

Expand All @@ -88,15 +88,15 @@ test_expect_success 'initial commit' 'git commit -a -m initial'
test_expect_success 'diff-index with --binary' '
echo AIT >a && mv b e && echo CIT >c && cat e >d &&
git update-index --add --remove a b c d e &&
tree0=`git write-tree` &&
tree0=$(git write-tree) &&
git diff --cached --binary >current &&
git apply --stat --summary current
'

test_expect_success 'apply binary patch' '
git reset --hard &&
git apply --binary --index <current &&
tree1=`git write-tree` &&
tree1=$(git write-tree) &&
test "$tree1" = "$tree0"
'

Expand Down

0 comments on commit e6ce6f4

Please sign in to comment.