@@ -19,6 +19,7 @@
#include "trailer.h"
#include "run-command.h"
#include "object-name.h"
+#include "patch-ids.h"
/*
* The limit for formatting directives, which enable the caller to append
@@ -1571,6 +1572,16 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
c->pretty_ctx->abbrev);
}
return 1;
+ case 'I':
+ {
+ struct diff_options diffopt;
+ struct object_id patch_id;
+ repo_diff_setup(the_repository, &diffopt);
+ if (commit_patch_id(commit, &diffopt, &patch_id, 0))
+ die(_("cannot get patch id"));
+ strbuf_addstr(sb, oid_to_hex(&patch_id));
+ return 1;
+ }
case 'm': /* left/right/bottom */
strbuf_addstr(sb, get_revision_mark(NULL, commit));
return 1;
@@ -38,6 +38,13 @@ test_expect_success 'set up basic repos' '
git config --unset i18n.commitEncoding
'
+# %I placeholder
+test_expect_success '%I placeholder is a patch-id' '
+ git diff-tree --patch-with-raw HEAD | git patch-id >expected &&
+ git show -s --pretty="%I %H" >actual &&
+ test_cmp expected actual
+'
+
test_expect_success 'alias builtin format' '
git log --pretty=oneline >expected &&
git config pretty.test-alias oneline &&
This doesn't actually work yet, and the test is probably in the wrong place, but I think it's sort of close enough to send an RFC patch to ask some questions. Signed-off-by: Michael McClimon <michael@mcclimon.org> --- pretty.c | 11 +++++++++++ t/t4205-log-pretty-formats.sh | 7 +++++++ 2 files changed, 18 insertions(+)