Code

gitweb: Secure against commit-ish/tree-ish with the same name as path
[git.git] / git-repack.sh
index b525fc5dfd9053a6fb63a4d38517e25e75341199..17e24526c279467891389295a55f8f257ca0d01b 100755 (executable)
@@ -3,7 +3,8 @@
 # Copyright (c) 2005 Linus Torvalds
 #
 
-USAGE='[-a] [-d] [-f] [-l] [-n] [-q]'
+USAGE='[-a] [-d] [-f] [-l] [-n] [-q] [--window=N] [--depth=N]'
+SUBDIRECTORY_OK='Yes'
 . git-sh-setup
 
 no_update_info= all_into_one= remove_redundant=
@@ -24,6 +25,15 @@ do
        shift
 done
 
+# Later we will default repack.UseDeltaBaseOffset to true
+default_dbo=false
+
+case "`git repo-config --bool repack.usedeltabaseoffset ||
+       echo $default_dbo`" in
+true)
+       extra="$extra --delta-base-offset" ;;
+esac
+
 PACKDIR="$GIT_OBJECT_DIRECTORY/pack"
 PACKTMP="$GIT_DIR/.tmp-$$-pack"
 rm -f "$PACKTMP"-*
@@ -32,12 +42,10 @@ trap 'rm -f "$PACKTMP"-*' 0 1 2 3 15
 # There will be more repacking strategies to come...
 case ",$all_into_one," in
 ,,)
-       rev_list='--unpacked'
-       pack_objects='--incremental'
+       args='--unpacked --incremental'
        ;;
 ,t,)
-       rev_list=
-       pack_objects=
+       args=
 
        # Redundancy check in all-into-one case is trivial.
        existing=`test -d "$PACKDIR" && cd "$PACKDIR" && \
@@ -45,11 +53,8 @@ case ",$all_into_one," in
        ;;
 esac
 
-pack_objects="$pack_objects $local $quiet $no_reuse_delta$extra"
-name=$( { git-rev-list --objects --all $rev_list ||
-         echo "git-rev-list died with exit code $?"
-       } |
-       git-pack-objects --non-empty $pack_objects "$PACKTMP") ||
+args="$args $local $quiet $no_reuse_delta$extra"
+name=$(git-pack-objects --non-empty --all $args </dev/null "$PACKTMP") ||
        exit 1
 if [ -z "$name" ]; then
        echo Nothing new to pack.