git-repack.shon commit Do not show .exe in git command list. (f9039f3)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Linus Torvalds
   4#
   5
   6. git-sh-setup || die "Not a git archive"
   7        
   8no_update_info= all_into_one= remove_redundant= local=
   9while case "$#" in 0) break ;; esac
  10do
  11        case "$1" in
  12        -n)     no_update_info=t ;;
  13        -a)     all_into_one=t ;;
  14        -d)     remove_redundant=t ;;
  15        -l)     local=t ;;
  16        *)      break ;;
  17        esac
  18        shift
  19done
  20
  21rm -f .tmp-pack-*
  22PACKDIR="$GIT_OBJECT_DIRECTORY/pack"
  23
  24# There will be more repacking strategies to come...
  25case ",$all_into_one," in
  26,,)
  27        rev_list='--unpacked'
  28        rev_parse='--all'
  29        pack_objects='--incremental'
  30        ;;
  31,t,)
  32        rev_list=
  33        rev_parse='--all'
  34        pack_objects=
  35        ;;
  36esac
  37if [ "$local" ]; then
  38        pack_objects="$pack_objects --local"
  39fi
  40name=$(git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) |
  41        git-pack-objects --non-empty $pack_objects .tmp-pack) ||
  42        exit 1
  43if [ -z "$name" ]; then
  44        echo Nothing new to pack.
  45        if test "$remove_redundant" = t ; then
  46                echo "Removing redundant packs."
  47                sync
  48                redundant=$(git-pack-redundant --all)
  49                if test "$redundant" != "" ; then
  50                        echo $redundant | xargs rm
  51                fi
  52        fi
  53        exit 0
  54fi
  55echo "Pack pack-$name created."
  56
  57mkdir -p "$PACKDIR" || exit
  58
  59mv .tmp-pack-$name.pack "$PACKDIR/pack-$name.pack" &&
  60mv .tmp-pack-$name.idx  "$PACKDIR/pack-$name.idx" ||
  61exit
  62
  63if test "$remove_redundant" = t
  64then
  65        sync
  66        if test "$all_into_one" = t
  67        then
  68                cd "$PACKDIR"
  69                existing=`find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
  70                for e in $existing
  71                do
  72                        case "$e" in
  73                        ./pack-$name.pack | ./pack-$name.idx) ;;
  74                        *)      rm -f $e ;;
  75                        esac
  76                done
  77        else
  78                redundant=$(git-pack-redundant --all)
  79                if test "$redundant" != "" ; then
  80                        echo $redundant | xargs rm
  81                fi
  82        fi
  83fi
  84
  85case "$no_update_info" in
  86t) : ;;
  87*) git-update-server-info ;;
  88esac