diff options
author | David Pursehouse <dpursehouse@collab.net> | 2018-10-28 23:30:50 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-10-28 23:30:50 +0000 |
commit | 36391bf5caa29cecaa1e7c4cfd3db503e34a17e6 (patch) | |
tree | 8759a8d50ab6fe1c968185c14f9ddf22ed98e6db | |
parent | bed8b62345e484b27e048e8f21280c5611f795df (diff) | |
parent | 09f0abb0efde83cfc4b850ebdc41f6ed3b61a123 (diff) | |
download | git-repo-36391bf5caa29cecaa1e7c4cfd3db503e34a17e6.tar.gz |
Merge "init: --dissociate option to copy objects borrowed with --reference"
-rwxr-xr-x | project.py | 10 | ||||
-rwxr-xr-x | repo | 3 | ||||
-rw-r--r-- | subcmds/init.py | 11 |
3 files changed, 24 insertions, 0 deletions
@@ -1310,6 +1310,16 @@ class Project(object): | |||
1310 | submodules=submodules)): | 1310 | submodules=submodules)): |
1311 | return False | 1311 | return False |
1312 | 1312 | ||
1313 | mp = self.manifest.manifestProject | ||
1314 | dissociate = mp.config.GetBoolean('repo.dissociate') | ||
1315 | if dissociate: | ||
1316 | alternates_file = os.path.join(self.gitdir, 'objects/info/alternates') | ||
1317 | if os.path.exists(alternates_file): | ||
1318 | cmd = ['repack', '-a', '-d'] | ||
1319 | if GitCommand(self, cmd, bare=True).Wait() != 0: | ||
1320 | return False | ||
1321 | platform_utils.remove(alternates_file) | ||
1322 | |||
1313 | if self.worktree: | 1323 | if self.worktree: |
1314 | self._InitMRef() | 1324 | self._InitMRef() |
1315 | else: | 1325 | else: |
@@ -190,6 +190,9 @@ group.add_option('--mirror', | |||
190 | group.add_option('--reference', | 190 | group.add_option('--reference', |
191 | dest='reference', | 191 | dest='reference', |
192 | help='location of mirror directory', metavar='DIR') | 192 | help='location of mirror directory', metavar='DIR') |
193 | group.add_option('--dissociate', | ||
194 | dest='dissociate', action='store_true', | ||
195 | help='dissociate from reference mirrors after clone') | ||
193 | group.add_option('--depth', type='int', default=None, | 196 | group.add_option('--depth', type='int', default=None, |
194 | dest='depth', | 197 | dest='depth', |
195 | help='create a shallow clone with given depth; see git clone') | 198 | help='create a shallow clone with given depth; see git clone') |
diff --git a/subcmds/init.py b/subcmds/init.py index 4e51dfe8..6e99658f 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -61,6 +61,11 @@ directory use as much data as possible from the local reference | |||
61 | directory when fetching from the server. This will make the sync | 61 | directory when fetching from the server. This will make the sync |
62 | go a lot faster by reducing data traffic on the network. | 62 | go a lot faster by reducing data traffic on the network. |
63 | 63 | ||
64 | The --dissociate option can be used to borrow the objects from | ||
65 | the directory specified with the --reference option only to reduce | ||
66 | network transfer, and stop borrowing from them after a first clone | ||
67 | is made by making necessary local copies of borrowed objects. | ||
68 | |||
64 | The --no-clone-bundle option disables any attempt to use | 69 | The --no-clone-bundle option disables any attempt to use |
65 | $URL/clone.bundle to bootstrap a new Git repository from a | 70 | $URL/clone.bundle to bootstrap a new Git repository from a |
66 | resumeable bundle file on a content delivery network. This | 71 | resumeable bundle file on a content delivery network. This |
@@ -103,6 +108,9 @@ to update the working directory files. | |||
103 | g.add_option('--reference', | 108 | g.add_option('--reference', |
104 | dest='reference', | 109 | dest='reference', |
105 | help='location of mirror directory', metavar='DIR') | 110 | help='location of mirror directory', metavar='DIR') |
111 | g.add_option('--dissociate', | ||
112 | dest='dissociate', action='store_true', | ||
113 | help='dissociate from reference mirrors after clone') | ||
106 | g.add_option('--depth', type='int', default=None, | 114 | g.add_option('--depth', type='int', default=None, |
107 | dest='depth', | 115 | dest='depth', |
108 | help='create a shallow clone with given depth; see git clone') | 116 | help='create a shallow clone with given depth; see git clone') |
@@ -219,6 +227,9 @@ to update the working directory files. | |||
219 | if opt.reference: | 227 | if opt.reference: |
220 | m.config.SetString('repo.reference', opt.reference) | 228 | m.config.SetString('repo.reference', opt.reference) |
221 | 229 | ||
230 | if opt.dissociate: | ||
231 | m.config.SetString('repo.dissociate', 'true') | ||
232 | |||
222 | if opt.archive: | 233 | if opt.archive: |
223 | if is_new: | 234 | if is_new: |
224 | m.config.SetString('repo.archive', 'true') | 235 | m.config.SetString('repo.archive', 'true') |