From: Junio C Hamano Date: Wed, 18 Oct 2017 05:19:01 +0000 (+0900) Subject: Merge branch 'jk/diff-blob' into maint X-Git-Tag: v2.15.0-rc2~5^2~37 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/16ba0f44c0cac7c06cf7ce37498b8c83e0f3b69b?hp=-c Merge branch 'jk/diff-blob' into maint "git cat-file --textconv" started segfaulting recently, which has been corrected. * jk/diff-blob: cat-file: handle NULL object_context.path --- 16ba0f44c0cac7c06cf7ce37498b8c83e0f3b69b diff --combined builtin/cat-file.c index 96b786e489,b91b167453..188ddc3e50 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@@ -4,9 -4,7 +4,9 @@@ * Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "config.h" #include "builtin.h" +#include "diff.h" #include "parse-options.h" #include "userdiff.h" #include "streaming.h" @@@ -57,11 -55,11 +57,11 @@@ static int cat_one_file(int opt, const struct object_context obj_context; struct object_info oi = OBJECT_INFO_INIT; struct strbuf sb = STRBUF_INIT; - unsigned flags = LOOKUP_REPLACE_OBJECT; + unsigned flags = OBJECT_INFO_LOOKUP_REPLACE; const char *path = force_path; if (unknown_type) - flags |= LOOKUP_UNKNOWN_OBJECT; + flags |= OBJECT_INFO_ALLOW_UNKNOWN_TYPE; if (get_sha1_with_context(obj_name, GET_SHA1_RECORD_PATH, oid.hash, &obj_context)) @@@ -96,7 -94,7 +96,7 @@@ return !has_object_file(&oid); case 'w': - if (!path[0]) + if (!path) die("git cat-file --filters %s: must be " "", obj_name); @@@ -106,7 -104,7 +106,7 @@@ break; case 'c': - if (!path[0]) + if (!path) die("git cat-file --textconv %s: must be ", obj_name); @@@ -168,7 -166,6 +168,7 @@@ die("git cat-file %s: bad file", obj_name); write_or_die(1, buf, size); + free(buf); free(obj_context.path); return 0; } @@@ -338,8 -335,7 +338,8 @@@ static void batch_object_write(const ch struct strbuf buf = STRBUF_INIT; if (!data->skip_object_info && - sha1_object_info_extended(data->oid.hash, &data->info, LOOKUP_REPLACE_OBJECT) < 0) { + sha1_object_info_extended(data->oid.hash, &data->info, + OBJECT_INFO_LOOKUP_REPLACE) < 0) { printf("%s missing\n", obj_name ? obj_name : oid_to_hex(&data->oid)); fflush(stdout);