Code

vcs-svn: guard against overflow when computing preimage length
[git.git] / t / t3306-notes-prune.sh
index a0ed0353e69dd6dbc96f1a8e3c9251757b4f408f..86bf909ee3dfca78f678fdefe961772dcd78d6b1 100755 (executable)
@@ -20,6 +20,9 @@ test_expect_success 'setup: create a few commits with notes' '
        git add file3 &&
        test_tick &&
        git commit -m 3rd &&
+       COMMIT_FILE=.git/objects/5e/e1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
+       test -f $COMMIT_FILE &&
+       test-chmtime =+0 $COMMIT_FILE &&
        git notes add -m "Note #3"
 '
 
@@ -60,15 +63,15 @@ test_expect_success 'verify commits and notes' '
 
 test_expect_success 'remove some commits' '
 
-       git reset --hard HEAD~2 &&
+       git reset --hard HEAD~1 &&
        git reflog expire --expire=now HEAD &&
        git gc --prune=now
 '
 
 test_expect_success 'verify that commits are gone' '
 
-       ! git cat-file -p 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
-       git cat-file -p 08341ad9e94faa089d60fd3f523affb25c6da189 &&
+       test_must_fail git cat-file -p 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
+       git cat-file -p 08341ad9e94faa089d60fd3f523affb25c6da189 &&
        git cat-file -p ab5f302035f2e7aaf04265f08b42034c23256e1f
 '
 
@@ -79,6 +82,26 @@ test_expect_success 'verify that notes are still present' '
        git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
 '
 
+test_expect_success 'prune -n does not remove notes' '
+
+       git notes list > expect &&
+       git notes prune -n &&
+       git notes list > actual &&
+       test_cmp expect actual
+'
+
+cat > expect <<EOF
+5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29
+EOF
+
+test_expect_success 'prune -n lists prunable notes' '
+
+
+       git notes prune -n > actual &&
+       test_cmp expect actual
+'
+
+
 test_expect_success 'prune notes' '
 
        git notes prune
@@ -86,8 +109,32 @@ test_expect_success 'prune notes' '
 
 test_expect_success 'verify that notes are gone' '
 
-       ! git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
-       ! git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
+       test_must_fail git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
+       git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
+       git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
+'
+
+test_expect_success 'remove some commits' '
+
+       git reset --hard HEAD~1 &&
+       git reflog expire --expire=now HEAD &&
+       git gc --prune=now
+'
+
+cat > expect <<EOF
+08341ad9e94faa089d60fd3f523affb25c6da189
+EOF
+
+test_expect_success 'prune -v notes' '
+
+       git notes prune -v > actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'verify that notes are gone' '
+
+       test_must_fail git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
+       test_must_fail git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
        git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
 '