Skip to content

Commit 6671346

Browse files
committed
Merge branch 'jk/use-write-script-more' into maint
Code clean-up. * jk/use-write-script-more: t3404: use write_script t1020: do not overuse printf and use write_script t5532: use write_script
2 parents 97d5165 + 7bec7f5 commit 6671346

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

t/t1020-subdirectory.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,13 @@ test_expect_success 'GIT_PREFIX for !alias' '
141141
test_expect_success 'GIT_PREFIX for built-ins' '
142142
# Use GIT_EXTERNAL_DIFF to test that the "diff" built-in
143143
# receives the GIT_PREFIX variable.
144-
printf "dir/" >expect &&
145-
printf "#!/bin/sh\n" >diff &&
146-
printf "printf \"\$GIT_PREFIX\"" >>diff &&
147-
chmod +x diff &&
144+
echo "dir/" >expect &&
145+
write_script diff <<-\EOF &&
146+
printf "%s\n" "$GIT_PREFIX"
147+
EOF
148148
(
149149
cd dir &&
150-
printf "change" >two &&
150+
echo "change" >two &&
151151
GIT_EXTERNAL_DIFF=./diff git diff >../actual
152152
git checkout -- two
153153
) &&

t/t3404-rebase-interactive.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,10 +555,9 @@ test_expect_success 'rebase a detached HEAD' '
555555
test_expect_success 'rebase a commit violating pre-commit' '
556556
557557
mkdir -p .git/hooks &&
558-
PRE_COMMIT=.git/hooks/pre-commit &&
559-
echo "#!/bin/sh" > $PRE_COMMIT &&
560-
echo "test -z \"\$(git diff --cached --check)\"" >> $PRE_COMMIT &&
561-
chmod a+x $PRE_COMMIT &&
558+
write_script .git/hooks/pre-commit <<-\EOF &&
559+
test -z "$(git diff --cached --check)"
560+
EOF
562561
echo "monde! " >> file1 &&
563562
test_tick &&
564563
test_must_fail git commit -m doesnt-verify file1 &&

t/t5532-fetch-proxy.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,25 @@ test_expect_success 'setup remote repo' '
1212
)
1313
'
1414

15-
cat >proxy <<'EOF'
16-
#!/bin/sh
17-
echo >&2 "proxying for $*"
18-
cmd=$("$PERL_PATH" -e '
15+
test_expect_success 'setup proxy script' '
16+
write_script proxy-get-cmd "$PERL_PATH" <<-\EOF &&
1917
read(STDIN, $buf, 4);
2018
my $n = hex($buf) - 4;
2119
read(STDIN, $buf, $n);
2220
my ($cmd, $other) = split /\0/, $buf;
2321
# drop absolute-path on repo name
2422
$cmd =~ s{ /}{ };
2523
print $cmd;
26-
')
27-
echo >&2 "Running '$cmd'"
28-
exec $cmd
29-
EOF
30-
chmod +x proxy
24+
EOF
25+
26+
write_script proxy <<-\EOF
27+
echo >&2 "proxying for $*"
28+
cmd=$(./proxy-get-cmd)
29+
echo >&2 "Running $cmd"
30+
exec $cmd
31+
EOF
32+
'
33+
3134
test_expect_success 'setup local repo' '
3235
git remote add fake git://example.com/remote &&
3336
git config core.gitproxy ./proxy

0 commit comments

Comments
 (0)