From 4f29a47afb727f8839ce7a1237ca8d4243d781fd Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 14 May 2014 15:07:58 +0900 Subject: 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 Signed-off-by: Dirk Hohndel --- load-git.c | 10 ++++++---- 1 file 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; } -- cgit v1.2.3-70-g09d2