diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-10 18:03:37 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-06-10 20:57:57 -0700 |
commit | 39a0ac965bf9af50ffc898dfa898b4b52dbfa943 (patch) | |
tree | d4a71045599aebcf850363e1ee896986d7e0fb7e /git-access.c | |
parent | 971f1c66742508161c023623aef260d9b777f55c (diff) | |
download | subsurface-39a0ac965bf9af50ffc898dfa898b4b52dbfa943.tar.gz |
git storage: actually update the remote repository if the local cache is 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>
Diffstat (limited to 'git-access.c')
-rw-r--r-- | git-access.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/git-access.c b/git-access.c index ded065e01..0cfd27483 100644 --- a/git-access.c +++ b/git-access.c @@ -101,6 +101,17 @@ static int reset_to_remote(git_repository *repo, git_reference *local, const git static int update_remote(git_repository *repo, git_remote *origin, git_reference *local, git_reference *remote) { + git_push_options opts = GIT_PUSH_OPTIONS_INIT; + git_strarray refspec; + const char *name = git_reference_name(local); + + refspec.count = 1; + refspec.strings = (char **)&name; + + if (git_remote_push(origin, &refspec, &opts)) + return report_error("Unable to update remote with current local cache state (%s)", giterr_last()->message); + + // Not actually an error, just informational report_error("Local cache more recent than remote"); return 0; } |