commit: -F overrides -t
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>
This commit is contained in:
parent
213195185c
commit
aae94ffbc1
@ -699,7 +699,11 @@ static int parse_and_validate_options(int argc, const char *argv[],
|
|||||||
|
|
||||||
argc = parse_options(argc, argv, builtin_commit_options, usage, 0);
|
argc = parse_options(argc, argv, builtin_commit_options, usage, 0);
|
||||||
logfile = parse_options_fix_filename(prefix, logfile);
|
logfile = parse_options_fix_filename(prefix, logfile);
|
||||||
|
if (logfile)
|
||||||
|
logfile = xstrdup(logfile);
|
||||||
template_file = parse_options_fix_filename(prefix, template_file);
|
template_file = parse_options_fix_filename(prefix, template_file);
|
||||||
|
if (template_file)
|
||||||
|
template_file = xstrdup(template_file);
|
||||||
|
|
||||||
if (force_author && !strchr(force_author, '>'))
|
if (force_author && !strchr(force_author, '>'))
|
||||||
force_author = find_author_by_nickname(force_author);
|
force_author = find_author_by_nickname(force_author);
|
||||||
|
@ -183,4 +183,14 @@ test_expect_success 'commit message from stdin' '
|
|||||||
commit_msg_is "Log with foo word"
|
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
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user