summaryrefslogtreecommitdiffstats
path: root/git-access.c
AgeCommit message (Collapse)Author
2015-10-04Print paths to internal files in verbose modeGravatar Robert C. Helling
When run with -v option, this prints local file names like the path to the local git repository and the hash file. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-01Avoid possible NULL dereferenceGravatar Dirk Hohndel
I actually think this might be a false positive, but the libgit2 API doesn't appear to guarantee that ancestor is not NULL, so let's add that check. Coverity CID 1325296 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-26Cloud storage: delete http.proxy key if no proxy is setGravatar Dirk Hohndel
Apparently Windows doesn't like it if the proxy string is set to the empty string. Also give some better debugging output when run in verbose mode. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-25Cloud storage: inform the user if remote sync failedGravatar Dirk Hohndel
Being silent in this particular case was the wrong decision as it hides problems. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-23Cloud storage: more user friendly handling of local cache corruptionGravatar Dirk Hohndel
When dealing with cloud storage most of the time the user will not be familiar with git. So if the local cache is corrupted don't leave them to clean up the mess. Instead just move things out of the way (just in case they know how to extract data from the damaged local repository) and ask them to restart the operation which should give them a fresh copy of their data from the remote server (minus any local changes that hadn't been synced to the server before things went bad). 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-20Cloud storage: verbose output to consoleGravatar Dirk Hohndel
If Subsurface is started with the verbose flag, also give progress information on the consol (just in case there are issues with the progress dialog). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-18Cloud storage: make user visible messages more consistentGravatar Dirk Hohndel
I hate this patch. But it makes no sense to expose users to git level error messages. So this is trying to make things much easier (and, frankly, less informative) if we are accessing the Subsurface cloud. The way this is implemented is really ugly; it tries to avoid frequent repetition of the same strings by using different exit points for the functions in question. I'm not convinced this was the best way to do it but it's what I have. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-10Be compatible with libgit2 0.22 againGravatar Anton Lundin
The callback function was introduced in 0.23, so put it behind that ifdef. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-10Cloud storage: add another progress callbackGravatar Dirk Hohndel
This one sadly only appears to be called with 0% and 100% in my examples. Not sure what to do about that. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-09Replace the spinner with a progress dialog for cloud storage accessGravatar Dirk Hohndel
Since the spinner caused all kinds of problems inside VMs, wasn't shown at all for some people on Win10 and appeared to get stuck a lot and still left people with the perception that Subsurface was hung, this patch takes a more traditional approach and gives the user a progress dialog. An additional benefit of this is that the user now can cancel a hung transfer. The slightly weird passing in of the callback allows for the separation of UI and core logic code... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31Be compatible with libgit2 0.22 againGravatar Anton Lundin
In libgit2 0.22 tree_flags was called flags. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Cloud storage: attempt to deal with conflicts about deleted filesGravatar Dirk Hohndel
This doesn't seem right, but it works. Definitely needs more analysis. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Cloud storage: test offline operationGravatar Dirk Hohndel
All this really does is make sure that the fast forward works if the local cache has received updates that haven't made it to the server, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Cloud storage: adjust debugging messagesGravatar Dirk Hohndel
We shouldn't always tell the user about the perceived validity of the cloud certificate - we force it anyway. But it's nice to be easily able to see if we tried to update the remote, so add another debug output when run with -v Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Cloud storage: be more verbose if asked to be verboseGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Cloud storage: try to brute force your way around merge issuesGravatar Dirk Hohndel
This seems to do the right thing in several cases that I tested, but I'm worried if it might end up causing us data loss in other cases. This needs a TON of testing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Cloud storage: be very strict about renamesGravatar Dirk Hohndel
Because of the structure of some of our files git too easily assumed that they were renames and that confused the merge algorithm. 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-25Cloud storage: move git merge into its own functionGravatar Dirk Hohndel
Just to keep things more readable. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Cloud storage: better error message for dirty stateGravatar Dirk Hohndel
Tell us WHAT is wrong with the state. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-22Cloud storage: use merge options to avoid conflictsGravatar Dirk Hohndel
In many cases Subsurface will do something "reasonable" if we have conflicting edits and then try to merge. GIT_MERGE_FILE_FAVOR_UNION means that both edits will be added to the final file and then Subsurface should quietly take one or the other - this will need quite a bit of testing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-22Cloud storage: merge local and remote changes if there is no conflictGravatar Dirk Hohndel
We still punt if there are any conflicts (which are likely to occur if we have touched dive sites in both changes). But in my testing at least for fairly simple, non-conflicting changes this works and creates a correctly merged tree. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-17Explicit cast to stop compiler warningGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-13Cloud storage: recognize our server certificate and accept itGravatar Dirk Hohndel
On some platforms like Android the installed root certificates are rather inconsistent. Same goes for older Windows machines. Instead of trying to figure out how to get the user to install the right root certificates (just kidding) we explicitly recognize our own server certificate and allow that to override the validity assessment by the OS. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-13Cloud storage: provide more information in debug buildsGravatar Dirk Hohndel
It makes sense to hide git URLs from the end user in release builds, but while developing and testing it's better to get more detailed information. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21Fix incorrect buffer length calculationGravatar Dirk Hohndel
Oops, this is bad as it will lead to a certain buffer overrun. The other change is more cosmetic - nested open comment '/*'. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-19Use remote transport parameter instead of comparing stringsGravatar Dirk Hohndel
We pass it in, we might as well use it. 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-16Cloud storage: warn the user if we are not onlineGravatar Dirk Hohndel
This isn't perfect, but at least tells the user if we weren't able to connect and are working just off the local cache. 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-14Fix compiling against libgit2-0.22.1Gravatar Gaetan Bisson
I have no idea whether the semantics is right, this patch was only written so Subsurface compiles against the current stable release of libgit2. [Dirk Hohndel: added an extra conditional so this also compiles with the curl-stream branch needed for https proxy support in libgit2] Signed-off-by: Gaetan Bisson <bisson@archlinux.org> 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: initialize local cache and remote on first useGravatar Dirk Hohndel
There's no point in telling the user that the remote is empty. We need to instead fix that and create the local cache and set things up for the remote. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13Cloud storage: if there is no remote tracking branch, create itGravatar Dirk Hohndel
When we first store things to the remote there won't be a matching branch for it. And even if for some silly reason the remote branch got lost - what's the point of telling the user that there is no remote branch? What are they supposed to do about it. Let's just fix the problem and move on. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13Cloud storage: don't print confusing warningGravatar Dirk Hohndel
This is no longer correct and is actively misleading. We now correctly sync with the remote. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13Cloud storage: setup proxy before cloning new repositoryGravatar Dirk Hohndel
If we don't have a repository yet, we can't setup the proxy option before calling into libgit2. Instead we use a callback. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13Cloud storage: give user friendly error messagesGravatar Dirk Hohndel
Instead of showing the git URL and talking about failures to clone repositories, simply tell the user what's happening with the cloud storage. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13Cloud storage: check connectivity before trying to connectGravatar Dirk Hohndel
With a new repository we take a different path. 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-12Add header for Qt helpers used from C functionsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12Cloud storage: check connection before connectingGravatar Dirk Hohndel
libgit2 takes forever (a minute or so) to figure out that it can't connect to a remote server. So if we are using https as connection protocol, quickly check utilizing RFCs 2324/7168 to make sure we can reach the cloud server (and not some captive portal or something). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12Cloud storage: Unset the proxy if none is configuredGravatar Dirk Hohndel
The settings are stored in the local cache repository - so without resetting it a proxy would stay configured even if it was disabled in the Subsurface preferences. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12Cloud storage: Setup http proxy for git connectionGravatar Dirk Hohndel
At the time of this commit support for this feature has not landed in upstream libgit2, yet (but there is a pull request). Yet supporting this here doesn't appear to cause any issue with older versions of libgit2, either, so the http proxy support will simply not work when enabled and a version of libgit2 that's too old is used. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10Cloud storage: use our credentials when updating the remoteGravatar Dirk Hohndel
If we are pushing to an ssh or https based remote we need to use our credentials. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10Cloud storageGravatar Dirk Hohndel
Use the credential helpers earlier in the source. This way we can use them for the push as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10Cloud storage: track the repository type and pass the information aroundGravatar Dirk Hohndel
This is easier than having various parts of the code to the string comparison on the URL. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10git storage: actually update the remote repository if the local cache is ↵Gravatar Linus Torvalds
more recent Again, note that this currently only happens when you initially open the repository. So if you do subsurface https://.../repo[myubranch] it will start up by fetching the remote information, and updating the local cache. If you then download new dives, and do a save-and-exit, it will save to the local cache, but it doesn't do the fetch at this point, so the remote is now begind. The *next* time you start subsurface, and load that git branch again, it will fetch the remote, and now notice that the local cache is ahead of it (because you downloaded new dives and saved them locally), and *then* it will try to update the remote with the new information. This is obviously bogus, but we will need to decide exactly how we want to sync with the remote repository. But now the core functionality is there, it's just that we need some interface to say "sync now". Especially in the face of spotty (or non-working) internet, you want a GUI etc for this whole remote sync, rather than doing it unconditionally and silently whenever you load the local cache initially. With that caveat: Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>