Michael J Gruber <git@xxxxxxxxxxxxxxxxxxxx> writes: > When a command is supposed to use textconv filters (by default or with > "--textconv") and none are configured then the blob is output without > conversion; the only exception to this rule is "cat-file --textconv". I am of two minds. Because cat-file is mostly a low-level plumbing, I do not necessarily think it is a bad behaviour for it to error out when it was asked to apply textconv where there is no filter or when the filter fails to produce an output. On the other hand, it certainly makes it more convenient for callers that do not care too deeply, taking textconv as a mere hint just like Porcelains do. > > Make it behave like the rest of textconv aware commands. > > Signed-off-by: Michael J Gruber <git@xxxxxxxxxxxxxxxxxxxx> > --- > builtin/cat-file.c | 9 +++++---- > t/t8007-cat-file-textconv.sh | 20 +++++--------------- > 2 files changed, 10 insertions(+), 19 deletions(-) > > diff --git a/builtin/cat-file.c b/builtin/cat-file.c > index 00528dd..6912dc2 100644 > --- a/builtin/cat-file.c > +++ b/builtin/cat-file.c > @@ -146,10 +146,11 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name) > die("git cat-file --textconv %s: <object> must be <sha1:path>", > obj_name); > > - if (!textconv_object(obj_context.path, obj_context.mode, sha1, 1, &buf, &size)) > - die("git cat-file --textconv: unable to run textconv on %s", > - obj_name); > - break; > + if (textconv_object(obj_context.path, obj_context.mode, sha1, 1, &buf, &size)) > + break; > + > + /* otherwise expect a blob */ > + exp_type = "blob"; Please use the constant string blob_type that is available for all callers including this one. But stepping back a bit. What happens when I say "cat-file -c HEAD:Documentation", and what should happen when I do so? I think what we want to see in the ideal world might be: * If we have a textconv for tree objects at that path to format it specially, textconv_object() may be allowed to textualize it (even though it is not a blob, and textconv so far has always been about blobs; it needs to be considered carefully if it makes sense to allow such a usage) and show it; * If we don't, we act as if -c were -p; in other words, we treat the built-in "human output" implemented by "cat-file -p" as if that is a textconv. In other words, you may want to fall-thru to case 'p', not case 0 with forced "blob" type. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html