worktree: disallow adding same path multiple times
[gitweb.git] / builtin / diff-index.c
index 1c737f79216fda2e5395422d8aee2e4f5d6482a4..522f4fdffd064de2e50232934cb7d616246c92e4 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "config.h"
 #include "diff.h"
 #include "commit.h"
 #include "revision.h"
@@ -7,7 +8,7 @@
 
 static const char diff_cache_usage[] =
 "git diff-index [-m] [--cached] "
-"[<common diff options>] <tree-ish> [<path>...]"
+"[<common-diff-options>] <tree-ish> [<path>...]"
 COMMON_DIFF_OPTIONS_HELP;
 
 int cmd_diff_index(int argc, const char **argv, const char *prefix)
@@ -17,10 +18,13 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
        int i;
        int result;
 
-       init_revisions(&rev, prefix);
-       gitmodules_config();
+       if (argc == 2 && !strcmp(argv[1], "-h"))
+               usage(diff_cache_usage);
+
        git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
+       init_revisions(&rev, prefix);
        rev.abbrev = 0;
+       precompose_argv(argc, argv);
 
        argc = setup_revisions(argc, argv, &rev, NULL);
        for (i = 1; i < argc; i++) {
@@ -43,7 +47,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
                usage(diff_cache_usage);
        if (!cached) {
                setup_work_tree();
-               if (read_cache_preload(rev.diffopt.pathspec.raw) < 0) {
+               if (read_cache_preload(&rev.diffopt.pathspec) < 0) {
                        perror("read_cache_preload");
                        return -1;
                }
@@ -52,5 +56,6 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
                return -1;
        }
        result = run_diff_index(&rev, cached);
+       UNLEAK(rev);
        return diff_result_code(&rev.diffopt, result);
 }