aboutsummaryrefslogtreecommitdiff
path: root/diff-no-index.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-07-11 12:48:44 -0700
committerJunio C Hamano <gitster@pobox.com>2012-07-11 12:48:44 -0700
commit36c5109e4a4d455a9aa9e0f8d20c957aa6a9bef8 (patch)
tree2d746180b910cc20d7129482ca391bbe239ff980 /diff-no-index.c
parent4ac01b0cbc27b314333362e77323850e78a7448c (diff)
parent304970dd5d9e542e70eca98932c1e9f26770678e (diff)
downloadgit-36c5109e4a4d455a9aa9e0f8d20c957aa6a9bef8.tar.gz
git-36c5109e4a4d455a9aa9e0f8d20c957aa6a9bef8.tar.xz
Merge branch 'th/diff-no-index-fixes' into maint
"git diff --no-index" did not correctly handle relative paths and did not correctly give 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 77667b810..beec49b5a 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));
}