Add git-depth option to gbp-clone and gbp-pull
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 12 Jan 2012 13:25:10 +0000 (15:25 +0200)
committerGuido Günther <agx@sigxcpu.org>
Tue, 17 Jan 2012 18:18:18 +0000 (19:18 +0100)
Allows creating and deepening shallow clones. This is sometimes
useful for e.g. saving bandwidth when cloning.

docs/manpages/gbp-clone.sgml
docs/manpages/gbp-pull.sgml
gbp/scripts/clone.py [changed mode: 0644->0755]
gbp/scripts/pull.py [changed mode: 0644->0755]

index 526f3f7..f4be976 100644 (file)
@@ -26,6 +26,7 @@
       <arg><option>--[no-]pristine-tar</option></arg>
       <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 choice="plain"><replaceable>remote_uri</replaceable></arg>
     </cmdsynopsis>
   </refsynopsisdiv>
         </listitem>
       </varlistentry>
       <varlistentry>
+        <term><option>--depth</option>=<replaceable>depth</replaceable>
+        </term>
+        <listitem>
+          <para>Git history depth, for creating shallow git clones.</para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
         <term><option>--verbose</option></term>
        <term><option>-v</option></term>
         <listitem>
index d1a9b23..b8dcde4 100644 (file)
@@ -27,6 +27,7 @@
       <arg><option>--[no-]pristine-tar</option></arg>
       <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>
     </cmdsynopsis>
   </refsynopsisdiv>
   <refsect1>
         </listitem>
       </varlistentry>
       <varlistentry>
+        <term><option>--depth</option>=<replaceable>depth</replaceable>
+        </term>
+        <listitem>
+          <para>Git history depth, for deepening shallow git clones.</para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
         <term><option>--verbose</option></term>
        <term><option>-v</option></term>
         <listitem>
old mode 100644 (file)
new mode 100755 (executable)
index 665b548..2c4a93b
@@ -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
old mode 100644 (file)
new mode 100755 (executable)
index 3502efe..face2cc
@@ -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