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>
This commit is contained in:
Linus Torvalds 2014-05-14 15:07:58 +09:00 committed by Dirk Hohndel
parent a8fbd3d283
commit 4f29a47afb

View file

@ -1115,11 +1115,13 @@ static struct divecomputer *create_new_dc(struct dive *dive)
/* Did we already fill that in? */ /* Did we already fill that in? */
if (dc->samples || dc->model || dc->when) { if (dc->samples || dc->model || dc->when) {
struct divecomputer *newdc = calloc(1, sizeof(*newdc)); struct divecomputer *newdc = calloc(1, sizeof(*newdc));
if (newdc) { if (!newdc)
dc->next = newdc; return NULL;
dc = newdc; dc->next = newdc;
} dc = newdc;
} }
dc->when = dive->when;
dc->duration = dive->duration;
return dc; return dc;
} }