Gentoo Archives: gentoo-dev

From: "W. Trevor King" <wking@×××××××.us>
To: "Michał Górny" <mgorny@g.o>
Cc: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Re: My masterplan for git migration (+ looking for infra to test it)
Date: Wed, 17 Sep 2014 17:02:38
Message-Id: 20140917170218.GZ22539@odin.tremily.us
In Reply to: Re: [gentoo-dev] Re: My masterplan for git migration (+ looking for infra to test it) by "Michał Górny"
1 On Wed, Sep 17, 2014 at 10:36:45AM +0200, Michał Górny wrote:
2 > Dnia 2014-09-16, o godz. 10:52:13
3 > W. Trevor King napisał(a):
4 > > $ git pull --depth=1
5 > >
6 > > for subsequent syncs. pym/_emerge/actions.py currently hardcodes
7 > > ‘git pull’ for the latter, and doesn't seem to have any code for
8 > > the former. On the other hand, it wouldn't be too terrible to
9 > > force users to shallow their history manually whenever they felt
10 > > like it.
11 >
12 > This isn't a good idea at all :). For git, --depth=1 fetching is the
13 > same thing as --depth=1 clone. This way, you refetch everything
14 > rather than just getting the update.
15
16 You don't refetch everything, but the pull fails because it doesn't
17 know how the original and new shallow commits are related (so it can't
18 (ff-)merge them). It works if you fetch and reset (skipping the
19 merge). Here's my test script:
20
21 #!/bin/sh
22
23 rm -rf upstream local-1 local-2 &&
24 mkdir upstream &&
25 (
26 cd upstream &&
27 git init &&
28 echo 'Some project' >README &&
29 git add README &&
30 git commit -m 'Start the project' &&
31 for X in 1 2 3 4 5 6 7 8 9
32 do
33 echo "${X}" >"${X}" &&
34 git add "${X}"
35 done &&
36 git commit -m 'Add a bunch of dummy files'
37 ) &&
38 git clone --depth 1 "file://${PWD}/upstream" local-1 &&
39 (
40 cd upstream &&
41 echo 'Build with ...' >>README &&
42 git commit -am 'Add building instructions' &&
43 echo 'Test with ...' >>README &&
44 git commit -am 'Add testing instructions'
45 ) &&
46 (
47 cd local-1 &&
48 git fetch --depth 1 &&
49 git reset --hard origin/master &&
50 git --no-pager log --oneline --decorate &&
51 du -s . &&
52 git reflog expire --expire=now --all &&
53 git gc --aggressive --prune=now &&
54 du -s .
55 ) &&
56 git clone --depth 1 "file://${PWD}/upstream" local-2 &&
57 (
58 cd local-2 &&
59 du -s .
60 )
61
62 and here are some excerpts of it's output:
63
64 * The shallow fetch only pulls in three objects (the new README, tree,
65 and commit):
66
67 remote: Counting objects: 3, done.
68 remote: Compressing objects: 100% (2/2), done.
69 remote: Total 3 (delta 1), reused 0 (delta 0)
70 Unpacking objects: 100% (3/3), done.
71 From file:///tmp/upstream
72 + 73f6253...5abbe64 master -> origin/master (forced update)
73 HEAD is now at 5abbe64 Add testing instructions
74
75 * After the shallow fetch and reset, local-1 has a shallow history:
76
77 5abbe64 (grafted, HEAD, origin/master, origin/HEAD, master) Add testing instructions
78
79 * But it still has references to the old master in the reflog, and
80 that takes up some space:
81
82 168 .
83
84 * Expiring the reflog and garbage collectiong gets us that space back
85 (although in practice, I'd just let Git expire these automatically
86 in the course of time):
87
88 Counting objects: 12, done.
89 Delta compression using up to 2 threads.
90 Compressing objects: 100% (2/2), done.
91 Writing objects: 100% (12/12), done.
92 Total 12 (delta 0), reused 9 (delta 0)
93 140 .
94
95 * A fresh shallow clone gets all 12 objects (not just the three new
96 ones):
97
98 Cloning into 'local-2'...
99 remote: Counting objects: 12, done.
100 remote: Compressing objects: 100% (2/2), done.
101 remote: Total 12 (delta 0), reused 0 (delta 0)
102 Receiving objects: 100% (12/12), done.
103 Checking connectivity... done.
104
105 * And takes up as much space as our garbage-collected local-1:
106
107 140 .
108
109 Again, I'm happy to leave it to users to manually
110
111 $ git fetch --depth 1
112 $ git reset --hard origin/master
113
114 to shorten their history, but I expect many will not bother, and then
115 get annoyed as that unpurged history takes up more and more space ;).
116 In any case, we don't have to resolve this before the transition.
117
118 Cheers,
119 Trevor
120
121 --
122 This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
123 For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy

Attachments

File name MIME type
signature.asc application/pgp-signature