sync: Enable use of git clone --reference
Use git clone to initialize a new repository, and when possible
allow callers to use --reference to reuse an existing checkout as
the initial object storage area for the new checkout.
Change-Id: Ie27f760247f311ce484c6d3e85a90d94da2febfc
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/subcmds/init.py b/subcmds/init.py
index 4023ab6..17edfa0 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -41,6 +41,13 @@
to be used. If no manifest is specified, the manifest default.xml
will be used.
+The --reference option can be used to point to a directory that
+has the content of a --mirror sync. This will make the working
+directory use as much data as possible from the local reference
+directory when fetching from the server. This will make the sync
+go a lot faster by reducing data traffic on the network.
+
+
Switching Manifest Branches
---------------------------
@@ -71,7 +78,9 @@
g.add_option('--mirror',
dest='mirror', action='store_true',
help='mirror the forrest')
-
+ g.add_option('--reference',
+ dest='reference',
+ help='location of mirror directory', metavar='DIR')
# Tool
g = p.add_option_group('repo Version options')
@@ -115,6 +124,9 @@
r.ResetFetch()
r.Save()
+ if opt.reference:
+ m.config.SetString('repo.reference', opt.reference)
+
if opt.mirror:
if is_new:
m.config.SetString('repo.mirror', 'true')