apply, fmt-merge-msg: use relative filenames
Commit dbd0f5c7 (Files given on the command line are relative to $cwd, 2008-08-06) only fixed git-commit and git-tag. But, git-apply and git-fmt-merge-msg didn't get the update and exhibit the same behavior. Fix them and add tests for "apply --build-fake-ancestor" and "fmt-merge-msg -F". Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stephen Boyd committed
May 23, 2009 at 11:53 UTC
4c8d4c14c6de59bc14d6118724ffee949e8654a7
4 files changed
+79
builtin-apply.c
+4
@@ -3316,6 +3316,10 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
3316
3317
argc = parse_options(argc, argv, builtin_apply_options,
3318
apply_usage, 0);
3319
+ fake_ancestor = parse_options_fix_filename(prefix, fake_ancestor);
3320
+ if (fake_ancestor)
3321
+ fake_ancestor = xstrdup(fake_ancestor);
3322
+
3323
if (apply_with_reject)
3324
apply = apply_verbosely = 1;
3325
if (!force_apply && (diffstat || numstat || summary || check || fake_ancestor))
builtin-fmt-merge-msg.c
+1
@@ -365,6 +365,7 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
365
argc = parse_options(argc, argv, options, fmt_merge_msg_usage, 0);
366
if (argc > 0)
367
usage_with_options(fmt_merge_msg_usage, options);
368
+ inpath = parse_options_fix_filename(prefix, inpath);
369
370
if (inpath && strcmp(inpath, "-")) {
371
in = fopen(inpath, "r");
t/t4131-apply-fake-ancestor.sh
new
+42
@@ -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
+32
@@ -208,4 +208,36 @@ test_expect_success 'merge-msg test #5-2' '
208
test_cmp expected actual
209
'
210
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
+
243
test_done