path: root/t/
diff options
authorJunio C Hamano <>2011-05-18 22:44:37 (GMT)
committerJunio C Hamano <>2011-05-19 17:44:44 (GMT)
commitc3ab1a8e4cb8a84967efcf45c5e6bee41b17f9f9 (patch)
tree207ae18917753171c9e1125cf19446319ae8ecd8 /t/
parentb602ed7dea968d72c5b3f61ca016de7f285d80ef (diff)
notes remove: allow removing more than one
While "xargs -n1 git notes rm" is certainly a possible way to remove notes from many objects, this would create one notes "commit" per removal, which is not quite suitable for seasonal housekeeping. Allow taking more than one on the command line, and record their removal as a single atomic event if everthing goes well. Even though the old code insisted that "git notes rm" must be given only one object (or zero, in which case it would default to HEAD), this condition was not tested. Add tests to handle the new case where we feed multiple objects, and also make sure if there is a bad input, no change is recorded. Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 20 insertions, 0 deletions
diff --git a/t/ b/t/
index 28e17c8..f49879e 100755
--- a/t/
+++ b/t/
@@ -435,6 +435,26 @@ test_expect_success 'removing non-existing note should not create new commit' '
test_cmp before_commit after_commit
+test_expect_success 'removing more than one' '
+ before=$(git rev-parse --verify refs/notes/commits) &&
+ test_when_finished "git update-ref refs/notes/commits $before" &&
+ # We have only two -- add another and make sure it stays
+ git notes add -m "extra" &&
+ git notes list HEAD >after-removal-expect &&
+ git notes remove HEAD^^ HEAD^^^ &&
+ git notes list | sed -e "s/ .*//" >actual &&
+ test_cmp after-removal-expect actual
+test_expect_success 'removing is atomic' '
+ before=$(git rev-parse --verify refs/notes/commits) &&
+ test_when_finished "git update-ref refs/notes/commits $before" &&
+ test_must_fail git notes remove HEAD^^ HEAD^^^ HEAD^ &&
+ after=$(git rev-parse --verify refs/notes/commits) &&
+ test "$before" = "$after"
test_expect_success 'list notes with "git notes list"' '
git notes list > output &&
test_cmp expect output