summaryrefslogtreecommitdiffstats
path: root/core/load-git.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-03-17 22:49:29 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-17 16:50:20 -0700
commited3e68c36a94a14d73c81ef7e2ce27ec3ea24217 (patch)
tree59466c90c0dc7c5d56681ab8b57a7694484cc824 /core/load-git.c
parent2042a472303ab33f0fb8a6625d6e69e533dbce43 (diff)
downloadsubsurface-ed3e68c36a94a14d73c81ef7e2ce27ec3ea24217.tar.gz
git: load into arbitrary dive tables
The git parser loads into the global dive table, even if it is called indirectly via parse_file(). However, parse_file() may be given a different table. Fix this by extending the git parser state. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/load-git.c')
-rw-r--r--core/load-git.c14
1 files changed, 10 insertions, 4 deletions
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);