Collect and convert git repo data to 'struct git_info'

We have this nasty habit of randomly passing down all the different
things that we use to look up the local and remote git repository, and
the information associated with it.

Start collecting the data into a 'struct git_info' instead, so that it
is easier to manage, and easier and more logical to just look up
different parts of the puzzle.

This is a fairly mechanical conversion, but has moved all the basic
information collection to the 'is_git_repository()' function.  That
function no longer actually opens the repository (so the 'dry_run'
argument is gone, and instead a successful 'is_git_repository()' is
followed by 'opn_git_repository()' if you actually want the old
non-dry_run semantics.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2022-04-13 06:43:37 -10:00 committed by Dirk Hohndel
parent acc4dc57af
commit 7e632173e0
11 changed files with 365 additions and 349 deletions

View file

@ -1945,23 +1945,23 @@ const char *get_sha(git_repository *repo, const char *branch)
* If it is a git repository, we return zero for success,
* or report an error and return 1 if the load failed.
*/
int git_load_dives(struct git_repository *repo, const char *branch, struct dive_table *table, struct trip_table *trips,
int git_load_dives(struct git_info *info, struct dive_table *table, struct trip_table *trips,
struct dive_site_table *sites, struct device_table *devices, struct filter_preset_table *filter_presets)
{
int ret;
struct git_parser_state state = { 0 };
state.repo = repo;
state.repo = info->repo;
state.table = table;
state.trips = trips;
state.sites = sites;
state.devices = devices;
state.filter_presets = filter_presets;
if (repo == dummy_git_repository)
return report_error("Unable to open git repository at '%s'", branch);
ret = do_git_load(repo, branch, &state);
git_repository_free(repo);
free((void *)branch);
if (!info->repo)
return report_error("Unable to open git repository '%s[%s]'", info->url, info->branch);
ret = do_git_load(info->repo, info->branch, &state);
git_repository_free(info->repo);
free((void *)info->branch);
finish_active_dive(&state);
finish_active_trip(&state);
return ret;