summaryrefslogtreecommitdiff
path: root/examples/diff.c
diff options
context:
space:
mode:
authorEtienne Samson <samson.etienne@gmail.com>2019-11-06 11:08:49 +0100
committerEtienne Samson <samson.etienne@gmail.com>2019-11-06 11:17:56 +0100
commit313908f9f5322f623ef1924f859726b39cb9740c (patch)
tree599dabe529ddda13e447366a7552ba74b0941d42 /examples/diff.c
parent4a4ad2bc8374db6e82464a6f066840430b6657ec (diff)
downloadlibgit2-313908f9f5322f623ef1924f859726b39cb9740c.tar.gz
examples: normalize decls and usage of options structs
Diffstat (limited to 'examples/diff.c')
-rw-r--r--examples/diff.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/examples/diff.c b/examples/diff.c
index 9e2aa9c41..2305c8652 100644
--- a/examples/diff.c
+++ b/examples/diff.c
@@ -47,8 +47,8 @@ enum {
CACHE_NONE = 2
};
-/** The 'opts' struct captures all the various parsed command line options. */
-struct opts {
+/** The 'diff_options' struct captures all the various parsed command line options. */
+struct diff_options {
git_diff_options diffopts;
git_diff_find_options findopts;
int color;
@@ -63,18 +63,17 @@ struct opts {
/** These functions are implemented at the end */
static void usage(const char *message, const char *arg);
-static void parse_opts(struct opts *o, int argc, char *argv[]);
+static void parse_opts(struct diff_options *o, int argc, char *argv[]);
static int color_printer(
const git_diff_delta*, const git_diff_hunk*, const git_diff_line*, void*);
-static void diff_print_stats(git_diff *diff, struct opts *o);
-static void compute_diff_no_index(git_diff **diff, struct opts *o);
+static void diff_print_stats(git_diff *diff, struct diff_options *o);
+static void compute_diff_no_index(git_diff **diff, struct diff_options *o);
int lg2_diff(git_repository *repo, int argc, char *argv[])
{
git_tree *t1 = NULL, *t2 = NULL;
git_diff *diff;
-
- struct opts o = {
+ struct diff_options o = {
GIT_DIFF_OPTIONS_INIT, GIT_DIFF_FIND_OPTIONS_INIT,
-1, -1, 0, 0, GIT_DIFF_FORMAT_PATCH, NULL, NULL, "."
};
@@ -166,7 +165,7 @@ int lg2_diff(git_repository *repo, int argc, char *argv[])
return 0;
}
-static void compute_diff_no_index(git_diff **diff, struct opts *o) {
+static void compute_diff_no_index(git_diff **diff, struct diff_options *o) {
git_patch *patch = NULL;
char *file1_str = NULL;
char *file2_str = NULL;
@@ -242,11 +241,10 @@ static int color_printer(
}
/** Parse arguments as copied from git-diff. */
-static void parse_opts(struct opts *o, int argc, char *argv[])
+static void parse_opts(struct diff_options *o, int argc, char *argv[])
{
struct args_info args = ARGS_INFO_INIT;
-
for (args.pos = 1; args.pos < argc; ++args.pos) {
const char *a = argv[args.pos];
@@ -343,7 +341,7 @@ static void parse_opts(struct opts *o, int argc, char *argv[])
}
/** Display diff output with "--stat", "--numstat", or "--shortstat" */
-static void diff_print_stats(git_diff *diff, struct opts *o)
+static void diff_print_stats(git_diff *diff, struct diff_options *o)
{
git_diff_stats *stats;
git_buf b = GIT_BUF_INIT_CONST(NULL, 0);