1#!/bin/sh
2#
3# Copyright (c) 2007 Johannes E. Schindelin
4#
5
6test_description='Test fsck --lost-found'
7. ./test-lib.sh
8
9test_expect_success setup '
10 git config core.logAllRefUpdates 0 &&
11 : > file1 &&
12 git add file1 &&
13 test_tick &&
14 git commit -m initial &&
15 echo 1 > file1 &&
16 echo 2 > file2 &&
17 git add file1 file2 &&
18 test_tick &&
19 git commit -m second &&
20 echo 3 > file3 &&
21 git add file3
22'
23
24test_expect_success 'lost and found something' '
25 git rev-parse HEAD > lost-commit &&
26 git rev-parse :file3 > lost-other &&
27 test_tick &&
28 git reset --hard HEAD^ &&
29 git fsck --lost-found &&
30 test 2 = $(ls .git/lost-found/*/* | wc -l) &&
31 test -f .git/lost-found/commit/$(cat lost-commit) &&
32 test -f .git/lost-found/other/$(cat lost-other)
33'
34
35test_done