diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-08-06 11:43:47 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-08-06 13:38:18 -0700 |
commit | dbd0f5c7692cce0c5fea535a06622b3a93df9598 (patch) | |
tree | 92606e8799f9f518296ef4e9124cf782d7e234f2 /t | |
parent | eabbc99a2198d1cae62ce951457e7edc23b5f1a9 (diff) | |
download | git-dbd0f5c7692cce0c5fea535a06622b3a93df9598.tar.gz |
Files given on the command line are relative to $cwd
When running "git commit -F file" and "git tag -F file" from a
subdirectory, we should take it as relative to the directory we started
from, not relative to the top-level directory.
This adds a helper function "parse_options_fix_filename()" to make it more
convenient to fix this class of issues. Ideally, parse_options() should
support a new type of option, "OPT_FILENAME", to do this uniformly, but
this patch is meant to go to 'maint' to fix it minimally.
One thing to note is that value for "commit template file" that comes from
the command line is taken as relative to $cwd just like other parameters,
but when it comes from the configuration varilable 'commit.template', it
is taken as relative to the working tree root as before. I think this
difference actually is sensible (not that I particularly think
commit.template itself is sensible).
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t7004-tag.sh | 20 | ||||
-rwxr-xr-x | t/t7500-commit.sh | 29 |
2 files changed, 49 insertions, 0 deletions
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index 241c70dc66..acddbf5037 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -1067,4 +1067,24 @@ test_expect_success \ test_cmp expect actual ' +test_expect_success 'filename for the message is relative to cwd' ' + mkdir subdir && + echo "Tag message in top directory" >msgfile-5 && + echo "Tag message in sub directory" >subdir/msgfile-5 && + ( + cd subdir && + git tag -a -F msgfile-5 tag-from-subdir + ) && + git cat-file tag tag-from-subdir | grep "in sub directory" +' + +test_expect_success 'filename for the message is relative to cwd' ' + echo "Tag message in sub directory" >subdir/msgfile-6 && + ( + cd subdir && + git tag -a -F msgfile-6 tag-from-subdir-2 + ) && + git cat-file tag tag-from-subdir-2 | grep "in sub directory" +' + test_done diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh index baed6ce96b..823256a246 100755 --- a/t/t7500-commit.sh +++ b/t/t7500-commit.sh @@ -138,4 +138,33 @@ test_expect_success '--signoff' ' diff expect output ' +test_expect_success 'commit message from file (1)' ' + mkdir subdir && + echo "Log in top directory" >log && + echo "Log in sub directory" >subdir/log && + ( + cd subdir && + git commit --allow-empty -F log + ) && + commit_msg_is "Log in sub directory" +' + +test_expect_success 'commit message from file (2)' ' + rm -f log && + echo "Log in sub directory" >subdir/log && + ( + cd subdir && + git commit --allow-empty -F log + ) && + commit_msg_is "Log in sub directory" +' + +test_expect_success 'commit message from stdin' ' + ( + cd subdir && + echo "Log with foo word" | git commit --allow-empty -F - + ) && + commit_msg_is "Log with foo word" +' + test_done |