Merge branch 'jk/pack-shallow-always-without-bitmap'
authorJunio C Hamano <gitster@pobox.com>
Tue, 26 Aug 2014 18:16:25 +0000 (11:16 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 Aug 2014 18:16:25 +0000 (11:16 -0700)
Reachability bitmaps do not work with shallow operations.
Fixes regression in 2.0.

* jk/pack-shallow-always-without-bitmap:
pack-objects: turn off bitmaps when we see --shallow lines

builtin/pack-objects.c
t/t5311-pack-bitmaps-shallow.sh [new file with mode: 0755]
index 238b5021eb105007a42061d5f8febc455530da45..b59f5d895e38bdb96d19b5fc5061669facdf22cc 100644 (file)
@@ -2494,6 +2494,7 @@ static void get_object_list(int ac, const char **av)
                                if (get_sha1_hex(line + 10, sha1))
                                        die("not an SHA-1 '%s'", line + 10);
                                register_shallow(sha1);
+                               use_bitmap_index = 0;
                                continue;
                        }
                        die("not a rev '%s'", line);
diff --git a/t/t5311-pack-bitmaps-shallow.sh b/t/t5311-pack-bitmaps-shallow.sh
new file mode 100755 (executable)
index 0000000..872a95d
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+test_description='check bitmap operation with shallow repositories'
+. ./test-lib.sh
+
+# We want to create a situation where the shallow, grafted
+# view of reachability does not match reality in a way that
+# might cause us to send insufficient objects.
+#
+# We do this with a history that repeats a state, like:
+#
+#      A    --   B    --   C
+#    file=1    file=2    file=1
+#
+# and then create a shallow clone to the second commit, B.
+# In a non-shallow clone, that would mean we already have
+# the tree for A. But in a shallow one, we've grafted away
+# A, and fetching A to B requires that the other side send
+# us the tree for file=1.
+test_expect_success 'setup shallow repo' '
+       echo 1 >file &&
+       git add file &&
+       git commit -m orig &&
+       echo 2 >file &&
+       git commit -a -m update &&
+       git clone --no-local --bare --depth=1 . shallow.git &&
+       echo 1 >file &&
+       git commit -a -m repeat
+'
+
+test_expect_success 'turn on bitmaps in the parent' '
+       git repack -adb
+'
+
+test_expect_success 'shallow fetch from bitmapped repo' '
+       (cd shallow.git && git fetch)
+'
+
+test_done