Skip to content

Commit 3336757

Browse files
committed
Merge branch 'ab/merge-file-prefix' into maint
"git merge-file" did not work correctly in a subdirectory. * ab/merge-file-prefix: merge-file: correctly open files when in a subdir
2 parents 3630be2 + 204a8ff commit 3336757

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

builtin/merge-file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
9090

9191
if (ret >= 0) {
9292
const char *filename = argv[0];
93-
FILE *f = to_stdout ? stdout : fopen(filename, "wb");
93+
const char *fpath = prefix_filename(prefix, prefixlen, argv[0]);
94+
FILE *f = to_stdout ? stdout : fopen(fpath, "wb");
9495

9596
if (!f)
9697
ret = error("Could not open %s for writing", filename);

t/t6023-merge-file.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ test_expect_success 'works in subdirectory' '
6969
cp new1.txt dir/a.txt &&
7070
cp orig.txt dir/o.txt &&
7171
cp new2.txt dir/b.txt &&
72-
( cd dir && git merge-file a.txt o.txt b.txt )
72+
( cd dir && git merge-file a.txt o.txt b.txt ) &&
73+
test_path_is_missing a.txt
7374
'
7475

7576
cp new1.txt test.txt

0 commit comments

Comments
 (0)