git-lost-found.shon commit Merge branch 'maint' (a130976)
   1#!/bin/sh
   2
   3USAGE=''
   4SUBDIRECTORY_OK='Yes'
   5. git-sh-setup
   6
   7echo "WARNING: '$0' is deprecated in favor of 'git fsck --lost-found'" >&2
   8
   9if [ "$#" != "0" ]
  10then
  11    usage
  12fi
  13
  14laf="$GIT_DIR/lost-found"
  15rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit
  16
  17git fsck --full --no-reflogs |
  18while read dangling type sha1
  19do
  20        case "$dangling" in
  21        dangling)
  22                if git rev-parse --verify "$sha1^0" >/dev/null 2>/dev/null
  23                then
  24                        dir="$laf/commit"
  25                        git show-branch "$sha1"
  26                else
  27                        dir="$laf/other"
  28                fi
  29                echo "$sha1" >"$dir/$sha1"
  30                ;;
  31        esac
  32done