diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-07-27 15:14:18 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-07-27 15:14:18 -0700 |
commit | 16737445a94cb9b18378fff973129d974c7cdf8a (patch) | |
tree | 44fe2074f4d4f146581e33e6d4b15bb9740c0b10 /commit.c | |
parent | 4799593e26f09e4209249caf9536001036618ac2 (diff) | |
parent | 3fa102590758594e3df45c58caba945894a608e5 (diff) | |
download | git-16737445a94cb9b18378fff973129d974c7cdf8a.tar.gz |
Merge branch 'cc/replace-graft'
"git replace" learned a "--graft" option to rewrite parents of a
commit.
* cc/replace-graft:
replace: add test for --graft with a mergetag
replace: check mergetags when using --graft
replace: add test for --graft with signed commit
replace: remove signature when using --graft
contrib: add convert-grafts-to-replace-refs.sh
Documentation: replace: add --graft option
replace: add test for --graft
replace: add --graft option
replace: cleanup redirection style in tests
Diffstat (limited to 'commit.c')
-rw-r--r-- | commit.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -1146,6 +1146,40 @@ int parse_signed_commit(const struct commit *commit, return saw_signature; } +int remove_signature(struct strbuf *buf) +{ + const char *line = buf->buf; + const char *tail = buf->buf + buf->len; + int in_signature = 0; + const char *sig_start = NULL; + const char *sig_end = NULL; + + while (line < tail) { + const char *next = memchr(line, '\n', tail - line); + next = next ? next + 1 : tail; + + if (in_signature && line[0] == ' ') + sig_end = next; + else if (starts_with(line, gpg_sig_header) && + line[gpg_sig_header_len] == ' ') { + sig_start = line; + sig_end = next; + in_signature = 1; + } else { + if (*line == '\n') + /* dump the whole remainder of the buffer */ + next = tail; + in_signature = 0; + } + line = next; + } + + if (sig_start) + strbuf_remove(buf, sig_start - buf->buf, sig_end - sig_start); + + return sig_start != NULL; +} + static void handle_signed_tag(struct commit *parent, struct commit_extra_header ***tail) { struct merge_remote_desc *desc; |