builtin/fmt-merge-message: convert to struct object_id
[gitweb.git] / builtin / diff.c
index d6b8f9834d8f1ef26da5994a24db73c1b0b83221..7f91f6d2267db962fb7c25e92983afd4e811d43e 100644 (file)
@@ -301,23 +301,25 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                        break;
        }
 
-       if (!no_index)
-               prefix = setup_git_directory_gently(&nongit);
+       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
-        * outside of a git repository.  In this case it behaves
-        * the same way as "git diff --no-index <a> <b>", which acts
-        * as a colourful "diff" replacement.
-        */
-       if (nongit || ((argc == i + 2) &&
-                      (!path_inside_repo(prefix, argv[i]) ||
-                       !path_inside_repo(prefix, argv[i + 1]))))
-               no_index = DIFF_NO_INDEX_IMPLICIT;
+       if (!no_index) {
+               /*
+                * Treat git diff with at least one path outside of the
+                * repo the same as if the command would have been executed
+                * outside of a git repository.  In this case it behaves
+                * the same way as "git diff --no-index <a> <b>", which acts
+                * as a colourful "diff" replacement.
+                */
+               if (nongit || ((argc == i + 2) &&
+                              (!path_inside_repo(prefix, argv[i]) ||
+                               !path_inside_repo(prefix, argv[i + 1]))))
+                       no_index = DIFF_NO_INDEX_IMPLICIT;
+       }
 
        if (!no_index)
                gitmodules_config();
+       init_diff_ui_defaults();
        git_config(git_diff_ui_config, NULL);
        precompose_argv(argc, argv);