summaryrefslogtreecommitdiffstats
path: root/save-git.c
AgeCommit message (Collapse)Author
2015-10-30Move all core-functionality to subsurface-coreGravatar Tomaz Canabrava
And adapt a new CMakeLists.txt file for it. On the way I've also found out that we where double-compilling a few files. I've also set the subsurface-core as a include_path but that was just to reduce the noise on this commit, since I plan to remove it from the include path to make it obligatory to specify something like include "subsurface-core/dive.h" for the header files. Since the app is growing quite a bit we ended up having a few different files with almost same name that did similar things, I want to kill that (for instance Dive.h, dive.h, PrintDive.h and such). Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-28Don't save unused, auto-create dive sitesGravatar Dirk Hohndel
Normally the auto-created sites that are used when downloading GPS data from the webservice that aren't associated with a dive will immediately discarded. But if such a site is used for a dive but then the user changes their mind and uses another site for that dive (for example because they had a previous dive at that spot and decided they liked that one better after all), then the dive site can stick around as an orphan. Having orphan dive site may make sense for named dive sites that for some reason are no longer used but may be used again in the future, but having an auto-named orphaned dive site in the data file seems silly. So let's remove them. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-28Fix incorrect and confusing warning messageGravatar Dirk Hohndel
In verbose mode we wanted to tell the user if they had a reference to a non-existant dive site that we removed for consistency. Except the condition was wrong and the warning was printed for every VALID dive site reference. Oops. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-20Cloud storage: in verbose mode give lots of progress informationGravatar Dirk Hohndel
If a user gets stuck accessing cloud storage it's often hard to figure out which step is hanging which makes it much harder to narrow down the problem. With this patch calling Subsurface with '-v' will give somewhat finely grained progress information on stderr. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-08Only store dive site uuid in dive if the dive site existsGravatar Dirk Hohndel
Don't store stale uuids. As a side effect this makes it easy to remove dive sites from the XML file (or the git repository) when duplicates have been added for some reason and the user wants to restart from scratch. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25When building against libgit2 v0.23 or newer we can assume API23Gravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Cloud storage: clean up after the mergeGravatar Dirk Hohndel
Make sure the branch is pointing at the merge commit, etc. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20Always save taxonomy data, even if disabled in the prefsGravatar Dirk Hohndel
Otherwise, if one of the systems used with cloud storage doesn't have the preference for geo encoding enabled, the taxonomy data will be lost. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-30RBT - Add load/save in git storage supportGravatar Salvador Cuñat
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-10Git storage: only show geo cat if there is a valueGravatar Dirk Hohndel
Otherwise we could get mangled data since the newline isn't printed. Now a good question would be "why do we have empty values in our data", but either way, we should write invalid data to the git repository. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02Rename enum values for taxonomyGravatar Dirk Hohndel
This avoids confusion and namespace collisions. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-01Geo taxonomy: save and load the geo taxonomy data with gitGravatar Dirk Hohndel
This also supports the cloud storage, of course. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-25Use our membuffer infrastructure to assemble stringGravatar Dirk Hohndel
We should use this consistently throughout the code instead of manually assembling strings and messing with memory all over the place. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21Add helper function to return local filename of picture as C stringGravatar Dirk Hohndel
This way we can actually find the picture that we are showing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21Git storage: store pictures in the repositoryGravatar Dirk Hohndel
In order to be able to see pictures when using cloud storage from different machines, we really need to store the pictures with the dive data. This could be made optional with a preference, but for now I'll just enable it by default. Loading the pictures from git still needs to be implemented. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21Git storage: replaces colons with equal in picture offsetGravatar Dirk Hohndel
I found another place where we had colons in file names... This fixes a small cut and paste error in an error message as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20Track minimum datafile versionGravatar Dirk Hohndel
Add infrastructure and helper functions to track minimum datafile version. To make this information useful we need to keep the XML and git data format versions in track moving forward. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-19Git storage: change time encoding in directory namesGravatar Dirk Hohndel
We used to use [[yyyy-]mm-]nn-ddd-hh:mm:ss[~hex] in our git storage format for directory that contained dives. Problem with the is that on Windows the colon ':' is an illegal character in a filename. So libgit2 refuses to clone such a repository on Windows. So instead we now always write dive directories in git repositories as [[yyyy-]mm-]nn-ddd-hh=mm=ss[~hex] which replaces the ':' with an '='. Of course we load / parse both formats so that older formats still work. The next time they are written all the names change which causes rather huge commits, but that's the only way I see for cloud storage to work on Windows. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-18Git storage: don't abort if there is no default user/email setGravatar Dirk Hohndel
I never ran into this because all of my computers have a global default set for my name and email address. But if the user never uses git and has no global settings there will be no such info. Instead of failing we need to just set up a default ID and then try to get a best guess from the OS (just as we used to do before libgit2 supported getting the git settings for authorship). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-18Fix potential crash if the existing filename is NULLGravatar Dirk Hohndel
Should have used same_string() anyway... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-17Store the user's unit preferences in git storageGravatar Dirk Hohndel
Save and load a usually unused copy of the preferences with the units that were active the last time the dive list was saved to git storage (this isn't used in XML files); storing the unit preferences in the data file is usually pointless (that's a setting of the software, not a property of the data), but it's a great hint of what the user might expect to see when creating a backend service that visualizes the dive list without Subsurface running - so this is basically a functionality for the core library that Subsurface itself doesn't use but that another consumer of the library (like an HTML exporter) will need. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-17Git storage: only check git_id if saving to the same remoteGravatar Dirk Hohndel
If we switch to a different remote (let's say we opened a local git repo and want to save its content to the cloud storage) then don't check to make sure that the branch stayed unchanged (because, duh, it's a different remote, it will have changed). This fixes the problem where you could open an XML file and store it to cloud storage just fine, but opening a local git repository and then storing that to cloud storage failed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-16git save: fix crash with no remoteGravatar Linus Torvalds
Commit e21cae2d46db ("Cloud storage: sync the remote after save") broke regular git saving without any remotes: it would never initialize the "remote" pointer, and then use that uninitialized remote pointer to see if it was a cloud storage remote that it should try to sync. Fix it. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-15Cloud storage: use preference member instead of hard coded stringsGravatar Dirk Hohndel
This creates the basis to allow other backends to be used with the cloud storage infrastructure. So far this should all just transparently continue to work. A user would have to manually add the cloud_base_url entry to the CloudStorage section in their config file in order to use a different backend server. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13Cloud storage: clean up error propagationGravatar Dirk Hohndel
We were falling of the end of a number of functions that were supposed to return 0 on success or an error. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13Cloud storage: make do_git_save available to other modulesGravatar Dirk Hohndel
And add a parameter that tells it whether to try to save any Subsurface data or whether to just create a branch and push it out. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13Move git related declarations into their own header fileGravatar Dirk Hohndel
Also change the name of the enum and make sure all the inner functions get passed the remote transport information. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12Cloud storage: sync the remote after saveGravatar Dirk Hohndel
This change once again tests if the remote can be reached. Even with a fairly big data file and a medium speed internet connection the remote sync is fast enough to call it nearly instantaneous. Maybe a couple of seconds. We may need more checks / different heuristics / warnings if the sync didn't happen, etc. But for now this should allow more reasonable testing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10When saving only selected dives, only include referenced dive computersGravatar Dirk Hohndel
Since we should have far fewer dive computers than dives this straight forward algorithm shouldn't cause any performance issues. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-28Add USE_LIBGIT23_API as cmake optionGravatar Dirk Hohndel
Just as we would expect, the libgit2 developers of course once again broke their API. In order to compile against current master we need to remap those APIs once again. Simply call cmake with -DUSE_LIBGIT23_API Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-27Add hashes to imagesGravatar Robert C. Helling
Upon successfull reading an image file, this computes a SHA1 hash of the image and saves it with the picture tag in the log file. When a file is not successfully loaded (for example because the log was created on a different computer) we look up the hash in a dictionary that maps hashes to local file names. That dictionary (actually two for both directions), is loaded on startup and saved upon destruction of the main window. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-15add and use a version.c / version.h pairGravatar Lubomir I. Ivanov
version.c is now object code which is recompiled each time ssrf-version.h changes, while the interface file version.h remains that same at all times and files which include it will not need to be recompiled. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-15Start splitting out git repo helper routinesGravatar Linus Torvalds
This doesn't actually change any code, but it moves the 'is_git_repo()' function that is used by both loading and saving into a new git-access.c file. This is where I'll start doing remote repo syncing too. Knock wood. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13Don't store empty dive sitesGravatar Dirk Hohndel
And remove references to them from the dives. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13Always print dive site uuids as 8 digits / leading 0s in git formatGravatar Dirk Hohndel
Otherwise there are ugly spaces in the file names. This didn't break anything, per se, it's mostly cosmetic. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Get location from dive site for git commit messageGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Save and load dive sites in git formatGravatar Dirk Hohndel
Update the version to 3. Continue to read version 2 files and create dive sites on the fly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24api change in libgit2-0.22Gravatar Martin Gysel
Yet another api change in libgit2... let's quote the website "libgit2 is ... linkable library with a solid API ..." Signed-off-by: Martin Gysel <me@bearsh.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10Refactor dctype -> divemodeGravatar Robert C. Helling
... and repair a failed rebase (sorry). Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-24CCR dive logs: git I/OGravatar willem ferguson
This patch privides for writing CCR dive log parameters to a git repository and for reading the data back from a git repository. This involves writing and reading the following members of the structures of sample: o2sensor[3] o2cylinderpressure and dc->no_o2sensors. Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-20Prevent garbage from being saved in the userid fieldGravatar Dirk Hohndel
It seems that in some scenarios we end up with a string that isn't NUL terminated and that results in garbage being stored as userid. This patch is a little brute force but it fixes the problem even if a previous version os Subsurface ended up adding other text to the end of the userid. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-16Load and save the dc type for CCR divesGravatar Dirk Hohndel
Oddly we already had code to load this from XML, but nothing else. This makes the load from XML work like the rest of our code and adds the save to XML plus the load and save for the git format. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-16Save CCR cylinder use in XML and gitGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-07Load and save extra data in git formatGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-19Make planner work again for CCR divesGravatar Robert C. Helling
The latest CCR patches had rendered the planner not usable for CCR dives. This patch corrects this (and reenables the CCR set point column for segments). The problem was that a new member setpoint of struct divepoint had been introduced, but there was already po2 which had the same meaning. This patch merges the two and renames them setpoint to prevent future confusion. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-12Start sanitizing gaschange event informationGravatar Linus Torvalds
Decode the gasmix data into a sane format when creating the event, and add the (currently unused) ability to specify a gas change to a particular cylinder rather than (or in addition to) the gasmix. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10Fix potential leak of branch in is_git_repositoryGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09Add support divecomputer based TTSGravatar Anton Lundin
Since earlier have we had support for our own calculated TTS. This adds support for holding TTS values reported by a dive computer. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-29git-format: save dive picture dataGravatar Linus Torvalds
This doesn't actually parse the data at load time yet, but I need a save file to do that.. The diff looks larger than it is because this moves the "mktree()" function up earlier to be used by the picture saving code. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03CCR code: Change to sample structureGravatar Willem Ferguson
1) All the variables in the sample structures are strongly typed 2) Two additional types were declared in units.h: o2pressure_t bearing_t 3) The following variables were added: diluentpressure o2setpoint o2sensor[3] 4) Changes to a number of files were made to chanf sample->po2 to sample->po2.mbar bearing to bearring.degrees Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>