[PATCH] git: Update diff-logic
- From: Peter Tyser <ptyser gmail com>
- To: meld-list gnome org
- Subject: [PATCH] git: Update diff-logic
- Date: Sun, 23 May 2010 23:25:26 -0500
Previously, meld would use the 'git diff-index HEAD' command to find out
the status of modified files. This command would compare the HEAD revision
to the files on disk. This command did not take into consideration git's
"index" which resulted in odd behavior such as not handling unmerged files
correctly as pointed out in https://bugzilla.gnome.org/show_bug.cgi?id=617098
Separating 'git diff-index HEAD' into 'git diff-index --cached HEAD' and
'git diff-files' proprerly accounts for git's "index". Now modifications
to files on disk, in the index, or unmerged files are shown in meld.
Note that the current functionality isn't perfect as a user can't decide
if they do/don't want to take git's "index" into consideration for
their diffs. Ideally a feature such as an "index filter" will be
added in the future to allow finer control over if and how the contents
of the "index" are shown.
Signed-off-by: Peter Tyser <ptyser gmail com>
---
meld/vc/git.py | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/meld/vc/git.py b/meld/vc/git.py
index a3b69c6..a124bba 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -77,9 +77,25 @@ class Vc(_vc.CachedVc):
# Update the index before getting status, otherwise we could
# be reading stale status information
_vc.popen(["git", "update-index", "--refresh"])
+
+ # Get the status of files that are different in the "index" vs
+ # the HEAD of the git repository
proc = _vc.popen([self.CMD, "diff-index", "--name-status", \
- "HEAD", "./"], cwd=self.location)
+ "--cached", "HEAD", "./"], cwd=self.location)
entries = proc.read().split("\n")[:-1]
+
+ # Get the status of files that are different in the "index" vs
+ # the files on disk
+ proc = _vc.popen([self.CMD, "diff-files", "--name-status", \
+ "-0", "./"], cwd=self.location)
+ entries += (proc.read().split("\n")[:-1])
+
+ # An unmerged file or a file that has been modified, added to
+ # git's index, then modified again would result in the file
+ # showing up in both the output of "diff-files" and
+ # "diff-index". The following command removes duplicate
+ # file entries.
+ entries = list(set(entries))
break
except OSError, e:
if e.errno != errno.EAGAIN:
--
1.7.1.13.gcfb88
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]