* Very limited pathspec wildcards..
@ 2005-08-03 17:48 Linus Torvalds
2005-08-03 19:02 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2005-08-03 17:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List
I ended up looking at wildcards in pathspecs, but wasn't quite ready
enough to pay the price of real wildcards. This limited form is the end
result.
It allows a final '*' in the path matching to indicate that we don't care
about the "match exact files/subdirectories only" rule.
So while
git-whatchanged git
will only show the file called "git" (or any changes under a subdirectory
called "git"),
git-whatchanged git*
will show anything that starts with "git".
Note that this _only_ works at the very end. You can't say
git-whatchanged git-*-script
even though maybe it would be good if we allowed full wildcards some day.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
Btw, I'm not sure this is a wonderful idea. I found it useful for doing
git-whatchanged -p drivers/scsi/aic7xxx/aic79xx*
since I was interested in seeign if only that particular driver had had
changes. But it's hacky and pretty limited, so I throw this patch out more
as a "maybe others think it is a good idea" thing.
So Junio, if you feel this is ugly, just drop it, I certainly won't mind.
As it is you can't even escape the '*', so if you actually only want to
match a filename that literally ends in an asterisk, this makes that
impossible, and will match that file _and_ anything that shares the same
prefix..
diff --git a/diff-tree.c b/diff-tree.c
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -163,6 +163,12 @@ static int interesting(void *tree, unsig
for (i=0; i < nr_paths; i++) {
const char *match = paths[i];
int matchlen = pathlens[i];
+ int wildcard = 0;
+
+ if (matchlen && match[matchlen-1] == '*') {
+ matchlen--;
+ wildcard = 1;
+ }
if (baselen >= matchlen) {
/* If it doesn't match, move along... */
@@ -183,7 +189,7 @@ static int interesting(void *tree, unsig
if (pathlen > matchlen)
continue;
- if (matchlen > pathlen) {
+ if (!wildcard && matchlen > pathlen) {
if (match[pathlen] != '/')
continue;
if (!S_ISDIR(mode))
diff --git a/read-cache.c b/read-cache.c
--- a/read-cache.c
+++ b/read-cache.c
@@ -183,10 +183,17 @@ int ce_path_match(const struct cache_ent
name = ce->name;
while ((match = *pathspec++) != NULL) {
int matchlen = strlen(match);
+ int wildcard = 0;
+ if (matchlen && match[matchlen-1]) {
+ matchlen--;
+ wildcard = 1;
+ }
if (matchlen > len)
continue;
if (memcmp(name, match, matchlen))
continue;
+ if (wildcard)
+ return 1;
if (matchlen && name[matchlen-1] == '/')
return 1;
if (name[matchlen] == '/' || !name[matchlen])
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Very limited pathspec wildcards..
2005-08-03 17:48 Very limited pathspec wildcards Linus Torvalds
@ 2005-08-03 19:02 ` Junio C Hamano
2005-08-03 19:38 ` Linus Torvalds
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2005-08-03 19:02 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
Linus Torvalds <torvalds@osdl.org> writes:
> Btw, I'm not sure this is a wonderful idea. I found it useful for doing
>
> git-whatchanged -p drivers/scsi/aic7xxx/aic79xx*
>
> since I was interested in seeign if only that particular driver had had
> changes. But it's hacky and pretty limited, so I throw this patch out more
> as a "maybe others think it is a good idea" thing.
Wouldn't something like this work equally well?
#!/bin/sh
git-whatchanged -r |
sed -ne '
/^:/s|aic7xxx/aic79xx|&|p
/^:/d
p' | git-diff-helper
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Very limited pathspec wildcards..
2005-08-03 19:02 ` Junio C Hamano
@ 2005-08-03 19:38 ` Linus Torvalds
0 siblings, 0 replies; 3+ messages in thread
From: Linus Torvalds @ 2005-08-03 19:38 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Wed, 3 Aug 2005, Junio C Hamano wrote:
>
> Wouldn't something like this work equally well?
Nope, for several reasons:
- it's _horribly_ inefficient (ie it traverses directories that it
doesn't need to)
- it shows all the changeset comments, regardless of whether they are
releant or not. It just removes the diffs.
Try it out.
Junio, name-based filters _have_ to be done early. This is why
"diffcore-pathspec" isn't used any more - it's _much_ too inefficient to
do it later.
Linus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-08-03 19:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-03 17:48 Very limited pathspec wildcards Linus Torvalds
2005-08-03 19:02 ` Junio C Hamano
2005-08-03 19:38 ` Linus Torvalds
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).