summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-07-27 22:14:18 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-07-27 22:14:18 (GMT)
commit16737445a94cb9b18378fff973129d974c7cdf8a (patch)
tree44fe2074f4d4f146581e33e6d4b15bb9740c0b10 /commit.c
parent4799593e26f09e4209249caf9536001036618ac2 (diff)
parent3fa102590758594e3df45c58caba945894a608e5 (diff)
downloadgit-16737445a94cb9b18378fff973129d974c7cdf8a.zip
git-16737445a94cb9b18378fff973129d974c7cdf8a.tar.gz
git-16737445a94cb9b18378fff973129d974c7cdf8a.tar.bz2
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.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/commit.c b/commit.c
index 2274e43..ae7f2b1 100644
--- a/commit.c
+++ b/commit.c
@@ -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;