From: Junio C Hamano <gitster@pobox•com>
To: Aleksander Boruch-Gruszecki <aleksander.boruchgruszecki@gmail•com>
Cc: Duy Nguyen <pclouds@gmail•com>,
Git Mailing List <git@vger•kernel.org>,
Stefan Beller <stefanbeller@googlemail•com>
Subject: Re: [PATCH v2] merge-file: correctly open files when in a subdir
Date: Tue, 10 Feb 2015 12:57:42 -0800 [thread overview]
Message-ID: <xmqqwq3pv60p.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CAPHKiG7vzKbtH7=cXD-7Cta=a-iy-ViMustn98z+VEog5ep2sg@mail.gmail.com> (Aleksander Boruch-Gruszecki's message of "Tue, 10 Feb 2015 21:23:55 +0100")
Aleksander Boruch-Gruszecki <aleksander.boruchgruszecki@gmail•com>
writes:
> 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 refering to the file from the user's working directory
> perspective.
>
> Signed-off-by: Aleksander Boruch-Gruszecki
> <aleksander.boruchgruszecki@gmail•com>
Please don't line wrap the footer.
> ---
> builtin/merge-file.c | 3 ++-
> t/t6023-merge-file.sh | 6 ++++++
> 2 files changed, 8 insertions(+), 1 deletion(-)
This patch does not apply.
> diff --git a/builtin/merge-file.c b/builtin/merge-file.c
> index 844f84f..232b768 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)
Please do not line-wrap the patch, either.
>
> if (ret >= 0) {
The original has a single tab at the beginning of this line to
indent, not four spaces.
> 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);
> diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh
> index 3758961..fdd104c 100755
> --- a/t/t6023-merge-file.sh
> +++ b/t/t6023-merge-file.sh
> @@ -72,6 +72,12 @@ test_expect_success 'works in subdirectory' '
> ( cd dir && git merge-file a.txt o.txt b.txt )
> '
>
> +mkdir -p dir/deep
> +cp new1.txt orig.txt new2.txt dir/deep
> +test_expect_success 'accounts for subdirectory when writing' '
> + (cd dir && git merge-file deep/new1.txt deep/orig.txt deep/new2.txt)
> +'
Interesting. Makes us wonder why the one before this new one you
added did not catch the issue, doesn't it?
> +
> cp new1.txt test.txt
> test_expect_success "merge without conflict (--quiet)" \
> "git merge-file --quiet test.txt orig.txt new2.txt"
next prev parent reply other threads:[~2015-02-10 20:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-10 20:23 [PATCH v2] merge-file: correctly open files when in a subdir Aleksander Boruch-Gruszecki
2015-02-10 20:57 ` Junio C Hamano [this message]
2015-02-11 9:58 ` Aleksander Boruch-Gruszecki
2015-02-11 18:21 ` Junio C Hamano
2015-02-11 19:02 ` Junio C Hamano
2015-02-11 21:20 ` Aleksander Boruch-Gruszecki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqwq3pv60p.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=aleksander.boruchgruszecki@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=pclouds@gmail$(echo .)com \
--cc=stefanbeller@googlemail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox