tag: make it operable from a subdirectory.
[git/dscho.git] / git-lost-found.sh
blob2beec2aa635d2876482294a162923a1dfd1572f6
1 #!/bin/sh
3 GIT_DIR=`git-rev-parse --git-dir` || exit $?
4 laf="$GIT_DIR/lost-found"
5 rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit
7 git fsck-objects |
8 while read dangling type sha1
9 do
10 case "$dangling" in
11 dangling)
12 if git-rev-parse --verify "$sha1^0" >/dev/null 2>/dev/null
13 then
14 dir="$laf/commit"
15 git-show-branch "$sha1"
16 else
17 dir="$laf/other"
19 echo "$sha1" >"$dir/$sha1"
21 esac
22 done