git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] merge-file: correctly open files when in a subdir

From
Aleksander Boruch-Gruszecki <aleksander.boruchgruszecki@gmail.com>
Date
Feb 11, 2015, 09:58 UTC
Message-ID
<CAPHKiG6M9_fOjpx8Pt8UTpUcrS+tmqL3YcT11WyJJu8m6nkJ4A@mail.gmail.com>
In-Reply-To
<xmqqwq3pv60p.fsf@gitster.dls.corp.google.com>
Show 23 quoted lines
>>          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?

The test before the one added by me does work because merge-file tries to open "a.txt" for writing in repo root directory, which will create a file if it does not exist. If you add a directory before the file, trying to open it will fail. I will additionally check of the file's content to make the test more clear, however it does actually fail with git 2.3.0.

The issue with line-wrapping and tab changing to space is my own stupidity, I used an older config with my vim and it mangled the file. It also probably is what caused the patch to not apply properly.

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 6 in “merge-file: correctly open files when in a subdir”
  1. merge-file: correctly open files when in a subdirAleksander Boruch-Gruszecki, Feb 10, 2015
  2. Junio C HamanoFeb 10, 2015
  3. Aleksander Boruch-GruszeckiFeb 11, 2015
  4. Junio C HamanoFeb 11, 2015
  5. Junio C HamanoFeb 11, 2015
  6. Aleksander Boruch-GruszeckiFeb 11, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.