oneway_merge(): only lstat() when told to update worktree
[gitweb.git] / git-repack.sh
index 1eb3bca352f38ec3807383cc5fff7f7e62731b2b..757933174e4c17136f14a1fdd7c8c67c0a8bca50 100755 (executable)
@@ -10,10 +10,12 @@ 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
+unpack-unreachable=  with -A, do not loosen objects older than this
  Packing constraints
 window=         size of the window used for delta compression
 window-memory=  same as the above, but limit memory size instead of entries count
@@ -32,9 +34,12 @@ do
        -a)     all_into_one=t ;;
        -A)     all_into_one=t
                unpack_unreachable=--unpack-unreachable ;;
+       --unpack-unreachable)
+               unpack_unreachable="--unpack-unreachable=$2"; shift ;;
        -d)     remove_redundant=t ;;
        -q)     GIT_QUIET=t ;;
-       -f)     no_reuse=--no-reuse-object ;;
+       -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 +55,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
 
@@ -74,12 +79,19 @@ case ",$all_into_one," in
                if test -n "$existing" -a -n "$unpack_unreachable" -a \
                        -n "$remove_redundant"
                then
-                       args="$args $unpack_unreachable"
+                       # This may have arbitrary user arguments, so we
+                       # have to protect it against whitespace splitting
+                       # when it gets run as "pack-objects $args" later.
+                       # Fortunately, we know it's an approxidate, so we
+                       # can just use dots instead.
+                       args="$args $(echo "$unpack_unreachable" | tr ' ' .)"
                fi
        fi
        ;;
 esac
 
+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
@@ -88,7 +100,6 @@ if [ -z "$names" ]; then
 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