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