summaryrefslogtreecommitdiff
path: root/gbp/scripts/common
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2012-10-25 09:25:25 +0300
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-06-05 14:20:04 +0300
commit9b3bc9416579b24d9f9ce0c1019369efe860efa2 (patch)
tree790c614f3edf0ec8cba3e37920c69a4cc9a53a97 /gbp/scripts/common
parentf440810e850d3dcadcd7fc855ee3f6bea06ce303 (diff)
downloadgit-buildpackage-9b3bc9416579b24d9f9ce0c1019369efe860efa2.tar.gz
git-buildpackage-9b3bc9416579b24d9f9ce0c1019369efe860efa2.tar.bz2
git-buildpackage-9b3bc9416579b24d9f9ce0c1019369efe860efa2.zip
buildpackage: fix exporting of working copy when run from a subdir
Exporting sources failed when git-buildpackage was run from a subdirectory of the git working directory because the path of the custom index file was not handled correctly. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'gbp/scripts/common')
-rw-r--r--gbp/scripts/common/buildpackage.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/gbp/scripts/common/buildpackage.py b/gbp/scripts/common/buildpackage.py
index 1b03293c..f621e6c5 100644
--- a/gbp/scripts/common/buildpackage.py
+++ b/gbp/scripts/common/buildpackage.py
@@ -35,8 +35,6 @@ wc_names = {'WC': {'force': True, 'untracked': True},
'WC.TRACKED': {'force': False, 'untracked': False},
'WC.UNTRACKED': {'force': False, 'untracked': True},
'WC.IGNORED': {'force': True, 'untracked': True}}
-# index file name used to export working copy
-wc_index = ".git/gbp_index"
def sanitize_prefix(prefix):
@@ -161,21 +159,25 @@ def dump_tree(repo, export_dir, treeish, with_submodules, recursive=True):
return True
+def wc_index(repo):
+ """Get path of the temporary index file used for exporting working copy"""
+ return os.path.join(repo.git_dir, "gbp_index")
+
def write_wc(repo, force=True, untracked=True):
"""write out the current working copy as a treeish object"""
- clone_index()
- repo.add_files(repo.path, force=force, untracked=untracked, index_file=wc_index)
- tree = repo.write_tree(index_file=wc_index)
+ clone_index(repo)
+ repo.add_files(repo.path, force=force, untracked=untracked, index_file=wc_index(repo))
+ tree = repo.write_tree(index_file=wc_index(repo))
return tree
-def drop_index():
+def drop_index(repo):
"""drop our custom index"""
- if os.path.exists(wc_index):
- os.unlink(wc_index)
+ if os.path.exists(wc_index(repo)):
+ os.unlink(wc_index(repo))
-def clone_index():
+def clone_index(repo):
"""Copy the current index file to our custom index file"""
- indexfn = ".git/index"
+ indexfn = os.path.join(repo.git_dir, "index")
if os.path.exists(indexfn):
- shutil.copy2(indexfn, wc_index)
+ shutil.copy2(indexfn, wc_index(repo))