[PATCH] git-diff-cache: handle pathspec beginning with a dash
authorJonas Fonseca <fonseca@diku.dk>
Mon, 6 Jun 2005 21:27:00 +0000 (23:27 +0200)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 8 Jun 2005 20:03:25 +0000 (13:03 -0700)
Parse everything after '--' as tree name or pathspec.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
diff-cache.c

index e95fd70da83640d821adb89e97c6fc8b24d649da..1d355aa028f2521e8da5b77d14f35bd26eaaa3e4 100644 (file)
@@ -167,13 +167,14 @@ int main(int argc, const char **argv)
        void *tree;
        unsigned long size;
        int ret;
+       int allow_options = 1;
        int i;
 
        read_cache();
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];
 
-               if (*arg != '-') {
+               if (!allow_options || *arg != '-') {
                        if (tree_name) {
                                pathspec = argv + i;
                                break;
@@ -182,6 +183,10 @@ int main(int argc, const char **argv)
                        continue;
                }
                        
+               if (!strcmp(arg, "--")) {
+                       allow_options = 0;
+                       continue;
+               }
                if (!strcmp(arg, "-r")) {
                        /* We accept the -r flag just to look like git-diff-tree */
                        continue;