diff options
Diffstat (limited to 'save-git.c')
-rw-r--r-- | save-git.c | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/save-git.c b/save-git.c index 84eb1a316..0aef48f0b 100644 --- a/save-git.c +++ b/save-git.c @@ -1127,73 +1127,6 @@ static int do_git_save(git_repository *repo, const char *branch, bool select_onl return create_new_commit(repo, branch, &id); } -/* - * If it's not a git repo, return NULL. Be very conservative. - */ -struct git_repository *is_git_repository(const char *filename, const char **branchp) -{ - int flen, blen, ret; - struct stat st; - git_repository *repo; - char *loc, *branch; - - flen = strlen(filename); - if (!flen || filename[--flen] != ']') - return NULL; - - /* Find the matching '[' */ - blen = 0; - while (flen && filename[--flen] != '[') - blen++; - - if (!flen) - return NULL; - - /* - * This is the "point of no return": the name matches - * the git repository name rules, and we will no longer - * return NULL. - * - * We will either return "dummy_git_repository" and the - * branch pointer will have the _whole_ filename in it, - * or we will return a real git repository with the - * branch pointer being filled in with just the branch - * name. - * - * The actual git reading/writing routines can use this - * to generate proper error messages. - */ - *branchp = filename; - loc = malloc(flen+1); - if (!loc) - return dummy_git_repository; - memcpy(loc, filename, flen); - loc[flen] = 0; - - branch = malloc(blen+1); - if (!branch) { - free(loc); - return dummy_git_repository; - } - memcpy(branch, filename+flen+1, blen); - branch[blen] = 0; - - if (stat(loc, &st) < 0 || !S_ISDIR(st.st_mode)) { - free(loc); - free(branch); - return dummy_git_repository; - } - - ret = git_repository_open(&repo, loc); - free(loc); - if (ret < 0) { - free(branch); - return dummy_git_repository; - } - *branchp = branch; - return repo; -} - int git_save_dives(struct git_repository *repo, const char *branch, bool select_only) { int ret; |