Code

Merge branch 'sp/maint-index-pack'
[git.git] / git-repack.sh
index a0e06ed0768f65241b59cfdec7b0f6b833580c53..8c3bc134add87f38a764f24c63b9e09f562ad6b1 100755 (executable)
@@ -8,9 +8,10 @@ OPTIONS_SPEC="\
 git-repack [options]
 --
 a               pack everything in a single pack
-A               same as -a, and keep unreachable objects too
+A               same as -a, and turn unreachable objects loose
 d               remove redundant packs, and run git-prune-packed
 f               pass --no-reuse-delta to git-pack-objects
+n               do not run git-update-server-info
 q,quiet         be quiet
 l               pass --local to git-pack-objects
  Packing constraints
@@ -22,7 +23,7 @@ max-pack-size=  maximum size of each packfile
 SUBDIRECTORY_OK='Yes'
 . git-sh-setup
 
-no_update_info= all_into_one= remove_redundant= keep_unreachable=
+no_update_info= all_into_one= remove_redundant= unpack_unreachable=
 local= quiet= no_reuse= extra=
 while test $# != 0
 do
@@ -30,7 +31,7 @@ do
        -n)     no_update_info=t ;;
        -a)     all_into_one=t ;;
        -A)     all_into_one=t
-               keep_unreachable=t ;;
+               unpack_unreachable=--unpack-unreachable ;;
        -d)     remove_redundant=t ;;
        -q)     quiet=-q ;;
        -f)     no_reuse=--no-reuse-object ;;
@@ -43,11 +44,7 @@ do
        shift
 done
 
-# Later we will default repack.UseDeltaBaseOffset to true
-default_dbo=false
-
-case "`git config --bool repack.usedeltabaseoffset ||
-       echo $default_dbo`" in
+case "`git config --bool repack.usedeltabaseoffset || echo true`" in
 true)
        extra="$extra --delta-base-offset" ;;
 esac
@@ -78,6 +75,9 @@ case ",$all_into_one," in
        if test -z "$args"
        then
                args='--unpacked --incremental'
+       elif test -n "$unpack_unreachable"
+       then
+               args="$args $unpack_unreachable"
        fi
        ;;
 esac
@@ -121,24 +121,12 @@ then
        # We know $existing are all redundant.
        if [ -n "$existing" ]
        then
-               sync
                ( cd "$PACKDIR" &&
                  for e in $existing
                  do
                        case " $fullbases " in
                        *" $e "*) ;;
-                       *)
-                               rm -f "$e.idx" "$e.keep"
-                               if test -n "$keep_unreachable" &&
-                                  test -f "$e.pack"
-                               then
-                                       git unpack-objects < "$e.pack" || {
-                                               echo >&2 "Failed unpacking unreachable objects from redundant pack file $e.pack"
-                                               exit 1
-                                       }
-                               fi
-                               rm -f "$e.pack"
-                       ;;
+                       *)      rm -f "$e.pack" "$e.idx" "$e.keep" ;;
                        esac
                  done
                )