3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description
='Test commit notes'
10 cat > fake_editor.sh
<< \EOF
15 chmod a
+x fake_editor.sh
16 GIT_EDITOR
=.
/fake_editor.sh
19 test_expect_success
'cannot annotate non-existing HEAD' '
20 (MSG=3 && export MSG && test_must_fail git notes add)
23 test_expect_success setup
'
34 test_expect_success
'need valid notes ref' '
35 (MSG=1 GIT_NOTES_REF=/ && export MSG GIT_NOTES_REF &&
36 test_must_fail git notes add) &&
37 (MSG=2 GIT_NOTES_REF=/ && export MSG GIT_NOTES_REF &&
38 test_must_fail git notes show)
41 test_expect_success
'refusing to add notes in refs/heads/' '
42 (MSG=1 GIT_NOTES_REF=refs/heads/bogus &&
43 export MSG GIT_NOTES_REF &&
44 test_must_fail git notes add)
47 test_expect_success
'refusing to edit notes in refs/remotes/' '
48 (MSG=1 GIT_NOTES_REF=refs/remotes/bogus &&
49 export MSG GIT_NOTES_REF &&
50 test_must_fail git notes edit)
53 # 1 indicates caught gracefully by die, 128 means git-show barked
54 test_expect_success
'handle empty notes gracefully' '
55 git notes show ; test 1 = $?
58 test_expect_success
'create notes' '
59 git config core.notesRef refs/notes/commits &&
60 MSG=b4 git notes add &&
61 test ! -f .git/NOTES_EDITMSG &&
62 test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
63 test b4 = $(git notes show) &&
65 test_must_fail git notes show HEAD^
68 test_expect_success
'edit existing notes' '
69 MSG=b3 git notes edit &&
70 test ! -f .git/NOTES_EDITMSG &&
71 test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
72 test b3 = $(git notes show) &&
74 test_must_fail git notes show HEAD^
77 test_expect_success
'cannot add note where one exists' '
78 ! MSG=b2 git notes add &&
79 test ! -f .git/NOTES_EDITMSG &&
80 test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
81 test b3 = $(git notes show) &&
83 test_must_fail git notes show HEAD^
86 test_expect_success
'can overwrite existing note with "git notes add -f"' '
87 MSG=b1 git notes add -f &&
88 test ! -f .git/NOTES_EDITMSG &&
89 test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
90 test b1 = $(git notes show) &&
92 test_must_fail git notes show HEAD^
96 commit 268048bfb8a1fb38e703baceb8ab235421bf80c5
97 Author: A U Thor <author@example.com>
98 Date: Thu Apr 7 15:14:13 2005 -0700
106 test_expect_success
'show notes' '
107 ! (git cat-file commit HEAD | grep b1) &&
108 git log -1 > output &&
109 test_cmp expect output
112 test_expect_success
'create multi-line notes (setup)' '
119 d3d3d3" git notes add
122 cat > expect-multiline
<< EOF
123 commit 1584215f1d29c65e99c6c6848626553fdd07fd75
124 Author: A U Thor <author@example.com>
125 Date: Thu Apr 7 15:15:13 2005 -0700
135 printf "\n" >> expect-multiline
136 cat expect
>> expect-multiline
138 test_expect_success
'show multi-line notes' '
139 git log -2 > output &&
140 test_cmp expect-multiline output
142 test_expect_success
'create -F notes (setup)' '
147 echo "xyzzy" > note5 &&
148 git notes add -F note5
151 cat > expect-F
<< EOF
152 commit 15023535574ded8b1a89052b32673f84cf9582b8
153 Author: A U Thor <author@example.com>
154 Date: Thu Apr 7 15:16:13 2005 -0700
162 printf "\n" >> expect-F
163 cat expect-multiline
>> expect-F
165 test_expect_success
'show -F notes' '
166 git log -3 > output &&
167 test_cmp expect-F output
171 commit 15023535574ded8b1a89052b32673f84cf9582b8
172 tree e070e3af51011e47b183c33adf9736736a525709
173 parent 1584215f1d29c65e99c6c6848626553fdd07fd75
174 author A U Thor <author@example.com> 1112912173 -0700
175 committer C O Mitter <committer@example.com> 1112912173 -0700
179 test_expect_success
'git log --pretty=raw does not show notes' '
180 git log -1 --pretty=raw >output &&
181 test_cmp expect output
189 test_expect_success
'git log --show-notes' '
190 git log -1 --pretty=raw --show-notes >output &&
191 test_cmp expect output
194 test_expect_success
'git log --no-notes' '
195 git log -1 --no-notes >output &&
199 test_expect_success
'git format-patch does not show notes' '
200 git format-patch -1 --stdout >output &&
204 test_expect_success
'git format-patch --show-notes does show notes' '
205 git format-patch --show-notes -1 --stdout >output &&
210 "" --pretty --pretty=raw
--pretty=short
--pretty=medium \
211 --pretty=full
--pretty=fuller
--pretty=format
:%s
--oneline
214 "") p
= not
= negate
="" ;;
215 ?
*) p
="$pretty" not
=" not" negate
="!" ;;
217 test_expect_success
"git show $pretty does$not show notes" '
218 git show $p >output &&
219 eval "$negate grep xyzzy output"
223 test_expect_success
'create -m notes (setup)' '
228 git notes add -m spam -m "foo
234 cat > expect-m
<< EOF
235 commit bd1753200303d0a0344be813e504253b3d98e74d
236 Author: A U Thor <author@example.com>
237 Date: Thu Apr 7 15:17:13 2005 -0700
249 printf "\n" >> expect-m
250 cat expect-F
>> expect-m
252 test_expect_success
'show -m notes' '
253 git log -4 > output &&
254 test_cmp expect-m output
257 test_expect_success
'remove note with add -f -F /dev/null (setup)' '
258 git notes add -f -F /dev/null
261 cat > expect-rm-F
<< EOF
262 commit bd1753200303d0a0344be813e504253b3d98e74d
263 Author: A U Thor <author@example.com>
264 Date: Thu Apr 7 15:17:13 2005 -0700
269 printf "\n" >> expect-rm-F
270 cat expect-F
>> expect-rm-F
272 test_expect_success
'verify note removal with -F /dev/null' '
273 git log -4 > output &&
274 test_cmp expect-rm-F output &&
278 test_expect_success
'do not create empty note with -m "" (setup)' '
282 test_expect_success
'verify non-creation of note with -m ""' '
283 git log -4 > output &&
284 test_cmp expect-rm-F output &&
288 cat > expect-combine_m_and_F
<< EOF
300 test_expect_success
'create note with combination of -m and -F' '
301 echo "xyzzy" > note_a &&
302 echo "zyxxy" > note_b &&
303 git notes add -m "foo" -F note_a -m "bar" -F note_b -m "baz" &&
304 git notes show > output &&
305 test_cmp expect-combine_m_and_F output
308 test_expect_success
'remove note with "git notes remove" (setup)' '
309 git notes remove HEAD^ &&
313 cat > expect-rm-remove
<< EOF
314 commit bd1753200303d0a0344be813e504253b3d98e74d
315 Author: A U Thor <author@example.com>
316 Date: Thu Apr 7 15:17:13 2005 -0700
320 commit 15023535574ded8b1a89052b32673f84cf9582b8
321 Author: A U Thor <author@example.com>
322 Date: Thu Apr 7 15:16:13 2005 -0700
327 printf "\n" >> expect-rm-remove
328 cat expect-multiline
>> expect-rm-remove
330 test_expect_success
'verify note removal with "git notes remove"' '
331 git log -4 > output &&
332 test_cmp expect-rm-remove output &&
333 ! git notes show HEAD^
337 c18dc024e14f08d18d14eea0d747ff692d66d6a3 1584215f1d29c65e99c6c6848626553fdd07fd75
338 c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 268048bfb8a1fb38e703baceb8ab235421bf80c5
341 test_expect_success
'list notes with "git notes list"' '
342 git notes list > output &&
343 test_cmp expect output
346 test_expect_success
'list notes with "git notes"' '
347 git notes > output &&
348 test_cmp expect output
352 c18dc024e14f08d18d14eea0d747ff692d66d6a3
355 test_expect_success
'list specific note with "git notes list <object>"' '
356 git notes list HEAD^^ > output &&
357 test_cmp expect output
363 test_expect_success
'listing non-existing notes fails' '
364 test_must_fail git notes list HEAD > output &&
365 test_cmp expect output
371 More notes appended with git notes append
374 test_expect_success
'append to existing note with "git notes append"' '
375 git notes add -m "Initial set of notes" &&
376 git notes append -m "More notes appended with git notes append" &&
377 git notes show > output &&
378 test_cmp expect output
381 cat > expect_list
<< EOF
382 c18dc024e14f08d18d14eea0d747ff692d66d6a3 1584215f1d29c65e99c6c6848626553fdd07fd75
383 c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 268048bfb8a1fb38e703baceb8ab235421bf80c5
384 4b6ad22357cc8a1296720574b8d2fbc22fab0671 bd1753200303d0a0344be813e504253b3d98e74d
387 test_expect_success
'"git notes list" does not expand to "git notes list HEAD"' '
388 git notes list > output &&
389 test_cmp expect_list output
392 test_expect_success
'appending empty string does not change existing note' '
393 git notes append -m "" &&
394 git notes show > output &&
395 test_cmp expect output
398 test_expect_success
'git notes append == add when there is no existing note' '
399 git notes remove HEAD &&
400 test_must_fail git notes list HEAD &&
401 git notes append -m "Initial set of notes
403 More notes appended with git notes append" &&
404 git notes show > output &&
405 test_cmp expect output
408 test_expect_success
'appending empty string to non-existing note does not create note' '
409 git notes remove HEAD &&
410 test_must_fail git notes list HEAD &&
411 git notes append -m "" &&
412 test_must_fail git notes list HEAD
415 test_expect_success
'create other note on a different notes ref (setup)' '
420 GIT_NOTES_REF="refs/notes/other" git notes add -m "other note"
423 cat > expect-other
<< EOF
424 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
425 Author: A U Thor <author@example.com>
426 Date: Thu Apr 7 15:18:13 2005 -0700
434 cat > expect-not-other
<< EOF
435 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
436 Author: A U Thor <author@example.com>
437 Date: Thu Apr 7 15:18:13 2005 -0700
442 test_expect_success
'Do not show note on other ref by default' '
443 git log -1 > output &&
444 test_cmp expect-not-other output
447 test_expect_success
'Do show note when ref is given in GIT_NOTES_REF' '
448 GIT_NOTES_REF="refs/notes/other" git log -1 > output &&
449 test_cmp expect-other output
452 test_expect_success
'Do show note when ref is given in core.notesRef config' '
453 git config core.notesRef "refs/notes/other" &&
454 git log -1 > output &&
455 test_cmp expect-other output
458 test_expect_success
'Do not show note when core.notesRef is overridden' '
459 GIT_NOTES_REF="refs/notes/wrong" git log -1 > output &&
460 test_cmp expect-not-other output
463 cat > expect-both
<< EOF
464 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
465 Author: A U Thor <author@example.com>
466 Date: Thu Apr 7 15:18:13 2005 -0700
476 commit bd1753200303d0a0344be813e504253b3d98e74d
477 Author: A U Thor <author@example.com>
478 Date: Thu Apr 7 15:17:13 2005 -0700
483 replacement for deleted note
486 test_expect_success
'Show all notes when notes.displayRef=refs/notes/*' '
487 GIT_NOTES_REF=refs/notes/commits git notes add \
488 -m"replacement for deleted note" HEAD^ &&
489 GIT_NOTES_REF=refs/notes/commits git notes add -m"order test" &&
490 git config --unset core.notesRef &&
491 git config notes.displayRef "refs/notes/*" &&
492 git log -2 > output &&
493 test_cmp expect-both output
496 test_expect_success
'core.notesRef is implicitly in notes.displayRef' '
497 git config core.notesRef refs/notes/commits &&
498 git config notes.displayRef refs/notes/other &&
499 git log -2 > output &&
500 test_cmp expect-both output
503 test_expect_success
'notes.displayRef can be given more than once' '
504 git config --unset core.notesRef &&
505 git config notes.displayRef refs/notes/commits &&
506 git config --add notes.displayRef refs/notes/other &&
507 git log -2 > output &&
508 test_cmp expect-both output
511 cat > expect-both-reversed
<< EOF
512 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
513 Author: A U Thor <author@example.com>
514 Date: Thu Apr 7 15:18:13 2005 -0700
525 test_expect_success
'notes.displayRef respects order' '
526 git config core.notesRef refs/notes/other &&
527 git config --unset-all notes.displayRef &&
528 git config notes.displayRef refs/notes/commits &&
529 git log -1 > output &&
530 test_cmp expect-both-reversed output
533 test_expect_success
'GIT_NOTES_DISPLAY_REF works' '
534 git config --unset-all core.notesRef &&
535 git config --unset-all notes.displayRef &&
536 GIT_NOTES_DISPLAY_REF=refs/notes/commits:refs/notes/other \
537 git log -2 > output &&
538 test_cmp expect-both output
541 cat > expect-none
<< EOF
542 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
543 Author: A U Thor <author@example.com>
544 Date: Thu Apr 7 15:18:13 2005 -0700
548 commit bd1753200303d0a0344be813e504253b3d98e74d
549 Author: A U Thor <author@example.com>
550 Date: Thu Apr 7 15:17:13 2005 -0700
555 test_expect_success
'GIT_NOTES_DISPLAY_REF overrides config' '
556 git config notes.displayRef "refs/notes/*" &&
557 GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log -2 > output &&
558 test_cmp expect-none output
561 test_expect_success
'--show-notes=* adds to GIT_NOTES_DISPLAY_REF' '
562 GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log --show-notes=* -2 > output &&
563 test_cmp expect-both output
566 cat > expect-commits
<< EOF
567 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
568 Author: A U Thor <author@example.com>
569 Date: Thu Apr 7 15:18:13 2005 -0700
577 test_expect_success
'--no-standard-notes' '
578 git log --no-standard-notes --show-notes=commits -1 > output &&
579 test_cmp expect-commits output
582 test_expect_success
'--standard-notes' '
583 git log --no-standard-notes --show-notes=commits \
584 --standard-notes -2 > output &&
585 test_cmp expect-both output
588 test_expect_success
'--show-notes=ref accumulates' '
589 git log --show-notes=other --show-notes=commits \
590 --no-standard-notes -1 > output &&
591 test_cmp expect-both-reversed output
594 test_expect_success
'Allow notes on non-commits (trees, blobs, tags)' '
595 git config core.notesRef refs/notes/other &&
596 echo "Note on a tree" > expect
597 git notes add -m "Note on a tree" HEAD: &&
598 git notes show HEAD: > actual &&
599 test_cmp expect actual &&
600 echo "Note on a blob" > expect
601 filename=$(git ls-tree --name-only HEAD | head -n1) &&
602 git notes add -m "Note on a blob" HEAD:$filename &&
603 git notes show HEAD:$filename > actual &&
604 test_cmp expect actual &&
605 echo "Note on a tag" > expect
606 git tag -a -m "This is an annotated tag" foobar HEAD^ &&
607 git notes add -m "Note on a tag" foobar &&
608 git notes show foobar > actual &&
609 test_cmp expect actual
613 commit 2ede89468182a62d0bde2583c736089bcf7d7e92
614 Author: A U Thor <author@example.com>
615 Date: Thu Apr 7 15:19:13 2005 -0700
623 test_expect_success
'create note from other note with "git notes add -C"' '
628 git notes add -C $(git notes list HEAD^) &&
629 git log -1 > actual &&
630 test_cmp expect actual &&
631 test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
634 test_expect_success
'create note from non-existing note with "git notes add -C" fails' '
639 test_must_fail git notes add -C deadbeef &&
640 test_must_fail git notes list HEAD
644 commit 016e982bad97eacdbda0fcbd7ce5b0ba87c81f1b
645 Author: A U Thor <author@example.com>
646 Date: Thu Apr 7 15:21:13 2005 -0700
654 test_expect_success
'create note from other note with "git notes add -c"' '
659 MSG="yet another note" git notes add -c $(git notes list HEAD^^) &&
660 git log -1 > actual &&
661 test_cmp expect actual
664 test_expect_success
'create note from non-existing note with "git notes add -c" fails' '
668 git commit -m 10th &&
669 test_must_fail MSG="yet another note" git notes add -c deadbeef &&
670 test_must_fail git notes list HEAD
674 commit 016e982bad97eacdbda0fcbd7ce5b0ba87c81f1b
675 Author: A U Thor <author@example.com>
676 Date: Thu Apr 7 15:21:13 2005 -0700
686 test_expect_success
'append to note from other note with "git notes append -C"' '
687 git notes append -C $(git notes list HEAD^) HEAD^ &&
688 git log -1 HEAD^ > actual &&
689 test_cmp expect actual
693 commit ffed603236bfa3891c49644257a83598afe8ae5a
694 Author: A U Thor <author@example.com>
695 Date: Thu Apr 7 15:22:13 2005 -0700
703 test_expect_success
'create note from other note with "git notes append -c"' '
704 MSG="other note" git notes append -c $(git notes list HEAD^) &&
705 git log -1 > actual &&
706 test_cmp expect actual
710 commit ffed603236bfa3891c49644257a83598afe8ae5a
711 Author: A U Thor <author@example.com>
712 Date: Thu Apr 7 15:22:13 2005 -0700
722 test_expect_success
'append to note from other note with "git notes append -c"' '
723 MSG="yet another note" git notes append -c $(git notes list HEAD) &&
724 git log -1 > actual &&
725 test_cmp expect actual
729 commit 6352c5e33dbcab725fe0579be16aa2ba8eb369be
730 Author: A U Thor <author@example.com>
731 Date: Thu Apr 7 15:23:13 2005 -0700
741 test_expect_success
'copy note with "git notes copy"' '
745 git commit -m 11th &&
746 git notes copy HEAD^ HEAD &&
747 git log -1 > actual &&
748 test_cmp expect actual &&
749 test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
752 test_expect_success
'prevent overwrite with "git notes copy"' '
753 test_must_fail git notes copy HEAD~2 HEAD &&
754 git log -1 > actual &&
755 test_cmp expect actual &&
756 test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
760 commit 6352c5e33dbcab725fe0579be16aa2ba8eb369be
761 Author: A U Thor <author@example.com>
762 Date: Thu Apr 7 15:23:13 2005 -0700
772 test_expect_success
'allow overwrite with "git notes copy -f"' '
773 git notes copy -f HEAD~2 HEAD &&
774 git log -1 > actual &&
775 test_cmp expect actual &&
776 test "$(git notes list HEAD)" = "$(git notes list HEAD~2)"
779 test_expect_success
'cannot copy note from object without notes' '
783 git commit -m 12th &&
787 git commit -m 13th &&
788 test_must_fail git notes copy HEAD^ HEAD
792 commit e5d4fb5698d564ab8c73551538ecaf2b0c666185
793 Author: A U Thor <author@example.com>
794 Date: Thu Apr 7 15:25:13 2005 -0700
803 commit 7038787dfe22a14c3867ce816dbba39845359719
804 Author: A U Thor <author@example.com>
805 Date: Thu Apr 7 15:24:13 2005 -0700
815 test_expect_success
'git notes copy --stdin' '
816 (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
817 echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
818 git notes copy --stdin &&
819 git log -2 > output &&
820 test_cmp expect output &&
821 test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" &&
822 test "$(git notes list HEAD^)" = "$(git notes list HEAD~3)"
826 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
827 Author: A U Thor <author@example.com>
828 Date: Thu Apr 7 15:27:13 2005 -0700
832 commit be28d8b4d9951ad940d229ee3b0b9ee3b1ec273d
833 Author: A U Thor <author@example.com>
834 Date: Thu Apr 7 15:26:13 2005 -0700
839 test_expect_success
'git notes copy --for-rewrite (unconfigured)' '
842 (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
843 echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
844 git notes copy --for-rewrite=foo &&
845 git log -2 > output &&
846 test_cmp expect output
850 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
851 Author: A U Thor <author@example.com>
852 Date: Thu Apr 7 15:27:13 2005 -0700
861 commit be28d8b4d9951ad940d229ee3b0b9ee3b1ec273d
862 Author: A U Thor <author@example.com>
863 Date: Thu Apr 7 15:26:13 2005 -0700
873 test_expect_success
'git notes copy --for-rewrite (enabled)' '
874 git config notes.rewriteMode overwrite &&
875 git config notes.rewriteRef "refs/notes/*" &&
876 (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
877 echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
878 git notes copy --for-rewrite=foo &&
879 git log -2 > output &&
880 test_cmp expect output
883 test_expect_success
'git notes copy --for-rewrite (disabled)' '
884 git config notes.rewrite.bar false &&
885 echo $(git rev-parse HEAD~3) $(git rev-parse HEAD) |
886 git notes copy --for-rewrite=bar &&
887 git log -2 > output &&
888 test_cmp expect output
892 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
893 Author: A U Thor <author@example.com>
894 Date: Thu Apr 7 15:27:13 2005 -0700
902 test_expect_success
'git notes copy --for-rewrite (overwrite)' '
903 git notes add -f -m"a fresh note" HEAD^ &&
904 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
905 git notes copy --for-rewrite=foo &&
906 git log -1 > output &&
907 test_cmp expect output
910 test_expect_success
'git notes copy --for-rewrite (ignore)' '
911 git config notes.rewriteMode ignore &&
912 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
913 git notes copy --for-rewrite=foo &&
914 git log -1 > output &&
915 test_cmp expect output
919 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
920 Author: A U Thor <author@example.com>
921 Date: Thu Apr 7 15:27:13 2005 -0700
930 test_expect_success
'git notes copy --for-rewrite (append)' '
931 git notes add -f -m"another fresh note" HEAD^ &&
932 git config notes.rewriteMode concatenate &&
933 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
934 git notes copy --for-rewrite=foo &&
935 git log -1 > output &&
936 test_cmp expect output
940 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
941 Author: A U Thor <author@example.com>
942 Date: Thu Apr 7 15:27:13 2005 -0700
953 test_expect_success
'git notes copy --for-rewrite (append two to one)' '
954 git notes add -f -m"append 1" HEAD^ &&
955 git notes add -f -m"append 2" HEAD^^ &&
956 (echo $(git rev-parse HEAD^) $(git rev-parse HEAD);
957 echo $(git rev-parse HEAD^^) $(git rev-parse HEAD)) |
958 git notes copy --for-rewrite=foo &&
959 git log -1 > output &&
960 test_cmp expect output
963 test_expect_success
'git notes copy --for-rewrite (append empty)' '
964 git notes remove HEAD^ &&
965 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
966 git notes copy --for-rewrite=foo &&
967 git log -1 > output &&
968 test_cmp expect output
972 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
973 Author: A U Thor <author@example.com>
974 Date: Thu Apr 7 15:27:13 2005 -0700
982 test_expect_success
'GIT_NOTES_REWRITE_MODE works' '
983 git notes add -f -m"replacement note 1" HEAD^ &&
984 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
985 GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo &&
986 git log -1 > output &&
987 test_cmp expect output
991 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
992 Author: A U Thor <author@example.com>
993 Date: Thu Apr 7 15:27:13 2005 -0700
1001 test_expect_success
'GIT_NOTES_REWRITE_REF works' '
1002 git config notes.rewriteMode overwrite &&
1003 git notes add -f -m"replacement note 2" HEAD^ &&
1004 git config --unset-all notes.rewriteRef &&
1005 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1006 GIT_NOTES_REWRITE_REF=refs/notes/commits:refs/notes/other \
1007 git notes copy --for-rewrite=foo &&
1008 git log -1 > output &&
1009 test_cmp expect output
1012 test_expect_success
'GIT_NOTES_REWRITE_REF overrides config' '
1013 git config notes.rewriteRef refs/notes/other &&
1014 git notes add -f -m"replacement note 3" HEAD^ &&
1015 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1016 GIT_NOTES_REWRITE_REF= git notes copy --for-rewrite=foo &&
1017 git log -1 > output &&
1018 test_cmp expect output