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>
This commit is contained in:
Junio C Hamano
2011-11-08 15:38:07 -08:00
parent fab47d0575
commit ed7a42a075
3 changed files with 76 additions and 3 deletions

View File

@ -1382,6 +1382,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
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 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
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