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

Re: [PATCH 4/4] git-p4: resolve RCS keywords in binary

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 15, 2021, 21:41 UTC
Message-ID
<xmqqczlx4kcy.fsf@gitster.g>
In-Reply-To
<BN8PR12MB336146CB8B6FD458AE3BE42BC8759@BN8PR12MB3361.namprd12.prod.outlook.com>
Joel Holdsworth <jholdsworth@nvidia.com> writes:
Show 23 quoted lines
>> Makes sense, and I am with others who commented on the previous
>> discussion thread that the right approach to take is to take the stuff coming
>> from Perforce as byte strings, process them as such and write them out as
>> byte strings, UNLESS we positively know what the source and destination
>> encodings are.
>> 
>> And this change we see here, matching with patterns, is perfectly in line with
>> that direction.  Very nice.
>
> Not bad. Fortunately, it's not possible for $ characters to appear as a component of a multi-byte UTF-8 character, so it's possible to do the matching byte-wise.
>
>> 
>> >          try:
>> > -            with os.fdopen(handle, "w+") as outFile, open(file, "r") as inFile:
>> > +            with os.fdopen(handle, "wb") as outFile, open(file, "rb") as inFile:
>> 
>> We seem to have lost "w+" and now it is "wb".  I do not see a reason to make
>> outFile anything but write-only, so the end result looks good to me, but is it
>> an unrelated "bug"fix that should be explained as such (e.g. "there is no
>> reason to make outFile read-write, so instead of using 'w+' just use 'wb'
>> while we make it unencoded output by adding 'b' to it")?
>
> I am happy to split this change into a separate patch if this is preferred.

I do not think this is big enough for a separate patch; just a mention in the log message is sufficient.

Previous: Joel HoldsworthNext: Andrew Oakley
Message 8 of 9 in “git-p4: fix RCS keyword processing encoding errors”
  1. 0/4 git-p4: fix RCS keyword processing encoding errorsJoel Holdsworth, Dec 13, 2021
  2. 1/4 git-p4: use with statements to close files after use in patchRCSKeywordsJoel Holdsworth, Dec 13, 2021
  3. 2/4 git-p4: pre-compile RCS keyword regexesJoel Holdsworth, Dec 13, 2021
  4. 3/4 git-p4: add raw option to read_pipelinesJoel Holdsworth, Dec 13, 2021
  5. 4/4 git-p4: resolve RCS keywords in binaryJoel Holdsworth, Dec 13, 2021
  6. Junio C HamanoDec 13, 2021
  7. Joel HoldsworthDec 14, 2021
  8. Junio C HamanoDec 15, 2021
  9. Andrew OakleyDec 14, 2021

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.