parse_pathspec: accept :(icase)path syntax
[gitweb.git] / builtin / diff.c
index 661fdde4d5169a59232db5494edc85b06a9928cc..2fb8c5dc0b6fdc97beb82f4dc3802a8f0dad8211 100644 (file)
@@ -140,7 +140,7 @@ static int builtin_diff_index(struct rev_info *revs,
                usage(builtin_diff_usage);
        if (!cached) {
                setup_work_tree();
-               if (read_cache_preload(revs->diffopt.pathspec.raw) < 0) {
+               if (read_cache_preload(&revs->diffopt.pathspec) < 0) {
                        perror("read_cache_preload");
                        return -1;
                }
@@ -242,7 +242,7 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv
                revs->combine_merges = revs->dense_combined_merges = 1;
 
        setup_work_tree();
-       if (read_cache_preload(revs->diffopt.pathspec.raw) < 0) {
+       if (read_cache_preload(&revs->diffopt.pathspec) < 0) {
                perror("read_cache_preload");
                return -1;
        }
@@ -339,9 +339,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
        }
 
        for (i = 0; i < rev.pending.nr; i++) {
-               struct object_array_entry *list = rev.pending.objects+i;
-               struct object *obj = list->item;
-               const char *name = list->name;
+               struct object_array_entry *entry = &rev.pending.objects[i];
+               struct object *obj = entry->item;
+               const char *name = entry->name;
                int flags = (obj->flags & UNINTERESTING);
                if (!obj->parsed)
                        obj = parse_object(obj->sha1);
@@ -350,24 +350,25 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                        die(_("invalid object '%s' given."), name);
                if (obj->type == OBJ_COMMIT)
                        obj = &((struct commit *)obj)->tree->object;
+
                if (obj->type == OBJ_TREE) {
                        obj->flags |= flags;
                        add_object_array(obj, name, &ent);
-                       continue;
-               }
-               if (obj->type == OBJ_BLOB) {
+               } else if (obj->type == OBJ_BLOB) {
                        if (2 <= blobs)
                                die(_("more than two blobs given: '%s'"), name);
                        hashcpy(blob[blobs].sha1, obj->sha1);
                        blob[blobs].name = name;
-                       blob[blobs].mode = list->mode;
+                       blob[blobs].mode = entry->mode;
                        blobs++;
-                       continue;
 
+               } else {
+                       die(_("unhandled object '%s' given."), name);
                }
-               die(_("unhandled object '%s' given."), name);
        }
        if (rev.prune_data.nr) {
+               /* builtin_diff_b_f() */
+               GUARD_PATHSPEC(&rev.prune_data, PATHSPEC_FROMTOP | PATHSPEC_LITERAL);
                if (!path)
                        path = rev.prune_data.items[0].match;
                paths += rev.prune_data.nr;