commit 86abf691afcfe170d6225c87d8ffed982d0eecec from: Stefan Sperling date: Tue May 13 13:45:18 2025 UTC add comments explaining that .got/base-commit needs hash algo information Hopefully, if we ever bump the work tree format in the future we will see these comments and sneak in a change to the .got/base-commit file in order to record the hash algorithm of the base commit ID. commit - 866e94146b2586459ca83c90f49ece8c91e1fdff commit + 86abf691afcfe170d6225c87d8ffed982d0eecec blob - b1acd87d261a238419bf3f34736ce810f1efd4b8 blob + da0fd545613723ddd1935e8fc60b49dc9ffc3572 --- lib/got_lib_worktree.h +++ lib/got_lib_worktree.h @@ -77,6 +77,13 @@ struct got_commitable { #define GOT_WORKTREE_UUID "uuid" #define GOT_WORKTREE_HISTEDIT_SCRIPT "histedit-script" +/* + * When this version gets bumped, please consider adding a hash algo type + * indicator to the base-commit file, e.g. as a "sha1:" or "sha256:" prefix + * before the commit ID itself. At present, we can infer the hash algo via + * the commit ID string length or by reading the repository's Git config file, + * either of which is suboptimal. + */ #define GOT_WORKTREE_FORMAT_VERSION 1 #define GOT_WORKTREE_BASE_REF_PREFIX "refs/got/worktree/base" blob - 8dde07e115ca4bfbb8f8c8498d793847a4343c27 blob + fd2e3ed8fe3b3dbd2e5e8de7acc219ee467ee052 --- lib/worktree.c +++ lib/worktree.c @@ -214,6 +214,7 @@ got_worktree_init(const char *path, struct got_referen goto done; /* Record our base commit. */ + /* TODO: This should be recording the hash algo type as well. */ err = got_object_id_str(&basestr, commit_id); if (err) goto done; @@ -354,6 +355,7 @@ got_worktree_set_base_commit_id(struct got_worktree *w } /* Record our base commit. */ + /* TODO: This should be recording the hash algo type as well. */ err = got_object_id_str(&id_str, commit_id); if (err) goto done;