mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	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>
			
			
This commit is contained in:
		
							parent
							
								
									971f1c6674
								
							
						
					
					
						commit
						39a0ac965b
					
				
					 1 changed files with 11 additions and 0 deletions
				
			
		
							
								
								
									
										11
									
								
								git-access.c
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue