All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: lilinchao@oschina.cn
Cc: git <git@vger.kernel.org>
Subject: Re: [Question] git cat-file --batch cannot handle irregular path
Date: Mon, 19 Apr 2021 21:23:31 -0700	[thread overview]
Message-ID: <xmqqim4h7fek.fsf@gitster.g> (raw)
In-Reply-To: <54526f48a18b11ebad130024e87935e7@oschina.cn> (lilinchao@oschina.cn's message of "Tue, 20 Apr 2021 11:48:56 +0800")

"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.


  reply	other threads:[~2021-04-20  4:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-20  3:48 [Question] git cat-file --batch cannot handle irregular path lilinchao
2021-04-20  4:23 ` Junio C Hamano [this message]
2021-04-23 13:07   ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqim4h7fek.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=lilinchao@oschina.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.