@matheusbsbs / matheus-bagliano / commits / eb2151bb89
Fork 0

rebase: support automatic notes copying

Luckily, all the support already happens to be there. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Rast committed Mar 12, 2010 at 18:04 UTC eb2151bb8938a8e2af86e3ed34243af7b1c95786
5 files changed +50 -1
git-am.sh
+4 -1
@@ -780,8 +780,11 @@ do
780 go_next
781 done
782
783 -if test -s "$dotest"/rewritten && test -x "$GIT_DIR"/hooks/post-rewrite; then
783 +if test -s "$dotest"/rewritten; then
784 + git notes copy --for-rewrite=rebase < "$dotest"/rewritten
785 + if test -x "$GIT_DIR"/hooks/post-rewrite; then
786 "$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten
787 + fi
788 fi
789
790 git gc --auto
git-rebase--interactive.sh
+4
@@ -570,6 +570,10 @@ do_next () {
570 test ! -f "$DOTEST"/verbose ||
571 git diff-tree --stat $(cat "$DOTEST"/head)..HEAD
572 } &&
573 + {
574 + git notes copy --for-rewrite=rebase < "$REWRITTEN_LIST" ||
575 + true # we don't care if this copying failed
576 + } &&
577 if test -x "$GIT_DIR"/hooks/post-rewrite &&
578 test -s "$REWRITTEN_LIST"; then
579 "$GIT_DIR"/hooks/post-rewrite rebase < "$REWRITTEN_LIST"
git-rebase.sh
+1
@@ -154,6 +154,7 @@ move_to_original_branch () {
154
155 finish_rb_merge () {
156 move_to_original_branch
157 + git notes copy --for-rewrite=rebase < "$dotest"/rewritten
158 if test -x "$GIT_DIR"/hooks/post-rewrite &&
159 test -s "$dotest"/rewritten; then
160 "$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten
t/t3400-rebase.sh
+17
@@ -155,4 +155,21 @@ test_expect_success 'Rebase a commit that sprinkles CRs in' '
155 git diff --exit-code file-with-cr:CR HEAD:CR
156 '
157
158 +test_expect_success 'rebase can copy notes' '
159 + git config notes.rewrite.rebase true &&
160 + git config notes.rewriteRef "refs/notes/*" &&
161 + test_commit n1 &&
162 + test_commit n2 &&
163 + test_commit n3 &&
164 + git notes add -m"a note" n3 &&
165 + git rebase --onto n1 n2 &&
166 + test "a note" = "$(git notes show HEAD)"
167 +'
168 +
169 +test_expect_success 'rebase -m can copy notes' '
170 + git reset --hard n3 &&
171 + git rebase -m --onto n1 n2 &&
172 + test "a note" = "$(git notes show HEAD)"
173 +'
174 +
175 test_done
t/t3404-rebase-interactive.sh
+24
@@ -553,4 +553,28 @@ test_expect_success 'reword' '
553 git show HEAD~2 | grep "C changed"
554 '
555
556 +test_expect_success 'rebase -i can copy notes' '
557 + git config notes.rewrite.rebase true &&
558 + git config notes.rewriteRef "refs/notes/*" &&
559 + test_commit n1 &&
560 + test_commit n2 &&
561 + test_commit n3 &&
562 + git notes add -m"a note" n3 &&
563 + git rebase --onto n1 n2 &&
564 + test "a note" = "$(git notes show HEAD)"
565 +'
566 +
567 +cat >expect <<EOF
568 +an earlier note
569 +a note
570 +EOF
571 +
572 +test_expect_success 'rebase -i can copy notes over a fixup' '
573 + git reset --hard n3 &&
574 + git notes add -m"an earlier note" n2 &&
575 + GIT_NOTES_REWRITE_MODE=concatenate FAKE_LINES="1 fixup 2" git rebase -i n1 &&
576 + git notes show > output &&
577 + test_cmp expect output
578 +'
579 +
580 test_done