diff options
author | Aleksander Boruch-Gruszecki <aleksander.boruchgruszecki@gmail.com> | 2015-02-08 19:53:53 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-02-11 22:01:50 +0300 |
commit | 204a8ffe67d2b789a34a14a06618a24756f7d9a9 (patch) | |
tree | ae27dede5a5b4501c9afd7742154554a105b2d47 /builtin/merge-file.c | |
parent | 3d8a54eb37d298c251c0b6823dc06935a611bc33 (diff) |
merge-file: correctly open files when in a subdir
run_setup_gently() is called before merge-file. This may result in changing
current working directory, which wasn't taken into account when opening a file
for writing.
Fix by prepending the passed prefix. Previous var is left so that error
messages keep referring to the file from the user's working directory
perspective.
Signed-off-by: Aleksander Boruch-Gruszecki <aleksander.boruchgruszecki@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/merge-file.c')
-rw-r--r-- | builtin/merge-file.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin/merge-file.c b/builtin/merge-file.c index 844f84f40bf..232b76857cf 100644 --- a/builtin/merge-file.c +++ b/builtin/merge-file.c @@ -90,7 +90,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix) if (ret >= 0) { const char *filename = argv[0]; - FILE *f = to_stdout ? stdout : fopen(filename, "wb"); + const char *fpath = prefix_filename(prefix, prefixlen, argv[0]); + FILE *f = to_stdout ? stdout : fopen(fpath, "wb"); if (!f) ret = error("Could not open %s for writing", filename); |