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

Re: [PATCH v3 3/3] git-p4: fix Git LFS pointer parsing

From
Sebastian Schuberth <sschuberth@gmail.com>
Date
Apr 25, 2016, 07:35 UTC
Message-ID
<CAHGBnuO16Y2b3G5pyuG59b+vojRGe_wySmUcAUka9eT2opABdA@mail.gmail.com>
In-Reply-To
<8340C6E5-C774-46EE-A1F9-1C4C7DF9CEB9@gmail.com>

On Mon, Apr 25, 2016 at 9:33 AM, Lars Schneider <larsxschneider@gmail.com> wrote:

Show 12 quoted lines
>> if you're omitting lines from the output. Also, the regex matches
>> against the whole multi-line string. That is, if the file for some
>> reason was ending in '\n\n' instead of just '\n', the '.*' would match
>> almost all content of the pointer file, not just the remains of the
>> preamble. One way to fix this would be to use
>>
>> re.sub(r'Git LFS pointer for [^\n]+\n\n', '', pointerFile)
>>
>> instead.
>
> In general you are right as "*" is greedy. However, in Python "." matches any
> character except a newline [1]. Therefore I think the regex is correct.
Ah, thanks for pointing that out. Looks ok to me then.
Show 6 quoted lines
> Nevertheless... thanks for making me read the line again. I forgot to
> assign the pointerFile variable in the version I sent around :-(
>
> This is how it should be:
>
> pointerFile = re.sub(r'Git LFS pointer for.*\n\n', '', pointerFile)
Right. Good you've catched that!
-- 
Sebastian Schuberth
Previous: Lars Schneider
Message 9 of 9 in “git-p4: fix Git LFS pointer parsing”
  1. 0/3 git-p4: fix Git LFS pointer parsinglarsxschneider@gmail.com, Apr 24, 2016
  2. 1/3 travis-ci: update Git-LFS and P4 to the latest versionlarsxschneider@gmail.com, Apr 24, 2016
  3. 2/3 travis-ci: express Linux/OS X dependency versions more clearlylarsxschneider@gmail.com, Apr 24, 2016
  4. Eric SunshineApr 25, 2016
  5. Lars SchneiderApr 25, 2016
  6. 3/3 git-p4: fix Git LFS pointer parsinglarsxschneider@gmail.com, Apr 24, 2016
  7. Sebastian SchuberthApr 24, 2016
  8. Lars SchneiderApr 25, 2016
  9. Sebastian SchuberthApr 25, 2016

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.