commit: teach --amend to carry forward extra headers

After running "git pull $there for-linus" to merge a signed tag, the
integrator may need to amend the resulting merge commit to fix typoes
in it. Teach --amend option to read the existing extra headers, and
carry them forward.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/builtin/commit.c b/builtin/commit.c
index 4688a73..fca7ea0 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1382,6 +1382,7 @@
 	int allow_fast_forward = 1;
 	struct wt_status s;
 	struct commit *current_head = NULL;
+	struct commit_extra_header *extra = NULL;
 
 	if (argc == 2 && !strcmp(argv[1], "-h"))
 		usage_with_options(builtin_commit_usage, builtin_commit_options);
@@ -1483,12 +1484,16 @@
 		exit(1);
 	}
 
-	if (commit_tree(sb.buf, active_cache_tree->sha1, parents, sha1,
-			author_ident.buf)) {
+	if (amend)
+		extra = read_commit_extra_headers(current_head);
+
+	if (commit_tree_extended(sb.buf, active_cache_tree->sha1, parents, sha1,
+				 author_ident.buf, extra)) {
 		rollback_index_files();
 		die(_("failed to write commit object"));
 	}
 	strbuf_release(&author_ident);
+	free_commit_extra_headers(extra);
 
 	ref_lock = lock_any_ref_for_update("HEAD",
 					   !current_head