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

Re: [PATCH] fast-import: catch garbage after marks in from/merge

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Apr 2, 2012, 15:43 UTC
Message-ID
<20120402154356.GD3365@burratino>
In-Reply-To
<20120402001354.GA12651@padd.com>
Pete Wyckoff wrote:
> jrnieder@gmail.com wrote on Sun, 01 Apr 2012 18:12 -0500:
>> Why allow whitespace after the mark number?
>
> Fear of breaking existing fast-import users that might happen
> to have stray whitespace, or \r\n terminators.

Oh. I think worrying about that sort of thing is a very good thing. In particular, the possibility of \r\n terminators from an importer that writes its output in text mode on Windows is somewhat scary.

Luckily such a problem would be caught as soon as the importer uses a filemodify (M) command:

 - if it quotes the path:
	fatal: Garbage after path in: M ...
 - if it doesn't quote the path, the resulting import would use
   filenames with trailing CRs.
So we narrowly escape that problem.

Other types of stray whitespace at eol seem less likely but it's probably worth letting a patch like this incubate in the "next" branch for a little while to see if anyone complains.

The reason to care instead of just being permissive is that git fast-import is not the only fast-import backend. The tighter we can make the parsing without breaking existing frontends, the better the chance that a frontend that was only tested against git fast-import will be usable against all other backends, too.

In other words, there are two requirements in tension here (compatibility with sloppy frontends, compatibility with fussy backends). Some day fast-import might want to learn a --permissive option to reconcile them. In this particular case being strict unconditionally seems safe enough.

My only other hint is that as Dmitry mentioned it would be nice to nice to use the same logic for other places where fast-import parses a number at the end of a line, so people don't keep on making the same print vs println mistake and sending new patches to detect it in each place one at a time.

Sane?

Thanks, Jonathan

Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 22 in “fast-import: catch garbage after marks in from/merge”
  1. fast-import: catch garbage after marks in from/mergePete Wyckoff, Apr 1, 2012
  2. Jonathan NiederApr 1, 2012
  3. Pete WyckoffApr 2, 2012
  4. Dmitry IvankovApr 2, 2012
  5. Junio C HamanoApr 2, 2012
  6. Jonathan NiederApr 2, 2012
  7. Junio C HamanoApr 2, 2012
  8. 0/2 fast-import: tighten parsing of mark referencesPete Wyckoff, Apr 3, 2012
  9. 1/2 fast-import: test behavior of garbage after mark referencesPete Wyckoff, Apr 3, 2012
  10. Jonathan NiederApr 3, 2012
  11. Pete WyckoffApr 4, 2012
  12. Jonathan NiederApr 4, 2012
  13. 2/2 fast-import: tighten parsing of mark referencesPete Wyckoff, Apr 3, 2012
  14. Jonathan NiederApr 3, 2012
  15. Pete WyckoffApr 4, 2012
  16. Jonathan NiederApr 4, 2012
  17. Sverre RabbelierApr 3, 2012
  18. [PATCHv3] fast-import: tighten parsing of mark referencesPete Wyckoff, Apr 5, 2012
  19. Jonathan NiederApr 5, 2012
  20. Junio C HamanoApr 5, 2012
  21. [PATCHv4] fast-import: tighten parsing of datarefsPete Wyckoff, Apr 7, 2012
  22. Junio C HamanoApr 10, 2012

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.