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