summaryrefslogtreecommitdiff
path: root/diff-no-index.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-07-04 23:40:38 -0700
committerJunio C Hamano <gitster@pobox.com>2012-07-04 23:40:38 -0700
commit60ad08bfdfe393fd86391e2f9e60e8ffccc78e5b (patch)
treee856039e5ad6149a72dfa5d9160ff1b1888dd23e /diff-no-index.c
parent348c44e78eb079fa97a575f8fb8c1fcac747efe5 (diff)
parent304970dd5d9e542e70eca98932c1e9f26770678e (diff)
downloadgit-60ad08bfdfe393fd86391e2f9e60e8ffccc78e5b.tar.gz
Merge branch 'th/diff-no-index-fixes'
"git diff --no-index" did not correctly handle relative paths and did not give correct exit codes when run under "--quiet" option. * th/diff-no-index-fixes: diff-no-index: exit(1) if 'diff --quiet <repo file> <external file>' finds changes diff: handle relative paths in no-index
Diffstat (limited to 'diff-no-index.c')
-rw-r--r--diff-no-index.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/diff-no-index.c b/diff-no-index.c
index 77667b810d..beec49b5ac 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)
@@ -268,5 +251,5 @@ void diff_no_index(struct rev_info *revs,
* The return code for --no-index imitates diff(1):
* 0 = no changes, 1 = changes, else error
*/
- exit(revs->diffopt.found_changes);
+ exit(diff_result_code(&revs->diffopt, 0));
}