git save: fix crash with no remote

Commit e21cae2d46 ("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>
This commit is contained in:
Linus Torvalds 2015-06-16 17:37:15 -10:00 committed by Dirk Hohndel
parent eca7d998e1
commit eff3fd3261
2 changed files with 3 additions and 1 deletions

View file

@ -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;
}

View file

@ -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);