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