Merge branch 'jc/maint-1.6.0-keep-pack'
[git] / git-lost-found.sh
1 #!/bin/sh
2
3 USAGE=''
4 SUBDIRECTORY_OK='Yes'
5 OPTIONS_SPEC=
6 . git-sh-setup
7
8 echo "WARNING: '$0' is deprecated in favor of 'git fsck --lost-found'" >&2
9
10 if [ "$#" != "0" ]
11 then
12     usage
13 fi
14
15 laf="$GIT_DIR/lost-found"
16 rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit
17
18 git fsck --full --no-reflogs |
19 while read dangling type sha1
20 do
21         case "$dangling" in
22         dangling)
23                 if git rev-parse -q --verify "$sha1^0" >/dev/null
24                 then
25                         dir="$laf/commit"
26                         git show-branch "$sha1"
27                 else
28                         dir="$laf/other"
29                 fi
30                 echo "$sha1" >"$dir/$sha1"
31                 ;;
32         esac
33 done