Skip to content

Commit e02a714

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent efa7ae3 commit e02a714

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

worktree.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ const struct worktree *find_shared_symref(const char *symref,
449449
int submodule_uses_worktrees(const char *path)
450450
{
451451
char *submodule_gitdir;
452-
struct strbuf sb = STRBUF_INIT;
452+
struct strbuf sb = STRBUF_INIT, err = STRBUF_INIT;
453453
DIR *dir;
454454
struct dirent *d;
455455
int ret = 0;
@@ -463,18 +463,16 @@ int submodule_uses_worktrees(const char *path)
463463
get_common_dir_noenv(&sb, submodule_gitdir);
464464
free(submodule_gitdir);
465465

466-
/*
467-
* The check below is only known to be good for repository format
468-
* version 0 at the time of writing this code.
469-
*/
470466
strbuf_addstr(&sb, "/config");
471467
read_repository_format(&format, sb.buf);
472-
if (format.version != 0) {
468+
if (verify_repository_format(&format, &err)) {
469+
strbuf_release(&err);
473470
strbuf_release(&sb);
474471
clear_repository_format(&format);
475472
return 1;
476473
}
477474
clear_repository_format(&format);
475+
strbuf_release(&err);
478476

479477
/* Replace config by worktrees. */
480478
strbuf_setlen(&sb, sb.len - strlen("config"));

0 commit comments

Comments
 (0)