X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=diff-no-index.c;h=43aeeba2e0fd9c3c175dbc74a6f488e2c352c928;hb=01aedc930b6c3b46d229e33ac6f70b3d91fc1d2b;hp=7273a7a0b648cc8cbd6dce2043a6e544b87d28b6;hpb=c5034673fd92b6278e6c9d55683770ec01fafc89;p=git.git diff --git a/diff-no-index.c b/diff-no-index.c index 7273a7a0b..43aeeba2e 100644 --- a/diff-no-index.c +++ b/diff-no-index.c @@ -26,7 +26,7 @@ static int read_directory(const char *path, struct string_list *list) while ((e = readdir(dir))) if (strcmp(".", e->d_name) && strcmp("..", e->d_name)) - string_list_insert(e->d_name, list); + string_list_insert(list, e->d_name); closedir(dir); return 0; @@ -38,6 +38,10 @@ 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 (lstat(path, &st)) @@ -146,16 +150,14 @@ static int queue_diff(struct diff_options *o, static int path_outside_repo(const char *path) { - /* - * We have already done setup_git_directory_gently() so we - * know we are inside a git work tree already. - */ const char *work_tree; size_t len; if (!is_absolute_path(path)) return 0; work_tree = get_git_work_tree(); + if (!work_tree) + return 1; len = strlen(work_tree); if (strncmp(path, work_tree, len) || (path[len] != '\0' && path[len] != '/')) @@ -197,8 +199,8 @@ void diff_no_index(struct rev_info *revs, return; } if (argc != i + 2) - die("git diff %s takes two paths", - no_index ? "--no-index" : "[--no-index]"); + usagef("git diff %s ", + no_index ? "--no-index" : "[--no-index]"); diff_setup(&revs->diffopt); for (i = 1; i < argc - 2; ) { @@ -229,7 +231,7 @@ void diff_no_index(struct rev_info *revs, if (prefix) { int len = strlen(prefix); - revs->diffopt.paths = xcalloc(2, sizeof(char*)); + revs->diffopt.paths = xcalloc(2, sizeof(char *)); for (i = 0; i < 2; i++) { const char *p = argv[argc - 2 + i]; /*