summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2131951)
raw | patch | inline | side by side (parent: 2131951)
author | Stephen Boyd <bebarino@gmail.com> | |
Sat, 23 May 2009 18:53:10 +0000 (11:53 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 23 May 2009 22:45:52 +0000 (15:45 -0700) |
Commit dbd0f5c7 (Files given on the command line are relative to $cwd,
2008-08-06) introduced parse_options_fix_filename() as a quick fix for
filename arguments used in the parse options API.
git-commit was still broken. This means
git commit -F log -t temp
in a subdirectory would make git think the log message should be taken
from temp instead of log.
This is because parse_options_fix_filename() calls prefix_filename()
which uses a single static char buffer to do its work. Making two calls
with two char pointers causes the pointers to alias. To prevent
aliasing, we duplicate the string returned by
parse_options_fix_filename().
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-06) introduced parse_options_fix_filename() as a quick fix for
filename arguments used in the parse options API.
git-commit was still broken. This means
git commit -F log -t temp
in a subdirectory would make git think the log message should be taken
from temp instead of log.
This is because parse_options_fix_filename() calls prefix_filename()
which uses a single static char buffer to do its work. Making two calls
with two char pointers causes the pointers to alias. To prevent
aliasing, we duplicate the string returned by
parse_options_fix_filename().
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-commit.c | patch | blob | history | |
t/t7500-commit.sh | patch | blob | history |
diff --git a/builtin-commit.c b/builtin-commit.c
index 81371b1d2698a48dba36046d7ff9d849f830a762..baaa75cf908d57e6d8540b6483684400c0b2494b 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
argc = parse_options(argc, argv, builtin_commit_options, usage, 0);
logfile = parse_options_fix_filename(prefix, logfile);
+ if (logfile)
+ logfile = xstrdup(logfile);
template_file = parse_options_fix_filename(prefix, template_file);
+ if (template_file)
+ template_file = xstrdup(template_file);
if (force_author && !strchr(force_author, '>'))
force_author = find_author_by_nickname(force_author);
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index 5998baf27b5ad0fb32bf0fd42023d029a65d0e6b..8eec0fa9bc7278981b9a16571c588ede0a94d341 100755 (executable)
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
commit_msg_is "Log with foo word"
'
+test_expect_success 'commit -F overrides -t' '
+ (
+ cd subdir &&
+ echo "-F log" > f.log &&
+ echo "-t template" > t.template &&
+ git commit --allow-empty -F f.log -t t.template
+ ) &&
+ commit_msg_is "-F log"
+'
+
test_done