summaryrefslogtreecommitdiff
path: root/diff-lib.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-03-03 23:45:14 -0800
committerJunio C Hamano <junkio@cox.net>2007-03-03 23:45:14 -0800
commitae792aa52bb0962079f500bd491363f2b48457b6 (patch)
treee75f1fff3ce29b9eec2248839751ba261aaeddd8 /diff-lib.c
parente551208dea5cd40721c437faafb6d604dedffef5 (diff)
downloadgit-ae792aa52bb0962079f500bd491363f2b48457b6.tar.gz
diff-ni: allow running from a subdirectory.
When run from a subdirectory of a repository, the command forgot to adjust paths given to it with prefix. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'diff-lib.c')
-rw-r--r--diff-lib.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/diff-lib.c b/diff-lib.c
index 75ff0dd93d..88e59b5794 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -248,7 +248,19 @@ int setup_diff_no_index(struct rev_info *revs,
die("invalid diff option/value: %s", argv[i]);
i += j;
}
- revs->diffopt.paths = argv + argc - 2;
+
+ if (prefix) {
+ int len = strlen(prefix);
+
+ revs->diffopt.paths = xcalloc(2, sizeof(char*));
+ for (i = 0; i < 2; i++) {
+ const char *p;
+ p = prefix_filename(prefix, len, argv[argc - 2 + i]);
+ revs->diffopt.paths[i] = xstrdup(p);
+ }
+ }
+ else
+ revs->diffopt.paths = argv + argc - 2;
revs->diffopt.nr_paths = 2;
revs->max_count = -2;
return 0;