diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-03-12 14:12:58 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-03-12 19:41:19 -0700 |
commit | 7902af246c5fa2091caf8fd49e592d12b6e26daa (patch) | |
tree | 64f0ca570ab05157d0d5bb56d5ab653e4d5b7343 /file.c | |
parent | 5b3dab719e44f5c20304ed48c5df35f8e115c28b (diff) | |
download | subsurface-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 'file.c')
-rw-r--r-- | file.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -356,19 +356,21 @@ static void parse_file_buffer(const char *filename, struct memblock *mem, char * if (!mem->size || !mem->buffer) return; - if (mem->size > 3 && !memcmp(mem->buffer, "git", 3)) { - git_load_dives(mem->buffer); - return; - } parse_xml_buffer(filename, mem->buffer, mem->size, &dive_table, NULL, error); } void parse_file(const char *filename, char **error) { + struct git_repository *git; + const char *branch; struct memblock mem; char *fmt; + git = is_git_repository(filename, &branch); + if (git && !git_load_dives(git, branch)) + return; + if (readfile(filename, &mem) < 0) { /* we don't want to display an error if this was the default file */ if (prefs.default_filename && !strcmp(filename, prefs.default_filename)) |