summaryrefslogtreecommitdiff
path: root/trailer.h
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2020-12-09 15:52:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-12-09 22:16:42 (GMT)
commit9d87d5ae026433a2993fdb757fc80dbdcb078310 (patch)
tree342403fcb77eb8f7945f02ab653e9c21007a9d93 /trailer.h
parent8b966a0506f8b5aef7c6038fe518db45bc4a1852 (diff)
downloadgit-9d87d5ae026433a2993fdb757fc80dbdcb078310.zip
git-9d87d5ae026433a2993fdb757fc80dbdcb078310.tar.gz
git-9d87d5ae026433a2993fdb757fc80dbdcb078310.tar.bz2
pretty format %(trailers): add a "keyonly"
Add support for a "keyonly". This allows for easier parsing out of the key and value. Before if you didn't want to make assumptions about how the key was formatted. You'd need to parse it out as e.g.: --pretty=format:'%H%x00%(trailers:separator=%x00%x00)' \ '%x00%(trailers:separator=%x00%x00,valueonly)' And then proceed to deduce keys by looking at those two and subtracting the value plus the hardcoded ": " separator from the non-valueonly %(trailers) line. Now it's possible to simply do: --pretty=format:'%H%x00%(trailers:separator=%x00%x00,keyonly)' \ '%x00%(trailers:separator=%x00%x00,valueonly)' Which at least reduces it to a state machine where you get N keys and correlate them with N values. Even better would be to have a way to change the ": " delimiter to something easily machine-readable (a key might contain ": " too). A follow-up change will add support for that. I don't really have a use-case for just "keyonly" myself. I suppose it would be useful in some cases as "key=*" matches case-insensitively, so a plain "keyonly" will give you the variants of the keys you matched. I'm mainly adding it to fix the inconsistency with "valueonly". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'trailer.h')
-rw-r--r--trailer.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/trailer.h b/trailer.h
index cd93e7d..d2f2877 100644
--- a/trailer.h
+++ b/trailer.h
@@ -71,6 +71,7 @@ struct process_trailer_options {
int only_input;
int unfold;
int no_divider;
+ int key_only;
int value_only;
const struct strbuf *separator;
int (*filter)(const struct strbuf *, void *);