aboutsummaryrefslogtreecommitdiffstats
path: root/core/save-git.c
AgeCommit message (Collapse)Author
2017-11-27Store and load the planner related depth info of a cylinder in logfileGravatar Stefan Fuchs
Store cylinder.depth in XML files and in git storage. This info is in fact the gas switch depth of a specific gas/cylinder in the planner. This change avoids the need of typing in a user specific depth value again when replanning an existing planned dive. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-13Init every struct sample with default valuesGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-08Do not save dive sites that are not usedGravatar Jan Mulder
As it is not possible to delete dive sites from the logbook, we need to make sure that we never save sites that are not tied to any dive. With this change, unused site that are currently in the logbook will also be removed, so it will also clear up (wrong) historical data. Supposed to fix #786 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-26git save: create a better commit message for initial commitGravatar Dirk Hohndel
When we create an empty repo we should simply state that in the commit message. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26git save: don't save the git_id if just creating empty repoGravatar Dirk Hohndel
Otherwise the following call to do_git_save will potentially have incorrect information about the cache validity of the dives in the divelist. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26git save: remove redundant 'subsurface' from commit messageGravatar Dirk Hohndel
The user agent string already contains the (correctly capitalized) program name. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26git storage: print the actual errorGravatar Dirk Hohndel
It seems silly to not show what git told us went wrong. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26Move error reporting into its own source fileGravatar Dirk Hohndel
This doesn't really seem to belong in save_git.c. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04Don't add separate country field, use taxonomyGravatar Dirk Hohndel
The more I looked at the code that added the country to the dive site, the more it seemed redundant given what we have with the taxonomy. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02[Divesite] Load / Save divesite country on gitGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-11Do not save duration if it is zeroGravatar Miika Turkia
See #561
2017-08-26Remove some unused variablesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-25Add support for loading and saving multiple pressure samplesGravatar Linus Torvalds
This does both the XML and the git save format, because the changes really are the same, even if the actual format differs in some details. See how the two "save_samples()" routines both do the same basic setup, for example. This is fairly straightforward, with the possible exception of the odd sensor = sample->sensor[0]; default in the git pressure loading code. That line just means that if we do *not* have an explicit cylinder index for the pressure reading, we will always end up filling in the new pressure as the first pressure (because the cylinder index will match the first sensor slot). So that makes the "add_sample_pressure()" case always do the same thing it used to do for the legacy case: fill in the first slot. The actual sensor index may later change, since the legacy format has a "sensor=X" key value pair that sets the sensor, but it will also use the first sensor slot, making it all do exactly what it used to do. And on the other hand, if we're loading new-style data with cylinder pressure and sensor index together, we just end up using the new semantics for add_sample_pressure(), which tries to keep the same slot for the same sensor, but does the right thing if we already have other pressure values. The XML code has no such issues at all, since it can't share the cases anyway, and we need to have different node names for the different sensor values and cannot just have multiple "pressure" entries. Have I mentioned how much I despise XML lately? Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-21Fix up o2 pressure sensor handling at load timeGravatar Linus Torvalds
Because of how we traditionally did things, the "o2pressure" parsing depends on implicitly setting the sensor index to the last cylinder that was marked as being used for oxygen. We also always defaulted the primary sensor (which is used for the diluent tank for CCR) to cylinder 0, but that doesn't work when the oxygen tank is cylinder 0. This gets that right at file loading time, and unifies the xml and git sample parsing to make them match. The new defaults are: - unless anything else is explicitly specified, the primary sensor is associated with the first tank, and the secondary sensor is associated with the second tank - if we're a CCR dive, and have an explicit oxygen tank, we associate the secondary sensor with that oxygen cylinder. The primary sensor will be switched over to the second cylinder if the oxygen cylinder is the first one. This may sound backwards, but matches our traditional behavior where the O2 pressure was the secondary pressure. This is definitely not pretty, but it gets our historical files working right, and is at least reasonably sensible. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-21git save format: don't save redundant sample informationGravatar Linus Torvalds
When we load sample data from a git save-file, we always default to using the state from the previous sample (except for the special case of cylinder pressure where an empty value does not mean "same", but "interpolate", see core/load-git.c: new_sample()). But the corollary to that is that it's always redundant to save sample data that hasn't changed since the previous sample. For some reason, the rbt, bearing and heartrate sample data didn't follow that rule, and instead saved with lots of extra reduncancy. (The alternative would be to clear those samples at load time, and make them act like the pressure data, but it would appear that all these three values may as well just have the normal "if no change, don't save them" semantics). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-21Start cleaning up sensor indexing for multiple sensorsGravatar Linus Torvalds
This is a very timid start at making us actually use multiple sensors without the magical special case for just CCR oxygen tracking. It mainly does: - turn the "sample->sensor" index into an array of two indexes, to match the pressures themselves. - get rid of dive->{oxygen_cylinder_index,diluent_cylinder_index}, since a CCR dive should now simply set the sample->sensor[] indices correctly instead. - in a couple of places, start actually looping over the sensors rather than special-case the O2 case (although often the small "loops" are just unrolled, since it's just two cases. but in many cases we still end up only covering the zero sensor case, because the CCR O2 sensor code coverage was fairly limited. It's entirely possible (even likely) that this migth break some existing case: it tries to be a fairly direct ("stupid") translation of the old code, but unlike the preparatory patch this does actually does change some semantics. For example, right now the git loader code assumes that if the git save data contains a o2pressure entry, it just hardcodes the O2 sensor index to 1. In fact, one issue is going to simply be that our file formats do not have that multiple sensor format, but instead had very clearly encoded things as being the CCR O2 pressure sensor. But this is hopefully close to usable, and I will need feedback (and maybe test cases) from people who have existing CCR dives with pressure data. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-20Unify sample pressure and o2pressure as pressure[2] arrayGravatar Linus Torvalds
We currently carry two pressures around for all the samples and plot info, but the second pressure is reserved for CCR dives as the O2 cylinder pressure. That's kind of annoying when we *could* use it for regular sidemount dives as the secondary pressure. So start prepping for that instead: don't make it "pressure" and "o2pressure", make it just be an array of two pressure values. NOTE! This is purely mindless prepwork. It literally just does a search-and-replace, keeping the exact same semantics, so "pressure[1]" is still just O2 pressure. But at some future date, we can now start using it for a second sensor value for sidemount instead. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-18Clean up git storage update messagesGravatar Dirk Hohndel
Translate all of them, but also remove some redundant or possibly misleading messages. These are now seen by users, not just developers trying to debug the code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-17QML UI: redesign the user notificationGravatar Dirk Hohndel
The old system of cloud access updates with fake percentages just wasn't helpful. Even worse, it hid a lot important information from the user. This should be more useful (but it will require that we localize the messages sent from the git progress notifications and make them more 'user ready'). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29Add SPDX header to core C filesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-22Reduce default verbosityGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-12Only enable -Wmissing-field-initializers for ClangGravatar Lubomir I. Ivanov
The following pragma is Clang specific: It produces a warning: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas] Only enable it for Clang by checking the __clang__ macro. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-05Merge informational_prefs into git_prefsGravatar Joakim Bygdell
There is no need to have two variables for the same purpose. [Dirk Hohndel: changed to keep the two separate functions as otherwise we no longer parse existing repos successfully] Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-05Save profile settings to gitGravatar Joakim Bygdell
In order to streamline the view between desktop and mobile we need to save selected profile related settings to git. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2016-07-21Add proper line ending for unit line in git save formatGravatar Linus Torvalds
The imperial and metric unit formats already had this, but the personalized one missed the newline at the end. It shouldn't really matter, since it's the last line of the file, but it is not right. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29Extend time parsing to before 1970Gravatar Linus Torvalds
It turns out that we are starting to have users that have logs that go back that far. It won't be common, but let's get it right anyway. NOTE! With us now supporting dates earlier in 1900, this also makes "utc_mktime()" always add the "1900" to the year field. That way we avoid ever using the fairly ambiguous two-digit shorthand. It didn't use to be all that ambiguous when we knew that any two-digit number less than 70 had to be 2000+. Now that we support going back to earlier in the last centiry, that certainty is eroding. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-08git storage: only sync with remote if git_local_only isn't setGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05QML UI: more hacking around with git progress reportingGravatar Dirk Hohndel
I gave up on the magic numbers and instead report simply linear progress. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05Simplify git tracking of git tree creationGravatar Dirk Hohndel
With Linus' changes to the tree creation saving the dives is no longer the dominant part of that process, so simplify the output (which also removes the hacky buggy code to show the percentages that is of course totally bogus). (apparently a couple of white space cleanups snuck into this patch) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Start using the actual cylinder data for gas switch eventsGravatar Linus Torvalds
Now that gas switch events always have indices into the cylinder table, start using that to look up the gas mix from the cylinders rather than from the gas switch event itself. In other words, the cylinder index is now the primary data for gas switch events. This means that now as you change the cylinder information, the gas switch events will automatically update to reflect those changes. Note that on loading data from the outside (either from a xml file, from a git/cloud account, or from a dive computer), we may or may not initially have an index for the gas change event. The external data may be from an older version of subsurface, or it may be from a libdivecomputer download that just doesn't give index data at all. In that case, we will do: - if there is no index, but there is explicit gas mix information, we will look up the index based on that gas mix, picking the cylinder that has the closest mix. - if there isn't even explicit gas mix data, so we only have the event value from libdivecomputer, we will turn that value into a gasmix, and use that to look up the cylinder index as above. - if no valid cylinder information is available at all, gas switch events will just be dropped. When saving the data, we now always save the cylinder index, and the gas mix associated with that cylinder (that gas mix will be ignored on load, since the index is the primary, but it makes the event much easier to read). It is worth noting we do not modify the libdivecomputer value, even if the gasmix has changed, so that remains as a record of the original download. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Make gas change events always have a cylinder indexGravatar Linus Torvalds
In commit df4e26c8757a ("Start sanitizing gaschange event information") back about a year and a half ago, I started sanitizing the gas switch event data, allowing gas switches to be associated with a particular cylinder index rather than just the gas mix that is switched to. But that initial step only _allowed_ a gas switch event to be associated with a particular cylinder, the primary model was still to just specify the mix. This finally takes the next step, and *always* associates a gas switch event with a particular cylinder. Instead of then looking up the cylinder by trying to match gas mixes at runtime, subsurface now looks it up when loading the dive initially as part of the dive fixup code. The switch event still has an a separate gas mix associated with it, but this patch also starts preparing for entirely relying on the gas mix in the cylinder itself, by starting to pass in not just the event but also the dive pointer to the routines that look up gas mix details. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Move subsurface-core to core and qt-mobile to mobile-widgetsGravatar Dirk Hohndel
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>