[PATCH v2 0/1] cat-file: quote-format name in error when using -z
- From
Toon Claes <toon@iotcl.com>
- Date
- Jan 5, 2023, 06:24 UTC
- Message-ID
- <20230105062447.2943709-1-toon@iotcl.com>
- In-Reply-To
- <20221209150048.2400648-1-toon@iotcl.com>
This is the second revision of the patch to quote-format the filename in the error message of git-cat-file(1), when using option `-z`.
Changes since v1: * Added the same fix to batch_object_write(). * Removed FUNNYNAMES from the added test.
Toon Claes (1): cat-file: quote-format name in error when using -z
builtin/cat-file.c | 19 +++++++++++++++++++ t/t1006-cat-file.sh | 8 ++++++++ 2 files changed, 27 insertions(+)
Range-diff against v1:
1: c13602e28e ! 1: 4f39eb0719 cat-file: quote-format name in error when using -z
@@ builtin/cat-file.c
#include "object-store.h"
#include "promisor-remote.h"
#include "mailmap.h"
+@@ builtin/cat-file.c: static void batch_object_write(const char *obj_name,
+ &data->oid, &data->info,
+ OBJECT_INFO_LOOKUP_REPLACE);
+ if (ret < 0) {
++ struct strbuf quoted = STRBUF_INIT;
++
++ if (opt->nul_terminated &&
++ obj_name) {
++ quote_c_style(obj_name, "ed, NULL, 0);
++ obj_name = quoted.buf;
++ }
++
+ printf("%s missing\n",
+ obj_name ? obj_name : oid_to_hex(&data->oid));
++ strbuf_release("ed);
+ fflush(stdout);
+ return;
+ }
@@ builtin/cat-file.c: static void batch_one_object(const char *obj_name,
result = get_oid_with_context(the_repository, obj_name,
flags, &data->oid, &ctx);
@@ t/t1006-cat-file.sh: test_expect_success FUNNYNAMES '--batch-check, -z with newl
test_cmp expect actual
' -+test_expect_success FUNNYNAMES '--batch-check, -z with newline in non-existent named object' '
++test_expect_success '--batch-check, -z with newline in non-existent named object' '
+ printf "HEAD:newline${LF}embedded" >in &&
+ git cat-file --batch-check -z <in >actual &&
+
--
2.38.1