git-prune.shon commit Merge branch 'fixes' (d92ddb5)
   1#!/bin/sh
   2
   3. git-sh-setup || die "Not a git archive"
   4
   5dryrun=
   6echo=
   7while case "$#" in 0) break ;; esac
   8do
   9    case "$1" in
  10    -n) dryrun=-n echo=echo ;;
  11    --) break ;;
  12    -*) echo >&2 "usage: git-prune [ -n ] [ heads... ]"; exit 1 ;;
  13    *)  break ;;
  14    esac
  15    shift;
  16done
  17
  18sync
  19git-fsck-objects --full --cache --unreachable "$@" |
  20sed -ne '/unreachable /{
  21    s/unreachable [^ ][^ ]* //
  22    s|\(..\)|\1/|p
  23}' | {
  24        cd "$GIT_OBJECT_DIRECTORY" || exit
  25        xargs $echo rm -f
  26        rmdir 2>/dev/null [0-9a-f][0-9a-f]
  27}
  28
  29git-prune-packed $dryrun