diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-04-10 12:01:30 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-11 09:41:40 -0700 |
commit | a3bb8ca74ca01859f5eed962256faea737d4db7c (patch) | |
tree | f80b53fc4157b7bacc4458fe9f63d34c53050710 /t | |
parent | ca386ee177dac34a8a4721d546d05e4c6f96417b (diff) | |
download | git-a3bb8ca74ca01859f5eed962256faea737d4db7c.tar.gz git-a3bb8ca74ca01859f5eed962256faea737d4db7c.tar.xz |
t1020: do not overuse printf and use write_script
The test prepares a sample file "dir/two" with a single incomplete
line in it with "printf", and also prepares a small helper script
"diff" to create a file with a single incomplete line in it, again
with "printf". The output from the latter is compared with an
expected output, again prepared with "printf" hence lacking the
final LF. There is no reason for this test to be using files with
an incomplete line at the end, and these look more like a mistake
of not using
printf "%s\n" "string to be written"
and using
printf "string to be written"
Depending on what would be in $GIT_PREFIX, using the latter form
could be a bug waiting to happen. Correct them.
Also, the test uses hardcoded #!/bin/sh to create a small helper
script. For a small task like what the generated script does, it
does not matter too much in that what appears as /bin/sh would not
be _so_ broken, but while we are at it, use write_script instead,
which happens to make the result easier to read by reducing need
of one level of quoting.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t1020-subdirectory.sh | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index 8e22b03cd..df3183ea1 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -141,13 +141,13 @@ test_expect_success 'GIT_PREFIX for !alias' ' test_expect_success 'GIT_PREFIX for built-ins' ' # Use GIT_EXTERNAL_DIFF to test that the "diff" built-in # receives the GIT_PREFIX variable. - printf "dir/" >expect && - printf "#!/bin/sh\n" >diff && - printf "printf \"\$GIT_PREFIX\"" >>diff && - chmod +x diff && + echo "dir/" >expect && + write_script diff <<-\EOF && + printf "%s\n" "$GIT_PREFIX" + EOF ( cd dir && - printf "change" >two && + echo "change" >two && GIT_EXTERNAL_DIFF=./diff git diff >../actual git checkout -- two ) && |