Merge branch 'maint'
[gitweb.git] / diff-no-index.c
index e301aafff9ff230313425eea5987b18056b72c98..00a8eefde9aeb96592f5ed6455dbf5d3b16747c4 100644 (file)
@@ -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 <path> <path>",
                       no_index ? "--no-index" : "[--no-index]");
+       }
 
        diff_setup(&revs->diffopt);
        for (i = 1; i < argc - 2; ) {