git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [Question] git cat-file --batch cannot handle irregular path

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 20, 2021, 04:23 UTC
Message-ID
<xmqqim4h7fek.fsf@gitster.g>
In-Reply-To
<54526f48a18b11ebad130024e87935e7@oschina.cn>
"lilinchao@oschina.cn" <lilinchao@oschina.cn> writes:
> but it is irregular, such as "法律\(Law\)/民法\(civil\ law$'\n'\)\",
> ...
> d071ea971fb93ebc937517736c2a63d64ddbe0d9:法律(Law)/民法(civil law)
> d071ea971fb93ebc937517736c2a63d64ddbe0d9:法律(Law)/民法(civil law) missing

I may be misreading what you wrote, but if you mean that there is a LF in the pathname, I do not think cat-file --batch is prepared to handle it; as we can see in builtin/cat-cile.c:

static int batch_objects(struct batch_options *opt)
{
	...
	while (strbuf_getline(&input, stdin) != EOF) {
		if (data.split_on_whitespace) {
		...
		}
		batch_one_object(input.buf, &output, opt, &data);
	}
it always treats what strbuf_getline() returns as a single record.
If properly designed, it would have
 - supported "-z" to take NUL-delimited input, and
 - when "-z" is not in effect, after reading a single line of input,
   we would have called quote API to un-cquote the string, so that
   we can express LF and other special characters in the pathname.
but those who worked on "cat-file --batch" didn't.
Previous: lilinchao@oschina.cnNext: Jeff King
Message 2 of 3 in “[Question] git cat-file --batch cannot handle irregular path”
  1. lilinchao@oschina.cnApr 20, 2021
  2. Junio C HamanoApr 20, 2021
  3. Jeff KingApr 23, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.