From b214eddfb2d57e318a3f5b88da1cafcf19184b4d Mon Sep 17 00:00:00 2001 From: "Dale R. Worley" Date: Thu, 22 Aug 2013 16:31:21 -0400 Subject: diff --no-index: clarify operation when not inside a repository Clarify documentation for "diff --no-index". State that when not inside a repository, --no-index is implied and two arguments are mandatory. Clarify error message from diff-no-index to inform user that CWD is not inside a repository and thus two arguments are mandatory. Signed-off-by: Dale Worley Signed-off-by: Junio C Hamano --- diff-no-index.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'diff-no-index.c') diff --git a/diff-no-index.c b/diff-no-index.c index 74da65936..014d20a2b 100644 --- a/diff-no-index.c +++ b/diff-no-index.c @@ -215,9 +215,21 @@ void diff_no_index(struct rev_info *revs, path_inside_repo(prefix, argv[i+1]))) return; } - if (argc != i + 2) + if (argc != i + 2) { + if (!no_index) { + /* + * 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 ", no_index ? "--no-index" : "[--no-index]"); + } diff_setup(&revs->diffopt); for (i = 1; i < argc - 2; ) { -- cgit v1.2.1