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>
Linus Torvalds committed
Sep 18, 2006 at 10:07 UTC
a2ed6ae402582a3ee76e9b4639848eba261a12de
1 file changed
+8
-2
revision.c
+8
-2
@@ -677,6 +677,7 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
677
static void add_header_grep(struct rev_info *revs, const char *field, const char *pattern)
678
{
679
char *pat;
680
+ const char *prefix;
681
int patlen, fldlen;
682
683
if (!revs->header_filter) {
@@ -689,8 +690,13 @@ static void add_header_grep(struct rev_info *revs, const char *field, const char
690
691
fldlen = strlen(field);
692
patlen = strlen(pattern);
692
- pat = xmalloc(patlen + fldlen + 3);
693
- sprintf(pat, "^%s %s", field, pattern);
693
+ pat = xmalloc(patlen + fldlen + 10);
694
+ prefix = ".*";
695
+ if (*pattern == '^') {
696
+ prefix = "";
697
+ pattern++;
698
+ }
699
+ sprintf(pat, "^%s %s%s", field, prefix, pattern);
700
append_grep_pattern(revs->header_filter, pat,
701
"command line", 0, GREP_PATTERN);
702
}