Fix bunch of fd leaks in http-fetch
[git/dscho.git] / git-lost-found.sh
blob3892f52005d1e36676681806a87ef35dc0689f22
1 #!/bin/sh
3 . git-sh-setup || die "Not a git archive."
5 laf="$GIT_DIR/lost-found"
6 rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit
8 git fsck-objects |
9 while read dangling type sha1
11 case "$dangling" in
12 dangling)
13 if git-rev-parse --verify "$sha1^0" >/dev/null 2>/dev/null
14 then
15 dir="$laf/commit"
16 git-show-branch "$sha1"
17 else
18 dir="$laf/other"
20 echo "$sha1" >"$dir/$sha1"
22 esac
23 done