Re: Recent git changes and unmerged files



Hi Kai,

> Since I'm not a real git expert, I thought I'd solicit some help on
> bug 617098 (https://bugzilla.gnome.org/show_bug.cgi?id=617098). The
> short version is that now that we use git-diff-index, unmerged files
> are not correctly detected. There's a patch at the bug, but I'd love
> feedback and testing, particularly from anyone with an understanding
> of git plumbing.

I think we may need to get the status of files by combining the output of both:
git diff-index HEAD --cached --name-status ./
git diff-files --name-status -0 ./

>From the "Raw output format" section of
http://www.kernel.org/pub/software/scm/git/docs/git-diff-index.html:
git-diff-index --cached <tree-ish>
compares the <tree-ish> and the index.

git-diff-files [<pattern>…]
compares the index and the files on the filesystem.

The combination of those 2 commands should cover changes on the disk,
as well as to the index.  My understanding is that the "git-diff-index
HEAD --name-status" we currently use only compares the files on the
disk, and ignores the fact that the index is also modified/conflicted.
git-diff-index <tree-ish>
compares the <tree-ish> and the files on the filesystem.


Something like the following may work.  It seems to work on the test
case in the bugzilla thread at least:)  I'll dig a bit more in the
next day or 2, just wanted to throw this out there in case others had
comments.  I'm not intimately familiar with the git plumbing commands
either, so take it with a grain of salt.

Best,
Peter

--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -30,6 +30,7 @@
 import os
 import errno
 import _vc
+from sets import Set

 class Vc(_vc.CachedVc):

@@ -78,8 +79,14 @@ class Vc(_vc.CachedVc):
                 # be reading stale status information
                 _vc.popen(["git", "update-index", "--refresh"])
                 proc = _vc.popen([self.CMD, "diff-index", "--name-status", \
-                    "HEAD", "./"], cwd=self.location)
+                    "--cached", "HEAD", "./"], cwd=self.location)
                 entries = proc.read().split("\n")[:-1]
+                proc = _vc.popen([self.CMD, "diff-files", "--name-status", \
+                    "-0", "./"], cwd=self.location)
+                entries += (proc.read().split("\n")[:-1])
+
+                # Remove duplicate entries
+                entries = list(Set(entries))
                 break
             except OSError, e:
                 if e.errno != errno.EAGAIN:


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