From: Michael McClimon <michael@mcclimon.org>
To: git@vger.kernel.org
Cc: Michael McClimon <michael@mcclimon.org>
Subject: [RFC PATCH 0/2] pretty: add %I formatting for patch-id
Date: Sat, 21 Oct 2023 22:27:58 -0400 [thread overview]
Message-ID: <20231022022800.69219-1-michael@mcclimon.org> (raw)
I'll say up front that this patch doesn't actually work, but I am stuck
on it and interested in continuing, and am hopeful someone can point me
in something closer to the right direction. (Also, the proposed log
messages are not good, and I would not actually submit the patch for
merge consideration with these messages.)
I would like to have a single-command way to get the patch id for a
commit: the thing you'd see in a pipeline like
git diff-tree --patch-with-raw HEAD | git patch-id
My initial thought was to add a --patch-id flag to git diff-tree, but
then I thought that maybe better would be to add a pretty specifier to
do so, so that (for instance) you could generate patch-ids for
everything in a branch by saying something like
git log --pretty='%I %H' start..
I have taken a pass at doing so here, but it doesn't _work_, and I'm not
sure why. It seemed like the thing to do was to use commit_patch_id from
patch-ids.c, but I think that either I'm not holding it correctly, or
that it's not fit for purpose. It was added (or rather, made public) in
ded2c097 (patch-ids: make commit_patch_id() a public helper function,
2016-04-26), which was in service of fa2ab86d (format-patch: add
'--base' option to record base tree info, 2016-04-26). It seems like at
the very least, it probably won't work as expected on merge commits.
The thing that is perplexing to me is that it _does_ appear to work on
some commits, for example (where 8b3aa36f is a recent-ish commit from
master, chosen at random):
$ ./git --no-pager show -s --format='%I %H' 8b3aa36f5a7a0c923bc4a28ff19caae78644ae08
ec66952bdef82a1fc6d31c1057195af31c86da48 8b3aa36f5a7a0c923bc4a28ff19caae78644ae08
$ git diff-tree --patch-with-raw 8b3aa36f5a7a0c923bc4a28ff19caae78644ae08 | git patch-id
ec66952bdef82a1fc6d31c1057195af31c86da48 8b3aa36f5a7a0c923bc4a28ff19caae78644ae08
But for other commits, like the one in the test here, it does not. I
have done a bit of investigation, but I would not really call myself a C
programmer and I'm not super familiar with the codebase, so I'm a bit
stuck. I thought maybe at first I wasn't initializing the diff_options
correctly, but I suspect the problem is actually more fundamental than
that.
Anyway: I would be happy to hear any response at all, whether that's
a) a pointer to some other way of implementing a %I pretty format,
b) an easier-to-implement possible solution (maybe diff-tree --patch-id
would actually be better), or c) saying the thing I want isn't feasible
and I should stick with the pipeline. Thanks!
Michael McClimon (2):
patch-ids: add const modifier to commit
pretty: add 'I' placeholder for patch-id
patch-ids.c | 4 ++--
patch-ids.h | 2 +-
pretty.c | 11 +++++++++++
t/t4205-log-pretty-formats.sh | 7 +++++++
4 files changed, 21 insertions(+), 3 deletions(-)
--
2.42.0.424.gceadf0f3
next reply other threads:[~2023-10-22 2:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-22 2:27 Michael McClimon [this message]
2023-10-22 2:27 ` [RFC PATCH 1/2] patch-ids: add const modifier to commit Michael McClimon
2023-10-22 2:28 ` [RFC PATCH 2/2] pretty: add 'I' placeholder for patch-id Michael McClimon
2023-10-25 8:44 ` [RFC PATCH 0/2] pretty: add %I formatting " 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=20231022022800.69219-1-michael@mcclimon.org \
--to=michael@mcclimon.org \
--cc=git@vger.kernel.org \
/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).