diff options
author | Carlos Maddela <maddela@labyrinth.net.au> | 2015-07-03 03:27:50 +1000 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2015-07-10 09:58:18 +0200 |
commit | da4d469012e74936bc930ba7e726d19380411baa (patch) | |
tree | 81f26d6284cde061f5beaf8428b0db7386a854b2 | |
parent | b334eb7a58b5b8bd305045eb79cc9a6b9dbaac69 (diff) |
Add support for referencing existing local repositories when cloning repositories
On the off chance you forget to clone a git repo for a debian package
with gbp-clone instead of git-clone, it is handy to be able to
reference the local copy you already have when re-cloning the repo with
gbp-clone, in the same way that git-clone allows you to with the
--reference option.
Closes: #790889
Signed-off-by: Guido Günther <agx@sigxcpu.org>
-rw-r--r-- | docs/manpages/gbp-clone.sgml | 8 | ||||
-rw-r--r-- | gbp/git/repository.py | 5 | ||||
-rwxr-xr-x | gbp/scripts/clone.py | 4 |
3 files changed, 15 insertions, 2 deletions
diff --git a/docs/manpages/gbp-clone.sgml b/docs/manpages/gbp-clone.sgml index 20e61472..5b681584 100644 --- a/docs/manpages/gbp-clone.sgml +++ b/docs/manpages/gbp-clone.sgml @@ -27,6 +27,7 @@ <arg><option>--debian-branch=</option><replaceable>branch_name</replaceable></arg> <arg><option>--upstream-branch=</option><replaceable>branch_name</replaceable></arg> <arg><option>--depth=</option><replaceable>depth</replaceable></arg> + <arg><option>--reference=</option><replaceable>repository</replaceable></arg> <arg choice="plain"><replaceable>remote_uri</replaceable></arg> </cmdsynopsis> </refsynopsisdiv> @@ -77,6 +78,13 @@ </listitem> </varlistentry> <varlistentry> + <term><option>--reference</option>=<replaceable>repository</replaceable> + </term> + <listitem> + <para>Local repository to use as alternate instead of re-copying data from remote repository.</para> + </listitem> + </varlistentry> + <varlistentry> <term><option>--pristine-tar</option> </term> <listitem> diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 2fa4fdd6..8142a255 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -1891,7 +1891,7 @@ class GitRepository(object): @classmethod def clone(klass, path, remote, depth=0, recursive=False, mirror=False, - bare=False, auto_name=True): + bare=False, auto_name=True, reference=None): """ Clone a git repository at I{remote} to I{path}. @@ -1910,6 +1910,8 @@ class GitRepository(object): @param auto_name: If I{True} create a directory below I{path} based on the I{remote}s name. Otherwise create the repo directly at I{path}. @type auto_name: C{bool} + @param reference: create a clone using local objects from I{reference} repository + @type reference: C{str} @return: git repository object @rtype: L{GitRepository} """ @@ -1924,6 +1926,7 @@ class GitRepository(object): args.add_true(recursive, '--recursive') args.add_true(mirror, '--mirror') args.add_true(bare, '--bare') + args.add_true(reference, '--reference', reference) args.add(remote) args.add_true(name, name) try: diff --git a/gbp/scripts/clone.py b/gbp/scripts/clone.py index 1c7f4a93..216bf993 100755 --- a/gbp/scripts/clone.py +++ b/gbp/scripts/clone.py @@ -47,6 +47,8 @@ def build_parser(name): branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar") branch_group.add_option("--depth", action="store", dest="depth", default=0, help="git history depth (for creating shallow clones)") + branch_group.add_option("--reference", action="store", dest="reference", default=None, + help="git reference repository (use local copies where possible)") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose command execution") @@ -89,7 +91,7 @@ def main(argv): try: repo = DebianGitRepository.clone(clone_to, source, options.depth, - auto_name=auto_name) + auto_name=auto_name,reference=options.reference) os.chdir(repo.path) # Reparse the config files of the cloned repository so we pick up the |