mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-03 04:01:41 +00:00
examples/log.c: invert filtering impl and conditional
This commit is contained in:
parent
87493bca9c
commit
33bf1b1ab0
@ -67,8 +67,8 @@ static void print_commit(git_commit *commit);
|
|||||||
static int match_with_parent(git_commit *commit, int i, git_diff_options *);
|
static int match_with_parent(git_commit *commit, int i, git_diff_options *);
|
||||||
|
|
||||||
/** utility functions for filtering */
|
/** utility functions for filtering */
|
||||||
static int signature_does_not_match(const git_signature *sig, const char *filter);
|
static int signature_matches(const git_signature *sig, const char *filter);
|
||||||
static int log_message_does_not_match(const git_commit *commit, const char *filter);
|
static int log_message_matches(const git_commit *commit, const char *filter);
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -132,13 +132,13 @@ int main(int argc, char *argv[])
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signature_does_not_match(git_commit_author(commit), opt.author))
|
if (!signature_matches(git_commit_author(commit), opt.author))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (signature_does_not_match(git_commit_committer(commit), opt.committer))
|
if (!signature_matches(git_commit_committer(commit), opt.committer))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (log_message_does_not_match(commit, opt.grep))
|
if (!log_message_matches(commit, opt.grep))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (count++ < opt.skip)
|
if (count++ < opt.skip)
|
||||||
@ -186,26 +186,26 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Determine if the given git_signature does not contain the filter text. */
|
/** Determine if the given git_signature does not contain the filter text. */
|
||||||
static int signature_does_not_match(const git_signature *sig, const char *filter) {
|
static int signature_matches(const git_signature *sig, const char *filter) {
|
||||||
if (filter == NULL)
|
if (filter == NULL)
|
||||||
return 0;
|
return 1;
|
||||||
|
|
||||||
if (sig == NULL ||
|
if (sig != NULL &&
|
||||||
(strstr(sig->name, filter) == NULL &&
|
(strstr(sig->name, filter) != NULL ||
|
||||||
strstr(sig->email, filter) == NULL))
|
strstr(sig->email, filter) != NULL))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int log_message_does_not_match(const git_commit *commit, const char *filter) {
|
static int log_message_matches(const git_commit *commit, const char *filter) {
|
||||||
const char *message = NULL;
|
const char *message = NULL;
|
||||||
|
|
||||||
if (filter == NULL)
|
if (filter == NULL)
|
||||||
return 0;
|
return 1;
|
||||||
|
|
||||||
if ((message = git_commit_message(commit)) == NULL ||
|
if ((message = git_commit_message(commit)) != NULL &&
|
||||||
strstr(message, filter) == NULL)
|
strstr(message, filter) != NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user