From 546e0fd9e918b2ea3d9943124641d3b6af59a4fe Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 21 Jun 2012 14:09:50 -0400 Subject: diff: handle relative paths in no-index When diff-no-index is given a relative path to a file outside the repository, it aborts with error. However, if the file is given using an absolute path, the diff runs as expected. The two cases should be treated the same. Tests and commit message by Tim Henigan. Signed-off-by: Jeff King Signed-off-by: Tim Henigan Signed-off-by: Junio C Hamano --- diff-no-index.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'diff-no-index.c') diff --git a/diff-no-index.c b/diff-no-index.c index f0b0010ae..e6b9952b3 100644 --- a/diff-no-index.c +++ b/diff-no-index.c @@ -151,23 +151,6 @@ static int queue_diff(struct diff_options *o, } } -static int path_outside_repo(const char *path) -{ - const char *work_tree; - size_t len; - - if (!is_absolute_path(path)) - return 0; - work_tree = get_git_work_tree(); - if (!work_tree) - return 1; - len = strlen(work_tree); - if (strncmp(path, work_tree, len) || - (path[len] != '\0' && path[len] != '/')) - return 1; - return 0; -} - void diff_no_index(struct rev_info *revs, int argc, const char **argv, int nongit, const char *prefix) @@ -197,8 +180,8 @@ void diff_no_index(struct rev_info *revs, * a colourful "diff" replacement. */ if ((argc != i + 2) || - (!path_outside_repo(argv[i]) && - !path_outside_repo(argv[i+1]))) + (path_inside_repo(prefix, argv[i]) && + path_inside_repo(prefix, argv[i+1]))) return; } if (argc != i + 2) -- cgit v1.2.1