grep: prepare for new header field filter

grep supports only author and committer headers, which have the same
special treatment that later headers may or may not have. Check for
field type and only strip_timestamp() when the field is either author
or committer.

GREP_HEADER_FIELD_MAX is put in the grep_header_field enum to be
calculated automatically, correctly, as long as it's at the end of the
enum.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Nguyễn Thái Ngọc Duy
2012-09-29 11:41:27 +07:00
committed by Junio C Hamano
parent 652398a88e
commit ad4813b3c2
3 changed files with 24 additions and 3 deletions

6
grep.h
View File

@ -29,9 +29,11 @@ enum grep_context {
enum grep_header_field {
GREP_HEADER_AUTHOR = 0,
GREP_HEADER_COMMITTER
GREP_HEADER_COMMITTER,
/* Must be at the end of the enum */
GREP_HEADER_FIELD_MAX
};
#define GREP_HEADER_FIELD_MAX (GREP_HEADER_COMMITTER + 1)
struct grep_pat {
struct grep_pat *next;