Code

git-read-tree.txt: update sparse checkout examples
[git.git] / git-lost-found.sh
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
13 fi
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
20 do
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"
29                 fi
30                 echo "$sha1" >"$dir/$sha1"
31                 ;;
32         esac
33 done