Merge branch 'maint-1.6.1' into maint-1.6.2
authorJunio C Hamano <gitster@pobox.com>
Sat, 8 Aug 2009 03:44:09 +0000 (20:44 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 8 Aug 2009 03:44:09 +0000 (20:44 -0700)
* maint-1.6.1:
verify-pack -v: do not report "chain length 0"
t5510: harden the way verify-pack is used

1  2 
builtin-verify-pack.c
t/t5510-fetch.sh
diff --combined builtin-verify-pack.c
index 0ee0a9af60b0601fe0e6db98ec582e059f5e9064,e8fd68bfac024ebc2d994fb743d965faed2c5595..a18df04cf94c5a9720f8ccc3346f1dc5077eb692
@@@ -7,10 -7,13 +7,13 @@@
  
  static void show_pack_info(struct packed_git *p)
  {
-       uint32_t nr_objects, i, chain_histogram[MAX_CHAIN+1];
+       uint32_t nr_objects, i;
+       int cnt;
+       unsigned long chain_histogram[MAX_CHAIN+1], baseobjects;
  
        nr_objects = p->num_objects;
        memset(chain_histogram, 0, sizeof(chain_histogram));
+       baseobjects = 0;
  
        for (i = 0; i < nr_objects; i++) {
                const unsigned char *sha1;
                                                 &delta_chain_length,
                                                 base_sha1);
                printf("%s ", sha1_to_hex(sha1));
-               if (!delta_chain_length)
+               if (!delta_chain_length) {
                        printf("%-6s %lu %lu %"PRIuMAX"\n",
                               type, size, store_size, (uintmax_t)offset);
+                       baseobjects++;
+               }
                else {
                        printf("%-6s %lu %lu %"PRIuMAX" %u %s\n",
                               type, size, store_size, (uintmax_t)offset,
                }
        }
  
-       for (i = 0; i <= MAX_CHAIN; i++) {
-               if (!chain_histogram[i])
+       if (baseobjects)
+               printf("non delta: %lu object%s\n",
+                      baseobjects, baseobjects > 1 ? "s" : "");
+       for (cnt = 1; cnt <= MAX_CHAIN; cnt++) {
+               if (!chain_histogram[cnt])
                        continue;
-               printf("chain length = %"PRIu32": %"PRIu32" object%s\n", i,
-                      chain_histogram[i], chain_histogram[i] > 1 ? "s" : "");
+               printf("chain length = %d: %lu object%s\n", cnt,
+                      chain_histogram[cnt],
+                      chain_histogram[cnt] > 1 ? "s" : "");
        }
        if (chain_histogram[0])
-               printf("chain length > %d: %"PRIu32" object%s\n", MAX_CHAIN,
-                      chain_histogram[0], chain_histogram[0] > 1 ? "s" : "");
+               printf("chain length > %d: %lu object%s\n", MAX_CHAIN,
+                      chain_histogram[0],
+                      chain_histogram[0] > 1 ? "s" : "");
  }
  
  static int verify_one_pack(const char *path, int verbose)
        return err;
  }
  
 -static const char verify_pack_usage[] = "git-verify-pack [-v] <pack>...";
 +static const char verify_pack_usage[] = "git verify-pack [-v] <pack>...";
  
  int cmd_verify_pack(int argc, const char **argv, const char *prefix)
  {
diff --combined t/t5510-fetch.sh
index bee3424fed770aacac6dbcdf4ba58bfd7bf5c2da,b2e6e96b3f928c5ca66589e4e24f28eeeaf176c5..d13c806624bcc8a404be97d61500e8e1d4614c6b
@@@ -9,6 -9,11 +9,11 @@@ test_description='Per branch config var
  
  D=`pwd`
  
+ test_bundle_object_count () {
+       git verify-pack -v "$1" >verify.out &&
+       test "$2" = $(grep '^[0-9a-f]\{40\} ' verify.out | wc -l)
+ }
  test_expect_success setup '
        echo >file original &&
        git add file &&
@@@ -146,6 -151,7 +151,7 @@@ test_expect_success 'unbundle 1' 
        test_must_fail git fetch "$D/bundle1" master:master
  '
  
  test_expect_success 'bundle 1 has only 3 files ' '
        cd "$D" &&
        (
                cat
        ) <bundle1 >bundle.pack &&
        git index-pack bundle.pack &&
-       verify=$(git verify-pack -v bundle.pack) &&
-       test 4 = $(echo "$verify" | wc -l)
+       test_bundle_object_count bundle.pack 3
  '
  
  test_expect_success 'unbundle 2' '
@@@ -180,7 -185,7 +185,7 @@@ test_expect_success 'bundle does not pr
                cat
        ) <bundle3 >bundle.pack &&
        git index-pack bundle.pack &&
-       test 4 = $(git verify-pack -v bundle.pack | wc -l)
+       test_bundle_object_count bundle.pack 3
  '
  
  test_expect_success 'bundle should be able to create a full history' '
  
  '
  
 -test "$TEST_RSYNC" && {
 +! rsync --help > /dev/null 2> /dev/null &&
 +say 'Skipping rsync tests because rsync was not found' || {
  test_expect_success 'fetch via rsync' '
        git pack-refs &&
        mkdir rsynced &&
 -      cd rsynced &&
 -      git init &&
 -      git fetch rsync://127.0.0.1$(pwd)/../.git master:refs/heads/master &&
 -      git gc --prune &&
 -      test $(git rev-parse master) = $(cd .. && git rev-parse master) &&
 -      git fsck --full
 +      (cd rsynced &&
 +       git init --bare &&
 +       git fetch "rsync:$(pwd)/../.git" master:refs/heads/master &&
 +       git gc --prune &&
 +       test $(git rev-parse master) = $(cd .. && git rev-parse master) &&
 +       git fsck --full)
  '
  
  test_expect_success 'push via rsync' '
 -      mkdir ../rsynced2 &&
 -      (cd ../rsynced2 &&
 +      mkdir rsynced2 &&
 +      (cd rsynced2 &&
         git init) &&
 -      git push rsync://127.0.0.1$(pwd)/../rsynced2/.git master &&
 -      cd ../rsynced2 &&
 -      git gc --prune &&
 -      test $(git rev-parse master) = $(cd .. && git rev-parse master) &&
 -      git fsck --full
 +      (cd rsynced &&
 +       git push "rsync:$(pwd)/../rsynced2/.git" master) &&
 +      (cd rsynced2 &&
 +       git gc --prune &&
 +       test $(git rev-parse master) = $(cd .. && git rev-parse master) &&
 +       git fsck --full)
  '
  
  test_expect_success 'push via rsync' '
 -      cd .. &&
        mkdir rsynced3 &&
        (cd rsynced3 &&
         git init) &&
 -      git push --all rsync://127.0.0.1$(pwd)/rsynced3/.git &&
 -      cd rsynced3 &&
 -      test $(git rev-parse master) = $(cd .. && git rev-parse master) &&
 -      git fsck --full
 +      git push --all "rsync:$(pwd)/rsynced3/.git" &&
 +      (cd rsynced3 &&
 +       test $(git rev-parse master) = $(cd .. && git rev-parse master) &&
 +       git fsck --full)
  '
  }