Browse Source

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>
maint
Thomas Rast 15 years ago committed by Junio C Hamano
parent
commit
eb2151bb89
  1. 5
      git-am.sh
  2. 4
      git-rebase--interactive.sh
  3. 1
      git-rebase.sh
  4. 17
      t/t3400-rebase.sh
  5. 24
      t/t3404-rebase-interactive.sh

5
git-am.sh

@ -780,8 +780,11 @@ do
go_next go_next
done done


if test -s "$dotest"/rewritten && test -x "$GIT_DIR"/hooks/post-rewrite; then if test -s "$dotest"/rewritten; then
git notes copy --for-rewrite=rebase < "$dotest"/rewritten
if test -x "$GIT_DIR"/hooks/post-rewrite; then
"$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten "$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten
fi
fi fi


git gc --auto git gc --auto

4
git-rebase--interactive.sh

@ -570,6 +570,10 @@ do_next () {
test ! -f "$DOTEST"/verbose || test ! -f "$DOTEST"/verbose ||
git diff-tree --stat $(cat "$DOTEST"/head)..HEAD git diff-tree --stat $(cat "$DOTEST"/head)..HEAD
} && } &&
{
git notes copy --for-rewrite=rebase < "$REWRITTEN_LIST" ||
true # we don't care if this copying failed
} &&
if test -x "$GIT_DIR"/hooks/post-rewrite && if test -x "$GIT_DIR"/hooks/post-rewrite &&
test -s "$REWRITTEN_LIST"; then test -s "$REWRITTEN_LIST"; then
"$GIT_DIR"/hooks/post-rewrite rebase < "$REWRITTEN_LIST" "$GIT_DIR"/hooks/post-rewrite rebase < "$REWRITTEN_LIST"

1
git-rebase.sh

@ -154,6 +154,7 @@ move_to_original_branch () {


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

17
t/t3400-rebase.sh

@ -155,4 +155,21 @@ test_expect_success 'Rebase a commit that sprinkles CRs in' '
git diff --exit-code file-with-cr:CR HEAD:CR git diff --exit-code file-with-cr:CR HEAD:CR
' '


test_expect_success 'rebase can copy notes' '
git config notes.rewrite.rebase true &&
git config notes.rewriteRef "refs/notes/*" &&
test_commit n1 &&
test_commit n2 &&
test_commit n3 &&
git notes add -m"a note" n3 &&
git rebase --onto n1 n2 &&
test "a note" = "$(git notes show HEAD)"
'

test_expect_success 'rebase -m can copy notes' '
git reset --hard n3 &&
git rebase -m --onto n1 n2 &&
test "a note" = "$(git notes show HEAD)"
'

test_done test_done

24
t/t3404-rebase-interactive.sh

@ -553,4 +553,28 @@ test_expect_success 'reword' '
git show HEAD~2 | grep "C changed" git show HEAD~2 | grep "C changed"
' '


test_expect_success 'rebase -i can copy notes' '
git config notes.rewrite.rebase true &&
git config notes.rewriteRef "refs/notes/*" &&
test_commit n1 &&
test_commit n2 &&
test_commit n3 &&
git notes add -m"a note" n3 &&
git rebase --onto n1 n2 &&
test "a note" = "$(git notes show HEAD)"
'

cat >expect <<EOF
an earlier note
a note
EOF

test_expect_success 'rebase -i can copy notes over a fixup' '
git reset --hard n3 &&
git notes add -m"an earlier note" n2 &&
GIT_NOTES_REWRITE_MODE=concatenate FAKE_LINES="1 fixup 2" git rebase -i n1 &&
git notes show > output &&
test_cmp expect output
'

test_done test_done

Loading…
Cancel
Save