summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f8bf132)
raw | patch | inline | side by side (parent: f8bf132)
author | Dominik Vogt <dvogt@ffm.tc.iot.dtag.de> | |
Mon, 7 Apr 2008 11:34:53 +0000 (13:34 +0200) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Thu, 17 Apr 2008 12:17:53 +0000 (14:17 +0200) |
Do not search for matches in hidden view elements.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
tig.c | patch | blob | history |
index 42a2da5a18bcf01b56b51c46e1f420b781c95dab..9d0dca1a07d81694a5732f92d75f9b68ea41fd14 100644 (file)
--- a/tig.c
+++ b/tig.c
struct blame_commit *commit = blame->commit;
regmatch_t pmatch;
-#define MATCH(text) \
- (*text && regexec(view->regex, text, 1, &pmatch, 0) != REG_NOMATCH)
+#define MATCH(text, on) \
+ (on && *text && regexec(view->regex, text, 1, &pmatch, 0) != REG_NOMATCH)
if (commit) {
char buf[DATE_COLS + 1];
- if (MATCH(commit->title) ||
- MATCH(commit->author) ||
- MATCH(commit->id))
+ if (MATCH(commit->title, 1) ||
+ MATCH(commit->author, opt_author) ||
+ MATCH(commit->id, opt_date))
return TRUE;
if (strftime(buf, sizeof(buf), DATE_FORMAT, &commit->time) &&
- MATCH(buf))
+ MATCH(buf, 1))
return TRUE;
}
- return MATCH(blame->text);
+ return MATCH(blame->text, 1);
#undef MATCH
}
return REQ_NONE;
}
+static bool
+grep_refs(struct ref **refs, regex_t *regex)
+{
+ regmatch_t pmatch;
+ size_t i = 0;
+
+ if (!refs)
+ return FALSE;
+ do {
+ if (regexec(regex, refs[i]->name, 1, &pmatch, 0) != REG_NOMATCH)
+ return TRUE;
+ } while (refs[i++]->next);
+
+ return FALSE;
+}
+
static bool
main_grep(struct view *view, struct line *line)
{
struct commit *commit = line->data;
- enum { S_TITLE, S_AUTHOR, S_DATE, S_END } state;
+ enum { S_TITLE, S_AUTHOR, S_DATE, S_REFS, S_END } state;
char buf[DATE_COLS + 1];
regmatch_t pmatch;
switch (state) {
case S_TITLE: text = commit->title; break;
- case S_AUTHOR: text = commit->author; break;
+ case S_AUTHOR:
+ if (!opt_author)
+ continue;
+ text = commit->author;
+ break;
case S_DATE:
+ if (!opt_date)
+ continue;
if (!strftime(buf, sizeof(buf), DATE_FORMAT, &commit->time))
continue;
text = buf;
break;
-
+ case S_REFS:
+ if (!opt_show_refs)
+ continue;
+ if (grep_refs(commit->refs, view->regex) == TRUE)
+ return TRUE;
+ continue;
default:
return FALSE;
}