This makes it possible to use git diff when we are outside the repo but
--work-tree and --git-dir is used.
Signed-off-by: Miklos Vajna <redacted>
---
builtin-diff-files.c | 1 +
builtin-diff-index.c | 2 ++
builtin-diff.c | 1 +
3 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/builtin-diff-files.c b/builtin-diff-files.c
index 9bf10bb..4802e00 100644
--- a/builtin-diff-files.c
+++ b/builtin-diff-files.c
@@ -19,6 +19,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
int result;
unsigned options = 0;
+ setup_work_tree();
init_revisions(&rev, prefix);
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
rev.abbrev = 0;
diff --git a/builtin-diff-index.c b/builtin-diff-index.c
index 17d851b..5510291 100644
--- a/builtin-diff-index.c
+++ b/builtin-diff-index.c
@@ -29,6 +29,8 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
else
usage(diff_cache_usage);
}
+ if (!cached)
+ setup_work_tree();
if (!rev.diffopt.output_format)
rev.diffopt.output_format = DIFF_FORMAT_RAW;
diff --git a/builtin-diff.c b/builtin-diff.c
index 7ffea97..57da6ed 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -279,6 +279,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
diff_no_index(&rev, argc, argv, nongit, prefix);
/* Otherwise, we are doing the usual "git" diff */
+ setup_work_tree();
rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
if (nongit)
--
1.6.0.rc3.17.gc14c8.dirty