threads / patch / 10725

patch, 3 partsgit-fetch: test avoiding unnecessary copying from alternates

Subject: [PATCH 4/3] git-fetch: test avoiding unnecessary copying from alternates

## tl;dr

2 messages between Nov 8, 2007 and Nov 8, 2007. Diffs are folded; open one to read it.

replies: 1people: 1as markdown or json

Shawn O. Pearce· Nov 8, 2007, 08:22 UTC · lore

This test verifies my prior "avoid local fetching from alternate" patch is functional and doesn't regress in the future during any additional improvements made to git.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 t/t5502-quickfetch.sh |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
Show changes to t/t5502-quickfetch.sh +33 −0
diff --git a/t/t5502-quickfetch.sh b/t/t5502-quickfetch.sh
index b4760f2..16eadd6 100755
--- a/t/t5502-quickfetch.sh
+++ b/t/t5502-quickfetch.sh
@@ -86,4 +86,37 @@ test_expect_success 'quickfetch should not leave a corrupted repository' '
 
 '
 
+test_expect_success 'quickfetch should not copy from alternate' '
+
+	(
+		mkdir quickclone &&
+		cd quickclone &&
+		git init-db &&
+		(cd ../.git/objects && pwd) >.git/objects/info/alternates &&
+		git remote add origin .. &&
+		git fetch -k -k
+	) &&
+	obj_cnt=$( (
+		cd quickclone &&
+		git count-objects | sed -e "s/ *objects,.*//"
+	) ) &&
+	pck_cnt=$( (
+		cd quickclone &&
+		git count-objects -v | sed -n -e "/packs:/{
+				s/packs://
+				p
+				q
+			}"
+	) ) &&
+	origin_master=$( (
+		cd quickclone &&
+		git rev-parse origin/master
+	) ) &&
+	echo "loose objects: $obj_cnt, packfiles: $pck_cnt" &&
+	test $obj_cnt -eq 0 &&
+	test $pck_cnt -eq 0 &&
+	test z$origin_master = z$(git rev-parse master)
+
+'
+
 test_done
-- 
1.5.3.5.1590.gfadfad
Shawn O. Pearce· Nov 8, 2007, 08:34 UTC · re: Shawn O. Pearce · lore

Re: [PATCH 4/3] git-fetch: test avoiding unnecessary copying from alternates

"Shawn O. Pearce" <spearce@spearce.org> wrote:
> This test verifies my prior "avoid local fetching from alternate"
> patch is functional and doesn't regress in the future during any
> additional improvements made to git.
...
Show 9 quoted lines
> +test_expect_success 'quickfetch should not copy from alternate' '
> +
> +	(
> +		mkdir quickclone &&
> +		cd quickclone &&
> +		git init-db &&
> +		(cd ../.git/objects && pwd) >.git/objects/info/alternates &&
> +		git remote add origin .. &&
> +		git fetch -k -k

Hmmph. On second thought I think this is a little sketchy for a test. Versions without my quickfetch patch fail this test and versions with it pass. But it depends on the implementation of `-k -k` to always call index-pack over unpack-objects.

I'm using -k -k here to ensure we keep the pack fetched as we're only fetching 6 objects and they are already reachable in the quickclone repository thanks to the alternate ODB. If we use unpack-objects during this fetch we will still pass this test because the objects won't be unpacked if they are already reachable locally.

Of course this test is for a performance optimization. For 6 tiny objects it really doesn't matter if we copy them or not, or if we copy them over a pipe only to discard them because they are already reachable. It does however matter when you are talking about nearly 300MB worth of objects. :-\

-- 
Shawn.

← back to recent threads