mirror of
https://github.com/libgit2/libgit2.git
synced 2026-01-25 02:56:17 +00:00
examples: normalize decls and usage of options structs
This commit is contained in:
@@ -40,7 +40,7 @@ struct index_options {
|
||||
};
|
||||
|
||||
/* Forward declarations for helpers */
|
||||
static void parse_opts(const char **repo_path, struct index_options *options, struct args_info *args);
|
||||
static void parse_opts(const char **repo_path, struct index_options *opts, struct args_info *args);
|
||||
int print_matched_cb(const char *path, const char *matched_pathspec, void *payload);
|
||||
|
||||
int lg2_add(git_repository *repo, int argc, char **argv)
|
||||
@@ -86,13 +86,13 @@ int lg2_add(git_repository *repo, int argc, char **argv)
|
||||
*/
|
||||
int print_matched_cb(const char *path, const char *matched_pathspec, void *payload)
|
||||
{
|
||||
struct index_options options = *(struct index_options *)(payload);
|
||||
struct index_options *opts = (struct index_options *)(payload);
|
||||
int ret;
|
||||
unsigned status;
|
||||
(void)matched_pathspec;
|
||||
|
||||
/* Get the file status */
|
||||
if (git_status_file(&status, options.repo, path) < 0)
|
||||
if (git_status_file(&status, opts->repo, path) < 0)
|
||||
return -1;
|
||||
|
||||
if ((status & GIT_STATUS_WT_MODIFIED) || (status & GIT_STATUS_WT_NEW)) {
|
||||
@@ -102,7 +102,7 @@ int print_matched_cb(const char *path, const char *matched_pathspec, void *paylo
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
if (options.dry_run)
|
||||
if (opts->dry_run)
|
||||
ret = 1;
|
||||
|
||||
return ret;
|
||||
@@ -132,7 +132,7 @@ void print_usage(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void parse_opts(const char **repo_path, struct index_options *options, struct args_info *args)
|
||||
static void parse_opts(const char **repo_path, struct index_options *opts, struct args_info *args)
|
||||
{
|
||||
if (args->argc <= 1)
|
||||
print_usage();
|
||||
@@ -142,9 +142,9 @@ static void parse_opts(const char **repo_path, struct index_options *options, st
|
||||
|
||||
if (curr[0] != '-') {
|
||||
if (!strcmp("add", curr)) {
|
||||
options->mode = INDEX_ADD;
|
||||
opts->mode = INDEX_ADD;
|
||||
continue;
|
||||
} else if (options->mode == INDEX_NONE) {
|
||||
} else if (opts->mode == INDEX_NONE) {
|
||||
fprintf(stderr, "missing command: %s", curr);
|
||||
print_usage();
|
||||
break;
|
||||
@@ -152,10 +152,10 @@ static void parse_opts(const char **repo_path, struct index_options *options, st
|
||||
/* We might be looking at a filename */
|
||||
break;
|
||||
}
|
||||
} else if (match_bool_arg(&options->verbose, args, "--verbose") ||
|
||||
match_bool_arg(&options->dry_run, args, "--dry-run") ||
|
||||
} else if (match_bool_arg(&opts->verbose, args, "--verbose") ||
|
||||
match_bool_arg(&opts->dry_run, args, "--dry-run") ||
|
||||
match_str_arg(repo_path, args, "--git-dir") ||
|
||||
(options->mode == INDEX_ADD && match_bool_arg(&options->add_update, args, "--update"))) {
|
||||
(opts->mode == INDEX_ADD && match_bool_arg(&opts->add_update, args, "--update"))) {
|
||||
continue;
|
||||
} else if (match_bool_arg(NULL, args, "--help")) {
|
||||
print_usage();
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* simulate the output of `git blame` and a few of its command line arguments.
|
||||
*/
|
||||
|
||||
struct opts {
|
||||
struct blame_opts {
|
||||
char *path;
|
||||
char *commitspec;
|
||||
int C;
|
||||
@@ -28,14 +28,14 @@ struct opts {
|
||||
int end_line;
|
||||
int F;
|
||||
};
|
||||
static void parse_opts(struct opts *o, int argc, char *argv[]);
|
||||
static void parse_opts(struct blame_opts *o, int argc, char *argv[]);
|
||||
|
||||
int lg2_blame(git_repository *repo, int argc, char *argv[])
|
||||
{
|
||||
int line, break_on_null_hunk;
|
||||
git_off_t i, rawsize;
|
||||
char spec[1024] = {0};
|
||||
struct opts o = {0};
|
||||
struct blame_opts o = {0};
|
||||
const char *rawdata;
|
||||
git_revspec revspec = {0};
|
||||
git_blame_options blameopts = GIT_BLAME_OPTIONS_INIT;
|
||||
@@ -143,7 +143,7 @@ static void usage(const char *msg, const char *arg)
|
||||
}
|
||||
|
||||
/** Parse the arguments. */
|
||||
static void parse_opts(struct opts *o, int argc, char *argv[])
|
||||
static void parse_opts(struct blame_opts *o, int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
char *bare_args[3] = {0};
|
||||
|
||||
@@ -102,27 +102,28 @@ static void show_tag(const git_tag *tag)
|
||||
printf("\n%s\n", git_tag_message(tag));
|
||||
}
|
||||
|
||||
enum {
|
||||
typedef enum {
|
||||
SHOW_TYPE = 1,
|
||||
SHOW_SIZE = 2,
|
||||
SHOW_NONE = 3,
|
||||
SHOW_PRETTY = 4
|
||||
};
|
||||
} catfile_mode;
|
||||
|
||||
/* Forward declarations for option-parsing helper */
|
||||
struct opts {
|
||||
struct catfile_options {
|
||||
const char *dir;
|
||||
const char *rev;
|
||||
int action;
|
||||
catfile_mode action;
|
||||
int verbose;
|
||||
};
|
||||
static void parse_opts(struct opts *o, int argc, char *argv[]);
|
||||
|
||||
static void parse_opts(struct catfile_options *o, int argc, char *argv[]);
|
||||
|
||||
|
||||
/** Entry point for this command */
|
||||
int lg2_cat_file(git_repository *repo, int argc, char *argv[])
|
||||
{
|
||||
struct opts o = { ".", NULL, 0, 0 };
|
||||
struct catfile_options o = { ".", NULL, 0, 0 };
|
||||
git_object *obj = NULL;
|
||||
char oidstr[GIT_OID_HEXSZ + 1];
|
||||
|
||||
@@ -201,7 +202,7 @@ static void usage(const char *message, const char *arg)
|
||||
}
|
||||
|
||||
/** Parse the command-line options taken from git */
|
||||
static void parse_opts(struct opts *o, int argc, char *argv[])
|
||||
static void parse_opts(struct catfile_options *o, int argc, char *argv[])
|
||||
{
|
||||
struct args_info args = ARGS_INFO_INIT;
|
||||
|
||||
|
||||
@@ -37,16 +37,14 @@
|
||||
*/
|
||||
|
||||
/** describe_options represents the parsed command line options */
|
||||
typedef struct {
|
||||
struct describe_options {
|
||||
const char **commits;
|
||||
size_t commit_count;
|
||||
git_describe_options describe_options;
|
||||
git_describe_format_options format_options;
|
||||
} describe_options;
|
||||
};
|
||||
|
||||
typedef struct args_info args_info;
|
||||
|
||||
static void opts_add_commit(describe_options *opts, const char *commit)
|
||||
static void opts_add_commit(struct describe_options *opts, const char *commit)
|
||||
{
|
||||
size_t sz;
|
||||
|
||||
@@ -57,7 +55,7 @@ static void opts_add_commit(describe_options *opts, const char *commit)
|
||||
opts->commits[opts->commit_count - 1] = commit;
|
||||
}
|
||||
|
||||
static void do_describe_single(git_repository *repo, describe_options *opts, const char *rev)
|
||||
static void do_describe_single(git_repository *repo, struct describe_options *opts, const char *rev)
|
||||
{
|
||||
git_object *commit;
|
||||
git_describe_result *describe_result;
|
||||
@@ -80,7 +78,7 @@ static void do_describe_single(git_repository *repo, describe_options *opts, con
|
||||
printf("%s\n", buf.ptr);
|
||||
}
|
||||
|
||||
static void do_describe(git_repository *repo, describe_options *opts)
|
||||
static void do_describe(git_repository *repo, struct describe_options *opts)
|
||||
{
|
||||
if (opts->commit_count == 0)
|
||||
do_describe_single(repo, opts, NULL);
|
||||
@@ -99,9 +97,9 @@ static void print_usage(void)
|
||||
}
|
||||
|
||||
/** Parse command line arguments */
|
||||
static void parse_options(describe_options *opts, int argc, char **argv)
|
||||
static void parse_options(struct describe_options *opts, int argc, char **argv)
|
||||
{
|
||||
args_info args = ARGS_INFO_INIT;
|
||||
struct args_info args = ARGS_INFO_INIT;
|
||||
|
||||
for (args.pos = 1; args.pos < argc; ++args.pos) {
|
||||
const char *curr = argv[args.pos];
|
||||
@@ -141,7 +139,7 @@ static void parse_options(describe_options *opts, int argc, char **argv)
|
||||
}
|
||||
|
||||
/** Initialize describe_options struct */
|
||||
static void describe_options_init(describe_options *opts)
|
||||
static void describe_options_init(struct describe_options *opts)
|
||||
{
|
||||
memset(opts, 0, sizeof(*opts));
|
||||
|
||||
@@ -153,7 +151,7 @@ static void describe_options_init(describe_options *opts)
|
||||
|
||||
int lg2_describe(git_repository *repo, int argc, char **argv)
|
||||
{
|
||||
describe_options opts;
|
||||
struct describe_options opts;
|
||||
|
||||
describe_options_init(&opts);
|
||||
parse_options(&opts, argc, argv);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
/** Forward declarations of helpers */
|
||||
struct opts {
|
||||
struct init_opts {
|
||||
int no_options;
|
||||
int quiet;
|
||||
int bare;
|
||||
@@ -38,11 +38,11 @@ struct opts {
|
||||
const char *dir;
|
||||
};
|
||||
static void create_initial_commit(git_repository *repo);
|
||||
static void parse_opts(struct opts *o, int argc, char *argv[]);
|
||||
static void parse_opts(struct init_opts *o, int argc, char *argv[]);
|
||||
|
||||
int lg2_init(git_repository *repo, int argc, char *argv[])
|
||||
{
|
||||
struct opts o = { 1, 0, 0, 0, GIT_REPOSITORY_INIT_SHARED_UMASK, 0, 0, 0 };
|
||||
struct init_opts o = { 1, 0, 0, 0, GIT_REPOSITORY_INIT_SHARED_UMASK, 0, 0, 0 };
|
||||
|
||||
parse_opts(&o, argc, argv);
|
||||
|
||||
@@ -210,7 +210,7 @@ static uint32_t parse_shared(const char *shared)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void parse_opts(struct opts *o, int argc, char *argv[])
|
||||
static void parse_opts(struct init_opts *o, int argc, char *argv[])
|
||||
{
|
||||
struct args_info args = ARGS_INFO_INIT;
|
||||
const char *sharedarg;
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
* This currently supports the default behavior and the `--error-unmatch` option.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
struct ls_options {
|
||||
int error_unmatch;
|
||||
char *files[1024];
|
||||
size_t file_count;
|
||||
} ls_options;
|
||||
};
|
||||
|
||||
static void usage(const char *message, const char *arg)
|
||||
{
|
||||
@@ -41,12 +41,12 @@ static void usage(const char *message, const char *arg)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static int parse_options(ls_options *opts, int argc, char *argv[])
|
||||
static int parse_options(struct ls_options *opts, int argc, char *argv[])
|
||||
{
|
||||
int parsing_files = 0;
|
||||
int i;
|
||||
|
||||
memset(opts, 0, sizeof(ls_options));
|
||||
memset(opts, 0, sizeof(struct ls_options));
|
||||
|
||||
if (argc < 2)
|
||||
return 0;
|
||||
@@ -78,7 +78,7 @@ static int parse_options(ls_options *opts, int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int print_paths(ls_options *opts, git_index *index)
|
||||
static int print_paths(struct ls_options *opts, git_index *index)
|
||||
{
|
||||
size_t i;
|
||||
const git_index_entry *entry;
|
||||
@@ -113,7 +113,7 @@ static int print_paths(ls_options *opts, git_index *index)
|
||||
int lg2_ls_files(git_repository *repo, int argc, char *argv[])
|
||||
{
|
||||
git_index *index = NULL;
|
||||
ls_options opts;
|
||||
struct ls_options opts;
|
||||
int error;
|
||||
|
||||
if ((error = parse_options(&opts, argc, argv)) < 0)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
struct merge_options {
|
||||
const char **heads;
|
||||
size_t heads_count;
|
||||
|
||||
@@ -31,7 +31,7 @@ typedef struct {
|
||||
size_t annotated_count;
|
||||
|
||||
int no_commit : 1;
|
||||
} merge_options;
|
||||
};
|
||||
|
||||
static void print_usage(void)
|
||||
{
|
||||
@@ -39,7 +39,7 @@ static void print_usage(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void merge_options_init(merge_options *opts)
|
||||
static void merge_options_init(struct merge_options *opts)
|
||||
{
|
||||
memset(opts, 0, sizeof(*opts));
|
||||
|
||||
@@ -49,7 +49,7 @@ static void merge_options_init(merge_options *opts)
|
||||
opts->annotated_count = 0;
|
||||
}
|
||||
|
||||
static void opts_add_refish(merge_options *opts, const char *refish)
|
||||
static void opts_add_refish(struct merge_options *opts, const char *refish)
|
||||
{
|
||||
size_t sz;
|
||||
|
||||
@@ -60,7 +60,7 @@ static void opts_add_refish(merge_options *opts, const char *refish)
|
||||
opts->heads[opts->heads_count - 1] = refish;
|
||||
}
|
||||
|
||||
static void parse_options(const char **repo_path, merge_options *opts, int argc, char **argv)
|
||||
static void parse_options(const char **repo_path, struct merge_options *opts, int argc, char **argv)
|
||||
{
|
||||
struct args_info args = ARGS_INFO_INIT;
|
||||
|
||||
@@ -82,7 +82,7 @@ static void parse_options(const char **repo_path, merge_options *opts, int argc,
|
||||
}
|
||||
}
|
||||
|
||||
static int resolve_heads(git_repository *repo, merge_options *opts)
|
||||
static int resolve_heads(git_repository *repo, struct merge_options *opts)
|
||||
{
|
||||
git_annotated_commit **annotated = calloc(opts->heads_count, sizeof(git_annotated_commit *));
|
||||
size_t annotated_count = 0, i;
|
||||
@@ -200,7 +200,7 @@ static void output_conflicts(git_index *index)
|
||||
git_index_conflict_iterator_free(conflicts);
|
||||
}
|
||||
|
||||
static int create_merge_commit(git_repository *repo, git_index *index, merge_options *opts)
|
||||
static int create_merge_commit(git_repository *repo, git_index *index, struct merge_options *opts)
|
||||
{
|
||||
git_oid tree_oid, commit_oid;
|
||||
git_tree *tree;
|
||||
@@ -276,7 +276,7 @@ cleanup:
|
||||
|
||||
int lg2_merge(git_repository *repo, int argc, char **argv)
|
||||
{
|
||||
merge_options opts;
|
||||
struct merge_options opts;
|
||||
git_index *index;
|
||||
git_repository_state_t state;
|
||||
git_merge_analysis_t analysis;
|
||||
|
||||
@@ -30,7 +30,7 @@ enum subcmd {
|
||||
subcmd_show,
|
||||
};
|
||||
|
||||
struct opts {
|
||||
struct remote_opts {
|
||||
enum subcmd cmd;
|
||||
|
||||
/* for command-specific args */
|
||||
@@ -38,20 +38,20 @@ struct opts {
|
||||
char **argv;
|
||||
};
|
||||
|
||||
static int cmd_add(git_repository *repo, struct opts *o);
|
||||
static int cmd_remove(git_repository *repo, struct opts *o);
|
||||
static int cmd_rename(git_repository *repo, struct opts *o);
|
||||
static int cmd_seturl(git_repository *repo, struct opts *o);
|
||||
static int cmd_show(git_repository *repo, struct opts *o);
|
||||
static int cmd_add(git_repository *repo, struct remote_opts *o);
|
||||
static int cmd_remove(git_repository *repo, struct remote_opts *o);
|
||||
static int cmd_rename(git_repository *repo, struct remote_opts *o);
|
||||
static int cmd_seturl(git_repository *repo, struct remote_opts *o);
|
||||
static int cmd_show(git_repository *repo, struct remote_opts *o);
|
||||
|
||||
static void parse_subcmd(
|
||||
struct opts *opt, int argc, char **argv);
|
||||
struct remote_opts *opt, int argc, char **argv);
|
||||
static void usage(const char *msg, const char *arg);
|
||||
|
||||
int lg2_remote(git_repository *repo, int argc, char *argv[])
|
||||
{
|
||||
int retval = 0;
|
||||
struct opts opt = {0};
|
||||
struct remote_opts opt = {0};
|
||||
|
||||
parse_subcmd(&opt, argc, argv);
|
||||
|
||||
@@ -77,7 +77,7 @@ int lg2_remote(git_repository *repo, int argc, char *argv[])
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int cmd_add(git_repository *repo, struct opts *o)
|
||||
static int cmd_add(git_repository *repo, struct remote_opts *o)
|
||||
{
|
||||
char *name, *url;
|
||||
git_remote *remote = {0};
|
||||
@@ -94,7 +94,7 @@ static int cmd_add(git_repository *repo, struct opts *o)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_remove(git_repository *repo, struct opts *o)
|
||||
static int cmd_remove(git_repository *repo, struct remote_opts *o)
|
||||
{
|
||||
char *name;
|
||||
|
||||
@@ -109,7 +109,7 @@ static int cmd_remove(git_repository *repo, struct opts *o)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_rename(git_repository *repo, struct opts *o)
|
||||
static int cmd_rename(git_repository *repo, struct remote_opts *o)
|
||||
{
|
||||
int i, retval;
|
||||
char *old, *new;
|
||||
@@ -134,7 +134,7 @@ static int cmd_rename(git_repository *repo, struct opts *o)
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int cmd_seturl(git_repository *repo, struct opts *o)
|
||||
static int cmd_seturl(git_repository *repo, struct remote_opts *o)
|
||||
{
|
||||
int i, retval, push = 0;
|
||||
char *name = NULL, *url = NULL;
|
||||
@@ -166,7 +166,7 @@ static int cmd_seturl(git_repository *repo, struct opts *o)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_show(git_repository *repo, struct opts *o)
|
||||
static int cmd_show(git_repository *repo, struct remote_opts *o)
|
||||
{
|
||||
int i;
|
||||
const char *arg, *name, *fetch, *push;
|
||||
@@ -213,7 +213,7 @@ static int cmd_show(git_repository *repo, struct opts *o)
|
||||
}
|
||||
|
||||
static void parse_subcmd(
|
||||
struct opts *opt, int argc, char **argv)
|
||||
struct remote_opts *opt, int argc, char **argv)
|
||||
{
|
||||
char *arg = argv[1];
|
||||
enum subcmd cmd = 0;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
int lg2_show_index(git_repository *repo, int argc, char** argv)
|
||||
int lg2_show_index(git_repository *repo, int argc, char **argv)
|
||||
{
|
||||
git_index *index;
|
||||
size_t i, ecount;
|
||||
|
||||
@@ -43,7 +43,7 @@ enum {
|
||||
|
||||
#define MAX_PATHSPEC 8
|
||||
|
||||
struct opts {
|
||||
struct status_opts {
|
||||
git_status_options statusopt;
|
||||
char *repodir;
|
||||
char *pathspec[MAX_PATHSPEC];
|
||||
@@ -55,7 +55,7 @@ struct opts {
|
||||
int repeat;
|
||||
};
|
||||
|
||||
static void parse_opts(struct opts *o, int argc, char *argv[]);
|
||||
static void parse_opts(struct status_opts *o, int argc, char *argv[]);
|
||||
static void show_branch(git_repository *repo, int format);
|
||||
static void print_long(git_status_list *status);
|
||||
static void print_short(git_repository *repo, git_status_list *status);
|
||||
@@ -64,7 +64,7 @@ static int print_submod(git_submodule *sm, const char *name, void *payload);
|
||||
int lg2_status(git_repository *repo, int argc, char *argv[])
|
||||
{
|
||||
git_status_list *status;
|
||||
struct opts o = { GIT_STATUS_OPTIONS_INIT, "." };
|
||||
struct status_opts o = { GIT_STATUS_OPTIONS_INIT, "." };
|
||||
|
||||
o.statusopt.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
|
||||
o.statusopt.flags = GIT_STATUS_OPT_INCLUDE_UNTRACKED |
|
||||
@@ -435,7 +435,7 @@ static int print_submod(git_submodule *sm, const char *name, void *payload)
|
||||
/**
|
||||
* Parse options that git's status command supports.
|
||||
*/
|
||||
static void parse_opts(struct opts *o, int argc, char *argv[])
|
||||
static void parse_opts(struct status_opts *o, int argc, char *argv[])
|
||||
{
|
||||
struct args_info args = ARGS_INFO_INIT;
|
||||
|
||||
|
||||
@@ -31,19 +31,19 @@
|
||||
*/
|
||||
|
||||
/** tag_options represents the parsed command line options */
|
||||
typedef struct {
|
||||
struct tag_options {
|
||||
const char *message;
|
||||
const char *pattern;
|
||||
const char *tag_name;
|
||||
const char *target;
|
||||
int num_lines;
|
||||
int force;
|
||||
} tag_options;
|
||||
};
|
||||
|
||||
/** tag_state represents the current program state for dragging around */
|
||||
typedef struct {
|
||||
git_repository *repo;
|
||||
tag_options *opts;
|
||||
struct tag_options *opts;
|
||||
} tag_state;
|
||||
|
||||
/** An action to execute based on the command line arguments */
|
||||
@@ -167,7 +167,7 @@ static void action_list_tags(tag_state *state)
|
||||
|
||||
static void action_delete_tag(tag_state *state)
|
||||
{
|
||||
tag_options *opts = state->opts;
|
||||
struct tag_options *opts = state->opts;
|
||||
git_object *obj;
|
||||
git_buf abbrev_oid = {0};
|
||||
|
||||
@@ -191,7 +191,7 @@ static void action_delete_tag(tag_state *state)
|
||||
static void action_create_lighweight_tag(tag_state *state)
|
||||
{
|
||||
git_repository *repo = state->repo;
|
||||
tag_options *opts = state->opts;
|
||||
struct tag_options *opts = state->opts;
|
||||
git_oid oid;
|
||||
git_object *target;
|
||||
|
||||
@@ -213,7 +213,7 @@ static void action_create_lighweight_tag(tag_state *state)
|
||||
static void action_create_tag(tag_state *state)
|
||||
{
|
||||
git_repository *repo = state->repo;
|
||||
tag_options *opts = state->opts;
|
||||
struct tag_options *opts = state->opts;
|
||||
git_signature *tagger;
|
||||
git_oid oid;
|
||||
git_object *target;
|
||||
@@ -243,7 +243,7 @@ static void print_usage(void)
|
||||
}
|
||||
|
||||
/** Parse command line arguments and choose action to run when done */
|
||||
static void parse_options(tag_action *action, tag_options *opts, int argc, char **argv)
|
||||
static void parse_options(tag_action *action, struct tag_options *opts, int argc, char **argv)
|
||||
{
|
||||
args_info args = ARGS_INFO_INIT;
|
||||
*action = &action_list_tags;
|
||||
@@ -281,7 +281,7 @@ static void parse_options(tag_action *action, tag_options *opts, int argc, char
|
||||
}
|
||||
|
||||
/** Initialize tag_options struct */
|
||||
static void tag_options_init(tag_options *opts)
|
||||
static void tag_options_init(struct tag_options *opts)
|
||||
{
|
||||
memset(opts, 0, sizeof(*opts));
|
||||
|
||||
@@ -295,7 +295,7 @@ static void tag_options_init(tag_options *opts)
|
||||
|
||||
int lg2_tag(git_repository *repo, int argc, char **argv)
|
||||
{
|
||||
tag_options opts;
|
||||
struct tag_options opts;
|
||||
tag_action action;
|
||||
tag_state state;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user