[meld] Fix diffing of sub-directories in git repositories (bug 609025)



commit d6b0cdb4fe74f6a4d707da44f5b7d1dce2ea016d
Author: Peter Tyser <ptyser gmail com>
Date:   Sun Feb 28 14:42:03 2010 -0600

    Fix diffing of sub-directories in git repositories (bug 609025)
    
    Previously, running meld on a path located anywhere in a git repository
    would result in meld displaying all modified files in the repository -
    not just those files which are located under the path specified by the
    user.  For example, if a git repository contained 3 modified files
    layed out as follows:
     dir1/
    	file1
     dir2/
    	file2
     /file3
    
    running "meld ./" from within dir1 would present the user with diffs
    for file1, file2, and file3 even though the user only wanted to diff
    the files in dir1.  Similarly, running "git diff dir1" from the root
    of the repository would result in diffs for file1, file2, and file3
    being displayed.
    
    This change causes meld to behave in a more sane manner, similar to
    its operation in subversion and CVS repositories.  Running "git diff ./"
    from within dir1 will now only show file1 as being modified, and
    running "git diff dir1" from the root of the repository will similarly
    show only file1 as being modified.
    
    Signed-off-by: Peter Tyser <ptyser gmail com>

 meld/vc/_vc.py |    5 +++++
 meld/vc/git.py |    3 ++-
 2 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/meld/vc/_vc.py b/meld/vc/_vc.py
index 0331a6d..ba5d49e 100644
--- a/meld/vc/_vc.py
+++ b/meld/vc/_vc.py
@@ -76,6 +76,11 @@ class Vc(object):
     VC_METADATA = None
 
     def __init__(self, location):
+        # Save the requested diff directory.  It may be a sub-directory
+        # of the repository we are diffing and can be useful in limiting meld's
+        # output to the requested location.
+        self.location = location
+
         if self.VC_ROOT_WALK:
             self.root = self.find_repo_root(location)
         else:
diff --git a/meld/vc/git.py b/meld/vc/git.py
index 4067692..6fafa16 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -74,7 +74,8 @@ class Vc(_vc.CachedVc):
     def _lookup_tree_cache(self, rootdir):
         while 1:
             try:
-                proc = _vc.popen([self.CMD, "diff-index", "--name-status", "HEAD", "./"], cwd=self.root)
+                proc = _vc.popen([self.CMD, "diff-index", "--name-status", \
+                    "HEAD", "./"], cwd=self.location)
                 entries = proc.read().split("\n")[:-1]
                 break
             except OSError, e:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]