diff options
Diffstat (limited to 'save-xml.c')
-rw-r--r-- | save-xml.c | 21 |
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); |