diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-06-24 01:07:58 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-06-24 01:07:58 +0200 |
commit | 129f90aa8d83d9b250c87b0ba790605c4a2bb06a (patch) | |
tree | f31b6a9b9efb4a76d6a4de355c00eb60d72b5418 /lib/git/index/util.py | |
parent | 57050184f3d962bf91511271af59ee20f3686c3f (diff) | |
download | gitpython-129f90aa8d83d9b250c87b0ba790605c4a2bb06a.tar.gz |
Multiple partly critical bugfixes related to index handling
Diffstat (limited to 'lib/git/index/util.py')
-rw-r--r-- | lib/git/index/util.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/git/index/util.py b/lib/git/index/util.py index c9fb1922..bd5fcc03 100644 --- a/lib/git/index/util.py +++ b/lib/git/index/util.py @@ -3,7 +3,7 @@ import struct import tempfile import os -__all__ = ( 'TemporaryFileSwap', 'post_clear_cache', 'default_index' ) +__all__ = ( 'TemporaryFileSwap', 'post_clear_cache', 'default_index', 'git_working_dir' ) #{ Aliases pack = struct.pack @@ -67,4 +67,20 @@ def default_index(func): check_default_index.__name__ = func.__name__ return check_default_index +def git_working_dir(func): + """Decorator which changes the current working dir to the one of the git + repository in order to assure relative paths are handled correctly""" + def set_git_working_dir(self, *args, **kwargs): + cur_wd = os.getcwd() + os.chdir(self.repo.working_tree_dir) + try: + return func(self, *args, **kwargs) + finally: + os.chdir(cur_wd) + # END handle working dir + # END wrapper + + set_git_working_dir.__name__ = func.__name__ + return set_git_working_dir + #} END decorators |