Re: [PATCH v3 2/4] cat-file: introduce the --filters option
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 9, 2016, 15:09 UTC
- Message-ID
- <xmqqfup9ds9p.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <084088ba86c0af3636d960276c0bfdf7f5d2cfde.1473415827.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
Show 23 quoted lines
> +static int filter_object(const char *path, unsigned mode,
> + const unsigned char *sha1,
> + char **buf, unsigned long *size)
> +{
> + enum object_type type;
> +
> + *buf = read_sha1_file(sha1, &type, size);
> + if (!*buf)
> + return error(_("cannot read object %s '%s'"),
> + sha1_to_hex(sha1), path);
> + if (type != OBJ_BLOB) {
> + free(*buf);
> + return error(_("blob expected for %s '%s'"),
> + sha1_to_hex(sha1), path);
> + }
> + if (S_ISREG(mode)) {
> + struct strbuf strbuf = STRBUF_INIT;
> + if (convert_to_working_tree(path, *buf, *size, &strbuf)) {
> + free(*buf);
> + *size = strbuf.len;
> + *buf = strbuf_detach(&strbuf, NULL);
> + }
> + }This needs to error out when mode is not ISREG just like it errors out when type is not BLOB.
Other than that, I think these four patches are good to go.
Thanks.