Code

difftool: add various git-difftool tests
[git.git] / diff-no-index.c
index 2d541d9aba11ee69525a6a1ef5da6f8a61e9e65e..42c1dd8ad3b0633767bf577975a895722f882565 100644 (file)
@@ -38,9 +38,13 @@ static int get_mode(const char *path, int *mode)
 
        if (!path || !strcmp(path, "/dev/null"))
                *mode = 0;
+#ifdef _WIN32
+       else if (!strcasecmp(path, "nul"))
+               *mode = 0;
+#endif
        else if (!strcmp(path, "-"))
                *mode = create_ce_mode(0666);
-       else if (stat(path, &st))
+       else if (lstat(path, &st))
                return error("Could not access '%s'", path);
        else
                *mode = st.st_mode;
@@ -201,8 +205,6 @@ void diff_no_index(struct rev_info *revs,
                    no_index ? "--no-index" : "[--no-index]");
 
        diff_setup(&revs->diffopt);
-       if (!revs->diffopt.output_format)
-               revs->diffopt.output_format = DIFF_FORMAT_PATCH;
        for (i = 1; i < argc - 2; ) {
                int j;
                if (!strcmp(argv[i], "--no-index"))
@@ -248,6 +250,8 @@ void diff_no_index(struct rev_info *revs,
                revs->diffopt.paths = argv + argc - 2;
        revs->diffopt.nr_paths = 2;
        revs->diffopt.skip_stat_unmatch = 1;
+       if (!revs->diffopt.output_format)
+               revs->diffopt.output_format = DIFF_FORMAT_PATCH;
 
        DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
        DIFF_OPT_SET(&revs->diffopt, NO_INDEX);