Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 844cb24

Browse files
devzero2000gitster
authored andcommitted
git-checkout.sh: use the $( ... ) construct for command substitution
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 <[email protected]> Reviewed-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2c4a050 commit 844cb24

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

contrib/examples/git-checkout.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ else
222222

223223
# Match the index to the working tree, and do a three-way.
224224
git diff-files --name-only | git update-index --remove --stdin &&
225-
work=`git write-tree` &&
225+
work=$(git write-tree) &&
226226
git read-tree $v --reset -u $new || exit
227227

228228
eval GITHEAD_$new='${new_name:-${branch:-$new}}' &&
@@ -233,7 +233,7 @@ else
233233
# Do not register the cleanly merged paths in the index yet.
234234
# this is not a real merge before committing, but just carrying
235235
# the working tree changes along.
236-
unmerged=`git ls-files -u`
236+
unmerged=$(git ls-files -u)
237237
git read-tree $v --reset $new
238238
case "$unmerged" in
239239
'') ;;
@@ -269,7 +269,7 @@ if [ "$?" -eq 0 ]; then
269269
fi
270270
if test -n "$branch"
271271
then
272-
old_branch_name=`expr "z$oldbranch" : 'zrefs/heads/\(.*\)'`
272+
old_branch_name=$(expr "z$oldbranch" : 'zrefs/heads/\(.*\)')
273273
GIT_DIR="$GIT_DIR" git symbolic-ref -m "checkout: moving from ${old_branch_name:-$old} to $branch" HEAD "refs/heads/$branch"
274274
if test -n "$quiet"
275275
then
@@ -282,7 +282,7 @@ if [ "$?" -eq 0 ]; then
282282
fi
283283
elif test -n "$detached"
284284
then
285-
old_branch_name=`expr "z$oldbranch" : 'zrefs/heads/\(.*\)'`
285+
old_branch_name=$(expr "z$oldbranch" : 'zrefs/heads/\(.*\)')
286286
git update-ref --no-deref -m "checkout: moving from ${old_branch_name:-$old} to $arg" HEAD "$detached" ||
287287
die "Cannot detach HEAD"
288288
if test -n "$detach_warn"

0 commit comments

Comments
 (0)