aboutsummaryrefslogtreecommitdiffstats
path: root/load-git.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2014-05-14 15:07:58 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-14 16:04:45 +0900
commit4f29a47afb727f8839ce7a1237ca8d4243d781fd (patch)
tree0f8bc3cd723257755605f9939d9c23154cd21ef9 /load-git.c
parenta8fbd3d283d8fe48b9e9658d81bbaee2a25b5a69 (diff)
downloadsubsurface-4f29a47afb727f8839ce7a1237ca8d4243d781fd.tar.gz
git load: initialize dive computer timestamp and duration from dive
We don't save the dive computer timestamp and duration if they match the dive timestamp and duration. But that means that on loading, we need to default the dive computer time/duration to the dive one. If they differ, the loading of the divecomputer file will then override the default timestamp/duration. This mainly matters if a later dive merge then changes the timestamp of the dive: the dive computer timestamp needs to have been set correctly and not change. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'load-git.c')
-rw-r--r--load-git.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/load-git.c b/load-git.c
index c1007358c..acfdd2527 100644
--- a/load-git.c
+++ b/load-git.c
@@ -1115,11 +1115,13 @@ static struct divecomputer *create_new_dc(struct dive *dive)
/* Did we already fill that in? */
if (dc->samples || dc->model || dc->when) {
struct divecomputer *newdc = calloc(1, sizeof(*newdc));
- if (newdc) {
- dc->next = newdc;
- dc = newdc;
- }
+ if (!newdc)
+ return NULL;
+ dc->next = newdc;
+ dc = newdc;
}
+ dc->when = dive->when;
+ dc->duration = dive->duration;
return dc;
}