From 84c422ee38b531d2c83b6dcab4fc4e76b5fdafbf Mon Sep 17 00:00:00 2001 From: Hoffmann Gerhard Date: Wed, 3 Apr 2024 16:40:46 +0200 Subject: [PATCH] just safe again --- CalculatorCInterface/git_library.cpp | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/CalculatorCInterface/git_library.cpp b/CalculatorCInterface/git_library.cpp index fd6f032..eb71961 100644 --- a/CalculatorCInterface/git_library.cpp +++ b/CalculatorCInterface/git_library.cpp @@ -340,8 +340,58 @@ on_error: // // git merge // +struct merge_options { const char **heads; + size_t heads_count; + + git_annotated_commit **annotated; + size_t annotated_count; + + unsigned int no_commit : 1; +}; + +static void merge_options_init(struct merge_options *opts) { + memset(opts, 0, sizeof(*opts)); + + opts->heads = NULL; + opts->heads_count = 0; + opts->annotated = NULL; + opts->annotated_count = 0; +} + +static void parse_options(const char **repo_path, struct merge_options *opts) { +#if 0 + struct args_info args = ARGS_INFO_INIT; + + for (args.pos = 1; args.pos < argc; ++args.pos) { + const char *curr = argv[args.pos]; + + if (curr[0] != '-') { + opts_add_refish(opts, curr); + } else if (!strcmp(curr, "--no-commit")) { + opts->no_commit = 1; + } else if (match_str_arg(repo_path, &args, "--git-dir")) { + continue; + } + } +#endif +} static int merge(git_repository *repo) { + struct merge_options opts; + git_index *index; + git_repository_state_t state; + git_merge_analysis_t analysis; + git_merge_preference_t preference; + const char *path = "."; + int err = 0; + + merge_options_init(&opts); + parse_options(&path, &opts); + +cleanup: + free((char **)opts.heads); + free(opts.annotated); + return 0; }