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>
This commit is contained in:
Nguyễn Thái Ngọc Duy
2019-03-24 15:20:13 +07:00
committed by Junio C Hamano
parent c380a48c8b
commit 16bb3d714d
4 changed files with 35 additions and 41 deletions

View File

@ -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;