From 895680f044ebe9df600e6c9e042d40d9d953bc9b Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 4 Nov 2011 21:06:30 -0700 Subject: fmt-merge-msg: Add contents of merged tag in the merge message When a contributor asks the integrator to merge her history, a signed tag can be a good vehicle to communicate the authenticity of the request while conveying other information such as the purpose of the topic. E.g. a signed tag "for-linus" can be created, and the integrator can run: $ git pull git://example.com/work.git/ for-linus This would allow the integrator to run "git verify-tag FETCH_HEAD" to validate the signed tag. Update fmt-merge-msg so that it pre-fills the merge message template with the body (but not signature) of the tag object to help the integrator write a better merge message, in the same spirit as the existing merge.log summary lines. The message that comes from GPG signature validation is also included in the merge message template to help the integrator verify it, but they are prefixed with "#" to make them comments. Signed-off-by: Junio C Hamano --- strbuf.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'strbuf.c') diff --git a/strbuf.c b/strbuf.c index 3ad2cc0016..a849705197 100644 --- a/strbuf.c +++ b/strbuf.c @@ -397,3 +397,17 @@ int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint) return len; } + +void strbuf_add_lines(struct strbuf *out, const char *prefix, + const char *buf, size_t size) +{ + while (size) { + const char *next = memchr(buf, '\n', size); + next = next ? (next + 1) : (buf + size); + strbuf_addstr(out, prefix); + strbuf_add(out, buf, next - buf); + size -= next - buf; + buf = next; + } + strbuf_complete_line(out); +} -- cgit 1.2.3-korg