Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEoin Coffey <ecoffey@gmail.com>2014-05-23 02:01:45 +0400
committerEoin Coffey <ecoffey@gmail.com>2014-05-23 03:22:45 +0400
commit97fc71ab3b935df5f32faae13035e40eeb03c07f (patch)
tree1c0c674b705baa11bdca7feebf9d8c8c32ca0b1c /examples
parent9331f98acaffd377a8076ab111bed84ff89e8e72 (diff)
Add support for --author flag in example log implementation
Diffstat (limited to 'examples')
-rw-r--r--examples/log.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/examples/log.c b/examples/log.c
index 471c5ff96..655b95d10 100644
--- a/examples/log.c
+++ b/examples/log.c
@@ -54,7 +54,7 @@ struct log_options {
int min_parents, max_parents;
git_time_t before;
git_time_t after;
- char *author;
+ const char *author;
char *committer;
};
@@ -75,6 +75,7 @@ int main(int argc, char *argv[])
git_oid oid;
git_commit *commit = NULL;
git_pathspec *ps = NULL;
+ const git_signature *sig;
git_threads_init();
@@ -128,6 +129,12 @@ int main(int argc, char *argv[])
continue;
}
+ if (opt.author != NULL) {
+ if ((sig = git_commit_author(commit)) == NULL ||
+ strstr(sig->name, opt.author) == NULL)
+ continue;
+ }
+
if (count++ < opt.skip)
continue;
if (opt.limit != -1 && printed++ >= opt.limit) {
@@ -401,6 +408,8 @@ static int parse_options(
set_sorting(s, GIT_SORT_TOPOLOGICAL);
else if (!strcmp(a, "--reverse"))
set_sorting(s, GIT_SORT_REVERSE);
+ else if (match_str_arg(&opt->author, &args, "--author"))
+ /** Found valid --author */;
else if (match_str_arg(&s->repodir, &args, "--git-dir"))
/** Found git-dir. */;
else if (match_int_arg(&opt->skip, &args, "--skip", 0))