aboutsummaryrefslogtreecommitdiffstats
path: root/git-access.c
AgeCommit message (Collapse)Author
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>
2015-06-10git storage: re-organize code to make 'origin' remote more widely availableGravatar Linus Torvalds
I'm going to try to update the remote if the local cache is more recent when we fetch the data, which requires access to the remote over a wider range of code. This re-organizes the code so that we can free the remote later without having to have nasty error handling. We avoid the whole "if an error happened, free the remote and return" by creating helper functions and freeing the remote in the caller, so that all paths end up freeing it naturally. NOTE! We want to try to update the remote when we save the local cache too, so this whole "update remote when opening it" is incomplete. But (a) we do want to do it here as well and (b) this is the easiest place to create the initial "push to remote" code without any new "sync with cloud" interfaces. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10git storage: actually update cached copy from remoteGravatar Linus Torvalds
We used to fetch the remote information but not actually do anything about it, except report when it wasn't up-to-date. Now we actually update the local cached copy if the remote has changed. The code does not try to actually merge things, so only fast-forward updates are done, but that should be the normal case. We might eventually do some simple merging on our own, but I suspect manual merging may be the safer option. We don't currently ever update the remote repository, and only inform users that our local repository is ahead of the remote. Fixing that is the next step. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-09Cloud storage: be more careful when trying to determine a user nameGravatar Dirk Hohndel
Since we use the email address (including the '@' sign) as the repository name we have to be more careful when trying to pick an account name from a git URL. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-31Add strndup.h header so we can use this useful functionGravatar Dirk Hohndel
It's missing on Windows... we had this helper in liquivision.c but since I used the function in git-access.c I figured I should just turn it into a little helper. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-31Cloud storage: first stab at implementing cloud storageGravatar Dirk Hohndel
So far there is no mechanism to actually create a repository on the server, so this only works with the two test repositories. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-31Cloud storage: rethink the terminology usedGravatar Dirk Hohndel
Cloud storage makes more sense that remote storage - at least I assume that more people are used to thinking about "storing things in the cloud". Don't use PIN or passphrase, call it a password everywhere. Don't use copy_string() to copy the password - the git credentials routine asserts that password is not NULL, so make sure we at least have a pointer to an empty string here. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-31Cloud storage: add support for https based remoteGravatar Dirk Hohndel
This will make it easier to access the remote storage. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-28Remote storage: second attempt to fix build with older libgit2Gravatar Dirk Hohndel
That was embarrassing... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-28Remote storage: turns out you need a newer libgit2Gravatar Dirk Hohndel
I was afraid that this would only work with a farily current git master of libgit2 and it turns out I was right. The API was available, but the correct type wasn't. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-28Remote storage: provide credentials for ssh based remotesGravatar Dirk Hohndel
The key location is hard coded as this is only intended for our own infrastructure, so we don't need multiple keys. If the private key is protected by a passphrase, this needs to be manually added to the preferences. As RemoteStorage->passphrase. This has only be tested with a current version of libgit2 master, but should compile with any previous version (the API doesn't exist in v0.19 and earlier - that's handled with appropriate #if clauses). 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-05-28Fix parsing of git branch encoded in file nameGravatar Dirk Hohndel
If the folder has a trailing '/' we picked the wrong substring as branch name. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-24Fix Ubuntu compilation error.Gravatar Patrick Valsecchi
Ubuntu has git minor version 20 which has less parameters in git-remote-fetch. From ac9516984e4fbc787635b0dfd76649c8e43fab83 Mon Sep 17 00:00:00 2001 From: Patrick Valsecchi <patrick@thus.ch> Date: Tue, 24 Feb 2015 08:45:21 +0100 Subject: [PATCH 2/2] Fix Ubuntu compilation error. Ubuntu has git minor version 20 which has less parameters in git-remote-fetch. Signed-off-by: Patrick Valsecchi <patrick@thus.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-15Remove unnecessary use of non-portable 'mkdir()'Gravatar Linus Torvalds
This fixes the problem with Windows being the usual non-POSIX PoS that it is.. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-15Start parsing remote git repository addressesGravatar Linus Torvalds
This doesn't really usefully work, but I'm committing it to have git diff and history. It also insanely hardcodes the git-repo cache directory, because right now it's purely useful for development. The big missing pieces are: - progress information - credential callbacks not implemented where the first one makes the user interface horrible (long delays with nothing visibly going on), and the second one makes ssh logins etc not work. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-15git-access: use the new format_string helpersGravatar Linus Torvalds
It may be a bit less efficient to use a printf-style interface rather than the explicit malloc and memcpy, but the code ends up simpler and more readable. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> 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>