diff: don't read index when --no-index is given
[gitweb.git] / builtin / diff.c
index da69e4a3c81174cffe4d04b5531538b7d9fc78b2..ea1dd65a2f17e257c195aa561400ed04fd0ef636 100644 (file)
@@ -298,7 +298,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                        break;
        }
 
-       prefix = setup_git_directory_gently(&nongit);
+       if (!no_index)
+               prefix = setup_git_directory_gently(&nongit);
+
        /*
         * Treat git diff with at least one path outside of the
         * repo the same as if the command would have been executed
@@ -311,7 +313,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                        !path_inside_repo(prefix, argv[i + 1]))))
                no_index = DIFF_NO_INDEX_IMPLICIT;
 
-       gitmodules_config();
+       if (!no_index)
+               gitmodules_config();
        git_config(git_diff_ui_config, NULL);
 
        init_revisions(&rev, prefix);