mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-19 22:44:42 +00:00
Add support for --author flag in example log implementation
This commit is contained in:
parent
9331f98aca
commit
97fc71ab3b
@ -54,7 +54,7 @@ struct log_options {
|
|||||||
int min_parents, max_parents;
|
int min_parents, max_parents;
|
||||||
git_time_t before;
|
git_time_t before;
|
||||||
git_time_t after;
|
git_time_t after;
|
||||||
char *author;
|
const char *author;
|
||||||
char *committer;
|
char *committer;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -75,6 +75,7 @@ int main(int argc, char *argv[])
|
|||||||
git_oid oid;
|
git_oid oid;
|
||||||
git_commit *commit = NULL;
|
git_commit *commit = NULL;
|
||||||
git_pathspec *ps = NULL;
|
git_pathspec *ps = NULL;
|
||||||
|
const git_signature *sig;
|
||||||
|
|
||||||
git_threads_init();
|
git_threads_init();
|
||||||
|
|
||||||
@ -128,6 +129,12 @@ int main(int argc, char *argv[])
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opt.author != NULL) {
|
||||||
|
if ((sig = git_commit_author(commit)) == NULL ||
|
||||||
|
strstr(sig->name, opt.author) == NULL)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (count++ < opt.skip)
|
if (count++ < opt.skip)
|
||||||
continue;
|
continue;
|
||||||
if (opt.limit != -1 && printed++ >= opt.limit) {
|
if (opt.limit != -1 && printed++ >= opt.limit) {
|
||||||
@ -401,6 +408,8 @@ static int parse_options(
|
|||||||
set_sorting(s, GIT_SORT_TOPOLOGICAL);
|
set_sorting(s, GIT_SORT_TOPOLOGICAL);
|
||||||
else if (!strcmp(a, "--reverse"))
|
else if (!strcmp(a, "--reverse"))
|
||||||
set_sorting(s, GIT_SORT_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"))
|
else if (match_str_arg(&s->repodir, &args, "--git-dir"))
|
||||||
/** Found git-dir. */;
|
/** Found git-dir. */;
|
||||||
else if (match_int_arg(&opt->skip, &args, "--skip", 0))
|
else if (match_int_arg(&opt->skip, &args, "--skip", 0))
|
||||||
|
Loading…
Reference in New Issue
Block a user