subsurface would SIGSEGV for me after a git save, and it turns out
that the reason is that the remote cloud handling was broken for the
case where there was no remote repository, you just saved to a local
git repo.

This fixes it.

                 Linus
From 6c839ed1d411d9ab97efa9cc4e659b84fae8260d Mon Sep 17 00:00:00 2001
From: Linus Torvalds <[email protected]>
Date: Tue, 16 Jun 2015 17:37:15 -1000
Subject: [PATCH] git save: fix crash with no remote

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 <[email protected]>
---
 git-access.c | 2 ++
 save-git.c   | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/git-access.c b/git-access.c
index 2d914ebfeff9..3a99d591c8d2 100644
--- a/git-access.c
+++ b/git-access.c
@@ -568,6 +568,8 @@ struct git_repository *is_git_repository(const char *filename, const char **bran
 		free(branch);
 		return dummy_git_repository;
 	}
+	if (remote)
+		*remote = NULL;
 	*branchp = branch;
 	return repo;
 }
diff --git a/save-git.c b/save-git.c
index 6e44b0851121..64e04823b745 100644
--- a/save-git.c
+++ b/save-git.c
@@ -1139,7 +1139,7 @@ int do_git_save(git_repository *repo, const char *branch, const char *remote, bo
 	if (create_new_commit(repo, branch, &id))
 		return report_error("creating commit failed");
 
-	if (prefs.cloud_background_sync) {
+	if (remote && prefs.cloud_background_sync) {
 		/* now sync the tree with the cloud server */
 		if (strstr(remote, prefs.cloud_git_url)) {
 			return sync_with_remote(repo, remote, branch, RT_HTTPS);
-- 
2.4.2.387.gf86f31a

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to