Merge branch 'np/maint-sideband-favor-status'
[git/gitbuild.git] / git-lost-found.sh
blob0b3e8c7a8652478a7dd3d629fde9240cac6d6e2b
1 #!/bin/sh
3 USAGE=''
4 SUBDIRECTORY_OK='Yes'
5 OPTIONS_SPEC=
6 . git-sh-setup
8 echo "WARNING: '$0' is deprecated in favor of 'git fsck --lost-found'" >&2
10 if [ "$#" != "0" ]
11 then
12 usage
15 laf="$GIT_DIR/lost-found"
16 rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit
18 git fsck --full --no-reflogs |
19 while read dangling type sha1
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"
30 echo "$sha1" >"$dir/$sha1"
32 esac
33 done