aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-05-18 16:44:30 -0700
committerJunio C Hamano <gitster@pobox.com>2011-05-19 10:54:16 -0700
commit46538012d943156ead4024fb510a1ce5d4ff443a (patch)
tree8e167868b9e1a252582013f21c556d6a73e9280b /t
parent2d370d2fbcf896912cc0739b806224f9a270bb5e (diff)
downloadgit-46538012d943156ead4024fb510a1ce5d4ff443a.tar.gz
git-46538012d943156ead4024fb510a1ce5d4ff443a.tar.xz
notes remove: --stdin reads from the standard input
Teach the command to read object names to remove from the standard input, in addition to the object names given from the command line. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t3301-notes.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index e820a6bc7..16de05aff 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -475,6 +475,41 @@ test_expect_success 'removing with --ignore-missing but bogus ref' '
test "$before" = "$after"
'
+test_expect_success 'remove reads from --stdin' '
+ 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 rev-parse HEAD^^ HEAD^^^ >input &&
+ git notes remove --stdin <input &&
+ git notes list | sed -e "s/ .*//" >actual &&
+ test_cmp after-removal-expect actual
+'
+
+test_expect_success 'remove --stdin is also atomic' '
+ before=$(git rev-parse --verify refs/notes/commits) &&
+ test_when_finished "git update-ref refs/notes/commits $before" &&
+ git rev-parse HEAD^^ HEAD^^^ HEAD^ >input &&
+ test_must_fail git notes remove --stdin <input &&
+ after=$(git rev-parse --verify refs/notes/commits) &&
+ test "$before" = "$after"
+'
+
+test_expect_success 'removing with --stdin --ignore-missing' '
+ 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 rev-parse HEAD^^ HEAD^^^ HEAD^ >input &&
+ git notes remove --ignore-missing --stdin <input &&
+ git notes list | sed -e "s/ .*//" >actual &&
+ test_cmp after-removal-expect actual
+'
+
test_expect_success 'list notes with "git notes list"' '
git notes list > output &&
test_cmp expect output