Code

Avoid using git-diff since it might run external diff drivers
authorJonas Fonseca <fonseca@diku.dk>
Thu, 18 Oct 2007 19:26:05 +0000 (21:26 +0200)
committerJonas Fonseca <fonseca@diku.dk>
Thu, 18 Oct 2007 19:26:25 +0000 (21:26 +0200)
Relying only on the diff plumbing seems to be the safer thing to do.

tig.c

diff --git a/tig.c b/tig.c
index f6bb9f3ef64d4e3cde92a9a7b557f79326931498..fbc65b911894f1a598997ef0728b97f29567ce32 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -3260,8 +3260,11 @@ error_out:
 #define STATUS_LIST_OTHER_CMD \
        "git ls-files -z --others --exclude-per-directory=.gitignore"
 
-#define STATUS_DIFF_SHOW_CMD \
-       "git diff --no-color --root --patch-with-stat --find-copies-harder -B -C %s -- %s 2>/dev/null"
+#define STATUS_DIFF_INDEX_SHOW_CMD \
+       "git diff-index --root --patch-with-stat --find-copies-harder -B -C --cached HEAD -- %s 2>/dev/null"
+
+#define STATUS_DIFF_FILES_SHOW_CMD \
+       "git diff-files --root --patch-with-stat --find-copies-harder -B -C -- %s 2>/dev/null"
 
 /* First parse staged info using git-diff-index(1), then parse unstaged
  * info using git-diff-files(1), and finally untracked files using
@@ -3392,8 +3395,8 @@ status_enter(struct view *view, struct line *line)
 
        switch (line->type) {
        case LINE_STAT_STAGED:
-               if (!string_format_from(opt_cmd, &cmdsize, STATUS_DIFF_SHOW_CMD,
-                                       "--cached", path))
+               if (!string_format_from(opt_cmd, &cmdsize,
+                                       STATUS_DIFF_INDEX_SHOW_CMD, path))
                        return REQ_QUIT;
                if (status)
                        info = "Staged changes to %s";
@@ -3402,8 +3405,8 @@ status_enter(struct view *view, struct line *line)
                break;
 
        case LINE_STAT_UNSTAGED:
-               if (!string_format_from(opt_cmd, &cmdsize, STATUS_DIFF_SHOW_CMD,
-                                       "", path))
+               if (!string_format_from(opt_cmd, &cmdsize,
+                                       STATUS_DIFF_FILES_SHOW_CMD, path))
                        return REQ_QUIT;
                if (status)
                        info = "Unstaged changes to %s";