git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Christian Couder <christian.couder@gmail.com>
Cc: Justin Tobler <jltobler@gmail.com>,
	 git@vger.kernel.org, karthik.188@gmail.com
Subject: Re: [PATCH v2 1/2] rev-list: add --missing-info to print missing object path
Date: Fri, 10 Jan 2025 07:22:48 -0800	[thread overview]
Message-ID: <xmqqtta68zhz.fsf@gitster.g> (raw)
In-Reply-To: <CAP8UFD2Cfriv4puPe8agaTZOpLHr-=4CkK-yrzw8fH-k5mPkAA@mail.gmail.com> (Christian Couder's message of "Fri, 10 Jan 2025 09:47:08 +0100")

Christian Couder <christian.couder@gmail.com> writes:

> On Fri, Jan 10, 2025 at 6:38 AM Justin Tobler <jltobler@gmail.com> wrote:
>
>> +--missing-info::
>> +       Only useful with `--missing=print`; prints any additional information
>> +       about the missing object inferred from its containing object. The
>> +       information is all printed on the same line with the missing object ID
>> +       in the form: `?<oid> [<token>=<value>]...`. Additional attributes are
>> +       each separated by a SP.
>
> Nit: I'd rather say "The `<token>=<value>` pairs containing additional
> information are separated from each other by a SP." to avoid
> introducing "attributes" which might not be very clear.

Excellent.

>> Any value containing a SP or special character
>> +       is enclosed in double-quotes in the C style as needed. Each
>> +       `<token>=<value>` may be one of the following:
>
> It might be a bit better to decide for each token-value pair how the
> value is encoded, instead of deciding in advance for all of them.

I strongly advise against it.

Declaring the syntax we will use for forseeable future for new
attributes upfront would allow the receiving end, the scripts that
interpret our output, to be written in a futureproof way.

An alternative is "value is encoded in token specific fashion, but
one thing that is common across these future encodings is that SP or
LF contained in value will be represented in such a way that the
resulting encoded value will not have either of these two
problematic bytes".

>> +       if (entry->path && *entry->path) {
>> +               strbuf_addstr(&sb, " path=");
>> +
>> +               if (quote_c_style(entry->path, NULL, NULL, 0))
>> +                       quote_c_style(entry->path, &sb, NULL, 0);
>> +               else if (strchr(entry->path, ' '))
>> +                       strbuf_addf(&sb, "\"%s\"", entry->path);
>> +               else
>> +                       strbuf_addstr(&sb, entry->path);
>
> I think the above code paragraph could be simplified to just:
>
>             quote_c_style(entry->path, &sb, NULL, 0);

Hmph, you two may be both wrong ;-)  It is unfortunate that you
cannot easily configure what is considered "must be quoted" bytes
per invocation of the quote_c_style() function.  Most problematic
is that in the cq_lookup[] table, SP and "!" are treated the same
way, i.e., <a b c> does not need to be quoted.  This comes from the
fact that quote_c_style() was written for the sole purpose of
showing the pathnames on the header lines of "git diff" output.

We may be able to (ab)use quote_path() with QUOTE_PATH_QUOTE_SP
bit set for this purpose, though, to work around the above.

cq_must_quote() also is affected by core.quotepath, which is not a
desirable feature here---we want our machine readable program output
stable regardless of end-user preference.

By the way, perhaps we should propose to make the default value for
core.quotepath to "no" at Git 3.0 boundary?

Thanks.

  reply	other threads:[~2025-01-10 15:22 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-08  3:40 [PATCH] rev-list: print missing object type with --missing=print-type Justin Tobler
2025-01-08 10:08 ` Christian Couder
2025-01-08 22:28   ` Justin Tobler
2025-01-08 15:17 ` Junio C Hamano
2025-01-08 22:18   ` Justin Tobler
2025-01-08 22:43     ` Junio C Hamano
2025-01-08 23:13       ` Justin Tobler
2025-01-10  5:34 ` [PATCH v2 0/2] rev-list: print additional missing object information Justin Tobler
2025-02-01 20:16   ` [PATCH v3 0/4] " Justin Tobler
2025-02-01 20:16     ` [PATCH v3 1/4] quote: add c quote flag to ignore core.quotePath Justin Tobler
2025-02-03  9:51       ` Christian Couder
2025-02-03 22:14         ` Junio C Hamano
2025-02-03 22:33       ` Junio C Hamano
2025-02-04 16:40         ` Junio C Hamano
2025-02-04 22:50           ` Justin Tobler
2025-02-01 20:16     ` [PATCH v3 2/4] quote: add quote_path() flag to ignore config Justin Tobler
2025-02-02 10:52       ` Phillip Wood
2025-02-04 22:39         ` Justin Tobler
2025-02-11 16:51           ` Phillip Wood
2025-02-03 10:07       ` Christian Couder
2025-02-03 22:52       ` Junio C Hamano
2025-02-01 20:16     ` [PATCH v3 3/4] rev-list: add print-info action to print missing object path Justin Tobler
2025-02-01 20:16     ` [PATCH v3 4/4] rev-list: extend print-info to print missing object type Justin Tobler
2025-02-03 10:45     ` [PATCH v3 0/4] rev-list: print additional missing object information Christian Couder
2025-02-04 22:51       ` Justin Tobler
2025-02-05  0:41     ` [PATCH v4 0/2] " Justin Tobler
2025-02-05  0:41       ` [PATCH v4 1/2] rev-list: add print-info action to print missing object path Justin Tobler
2025-02-05  0:41       ` [PATCH v4 2/2] rev-list: extend print-info to print missing object type Justin Tobler
2025-02-05 10:35       ` [PATCH v4 0/2] rev-list: print additional missing object information Christian Couder
2025-02-05 17:18         ` Justin Tobler
2025-02-05 13:18       ` Junio C Hamano
2025-02-05 17:17         ` Justin Tobler
2025-02-05 18:29           ` Junio C Hamano
2025-01-10  5:34 ` [PATCH v2 1/2] rev-list: add --missing-info to print missing object path Justin Tobler
2025-01-10  8:47   ` Christian Couder
2025-01-10 15:22     ` Junio C Hamano [this message]
2025-01-10  5:34 ` [PATCH v2 2/2] rev-list: extend --missing-info to print missing object type Justin Tobler

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=xmqqtta68zhz.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jltobler@gmail.com \
    --cc=karthik.188@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).