@@ -33,7 +33,7 @@ test_expect_success 'nonexistent template file should return error' '
3333 (
3434 GIT_EDITOR="echo hello >" &&
3535 export GIT_EDITOR &&
36- test_must_fail git commit --template "$PWD "/notexist
36+ test_must_fail git commit --template "$(pwd) "/notexist
3737 )
3838'
3939
@@ -43,12 +43,12 @@ test_expect_success 'nonexistent optional template file on command line' '
4343 (
4444 GIT_EDITOR="echo hello >\"\$1\"" &&
4545 export GIT_EDITOR &&
46- git commit --template ":(optional)$PWD /notexist"
46+ git commit --template ":(optional)$(pwd) /notexist"
4747 )
4848'
4949
5050test_expect_success ' nonexistent template file in config should return error' '
51- test_config commit.template "$PWD "/notexist &&
51+ test_config commit.template "$(pwd) "/notexist &&
5252 (
5353 GIT_EDITOR="echo hello >" &&
5454 export GIT_EDITOR &&
@@ -57,15 +57,15 @@ test_expect_success 'nonexistent template file in config should return error' '
5757'
5858
5959test_expect_success ' nonexistent optional template file in config' '
60- test_config commit.template ":(optional)$PWD "/notexist &&
60+ test_config commit.template ":(optional)$(pwd) "/notexist &&
6161 GIT_EDITOR="echo hello >" git commit --allow-empty &&
6262 git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
6363 echo hello >expect &&
6464 test_cmp expect actual
6565'
6666
6767# From now on we'll use a template file that exists.
68- TEMPLATE=" $PWD " /template
68+ TEMPLATE=" $( pwd ) " /template
6969
7070test_expect_success ' unedited template should not commit' '
7171 echo "template line" >"$TEMPLATE" &&
@@ -99,6 +99,15 @@ test_expect_success 'adding real content to a template should commit' '
9999 commit_msg_is "template linecommit message"
100100'
101101
102+ test_expect_success ' existent template marked optional should commit' '
103+ echo "existent template" >"$TEMPLATE" &&
104+ (
105+ test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
106+ git commit --allow-empty --template ":(optional)$TEMPLATE"
107+ ) &&
108+ commit_msg_is "existent templatecommit message"
109+ '
110+
102111test_expect_success ' -t option should be short for --template' '
103112 echo "short template" > "$TEMPLATE" &&
104113 echo "new content" >> foo &&
0 commit comments