diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/file.c | 2 | ||||
-rw-r--r-- | core/git-access.h | 2 | ||||
-rw-r--r-- | core/load-git.c | 14 |
3 files changed, 12 insertions, 6 deletions
diff --git a/core/file.c b/core/file.c index abee7c793..b4783f3fc 100644 --- a/core/file.c +++ b/core/file.c @@ -325,7 +325,7 @@ int parse_file(const char *filename, struct dive_table *table, struct trip_table } free(current_sha); if (git) - return git_load_dives(git, branch); + return git_load_dives(git, branch, table, trips, sites); if ((ret = readfile(filename, &mem)) < 0) { /* we don't want to display an error if this was the default file */ diff --git a/core/git-access.h b/core/git-access.h index 82927b87f..19cdde46a 100644 --- a/core/git-access.h +++ b/core/git-access.h @@ -19,7 +19,7 @@ extern struct git_repository *is_git_repository(const char *filename, const char extern int check_git_sha(const char *filename, git_repository **git_p, const char **branch_p); extern int sync_with_remote(struct git_repository *repo, const char *remote, const char *branch, enum remote_transport rt); extern int git_save_dives(struct git_repository *, const char *, const char *remote, bool select_only); -extern int git_load_dives(struct git_repository *, const char *); +extern int git_load_dives(struct git_repository *repo, const char *branch, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); extern const char *get_sha(git_repository *repo, const char *branch); extern int do_git_save(git_repository *repo, const char *branch, const char *remote, bool select_only, bool create_empty); extern const char *saved_git_id; diff --git a/core/load-git.c b/core/load-git.c index e99bc9af0..a9e9107f7 100644 --- a/core/load-git.c +++ b/core/load-git.c @@ -34,6 +34,9 @@ struct git_parser_state { dive_trip_t *active_trip; struct picture *active_pic; struct dive_site *active_site; + struct dive_table *table; + struct trip_table *trips; + struct dive_site_table *sites; int o2pressure_sensor; }; @@ -159,7 +162,7 @@ static void parse_dive_gps(char *line, struct membuffer *str, struct git_parser_ parse_location(line, &location); if (!ds) { - ds = get_dive_site_by_gps(&location, &dive_site_table); + ds = get_dive_site_by_gps(&location, state->sites); if (!ds) ds = create_dive_site_with_gps("", &location, &dive_site_table); add_dive_to_dive_site(state->active_dive, ds); @@ -1225,7 +1228,7 @@ static void finish_active_trip(struct git_parser_state *state) if (trip) { state->active_trip = NULL; - insert_trip(trip, &trip_table); + insert_trip(trip, state->trips); } } @@ -1235,7 +1238,7 @@ static void finish_active_dive(struct git_parser_state *state) if (dive) { state->active_dive = NULL; - record_dive(dive); + record_dive_to_table(dive, state->table); } } @@ -1729,11 +1732,14 @@ 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) +int git_load_dives(struct git_repository *repo, const char *branch, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites) { int ret; struct git_parser_state state = { 0 }; state.repo = repo; + state.table = table; + state.trips = trips; + state.sites = sites; if (repo == dummy_git_repository) return report_error("Unable to open git repository at '%s'", branch); |