Junio C Hamano | 04e7ca1 | 2005-11-07 15:15:34 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
freku045@student.liu.se | d20e2f1 | 2005-12-13 23:30:31 +0100 | [diff] [blame] | 3 | USAGE='' |
| 4 | SUBDIRECTORY_OK='Yes' |
Junio C Hamano | 8f321a3 | 2007-11-06 01:50:02 -0800 | [diff] [blame] | 5 | OPTIONS_SPEC= |
freku045@student.liu.se | d20e2f1 | 2005-12-13 23:30:31 +0100 | [diff] [blame] | 6 | . git-sh-setup |
| 7 | |
Johannes Schindelin | fc8b5f0 | 2007-11-08 00:41:22 +0000 | [diff] [blame] | 8 | echo "WARNING: '$0' is deprecated in favor of 'git fsck --lost-found'" >&2 |
| 9 | |
freku045@student.liu.se | d20e2f1 | 2005-12-13 23:30:31 +0100 | [diff] [blame] | 10 | if [ "$#" != "0" ] |
| 11 | then |
| 12 | usage |
| 13 | fi |
| 14 | |
Junio C Hamano | 0720365 | 2005-11-10 19:16:26 -0800 | [diff] [blame] | 15 | laf="$GIT_DIR/lost-found" |
Junio C Hamano | 04e7ca1 | 2005-11-07 15:15:34 -0800 | [diff] [blame] | 16 | rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit |
| 17 | |
Shawn O. Pearce | 566842f | 2007-04-04 10:46:14 -0400 | [diff] [blame] | 18 | git fsck --full --no-reflogs | |
Junio C Hamano | 04e7ca1 | 2005-11-07 15:15:34 -0800 | [diff] [blame] | 19 | while read dangling type sha1 |
| 20 | do |
| 21 | case "$dangling" in |
| 22 | dangling) |
Miklos Vajna | a86e8c1 | 2008-12-03 14:26:49 +0100 | [diff] [blame] | 23 | if git rev-parse -q --verify "$sha1^0" >/dev/null |
Junio C Hamano | 04e7ca1 | 2005-11-07 15:15:34 -0800 | [diff] [blame] | 24 | then |
| 25 | dir="$laf/commit" |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 26 | git show-branch "$sha1" |
Junio C Hamano | 04e7ca1 | 2005-11-07 15:15:34 -0800 | [diff] [blame] | 27 | else |
| 28 | dir="$laf/other" |
| 29 | fi |
| 30 | echo "$sha1" >"$dir/$sha1" |
| 31 | ;; |
| 32 | esac |
| 33 | done |