Julian Phillips <julian@quantumfyre.co.uk>:
quoted text > On Sat, 10 Apr 2010 00:09:59 -0400, Jeff King <peff@peff.net> wrote:
> > Your parser is already broken if you are calling split, as the filenames
> > may contain spaces (and will be quoted in that case, and you need to
> > unmangle). You should use "-z".
> >
> > You will probably then realize that the "-z" format looks like:
> >
> > XY file1__PLACEHOLDER__0_file2__PLACEHOLDER__0_
> >
> > which still sucks. It would be more friendly as:
> >
> > XY__PLACEHOLDER__0_file1__PLACEHOLDER__0_file2__PLACEHOLDER__0_
> >
> > So you could split on "__PLACEHOLDER__0_". But even with that, you can't just blindly
> > split, as the column and record separators are the same, and you might
> > have one or two filenames.
>
> Not true. If the second form was used, then you _can_ split on __PLACEHOLDER__0_. It
> will tokenise the data for you, and then you consume ether two or three
> tokens depending on the status flags. So it would make the parsing
> simpler. But to make it even easier, how about adding a -Z that makes the
> output format "XY__PLACEHOLDER__0_file1__PLACEHOLDER__0_[file2]__PLACEHOLDER__0_" (i.e. always three tokens per record,
> with the third token being empty if there is no second filename)? Though
> if future expandability was wanted you could end each record with __PLACEHOLDER__0___PLACEHOLDER__0_ and
> then parsing would be a two stages of split on __PLACEHOLDER__0___PLACEHOLDER__0_ for records and then
> split on __PLACEHOLDER__0_ for entries? The is already precedence for the -z option to
> change the output format, so a second similar switch should be ok? Then
> the updated documentation could recommend --porcelain -Z for new users
> without affecting old ones.
+1
-Z could fix some of the other issues, as well, like use of space
as a flag character.
--
<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html