From: Junio C Hamano <gitster@pobox.com>
To: "Michał Górny" <mgorny@gentoo.org>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Michael J Gruber <git@drmicha.warpmail.net>
Subject: Re: [PATCH] for-each-ref: add split message parts to %(contents:*).
Date: Wed, 31 Aug 2011 15:54:35 -0700 [thread overview]
Message-ID: <7vy5y9xkd0.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1314781909-19252-1-git-send-email-mgorny@gentoo.org> ("Michał Górny"'s message of "Wed, 31 Aug 2011 11:11:49 +0200")
Michał Górny <mgorny@gentoo.org> writes:
> Now %(contents:subject) contains the message subject, %(contents:body)
> main body part and %(contents:signature) GPG signature.
> ---
Please sign-off when submitting the final round of this patch.
> +The complete message in a commit and tag object is `contents`.
> +Its first line is `contents:subject`, the remaining lines
> +are `contents:body` and the optional GPG signature
> +is `contents:signature`.
To match the parsing of commit objects, I would prefer to see "subject" to
mean "the first paragraph" (usually the first line alone but that is
purely from convention), but that probably is a separate topic.
To paraphrase the last part of your sentence, if a tag is merely annotated
and not signed, contents:signature would be empty (I am just making sure
that I am reading the description correctly).
Is it possible to get %(contents) with a combination of these three new
variants, or does the calling script need to see if each part is empty and
decide where to place newlines? IOW, a naïve attempt:
--format='%(contents:subject)\n%(contents:body)\n%(contents:signature)'
is not equivalent to
--format='%(contents)'
right?
> @@ -478,18 +481,20 @@ static void find_subpos(const char *buf, unsigned long sz, const char **sub, con
> buf = strchr(buf, '\n');
> if (!buf) {
> *body = "";
> + *signature = *body;
> return; /* no body */
> }
> while (*buf == '\n')
> buf++; /* skip blank between subject and body */
> *body = buf;
> + *signature = buf + parse_signature(buf, strlen(buf));
If there is no signature, parse_signature() would return (size_t) 0, no?
I suspect it may be easier for the caller if *signature pointed at the
terminating NUL at the end of the whole thing in such a case. Otherwise,
the caller that finds the buf and the signature points at the same address
cannot tell if the object was a signed tag with no message
$ git tag -s -m "" empty-tag
or if it was an annotated but not signed tag.
Or better yet, you may even want to stuff NULL there if there is no signature
so that it is absolutely clear for the caller which case it is.
> static void grab_sub_body_contents(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)
> {
> int i;
> - const char *subpos = NULL, *bodypos = NULL;
> + const char *subpos = NULL, *bodypos = NULL, *sigpos = NULL;
>
> for (i = 0; i < used_atom_cnt; i++) {
> const char *name = used_atom[i];
> @@ -500,19 +505,26 @@ static void grab_sub_body_contents(struct atom_value *val, int deref, struct obj
> name++;
> if (strcmp(name, "subject") &&
> strcmp(name, "body") &&
> - strcmp(name, "contents"))
> + strcmp(name, "contents") &&
> + strcmp(name, "contents:subject") &&
> + strcmp(name, "contents:body") &&
> + strcmp(name, "contents:signature"))
> continue;
> if (!subpos)
> - find_subpos(buf, sz, &subpos, &bodypos);
> + find_subpos(buf, sz, &subpos, &bodypos, &sigpos);
> if (!subpos)
> return;
>
> - if (!strcmp(name, "subject"))
> + if (!strcmp(name, "subject") || !strcmp(name, "contents:subject"))
> v->s = copy_line(subpos);
> else if (!strcmp(name, "body"))
> v->s = xstrdup(bodypos);
> else if (!strcmp(name, "contents"))
> v->s = xstrdup(subpos);
> + else if (!strcmp(name, "contents:body"))
> + v->s = xstrndup(bodypos, sigpos - bodypos);
> + else if (!strcmp(name, "contents:signature"))
> + v->s = xstrdup(sigpos);
Again, how does this work for an annotated but not signed tag?
next prev parent reply other threads:[~2011-08-31 22:54 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-29 19:10 More formatting with 'git tag -l' Michał Górny
2011-08-29 19:36 ` Jeff King
2011-08-29 21:20 ` Michał Górny
2011-08-29 21:37 ` Jeff King
2011-08-29 21:50 ` Michał Górny
2011-08-30 8:57 ` [PATCH] git-for-each-ref: move GPG sigs off %(body) to %(signature) Michał Górny
2011-08-30 9:43 ` Michael J Gruber
2011-08-30 15:58 ` Michał Górny
2011-08-30 16:27 ` Jeff King
2011-08-31 9:11 ` [PATCH] for-each-ref: add split message parts to %(contents:*) Michał Górny
2011-08-31 16:42 ` Jeff King
2011-08-31 16:44 ` [PATCH 1/2] t7004: factor out gpg setup Jeff King
2011-08-31 16:44 ` [PATCH 2/2] t6300: test new content:* for-each-ref placeholders Jeff King
2011-08-31 22:54 ` Junio C Hamano [this message]
2011-08-31 23:22 ` [PATCH] for-each-ref: add split message parts to %(contents:*) Jeff King
2011-09-01 7:34 ` Michał Górny
2011-09-01 16:00 ` Junio C Hamano
2011-09-01 16:22 ` Jeff King
2011-09-01 16:48 ` Michał Górny
2011-09-01 16:50 ` Michał Górny
2011-09-02 16:39 ` Jeff King
2011-09-02 17:39 ` Michał Górny
2011-09-02 17:53 ` Jeff King
2011-09-07 17:40 ` Jeff King
2011-09-15 8:18 ` Michał Górny
2011-09-07 17:42 ` [PATCH 1/5] t7004: factor out gpg setup Jeff King
2011-09-07 17:43 ` [PATCH 2/5] t6300: add more body-parsing tests Jeff King
2011-09-07 17:44 ` [PATCH 3/5] for-each-ref: refactor subject and body placeholder parsing Jeff King
2011-09-07 17:44 ` [PATCH 4/5] for-each-ref: handle multiline subjects like --pretty Jeff King
2011-09-07 17:46 ` [PATCH 5/5] for-each-ref: add split message parts to %(contents:*) Jeff King
2011-09-01 17:16 ` [PATCH] " Junio C Hamano
2011-09-01 18:19 ` 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=7vy5y9xkd0.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=mgorny@gentoo.org \
--cc=peff@peff.net \
/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.