Merge branch 'maint'
authorJunio C Hamano <junkio@cox.net>
Thu, 24 May 2007 05:37:23 +0000 (22:37 -0700)
committerJunio C Hamano <junkio@cox.net>
Thu, 24 May 2007 05:37:23 +0000 (22:37 -0700)
* maint:
Fix possible coredump with fast-import --import-marks
Refactor fast-import branch creation from existing commit
fast-import: Fix crash when referencing already existing objects
fast-import: Fix uninitialized variable
Documentation: fix git-config.xml generation

1  2 
Documentation/config.txt
fast-import.c
diff --combined Documentation/config.txt
index eb2e79ae2f793e61dcfe096ffbeb591b62b7de94,fdb71de9f6c4f508996ccdf7970522ba53bb0dfe..3d8f03dfe54f5aff199f04b1bf1992d9b75916fa
@@@ -204,16 -204,23 +204,16 @@@ core.warnAmbiguousRefs:
        and might match multiple refs in the .git/refs/ tree. True by default.
  
  core.compression::
 +      An integer -1..9, indicating a default compression level.
 +      -1 is the zlib default. 0 means no compression,
 +      and 1..9 are various speed/size tradeoffs, 9 being slowest.
 +
 +core.loosecompression::
        An integer -1..9, indicating the compression level for objects that
 -      are not in a pack file. -1 is the zlib and git default. 0 means no
 +      are not in a pack file. -1 is the zlib default. 0 means no
        compression, and 1..9 are various speed/size tradeoffs, 9 being
 -      slowest.
 -
 -core.legacyheaders::
 -      A boolean which
 -      changes the format of loose objects so that they are more
 -      efficient to pack and to send out of the repository over git
 -      native protocol, since v1.4.2.  However, loose objects
 -      written in the new format cannot be read by git older than
 -      that version; people fetching from your repository using
 -      older versions of git over dumb transports (e.g. http)
 -      will also be affected.
 -+
 -To let git use the new loose object format, you have to
 -set core.legacyheaders to false.
 +      slowest.  If not set,  defaults to core.compression.  If that is
 +      not set,  defaults to 0 (best speed).
  
  core.packedGitWindowSize::
        Number of bytes of a pack file to map into memory in a
@@@ -281,7 -288,7 +281,7 @@@ apply.whitespace:
        as the '--whitespace' option. See gitlink:git-apply[1].
  
  branch.autosetupmerge::
-       Tells `git-branch' and `git-checkout' to setup new branches
+       Tells `git-branch` and `git-checkout` to setup new branches
        so that gitlink:git-pull[1] will appropriately merge from that
        remote branch.  Note that even if this option is not set,
        this behavior can be chosen per-branch using the `--track`
@@@ -389,11 -396,6 +389,11 @@@ format.suffix:
        `.patch`. Use this variable to change that suffix (make sure to
        include the dot if you want it).
  
 +gc.aggressiveWindow::
 +      The window size parameter used in the delta compression
 +      algorithm used by 'git gc --aggressive'.  This defaults
 +      to 10.
 +
  gc.packrefs::
        `git gc` does not run `git pack-refs` in a bare repository by
        default so that older dumb-transport clients can still fetch
@@@ -560,13 -562,6 +560,13 @@@ pack.depth:
        The maximum delta depth used by gitlink:git-pack-objects[1] when no
        maximum depth is given on the command line. Defaults to 50.
  
 +pack.compression::
 +      An integer -1..9, indicating the compression level for objects
 +      in a pack file. -1 is the zlib default. 0 means no
 +      compression, and 1..9 are various speed/size tradeoffs, 9 being
 +      slowest.  If not set,  defaults to core.compression.  If that is
 +      not set,  defaults to -1.
 +
  pull.octopus::
        The default merge strategy to use when pulling multiple branches
        at once.
diff --combined fast-import.c
index ffa00fd3c673f01a72676ea7cd2511b229aa2353,17554f68493a8409c64b47334a94e622d47d8133..f9bfcc72c87bf79fcb7a5faef01bc0d12aa15420
@@@ -1013,7 -1013,7 +1013,7 @@@ static void load_tree(struct tree_entr
                return;
  
        myoe = find_object(sha1);
-       if (myoe) {
+       if (myoe && myoe->pack_id != MAX_PACK_ID) {
                if (myoe->type != OBJ_TREE)
                        die("Not a tree: %s", sha1_to_hex(sha1));
                t->delta_depth = 0;
@@@ -1122,6 -1122,7 +1122,7 @@@ static void store_tree(struct tree_entr
                || le->pack_id != pack_id) {
                lo.data = NULL;
                lo.depth = 0;
+               lo.no_free = 0;
        } else {
                mktree(t, 0, &lo.len, &old_tree);
                lo.data = old_tree.buffer;
@@@ -1271,7 -1272,7 +1272,7 @@@ static int update_branch(struct branch 
  
        if (read_ref(b->name, old_sha1))
                hashclr(old_sha1);
 -      lock = lock_any_ref_for_update(b->name, old_sha1);
 +      lock = lock_any_ref_for_update(b->name, old_sha1, 0);
        if (!lock)
                return error("Unable to lock %s", b->name);
        if (!force_update && !is_null_sha1(old_sha1)) {
@@@ -1656,6 -1657,33 +1657,33 @@@ static void file_change_deleteall(struc
        load_tree(&b->branch_tree);
  }
  
+ static void cmd_from_commit(struct branch *b, char *buf, unsigned long size)
+ {
+       if (!buf || size < 46)
+               die("Not a valid commit: %s", sha1_to_hex(b->sha1));
+       if (memcmp("tree ", buf, 5)
+               || get_sha1_hex(buf + 5, b->branch_tree.versions[1].sha1))
+               die("The commit %s is corrupt", sha1_to_hex(b->sha1));
+       hashcpy(b->branch_tree.versions[0].sha1,
+               b->branch_tree.versions[1].sha1);
+ }
+ static void cmd_from_existing(struct branch *b)
+ {
+       if (is_null_sha1(b->sha1)) {
+               hashclr(b->branch_tree.versions[0].sha1);
+               hashclr(b->branch_tree.versions[1].sha1);
+       } else {
+               unsigned long size;
+               char *buf;
+               buf = read_object_with_reference(b->sha1,
+                       commit_type, &size, b->sha1);
+               cmd_from_commit(b, buf, size);
+               free(buf);
+       }
+ }
  static void cmd_from(struct branch *b)
  {
        const char *from;
        } else if (*from == ':') {
                uintmax_t idnum = strtoumax(from + 1, NULL, 10);
                struct object_entry *oe = find_mark(idnum);
-               unsigned long size;
-               char *buf;
                if (oe->type != OBJ_COMMIT)
                        die("Mark :%" PRIuMAX " not a commit", idnum);
                hashcpy(b->sha1, oe->sha1);
-               buf = gfi_unpack_entry(oe, &size);
-               if (!buf || size < 46)
-                       die("Not a valid commit: %s", from);
-               if (memcmp("tree ", buf, 5)
-                       || get_sha1_hex(buf + 5, b->branch_tree.versions[1].sha1))
-                       die("The commit %s is corrupt", sha1_to_hex(b->sha1));
-               free(buf);
-               hashcpy(b->branch_tree.versions[0].sha1,
-                       b->branch_tree.versions[1].sha1);
-       } else if (!get_sha1(from, b->sha1)) {
-               if (is_null_sha1(b->sha1)) {
-                       hashclr(b->branch_tree.versions[0].sha1);
-                       hashclr(b->branch_tree.versions[1].sha1);
-               } else {
+               if (oe->pack_id != MAX_PACK_ID) {
                        unsigned long size;
-                       char *buf;
-                       buf = read_object_with_reference(b->sha1,
-                               commit_type, &size, b->sha1);
-                       if (!buf || size < 46)
-                               die("Not a valid commit: %s", from);
-                       if (memcmp("tree ", buf, 5)
-                               || get_sha1_hex(buf + 5, b->branch_tree.versions[1].sha1))
-                               die("The commit %s is corrupt", sha1_to_hex(b->sha1));
+                       char *buf = gfi_unpack_entry(oe, &size);
+                       cmd_from_commit(b, buf, size);
                        free(buf);
-                       hashcpy(b->branch_tree.versions[0].sha1,
-                               b->branch_tree.versions[1].sha1);
-               }
-       } else
+               } else
+                       cmd_from_existing(b);
+       } else if (!get_sha1(from, b->sha1))
+               cmd_from_existing(b);
+       else
                die("Invalid ref name or SHA1 expression: %s", from);
  
        read_next_command();