git-lost-found.shon commit sha1_file: add the ability to parse objects in "pack file format" (93821bd)
   1#!/bin/sh
   2
   3USAGE=''
   4SUBDIRECTORY_OK='Yes'
   5. git-sh-setup
   6
   7if [ "$#" != "0" ]
   8then
   9    usage
  10fi
  11
  12laf="$GIT_DIR/lost-found"
  13rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit
  14
  15git fsck-objects |
  16while read dangling type sha1
  17do
  18        case "$dangling" in
  19        dangling)
  20                if git-rev-parse --verify "$sha1^0" >/dev/null 2>/dev/null
  21                then
  22                        dir="$laf/commit"
  23                        git-show-branch "$sha1"
  24                else
  25                        dir="$laf/other"
  26                fi
  27                echo "$sha1" >"$dir/$sha1"
  28                ;;
  29        esac
  30done