summaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2014-03-12 14:12:58 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-03-12 19:41:19 -0700
commit7902af246c5fa2091caf8fd49e592d12b6e26daa (patch)
tree64f0ca570ab05157d0d5bb56d5ab653e4d5b7343 /save-xml.c
parent5b3dab719e44f5c20304ed48c5df35f8e115c28b (diff)
downloadsubsurface-7902af246c5fa2091caf8fd49e592d12b6e26daa.tar.gz
Stop using the "git descriptor file" model
Instead, just encode the git repository information in the filename. We want to make it much harder to make it match a real filename, but to still allow easy browsing with the file manager interface. So the git repository "filename" format is the path to the git repository directory, with the branch name encoded as "[branch]" at the end rather than the "path:branch" format that we used in the descriptor file. [ For example, on Windows, a filename like "c:\my.xml" could be interpreted as the branchame "\my.xml" in the repository in the directory "c" ] In particular, with this model, no filename that ends with ".xml" could possibly ever be considered a git repository name, since the last character of a git pathname is always ']'. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-xml.c')
-rw-r--r--save-xml.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/save-xml.c b/save-xml.c
index f5d17c49c..a27dcfa76 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -597,21 +597,14 @@ void save_dives_logic(const char *filename, const bool select_only)
{
struct membuffer buf = { 0 };
FILE *f;
- int fd;
+ void *git;
+ const char *branch;
- /*
- * See if the file already exists, and if so,
- * perhaps it's a git save-file pointer?
- *
- * Otherwise, try to back it up.
- */
- fd = subsurface_open(filename, O_RDONLY, 0);
- if (fd >= 0) {
- if (git_save_dives(fd, select_only))
- return;
- close(fd);
- try_to_backup(filename);
- }
+ git = is_git_repository(filename, &branch);
+ if (git && !git_save_dives(git, branch, select_only))
+ return;
+
+ try_to_backup(filename);
save_dives_buffer(&buf, select_only);