Skip to content

Commit eb2151b

Browse files
trastgitster
authored andcommitted
rebase: support automatic notes copying
Luckily, all the support already happens to be there. Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6956f85 commit eb2151b

File tree

5 files changed

+50
-1
lines changed

5 files changed

+50
-1
lines changed

git-am.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,11 @@ do
780780
go_next
781781
done
782782

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
784786
"$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten
787+
fi
785788
fi
786789

787790
git gc --auto

git-rebase--interactive.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,10 @@ do_next () {
570570
test ! -f "$DOTEST"/verbose ||
571571
git diff-tree --stat $(cat "$DOTEST"/head)..HEAD
572572
} &&
573+
{
574+
git notes copy --for-rewrite=rebase < "$REWRITTEN_LIST" ||
575+
true # we don't care if this copying failed
576+
} &&
573577
if test -x "$GIT_DIR"/hooks/post-rewrite &&
574578
test -s "$REWRITTEN_LIST"; then
575579
"$GIT_DIR"/hooks/post-rewrite rebase < "$REWRITTEN_LIST"

git-rebase.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ move_to_original_branch () {
154154

155155
finish_rb_merge () {
156156
move_to_original_branch
157+
git notes copy --for-rewrite=rebase < "$dotest"/rewritten
157158
if test -x "$GIT_DIR"/hooks/post-rewrite &&
158159
test -s "$dotest"/rewritten; then
159160
"$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten

t/t3400-rebase.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,21 @@ test_expect_success 'Rebase a commit that sprinkles CRs in' '
155155
git diff --exit-code file-with-cr:CR HEAD:CR
156156
'
157157

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+
158175
test_done

t/t3404-rebase-interactive.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,4 +553,28 @@ test_expect_success 'reword' '
553553
git show HEAD~2 | grep "C changed"
554554
'
555555

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+
556580
test_done

0 commit comments

Comments
 (0)