Merge branch 'nd/magic-pathspec' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 17 Dec 2013 19:21:34 +0000 (11:21 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 17 Dec 2013 19:21:34 +0000 (11:21 -0800)
"git diff -- ':(icase)makefile'" was unnecessarily rejected at the
command line parser.

* nd/magic-pathspec:
diff: restrict pathspec limitations to diff b/f case only

1  2 
builtin/diff.c
diff --combined builtin/diff.c
index adb93a9efa5ed9b97a08224e46f6fbaf680343e6,2af254222593883e9ea0b7288e016dd0aba7102f..fe0cc7f1b5b1451f267b1d9e24a6e40cd6e55325
@@@ -64,15 -64,18 +64,18 @@@ static void stuff_change(struct diff_op
  
  static int builtin_diff_b_f(struct rev_info *revs,
                            int argc, const char **argv,
-                           struct blobinfo *blob,
-                           const char *path)
+                           struct blobinfo *blob)
  {
        /* Blob vs file in the working tree*/
        struct stat st;
+       const char *path;
  
        if (argc > 1)
                usage(builtin_diff_usage);
  
+       GUARD_PATHSPEC(&revs->prune_data, PATHSPEC_FROMTOP | PATHSPEC_LITERAL);
+       path = revs->prune_data.items[0].match;
        if (lstat(path, &st))
                die_errno(_("failed to stat '%s'"), path);
        if (!(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)))
@@@ -169,7 -172,7 +172,7 @@@ static int builtin_diff_tree(struct rev
        if (ent1->item->flags & UNINTERESTING)
                swap = 1;
        sha1[swap] = ent0->item->sha1;
 -      sha1[1-swap] = ent1->item->sha1;
 +      sha1[1 - swap] = ent1->item->sha1;
        diff_tree_sha1(sha1[0], sha1[1], "", &revs->diffopt);
        log_tree_diff_flush(revs);
        return 0;
@@@ -255,7 -258,6 +258,6 @@@ int cmd_diff(int argc, const char **arg
        struct rev_info rev;
        struct object_array ent = OBJECT_ARRAY_INIT;
        int blobs = 0, paths = 0;
-       const char *path = NULL;
        struct blobinfo blob[2];
        int nongit;
        int result = 0;
                        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;
+       if (rev.prune_data.nr)
                paths += rev.prune_data.nr;
-       }
  
        /*
         * Now, do the arguments look reasonable?
                case 1:
                        if (paths != 1)
                                usage(builtin_diff_usage);
-                       result = builtin_diff_b_f(&rev, argc, argv, blob, path);
+                       result = builtin_diff_b_f(&rev, argc, argv, blob);
                        break;
                case 2:
                        if (paths)