summaryrefslogtreecommitdiff
path: root/builtin-diff-index.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2008-08-28 20:02:12 +0700
committerJunio C Hamano <gitster@pobox.com>2008-08-28 20:50:10 -0700
commit4f38f6b5bafb1f7f85c7b54d0bb0a0e977cd947c (patch)
tree899a49f15362f957cf67c71b23f9435e5600ebf6 /builtin-diff-index.c
parentc67b1fa349cc7b4341b32b9ef1c58a3821ce0830 (diff)
downloadgit-4f38f6b5bafb1f7f85c7b54d0bb0a0e977cd947c.tar.gz
diff*: fix worktree setup
This fixes "git diff", "git diff-files" and "git diff-index" to work correctly under worktree setup. Because diff* family works in many modes and not all of them require worktree, Junio made a nice summary (with a little modification from me): * diff-files is about comparing with work tree, so it obviously needs a work tree; * diff-index also does, except "diff-index --cached" or "diff --cached TREE" * no-index is about random files outside git context, so it obviously doesn't need any work tree; * comparing two (or more) trees doesn't; * comparing two blobs doesn't; * comparing a blob with a random file doesn't; Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-diff-index.c')
-rw-r--r--builtin-diff-index.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin-diff-index.c b/builtin-diff-index.c
index 17d851b29e..04837494fe 100644
--- a/builtin-diff-index.c
+++ b/builtin-diff-index.c
@@ -39,6 +39,8 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
if (rev.pending.nr != 1 ||
rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
usage(diff_cache_usage);
+ if (!cached)
+ setup_work_tree();
if (read_cache() < 0) {
perror("read_cache");
return -1;