commit a912299c03df09397587f434bd4d5e8f9ad19cbf from: Stefan Sperling via: Thomas Adam date: Thu May 15 16:08:55 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 - b5c9579e6c5505125ac9ce171891e126c1c728e0 commit + a912299c03df09397587f434bd4d5e8f9ad19cbf 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 - 7c025382cb49c81ae15a050a0ebb1d1718a764c8 blob + 04d3dfe04b61da58eac542016d305f7966dd7a08 --- lib/worktree.c +++ lib/worktree.c @@ -211,6 +211,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; @@ -351,6 +352,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;