On Wed, Jul 10, 2013 at 08:21:15PM +0530, Ramkumar Ramachandra wrote:
> Jeff King wrote:
> > +If `--batch` or `--batch-check` is given, `cat-file` will read objects
> > +from stdin, one per line, and print information about them.
> > +
> > +You can specify the information shown for each object by using a custom
> > +`<format>`. The `<format>` is copied literally to stdout for each
> > +object, with placeholders of the form `%(atom)` expanded, followed by a
> > +newline. The available atoms are:
> > +
> > +If no format is specified, the default format is `%(objectname)
> > +%(objecttype) %(objectsize)`.
> > +
> > +If `--batch` is specified, the object information is followed by the
> > +object contents (consisting of `%(objectsize)` bytes), followed by a
> > +newline.
> I find this slightly hideous, and would have expected an
> %(objectcontents) or similar.
I looked into doing that, but it makes the code significantly more
complicated, assuming you do not want to copy the full object contents
in memory. You cannot use strbuf_expand, and you need to worry about
buffering/flushing more (you do not want to write() each individual
item, but if you are using printf(), you need to flush before using the
unbuffered streaming interface).
My thinking was to leave it until somebody actually wants it, at which
point they can do the necessary refactoring (and hopefully this would be
part of unifying it with other format-parsers).
If we were designing from scratch and this was the difference between
having "--batch-check" and "--batch", or having a single "--batch", I'd
care more about doing %(objectcontents) right away. But because we must
support the historical --batch/--batch-check distinction anyway, I don't
think this is any worse.
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html