gc: handle & check gc.reflogExpire config
[gitweb.git] / t / t1410-reflog.sh
index 388b0611d8e4590f36d9aa44f11d4945a2ae7408..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' '
@@ -368,4 +377,19 @@ test_expect_success 'continue walking past root commits' '
        )
 '
 
+test_expect_success 'expire with multiple worktrees' '
+       git init main-wt &&
+       (
+               cd main-wt &&
+               test_tick &&
+               test_commit foo &&
+               git  worktree add link-wt &&
+               test_tick &&
+               test_commit -C link-wt foobar &&
+               test_tick &&
+               git reflog expire --verbose --all --expire=$test_tick &&
+               test_must_be_empty .git/worktrees/link-wt/logs/HEAD
+       )
+'
+
 test_done