[PATCH] allow pathspec to end with a slash
authorJunio C Hamano <junkio@cox.net>
Fri, 27 May 2005 00:52:43 +0000 (17:52 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 27 May 2005 01:50:38 +0000 (18:50 -0700)
The recent rewrite broke "git-whatchanged -v -p drivers/usb/" but
"git-whatchanged -v -p drivers/usb" still works.  Just strip out the
trailing slashes internally to make it work again.

It uses compare-thing-with-number comparison order instead of visual
comparison order ;-).

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
diffcore-pathspec.c

index 78b3cb4..fd11822 100644 (file)
@@ -45,8 +45,12 @@ void diffcore_pathspec(const char **pathspec)
        speccnt = i;
        spec = xmalloc(sizeof(*spec) * speccnt);
        for (i = 0; pathspec[i]; i++) {
+               int l;
                spec[i].spec = pathspec[i];
-               spec[i].len = strlen(pathspec[i]);
+               l = strlen(pathspec[i]);
+               while (l > 0 && pathspec[i][l-1] == '/')
+                       l--;
+               spec[i].len = l;
        }
 
        for (i = 0; i < q->nr; i++) {