contrib / examples / git-gc.shon commit Merge branch 'sn/ls-remote-get-url-doc' (e9496f8)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006, Shawn O. Pearce
   4#
   5# Cleanup unreachable files and optimize the repository.
   6
   7USAGE='[--prune]'
   8SUBDIRECTORY_OK=Yes
   9. git-sh-setup
  10
  11no_prune=:
  12while test $# != 0
  13do
  14        case "$1" in
  15        --prune)
  16                no_prune=
  17                ;;
  18        --)
  19                usage
  20                ;;
  21        esac
  22        shift
  23done
  24
  25case "$(git config --get gc.packrefs)" in
  26notbare|"")
  27        test $(is_bare_repository) = true || pack_refs=true;;
  28*)
  29        pack_refs=$(git config --bool --get gc.packrefs)
  30esac
  31
  32test "true" != "$pack_refs" ||
  33git pack-refs --prune &&
  34git reflog expire --all &&
  35git-repack -a -d -l &&
  36$no_prune git prune &&
  37git rerere gc || exit