Merge branch 'mk/unpack-careful'
authorJunio C Hamano <gitster@pobox.com>
Wed, 9 Apr 2008 07:44:17 +0000 (00:44 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 9 Apr 2008 07:44:17 +0000 (00:44 -0700)
* mk/unpack-careful:
t5300: add test for "index-pack --strict"
receive-pack: allow using --strict mode for unpacking objects
unpack-objects: fix --strict handling
t5300: add test for "unpack-objects --strict"
unpack-objects: prevent writing of inconsistent objects

1  2 
Documentation/config.txt
t/t5300-pack-object.sh
diff --combined Documentation/config.txt
index 04c01c5fdca566b1760e8eed02687607017e89aa,74a092c5e85c91fd4724fbbbab76226e22f325c5..fe43b12572fcb1a0b4b91972d2d504b2b594a4da
@@@ -420,11 -420,6 +420,11 @@@ branch.<name>.rebase:
        it unless you understand the implications (see linkgit:git-rebase[1]
        for details).
  
 +browser.<tool>.cmd::
 +      Specify the command to invoke the specified browser. The
 +      specified command is evaluated in shell with the URLs passed
 +      as arguments. (See linkgit:git-web--browse[1].)
 +
  browser.<tool>.path::
        Override the path for the given tool that may be used to
        browse HTML help (see '-w' option in linkgit:git-help[1]) or a
@@@ -561,11 -556,6 +561,11 @@@ format.suffix:
        `.patch`. Use this variable to change that suffix (make sure to
        include the dot if you want it).
  
 +format.pretty::
 +      The default pretty format for log/show/whatchanged command,
 +      See linkgit:git-log[1], linkgit:git-show[1],
 +      linkgit:git-whatchanged[1].
 +
  gc.aggressiveWindow::
        The window size parameter used in the delta compression
        algorithm used by 'git gc --aggressive'.  This defaults
@@@ -582,7 -572,7 +582,7 @@@ gc.autopacklimit:
        When there are more than this many packs that are not
        marked with `*.keep` file in the repository, `git gc
        --auto` consolidates them into one larger pack.  The
 -      default value is 20.  Setting this to 0 disables it.
 +      default value is 50.  Setting this to 0 disables it.
  
  gc.packrefs::
        `git gc` does not run `git pack-refs` in a bare repository by
        at some stage, and setting this to `false` will continue to
        prevent `git pack-refs` from being run from `git gc`.
  
 +gc.pruneexpire::
 +      When `git gc` is run, it will call `prune --expire 2.weeks.ago`.
 +      Override the grace period with this config variable.
 +
  gc.reflogexpire::
        `git reflog expire` removes reflog entries older than
        this time; defaults to 90 days.
@@@ -661,13 -647,6 +661,13 @@@ gitcvs.dbuser, gitcvs.dbpass:
        'gitcvs.dbuser' supports variable substitution (see
        linkgit:git-cvsserver[1] for details).
  
 +gitcvs.dbTableNamePrefix::
 +      Database table name prefix.  Prepended to the names of any
 +      database tables used, allowing a single database to be used
 +      for several repositories.  Supports variable substitution (see
 +      linkgit:git-cvsserver[1] for details).  Any non-alphabetic
 +      characters will be replaced with underscores.
 +
  All gitcvs variables except for 'gitcvs.allbinary' can also be
  specified as 'gitcvs.<access_method>.<varname>' (where 'access_method'
  is one of "ext" and "pserver") to make them apply only for the given
@@@ -764,20 -743,14 +764,20 @@@ log.showroot:
        Tools like linkgit:git-log[1] or linkgit:git-whatchanged[1], which
        normally hide the root commit will now show it. True by default.
  
 +man.viewer::
 +      Specify the programs that may be used to display help in the
 +      'man' format. See linkgit:git-help[1].
 +
  merge.summary::
        Whether to include summaries of merged commits in newly created
        merge commit messages. False by default.
  
  merge.tool::
        Controls which merge resolution program is used by
 -      linkgit:git-mergetool[1].  Valid values are: "kdiff3", "tkdiff",
 -      "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and "opendiff".
 +      linkgit:git-mergetool[1].  Valid built-in values are: "kdiff3",
 +      "tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and
 +      "opendiff".  Any other value is treated is custom merge tool
 +      and there must be a corresponing mergetool.<tool>.cmd option.
  
  merge.verbosity::
        Controls the amount of output shown by the recursive merge
@@@ -804,31 -777,6 +804,31 @@@ mergetool.<tool>.path:
        Override the path for the given tool.  This is useful in case
        your tool is not in the PATH.
  
 +mergetool.<tool>.cmd::
 +      Specify the command to invoke the specified merge tool.  The
 +      specified command is evaluated in shell with the following
 +      variables available: 'BASE' is the name of a temporary file
 +      containing the common base of the files to be merged, if available;
 +      'LOCAL' is the name of a temporary file containing the contents of
 +      the file on the current branch; 'REMOTE' is the name of a temporary
 +      file containing the contents of the file from the branch being
 +      merged; 'MERGED' contains the name of the file to which the merge
 +      tool should write the results of a successful merge.
 +
 +mergetool.<tool>.trustExitCode::
 +      For a custom merge command, specify whether the exit code of
 +      the merge command can be used to determine whether the merge was
 +      successful.  If this is not set to true then the merge target file
 +      timestamp is checked and the merge assumed to have been successful
 +      if the file has been updated, otherwise the user is prompted to
 +      indicate the success of the merge.
 +
 +mergetool.keepBackup::
 +      After performing a merge, the original file with conflict markers
 +      can be saved as a file with a `.orig` extension.  If this variable
 +      is set to `false` then this file is not preserved.  Defaults to
 +      `true` (i.e. keep the backup files).
 +
  pack.window::
        The size of the window used by linkgit:git-pack-objects[1] when no
        window size is given on the command line. Defaults to 10.
@@@ -880,7 -828,7 +880,7 @@@ pack.indexVersion:
        whenever the corresponding pack is larger than 2 GB.  Otherwise
        the default is 1.
  
 -pack.packSizeLimit:
 +pack.packSizeLimit::
        The default maximum size of a pack.  This setting only affects
        packing to a file, i.e. the git:// protocol is unaffected.  It
        can be overridden by the `\--max-pack-size` option of
@@@ -916,15 -864,15 +916,15 @@@ remote.<name>.skipDefaultUpdate:
  
  remote.<name>.receivepack::
        The default program to execute on the remote side when pushing.  See
 -      option \--exec of linkgit:git-push[1].
 +      option \--receive-pack of linkgit:git-push[1].
  
  remote.<name>.uploadpack::
        The default program to execute on the remote side when fetching.  See
 -      option \--exec of linkgit:git-fetch-pack[1].
 +      option \--upload-pack of linkgit:git-fetch-pack[1].
  
  remote.<name>.tagopt::
 -      Setting this value to --no-tags disables automatic tag following when fetching
 -      from remote <name>
 +      Setting this value to \--no-tags disables automatic tag following when
 +      fetching from remote <name>
  
  remotes.<group>::
        The list of remotes which are fetched by "git remote update
@@@ -991,6 -939,12 +991,12 @@@ imap:
        The configuration variables in the 'imap' section are described
        in linkgit:git-imap-send[1].
  
+ receive.fsckObjects::
+       If it is set to true, git-receive-pack will check all received
+       objects. It will abort in the case of a malformed object or a
+       broken link. The result of an abort are only dangling objects.
+       Defaults to false.
  receive.unpackLimit::
        If the number of objects received in a push is below this
        limit then the objects will be unpacked into loose object
diff --combined t/t5300-pack-object.sh
index c955fe44f5b962ef305e49c21bc3fb0e5b58d462,007b136fe64b1afb6b398dd3a2790aeabc2bd127..983a39398f17dc2b261771e780e8c010f038a12a
@@@ -15,7 -15,7 +15,7 @@@ test_expect_success 
      'rm -f .git/index*
       for i in a b c
       do
 -           dd if=/dev/zero bs=4k count=1 | tr "\\000" $i >$i &&
 +           dd if=/dev/zero bs=4k count=1 | perl -pe "y/\\000/$i/" >$i &&
             git update-index --add $i || return 1
       done &&
       cat c >d && echo foo >>d && git update-index --add d &&
@@@ -274,4 -274,99 +274,99 @@@ test_expect_success 
       packname_4=$(git pack-objects test-4 <obj-list) &&
       test 3 = $(ls test-4-*.pack | wc -l)'
  
+ test_expect_success 'unpacking with --strict' '
+       git config --unset pack.packsizelimit &&
+       for j in a b c d e f g
+       do
+               for i in 0 1 2 3 4 5 6 7 8 9
+               do
+                       o=$(echo $j$i | git hash-object -w --stdin) &&
+                       echo "100644 $o 0 $j$i"
+               done
+       done >LIST &&
+       rm -f .git/index &&
+       git update-index --index-info <LIST &&
+       LIST=$(git write-tree) &&
+       rm -f .git/index &&
+       head -n 10 LIST | git update-index --index-info &&
+       LI=$(git write-tree) &&
+       rm -f .git/index &&
+       tail -n 10 LIST | git update-index --index-info &&
+       ST=$(git write-tree) &&
+       PACK5=$( git rev-list --objects "$LIST" "$LI" "$ST" | \
+               git pack-objects test-5 ) &&
+       PACK6=$( (
+                       echo "$LIST"
+                       echo "$LI"
+                       echo "$ST"
+                ) | git pack-objects test-6 ) &&
+       test_create_repo test-5 &&
+       (
+               cd test-5 &&
+               git unpack-objects --strict <../test-5-$PACK5.pack &&
+               git ls-tree -r $LIST &&
+               git ls-tree -r $LI &&
+               git ls-tree -r $ST
+       ) &&
+       test_create_repo test-6 &&
+       (
+               # tree-only into empty repo -- many unreachables
+               cd test-6 &&
+               test_must_fail git unpack-objects --strict <../test-6-$PACK6.pack
+       ) &&
+       (
+               # already populated -- no unreachables
+               cd test-5 &&
+               git unpack-objects --strict <../test-6-$PACK6.pack
+       )
+ '
+ test_expect_success 'index-pack with --strict' '
+       for j in a b c d e f g
+       do
+               for i in 0 1 2 3 4 5 6 7 8 9
+               do
+                       o=$(echo $j$i | git hash-object -w --stdin) &&
+                       echo "100644 $o 0 $j$i"
+               done
+       done >LIST &&
+       rm -f .git/index &&
+       git update-index --index-info <LIST &&
+       LIST=$(git write-tree) &&
+       rm -f .git/index &&
+       head -n 10 LIST | git update-index --index-info &&
+       LI=$(git write-tree) &&
+       rm -f .git/index &&
+       tail -n 10 LIST | git update-index --index-info &&
+       ST=$(git write-tree) &&
+       PACK5=$( git rev-list --objects "$LIST" "$LI" "$ST" | \
+               git pack-objects test-5 ) &&
+       PACK6=$( (
+                       echo "$LIST"
+                       echo "$LI"
+                       echo "$ST"
+                ) | git pack-objects test-6 ) &&
+       test_create_repo test-7 &&
+       (
+               cd test-7 &&
+               git index-pack --strict --stdin <../test-5-$PACK5.pack &&
+               git ls-tree -r $LIST &&
+               git ls-tree -r $LI &&
+               git ls-tree -r $ST
+       ) &&
+       test_create_repo test-8 &&
+       (
+               # tree-only into empty repo -- many unreachables
+               cd test-8 &&
+               test_must_fail git index-pack --strict --stdin <../test-6-$PACK6.pack
+       ) &&
+       (
+               # already populated -- no unreachables
+               cd test-7 &&
+               git index-pack --strict --stdin <../test-6-$PACK6.pack
+       )
+ '
  test_done