summaryrefslogtreecommitdiff
path: root/builtin/diff.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2019-03-24 15:20:13 +0700
committerJunio C Hamano <gitster@pobox.com>2019-03-24 22:21:24 +0900
commit16bb3d714dcb1bf50f7f96b957c4306dc6df137e (patch)
tree94e12ab57590fba02355d55a5cb05839cbcb57dc /builtin/diff.c
parentc380a48c8b40331dd6466d6b565af6d44c7b11bf (diff)
downloadgit-16bb3d714dcb1bf50f7f96b957c4306dc6df137e.tar.gz
diff --no-index: use parse_options() instead of diff_opt_parse()
While at there, move exit() back to the caller. It's easier to see the flow that way than burying it in diff-no-index.c Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/diff.c')
-rw-r--r--builtin/diff.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/builtin/diff.c b/builtin/diff.c
index f0393bba23..52dc3e136f 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -320,26 +320,11 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
repo_init_revisions(the_repository, &rev, prefix);
- if (no_index && argc != i + 2) {
- if (no_index == DIFF_NO_INDEX_IMPLICIT) {
- /*
- * There was no --no-index and there were not two
- * paths. It is possible that the user intended
- * to do an inside-repository operation.
- */
- fprintf(stderr, "Not a git repository\n");
- fprintf(stderr,
- "To compare two paths outside a working tree:\n");
- }
- /* Give the usage message for non-repository usage and exit. */
- usagef("git diff %s <path> <path>",
- no_index == DIFF_NO_INDEX_EXPLICIT ?
- "--no-index" : "[--no-index]");
-
- }
if (no_index)
/* If this is a no-index diff, just run it and exit there. */
- diff_no_index(the_repository, &rev, argc, argv);
+ exit(diff_no_index(the_repository, &rev,
+ no_index == DIFF_NO_INDEX_IMPLICIT,
+ argc, argv));
/* Otherwise, we are doing the usual "git" diff */
rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;