git-log --author and --committer are not left-anchored by default

I know that I'd prefer a rule where

	"--author=^Junio"

would result in the grep-pattern being "^author Junio", but without the
initial '^' it would be "^author .*Junio".

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Linus Torvalds 2006-09-18 10:07:51 -07:00 коммит произвёл Junio C Hamano
Родитель f69895fb0c
Коммит a2ed6ae402
1 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -677,6 +677,7 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
static void add_header_grep(struct rev_info *revs, const char *field, const char *pattern) static void add_header_grep(struct rev_info *revs, const char *field, const char *pattern)
{ {
char *pat; char *pat;
const char *prefix;
int patlen, fldlen; int patlen, fldlen;
if (!revs->header_filter) { if (!revs->header_filter) {
@ -689,8 +690,13 @@ static void add_header_grep(struct rev_info *revs, const char *field, const char
fldlen = strlen(field); fldlen = strlen(field);
patlen = strlen(pattern); patlen = strlen(pattern);
pat = xmalloc(patlen + fldlen + 3); pat = xmalloc(patlen + fldlen + 10);
sprintf(pat, "^%s %s", field, pattern); prefix = ".*";
if (*pattern == '^') {
prefix = "";
pattern++;
}
sprintf(pat, "^%s %s%s", field, prefix, pattern);
append_grep_pattern(revs->header_filter, pat, append_grep_pattern(revs->header_filter, pat,
"command line", 0, GREP_PATTERN); "command line", 0, GREP_PATTERN);
} }