Skip to content

Commit 12a888d

Browse files
authored
examples: log: pass options pointer to print_commit
Cleaned up the PR to address styling issues.
1 parent 27ff888 commit 12a888d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

examples/log.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ static int add_revision(struct log_state *s, const char *revstr);
4949

5050
/** log_options holds other command line options that affect log output */
5151
struct log_options {
52-
int show_diff, show_log_size;
52+
int show_diff;
53+
int show_log_size;
5354
int skip, limit;
5455
int min_parents, max_parents;
5556
git_time_t before;
@@ -63,7 +64,7 @@ struct log_options {
6364
static int parse_options(
6465
struct log_state *s, struct log_options *opt, int argc, char **argv);
6566
static void print_time(const git_time *intime, const char *prefix);
66-
static void print_commit(git_commit *commit, int show_log_size);
67+
static void print_commit(git_commit *commit, struct log_options *opts);
6768
static int match_with_parent(git_commit *commit, int i, git_diff_options *);
6869

6970
/** utility functions for filtering */
@@ -148,7 +149,7 @@ int main(int argc, char *argv[])
148149
break;
149150
}
150151

151-
print_commit(commit, opt.show_log_size);
152+
print_commit(commit, &opt);
152153

153154
if (opt.show_diff) {
154155
git_tree *a = NULL, *b = NULL;
@@ -337,7 +338,7 @@ static void print_time(const git_time *intime, const char *prefix)
337338
}
338339

339340
/** Helper to print a commit object. */
340-
static void print_commit(git_commit *commit, int show_log_size)
341+
static void print_commit(git_commit *commit, struct log_options *opts)
341342
{
342343
char buf[GIT_OID_HEXSZ + 1];
343344
int i, count;
@@ -347,9 +348,8 @@ static void print_commit(git_commit *commit, int show_log_size)
347348
git_oid_tostr(buf, sizeof(buf), git_commit_id(commit));
348349
printf("commit %s\n", buf);
349350

350-
if (show_log_size) {
351-
printf("log size %d", (int)strlen(git_commit_message(commit)));
352-
printf("\n");
351+
if (opts->show_log_size) {
352+
printf("log size %d\n", (int)strlen(git_commit_message(commit)));
353353
}
354354

355355
if ((count = (int)git_commit_parentcount(commit)) > 1) {

0 commit comments

Comments
 (0)