diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2020-02-22 23:17:41 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-02-24 20:33:30 +0300 |
commit | e02a7141f83326f7098800fed764061ecf1f0eff (patch) | |
tree | 1318e9963b37976a2ed39db967a4e69e82b0ef96 | |
parent | efa7ae36c134cc0de6f766c1ab5dfd6b55fab65c (diff) |
worktree: allow repository version 1
Git supports both repository versions 0 and 1. These formats are
identical except for the presence of extensions. When using an
extension, such as for a different hash algorithm, a check for only
version 0 causes the check to fail. Instead, call
verify_repository_format to verify that we have an appropriate version
and no unknown extensions.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | worktree.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/worktree.c b/worktree.c index 5b4793caa3..d1d23aadb4 100644 --- a/worktree.c +++ b/worktree.c @@ -449,7 +449,7 @@ const struct worktree *find_shared_symref(const char *symref, int submodule_uses_worktrees(const char *path) { char *submodule_gitdir; - struct strbuf sb = STRBUF_INIT; + struct strbuf sb = STRBUF_INIT, err = STRBUF_INIT; DIR *dir; struct dirent *d; int ret = 0; @@ -463,18 +463,16 @@ int submodule_uses_worktrees(const char *path) get_common_dir_noenv(&sb, submodule_gitdir); free(submodule_gitdir); - /* - * The check below is only known to be good for repository format - * version 0 at the time of writing this code. - */ strbuf_addstr(&sb, "/config"); read_repository_format(&format, sb.buf); - if (format.version != 0) { + if (verify_repository_format(&format, &err)) { + strbuf_release(&err); strbuf_release(&sb); clear_repository_format(&format); return 1; } clear_repository_format(&format); + strbuf_release(&err); /* Replace config by worktrees. */ strbuf_setlen(&sb, sb.len - strlen("config")); |