Re: [PATCH v3 2/4] cat-file: introduce the --filters option
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 9, 2016, 16:08 UTC
- Message-ID
- <xmqqbmzxdpjp.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <alpine.DEB.2.20.1609091800020.129229@virtualbox>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 18 quoted lines
>> > + 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.
>
> Are you sure that this is desirable in batch mode?I do not quite see a reason why we should not diagnose a bad input that does not produce a filtered result. In batch mode or not, it diagnoses when the user feeds it a non-blob, and I think it should do so for non-regular, too. Both are "you asked me to filter, but you shouldn't have".