summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: eb2151b)
raw | patch | inline | side by side (parent: eb2151b)
author | Thomas Rast <trast@student.ethz.ch> | |
Fri, 12 Mar 2010 17:04:34 +0000 (18:04 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 13 Mar 2010 05:55:40 +0000 (21:55 -0800) |
Teaches 'git commit --amend' to copy notes. The catch is that this
must also be guarded by --no-post-rewrite, which we use to prevent
--amend from copying notes during a rebase -i 'edit'/'reword'.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
must also be guarded by --no-post-rewrite, which we use to prevent
--amend from copying notes during a rebase -i 'edit'/'reword'.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-commit.c | patch | blob | history | |
t/t7501-commit.sh | patch | blob | history |
diff --git a/builtin-commit.c b/builtin-commit.c
index f476d85293a5e2a79273054dda87073815213328..ccc4f926c09b4650751795075a8d64ab52a36b0a 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
rerere(0);
run_hook(get_index_file(), "post-commit", NULL);
if (amend && !no_post_rewrite) {
+ struct notes_rewrite_cfg *cfg;
+ cfg = init_copy_notes_for_rewrite("amend");
+ if (cfg) {
+ copy_note_for_rewrite(cfg, head_sha1, commit_sha1);
+ finish_copy_notes_for_rewrite(cfg);
+ }
run_rewrite_hook(head_sha1, commit_sha1);
}
if (!quiet)
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index 7940901d47fd457cda77ee333aa40145433be4d4..8297cb4f1e6e2d903dfbf6fde825d2c787082e58 100755 (executable)
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
'
+test_expect_success 'amend can copy notes' '
+
+ git config notes.rewrite.amend true &&
+ git config notes.rewriteRef "refs/notes/*" &&
+ test_commit foo &&
+ git notes add -m"a note" &&
+ test_tick &&
+ git commit --amend -m"new foo" &&
+ test "$(git notes show)" = "a note"
+
+'
+
test_done