Re: [PATCH] git-tag: Fix -l option to use better shell style globs.
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 1, 2007, 06:16 UTC
- Message-ID
- <7v8x7qvrka.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <46D8F431.70801@gmail.com>
Carlos Rica <jasampler@gmail.com> writes:
Show 13 quoted lines
> if (pattern == NULL) > - pattern = ""; > + pattern = "*"; > > - /* prepend/append * to the shell pattern: */ > - newpattern = xmalloc(strlen(pattern) + 3); > - sprintf(newpattern, "*%s*", pattern); > - > - filter.pattern = newpattern; > + filter.pattern = pattern; > filter.lines = lines; > > for_each_tag_ref(show_reference, (void *) &filter);
I think it is conceptually simpler on the show_reference side to allow (filter.pattern == NULL) and say:
if (!filter->pattern || !fnmatch(filter->pattern, refname, 0)) {
... show that ref ...
}It is not such a big deal now you do not do newpattern allocation anymore, so I'll apply the patch as is.