git-prune.shon commit Merge branch 'master' into next (d55e0ff)
   1#!/bin/sh
   2
   3USAGE='[-n] [--] [<head>...]'
   4. git-sh-setup
   5
   6dryrun=
   7echo=
   8while case "$#" in 0) break ;; esac
   9do
  10    case "$1" in
  11    -n) dryrun=-n echo=echo ;;
  12    --) break ;;
  13    -*) usage ;;
  14    *)  break ;;
  15    esac
  16    shift;
  17done
  18
  19sync
  20case "$#" in
  210) git-fsck-objects --full --cache --unreachable ;;
  22*) git-fsck-objects --full --cache --unreachable $(git-rev-parse --all) "$@" ;;
  23esac |
  24
  25sed -ne '/unreachable /{
  26    s/unreachable [^ ][^ ]* //
  27    s|\(..\)|\1/|p
  28}' | {
  29        cd "$GIT_OBJECT_DIRECTORY" || exit
  30        xargs $echo rm -f
  31        rmdir 2>/dev/null [0-9a-f][0-9a-f]
  32}
  33
  34git-prune-packed $dryrun
  35
  36if redundant=$(git-pack-redundant --all 2>/dev/null) && test "" != "$redundant"
  37then
  38        if test "" = "$dryrun"
  39        then
  40                echo "$redundant" | xargs rm -f
  41        else
  42                echo rm -f "$redundant"
  43        fi
  44fi