Skip to content

Commit b91ffd3

Browse files
committed
Merge branch 'sb/maint-1.6.2-opt-filename-fix' into maint
* sb/maint-1.6.2-opt-filename-fix: apply, fmt-merge-msg: use relative filenames commit: -F overrides -t
2 parents f282326 + 4c8d4c1 commit b91ffd3

File tree

6 files changed

+93
-0
lines changed

6 files changed

+93
-0
lines changed

builtin-apply.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3315,6 +3315,10 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
33153315

33163316
argc = parse_options(argc, argv, builtin_apply_options,
33173317
apply_usage, 0);
3318+
fake_ancestor = parse_options_fix_filename(prefix, fake_ancestor);
3319+
if (fake_ancestor)
3320+
fake_ancestor = xstrdup(fake_ancestor);
3321+
33183322
if (apply_with_reject)
33193323
apply = apply_verbosely = 1;
33203324
if (!force_apply && (diffstat || numstat || summary || check || fake_ancestor))

builtin-commit.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,11 @@ static int parse_and_validate_options(int argc, const char *argv[],
699699

700700
argc = parse_options(argc, argv, builtin_commit_options, usage, 0);
701701
logfile = parse_options_fix_filename(prefix, logfile);
702+
if (logfile)
703+
logfile = xstrdup(logfile);
702704
template_file = parse_options_fix_filename(prefix, template_file);
705+
if (template_file)
706+
template_file = xstrdup(template_file);
703707

704708
if (force_author && !strchr(force_author, '>'))
705709
force_author = find_author_by_nickname(force_author);

builtin-fmt-merge-msg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
363363
argc = parse_options(argc, argv, options, fmt_merge_msg_usage, 0);
364364
if (argc > 0)
365365
usage_with_options(fmt_merge_msg_usage, options);
366+
inpath = parse_options_fix_filename(prefix, inpath);
366367

367368
if (inpath && strcmp(inpath, "-")) {
368369
in = fopen(inpath, "r");

t/t4131-apply-fake-ancestor.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2009 Stephen Boyd
4+
#
5+
6+
test_description='git apply --build-fake-ancestor handling.'
7+
8+
. ./test-lib.sh
9+
10+
test_expect_success 'setup' '
11+
test_commit 1 &&
12+
test_commit 2 &&
13+
mkdir sub &&
14+
test_commit 3 sub/3 &&
15+
test_commit 4
16+
'
17+
18+
test_expect_success 'apply --build-fake-ancestor' '
19+
git checkout 2 &&
20+
echo "A" > 1.t &&
21+
git diff > 1.patch &&
22+
git reset --hard &&
23+
git checkout 1 &&
24+
git apply --build-fake-ancestor 1.ancestor 1.patch
25+
'
26+
27+
test_expect_success 'apply --build-fake-ancestor in a subdirectory' '
28+
git checkout 3 &&
29+
echo "C" > sub/3.t &&
30+
git diff > 3.patch &&
31+
git reset --hard &&
32+
git checkout 4 &&
33+
(
34+
cd sub &&
35+
git apply --build-fake-ancestor 3.ancestor ../3.patch &&
36+
test -f 3.ancestor
37+
) &&
38+
git apply --build-fake-ancestor 3.ancestor 3.patch &&
39+
test_cmp sub/3.ancestor 3.ancestor
40+
'
41+
42+
test_done

t/t6200-fmt-merge-msg.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,36 @@ test_expect_success 'merge-msg test #5-2' '
208208
test_cmp expected actual
209209
'
210210

211+
test_expect_success 'merge-msg -F' '
212+
213+
git config --unset-all merge.log
214+
git config --unset-all merge.summary
215+
git config merge.summary yes &&
216+
217+
git checkout master &&
218+
setdate &&
219+
git fetch . left right &&
220+
221+
git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
222+
test_cmp expected actual
223+
'
224+
225+
test_expect_success 'merge-msg -F in subdirectory' '
226+
227+
git config --unset-all merge.log
228+
git config --unset-all merge.summary
229+
git config merge.summary yes &&
230+
231+
git checkout master &&
232+
setdate &&
233+
git fetch . left right &&
234+
mkdir sub &&
235+
cp .git/FETCH_HEAD sub/FETCH_HEAD &&
236+
(
237+
cd sub &&
238+
git fmt-merge-msg -F FETCH_HEAD >../actual
239+
) &&
240+
test_cmp expected actual
241+
'
242+
211243
test_done

t/t7500-commit.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,14 @@ test_expect_success 'commit message from stdin' '
183183
commit_msg_is "Log with foo word"
184184
'
185185

186+
test_expect_success 'commit -F overrides -t' '
187+
(
188+
cd subdir &&
189+
echo "-F log" > f.log &&
190+
echo "-t template" > t.template &&
191+
git commit --allow-empty -F f.log -t t.template
192+
) &&
193+
commit_msg_is "-F log"
194+
'
195+
186196
test_done

0 commit comments

Comments
 (0)