blob: 0b3e8c7a8652478a7dd3d629fde9240cac6d6e2b [file] [log] [blame]
Junio C Hamano04e7ca12005-11-07 15:15:34 -08001#!/bin/sh
2
freku045@student.liu.sed20e2f12005-12-13 23:30:31 +01003USAGE=''
4SUBDIRECTORY_OK='Yes'
Junio C Hamano8f321a32007-11-06 01:50:02 -08005OPTIONS_SPEC=
freku045@student.liu.sed20e2f12005-12-13 23:30:31 +01006. git-sh-setup
7
Johannes Schindelinfc8b5f02007-11-08 00:41:22 +00008echo "WARNING: '$0' is deprecated in favor of 'git fsck --lost-found'" >&2
9
freku045@student.liu.sed20e2f12005-12-13 23:30:31 +010010if [ "$#" != "0" ]
11then
12 usage
13fi
14
Junio C Hamano07203652005-11-10 19:16:26 -080015laf="$GIT_DIR/lost-found"
Junio C Hamano04e7ca12005-11-07 15:15:34 -080016rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit
17
Shawn O. Pearce566842f2007-04-04 10:46:14 -040018git fsck --full --no-reflogs |
Junio C Hamano04e7ca12005-11-07 15:15:34 -080019while read dangling type sha1
20do
21 case "$dangling" in
22 dangling)
Miklos Vajnaa86e8c12008-12-03 14:26:49 +010023 if git rev-parse -q --verify "$sha1^0" >/dev/null
Junio C Hamano04e7ca12005-11-07 15:15:34 -080024 then
25 dir="$laf/commit"
Junio C Hamano5be60072007-07-02 22:52:14 -070026 git show-branch "$sha1"
Junio C Hamano04e7ca12005-11-07 15:15:34 -080027 else
28 dir="$laf/other"
29 fi
30 echo "$sha1" >"$dir/$sha1"
31 ;;
32 esac
33done