gc: handle & check gc.reflogExpire config
[gitweb.git] / t / t1410-reflog.sh
index 3e053532eb8df817e216532c807eba0ba549e8c3..79f731db37cfa1a9e44fe4b966cbe6a72706ee94 100755 (executable)
@@ -20,12 +20,12 @@ check_have () {
 }
 
 check_fsck () {
-       output=$(git fsck --full)
+       git fsck --full >fsck.output
        case "$1" in
        '')
-               test -z "$output" ;;
+               test_must_be_empty fsck.output ;;
        *)
-               echo "$output" | grep "$1" ;;
+               test_i18ngrep "$1" fsck.output ;;
        esac
 }
 
@@ -232,25 +232,34 @@ test_expect_success '--expire=never' '
 '
 
 test_expect_success 'gc.reflogexpire=never' '
+       test_config gc.reflogexpire never &&
+       test_config gc.reflogexpireunreachable never &&
+
+       git reflog expire --verbose --all >output &&
+       test_line_count = 9 output &&
 
-       git config gc.reflogexpire never &&
-       git config gc.reflogexpireunreachable never &&
-       git reflog expire --verbose --all &&
        git reflog refs/heads/master >output &&
        test_line_count = 4 output
 '
 
 test_expect_success 'gc.reflogexpire=false' '
+       test_config gc.reflogexpire false &&
+       test_config gc.reflogexpireunreachable false &&
 
-       git config gc.reflogexpire false &&
-       git config gc.reflogexpireunreachable false &&
        git reflog expire --verbose --all &&
        git reflog refs/heads/master >output &&
-       test_line_count = 4 output &&
+       test_line_count = 4 output
+
+'
 
-       git config --unset gc.reflogexpire &&
-       git config --unset gc.reflogexpireunreachable
+test_expect_success 'git reflog expire unknown reference' '
+       test_config gc.reflogexpire never &&
+       test_config gc.reflogexpireunreachable never &&
 
+       test_must_fail git reflog expire master@{123} 2>stderr &&
+       test_i18ngrep "points nowhere" stderr &&
+       test_must_fail git reflog expire does-not-exist 2>stderr &&
+       test_i18ngrep "points nowhere" stderr
 '
 
 test_expect_success 'checkout should not delete log for packed ref' '