@matheusbsbs / matheus-bagliano / commits / ae792aa52b
Fork 0

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>

Junio C Hamano committed Mar 3, 2007 at 23:45 UTC ae792aa52bb0962079f500bd491363f2b48457b6
1 file changed +13 -1
diff-lib.c
+13 -1
@@ -248,7 +248,19 @@ int setup_diff_no_index(struct rev_info *revs,
248 die("invalid diff option/value: %s", argv[i]);
249 i += j;
250 }
251 - revs->diffopt.paths = argv + argc - 2;
251 +
252 + if (prefix) {
253 + int len = strlen(prefix);
254 +
255 + revs->diffopt.paths = xcalloc(2, sizeof(char*));
256 + for (i = 0; i < 2; i++) {
257 + const char *p;
258 + p = prefix_filename(prefix, len, argv[argc - 2 + i]);
259 + revs->diffopt.paths[i] = xstrdup(p);
260 + }
261 + }
262 + else
263 + revs->diffopt.paths = argv + argc - 2;
264 revs->diffopt.nr_paths = 2;
265 revs->max_count = -2;
266 return 0;