aboutsummaryrefslogtreecommitdiffstats
path: root/load-git.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 /load-git.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 'load-git.c')
-rw-r--r--load-git.c35
1 files changed, 11 insertions, 24 deletions
diff --git a/load-git.c b/load-git.c
index 15c48027b..5d55245db 100644
--- a/load-git.c
+++ b/load-git.c
@@ -1214,32 +1214,19 @@ static int do_git_load(git_repository *repo, const char *branch)
return ret;
}
-int git_load_dives(char *where)
+/*
+ * Like git_save_dives(), this silently returns a negative
+ * value if it's not a git repository at all (so that you
+ * can try to load it some other way.
+ *
+ * If it is a git repository, we return zero for success,
+ * or report an error and return 1 if the load failed.
+ */
+int git_load_dives(struct git_repository *repo, const char *branch)
{
- int ret, len;
- git_repository *repo;
- char *loc, *branch;
-
- /* Jump over the "git" marker */
- loc = where + 3;
- while (isspace(*loc))
- loc++;
-
- /* Trim whitespace from the end */
- len = strlen(loc);
- while (len && isspace(loc[len-1]))
- loc[--len] = 0;
-
- /* Find a branch name if there is any */
- branch = strrchr(loc, ':');
- if (branch)
- *branch++ = 0;
-
- if (git_repository_open(&repo, loc))
- return report_error("Unable to open git repository at '%s' (branch '%s')", loc, branch);
-
- ret = do_git_load(repo, branch);
+ int ret = do_git_load(repo, branch);
git_repository_free(repo);
+ free((void *)branch);
finish_active_dive();
finish_active_trip();
return ret;