From e70bbb637e1dd631cb54c9880afe6c7ae04d0b3e Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 14 Mar 2014 16:01:52 -0700 Subject: [PATCH] If saving to a git repository fails, don't create oddly named XML file Before this change when the user gave a git style filename, say /tmp/mydives[myname], if Subsurface couldn't create a repository with that branch, it instead saved an XML file to this exact name, with '[' and ']'. That clearly is not the desired behavior, so report an error instead. Signed-off-by: Dirk Hohndel --- save-xml.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/save-xml.c b/save-xml.c index 61a9300bb..c83101c13 100644 --- a/save-xml.c +++ b/save-xml.c @@ -606,7 +606,12 @@ int save_dives_logic(const char *filename, const bool select_only) git = is_git_repository(filename, &branch); if (git) return git_save_dives(git, branch, select_only); - + /* if the syntax is for a git save but saving we didn't find a + * repository, throw error */ + if (strchr(filename, '[')) { + report_error("Save failed, invalid git repository %s", filename); + return -1; + } try_to_backup(filename); save_dives_buffer(&buf, select_only);