Add --export=WC to export the working copy into export-dir.
authorGuido Günther <agx@sigxcpu.org>
Mon, 23 Feb 2009 15:37:54 +0000 (16:37 +0100)
committerGuido Günther <agx@sigxcpu.org>
Mon, 23 Feb 2009 15:37:54 +0000 (16:37 +0100)
Closes: #509138
docs/chapters/building.sgml
docs/manpages/git-buildpackage.sgml
git-buildpackage

index e81a48e81e36c9649c99144bcb37cfeb4b1408f6..4b590988ce2818edf707299fce460364fead39ff 100644 (file)
 &git-buildpackage; <option>--git-export-dir</option>=<replaceable>../build-area</replaceable> <option>--git-export</option>=<replaceable>etch</replaceable>
 &git-buildpackage; <option>--git-export-dir</option>=<replaceable>../build-area</replaceable> <option>--git-export</option>=<replaceable>8caed309653d69b7ab440e3d35abc090eb4c6697</replaceable>
 &git-buildpackage; <option>--git-export-dir</option>=<replaceable>../build-area</replaceable> <option>--git-export</option>=<replaceable>INDEX</replaceable>
+&git-buildpackage; <option>--git-export-dir</option>=<replaceable>../build-area</replaceable> <option>--git-export</option>=<replaceable>WC</replaceable>
 </screen>
     <para>The special argument <replaceable>INDEX</replaceable> exports the
-    state of the current index which can be used to include staged but
-    uncommitted changes in the build.</para>
+    state of the current index which can be used to include staged but uncommitted
+    changes in the build. Whereas the special argument
+    <replaceable>WC</replaceable> exports the current working copy as is.</para>
     <para>If you want to default to build in a separate build area you can
     specify the directory to use in the gbp.conf.
 <programlisting>
index d4e8936a705c84261edf02ed771379fbe744581a..8ee48b0701e182b6f581b5341f666223be97b1b5 100644 (file)
        <listitem> 
          <para>Instead of exporting the current branch head, export the
          treeish object <replaceable>treeish</replaceable>. The special name
-         <replaceable>INDEX</replaceable> exports the current index.</para>
+         <replaceable>INDEX</replaceable> exports the current index whereas
+          the special name <replaceable>WC</replaceable> exports the current working
+          copy as is.</para>
         </listitem>
       </varlistentry>
       <varlistentry>
index b3e3bb244ac0a551985ee51a80dd7376cc019a07..57a2a93137691c941ef5898fbb9267c1eb4fcf3e 100755 (executable)
@@ -25,13 +25,15 @@ import pipes
 import time
 import gbp.deb_utils as du
 from gbp.git_utils import (GitRepositoryError, GitRepository, build_tag)
-from gbp.command_wrappers import (GitTag, Command, RunAtCommand, CommandExecFailed, 
-                                  PristineTar, RemoveTree)
+from gbp.command_wrappers import (GitTag, Command, RunAtCommand, CommandExecFailed,
+                                  PristineTar, RemoveTree, GitAdd)
 from gbp.config import (GbpOptionParser, GbpOptionGroup)
 from gbp.errors import GbpError
 
 # when we want to reference the index in a treeish context we call it:
 index_name = "INDEX"
+# when we want to reference the working copy in treeish context we call it:
+wc_name = "WC"
 
 def git_archive_pipe(prefix, pipe, output, treeish):
     """run the git_archive pipe"""
@@ -106,6 +108,7 @@ def pristine_tar_build_orig(repo, cp, output_dir, options):
     else:
         return False
 
+
 def git_archive_build_orig(repo, cp, output_dir, options):
     """build orig using git-archive"""
     # --upstream-branch was given on the command line, so use this:
@@ -122,6 +125,17 @@ def git_archive_build_orig(repo, cp, output_dir, options):
     if not git_archive(cp, output_dir, upstream_tree):
         raise GbpError, "Cannot create upstream tarball at '%s'" % output_dir
 
+
+def write_wc(repo):
+    """write out the current working copy as a treeish object"""
+    tree = None
+    os.putenv("GIT_INDEX_FILE", ".git/gbp_index")
+    GitAdd()(['-f', '.'])
+    tree = repo.write_tree()
+    os.unsetenv("GIT_INDEX_FILE")
+    return tree
+
+
 def main(argv):
     changelog = 'debian/changelog'
     default_tree = 'HEAD'
@@ -226,6 +240,8 @@ def main(argv):
                 # write a tree of the index if necessary:
                 if options.treeish == index_name:
                     tree = repo.write_tree()
+                elif options.treeish == wc_name:
+                    tree = write_wc(repo)
                 else:
                     tree = options.treeish
                 if not repo.has_treeish(tree):