aboutsummaryrefslogtreecommitdiff
path: root/t/t3301-notes.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-05-18 15:44:37 -0700
committerJunio C Hamano <gitster@pobox.com>2011-05-19 10:44:44 -0700
commitc3ab1a8e4cb8a84967efcf45c5e6bee41b17f9f9 (patch)
tree207ae18917753171c9e1125cf19446319ae8ecd8 /t/t3301-notes.sh
parentb602ed7dea968d72c5b3f61ca016de7f285d80ef (diff)
downloadgit-c3ab1a8e4cb8a84967efcf45c5e6bee41b17f9f9.tar.gz
git-c3ab1a8e4cb8a84967efcf45c5e6bee41b17f9f9.tar.xz
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 <gitster@pobox.com>
Diffstat (limited to 't/t3301-notes.sh')
-rwxr-xr-xt/t3301-notes.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index 28e17c892..f49879e03 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -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