Code

Merge branch 'jn/diffstat-tests'
[git.git] / git-repack.sh
index 0868734723b3c96144bfa9360a9e19ebae1995f7..624feec26f66b15926ffa11767c146222bc9a185 100755 (executable)
@@ -10,7 +10,8 @@ git repack [options]
 a               pack everything in a single pack
 A               same as -a, and turn unreachable objects loose
 d               remove redundant packs, and run git-prune-packed
-f               pass --no-reuse-object to git-pack-objects
+f               pass --no-reuse-delta to git-pack-objects
+F               pass --no-reuse-object to git-pack-objects
 n               do not run git-update-server-info
 q,quiet         be quiet
 l               pass --local to git-pack-objects
@@ -24,7 +25,7 @@ SUBDIRECTORY_OK='Yes'
 . git-sh-setup
 
 no_update_info= all_into_one= remove_redundant= unpack_unreachable=
-local= quiet= no_reuse= extra=
+local= no_reuse= extra=
 while test $# != 0
 do
        case "$1" in
@@ -33,8 +34,9 @@ do
        -A)     all_into_one=t
                unpack_unreachable=--unpack-unreachable ;;
        -d)     remove_redundant=t ;;
-       -q)     quiet=-q ;;
-       -f)     no_reuse=--no-reuse-object ;;
+       -q)     GIT_QUIET=t ;;
+       -f)     no_reuse=--no-reuse-delta ;;
+       -F)     no_reuse=--no-reuse-object ;;
        -l)     local=--local ;;
        --max-pack-size|--window|--window-memory|--depth)
                extra="$extra $1=$2"; shift ;;
@@ -50,7 +52,7 @@ true)
 esac
 
 PACKDIR="$GIT_OBJECT_DIRECTORY/pack"
-PACKTMP="$GIT_OBJECT_DIRECTORY/.tmp-$$-pack"
+PACKTMP="$PACKDIR/.tmp-$$-pack"
 rm -f "$PACKTMP"-*
 trap 'rm -f "$PACKTMP"-*' 0 1 2 3 15
 
@@ -80,17 +82,16 @@ case ",$all_into_one," in
        ;;
 esac
 
-args="$args $local $quiet $no_reuse$extra"
-names=$(git pack-objects --honor-pack-keep --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
+mkdir -p "$PACKDIR" || exit
+
+args="$args $local ${GIT_QUIET:+-q} $no_reuse$extra"
+names=$(git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
        exit 1
 if [ -z "$names" ]; then
-       if test -z "$quiet"; then
-               echo Nothing new to pack.
-       fi
+       say Nothing new to pack.
 fi
 
 # Ok we have prepared all new packfiles.
-mkdir -p "$PACKDIR" || exit
 
 # First see if there are packs of the same name and if so
 # if we can move them out of the way (this can happen if we
@@ -176,7 +177,7 @@ then
                  done
                )
        fi
-       git prune-packed $quiet
+       git prune-packed ${GIT_QUIET:+-q}
 fi
 
 case "$no_update_info" in