From 0c47432db776f37ceda027bf9901022df37e545d Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 12 Jan 2012 15:25:10 +0200 Subject: [PATCH] Add git-depth option to gbp-clone and gbp-pull Allows creating and deepening shallow clones. This is sometimes useful for e.g. saving bandwidth when cloning. --- docs/manpages/gbp-clone.sgml | 8 ++++++++ docs/manpages/gbp-pull.sgml | 8 ++++++++ gbp/scripts/clone.py | 4 +++- gbp/scripts/pull.py | 4 +++- 4 files changed, 22 insertions(+), 2 deletions(-) mode change 100644 => 100755 gbp/scripts/clone.py mode change 100644 => 100755 gbp/scripts/pull.py diff --git a/docs/manpages/gbp-clone.sgml b/docs/manpages/gbp-clone.sgml index 526f3f7..f4be976 100644 --- a/docs/manpages/gbp-clone.sgml +++ b/docs/manpages/gbp-clone.sgml @@ -26,6 +26,7 @@ branch_name branch_name + depth remote_uri @@ -67,6 +68,13 @@ + =depth + + + Git history depth, for creating shallow git clones. + + + diff --git a/docs/manpages/gbp-pull.sgml b/docs/manpages/gbp-pull.sgml index d1a9b23..b8dcde4 100644 --- a/docs/manpages/gbp-pull.sgml +++ b/docs/manpages/gbp-pull.sgml @@ -27,6 +27,7 @@ branch_name branch_name + depth @@ -74,6 +75,13 @@ + =depth + + + Git history depth, for deepening shallow git clones. + + + diff --git a/gbp/scripts/clone.py b/gbp/scripts/clone.py old mode 100644 new mode 100755 index 665b548..2c4a93b --- a/gbp/scripts/clone.py +++ b/gbp/scripts/clone.py @@ -40,6 +40,8 @@ def parse_args (argv): branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch") branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch") 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)") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose command execution") @@ -70,7 +72,7 @@ def main(argv): pass try: - repo = GitRepository.clone(os.path.curdir, source) + repo = GitRepository.clone(os.path.curdir, source, options.depth) os.chdir(repo.path) # Reparse the config files of the cloned repository so we pick up the diff --git a/gbp/scripts/pull.py b/gbp/scripts/pull.py old mode 100644 new mode 100755 index 3502efe..face2cc --- a/gbp/scripts/pull.py +++ b/gbp/scripts/pull.py @@ -81,6 +81,8 @@ def main(argv): branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch") branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch") 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 deepening shallow clones)") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose command execution") parser.add_config_file_option(option_name="color", dest="color", type='tristate') @@ -112,7 +114,7 @@ def main(argv): gbp.log.err(out) raise GbpError - repo.fetch() + repo.fetch(options.depth) for branch in branches: if not fast_forward_branch(branch, repo, options): retval = 2 -- 2.7.4