commit 70a9400973b89e28220493de1137372adf741ac690ee5c4eb8583c2e23c8840d 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 - a0c2847a9593249567d340ae77cba1cccc55782452be20fc8b842b05fc6a1b43 commit + 70a9400973b89e28220493de1137372adf741ac690ee5c4eb8583c2e23c8840d blob - faf9e56a02ee3b9db9ca8e86ae3f263772a9c52ce0a57399b260ca4e0a817027 blob + 51b00d28f2224478cec2447f58289d06639c86f3df64f47e234d62896eddfe38 --- 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 - c654126a37e9e9eae11baef75d3308ef5c0ac0237d553327cfd94eca6177b640 blob + 26c7302097f774a729ce24a12bdbc383944c7add8d56f458607e00e5cf5a8865 --- 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;