Download raw body.
got/cvg info: print work tree version
On Tue, Aug 13, 2024 at 08:27:14PM +0200, Stefan Sperling wrote:
> While we're at it we could also print the work tree format version,
> stored in .got/format. So I was thinking we would provide a function
> which returns two output arguments, the work tree format version and
> the file index version.
>
> That said, your patch is fine, too. The easiest way to extend the
> approach you took would be another got_worktree_format_version()
> function which returns the number stored in .got/format.`
The patch for this is straightforward. ok?
diff /home/stsp/src/got
commit - 088a1c3b8187114bdc9d9f4ee98c2c8dceb97172
path + /home/stsp/src/got
blob - 0c373141b94712c86b5183baed684811237bfdc0
file + cvg/cvg.c
--- cvg/cvg.c
+++ cvg/cvg.c
@@ -9108,6 +9108,8 @@ cmd_info(int argc, char *argv[])
printf("work tree branch reference: %s\n",
got_worktree_get_head_ref_name(worktree));
printf("work tree UUID: %s\n", uuidstr);
+ printf("work tree format version: %u\n",
+ got_worktree_get_format_version(worktree));
printf("file index version: %u\n",
got_worktree_fileindex_version(fileindex));
printf("repository: %s\n", got_worktree_get_repo_path(worktree));
blob - 2affb7860e6b084436d9adf95c331abd8fcfc8f6
file + got/got.c
--- got/got.c
+++ got/got.c
@@ -14705,6 +14705,8 @@ cmd_info(int argc, char *argv[])
printf("work tree branch reference: %s\n",
got_worktree_get_head_ref_name(worktree));
printf("work tree UUID: %s\n", uuidstr);
+ printf("work tree format version: %u\n",
+ got_worktree_get_format_version(worktree));
printf("file index version: %u\n",
got_worktree_fileindex_version(fileindex));
printf("repository: %s\n", got_worktree_get_repo_path(worktree));
blob - 2ffc0c695b85896305072307f75db7799c0e05a6
file + include/got_worktree.h
--- include/got_worktree.h
+++ include/got_worktree.h
@@ -91,6 +91,11 @@ const char *got_worktree_get_path_prefix(struct got_wo
const struct got_error *got_worktree_get_uuid(char **, struct got_worktree *);
/*
+ * Get the work tree's format version number.
+ */
+int got_worktree_get_format_version(struct got_worktree *);
+
+/*
* Check if a user-provided path prefix matches that of the worktree.
*/
const struct got_error *got_worktree_match_path_prefix(int *,
blob - 2f9d146493695f5d0f999c4ccca8b981ffdf7c9d
file + lib/got_lib_worktree.h
--- lib/got_lib_worktree.h
+++ lib/got_lib_worktree.h
@@ -23,6 +23,7 @@ struct got_worktree {
struct got_object_id *base_commit_id;
char *head_ref_name;
uuid_t uuid;
+ int format_version;
/*
* File descriptor for the lock file, open while a work tree is open.
blob - 4b99863a5f6d3ae6dcce8b52c6d2a93a1a80b3d3
file + lib/worktree_open.c
--- lib/worktree_open.c
+++ lib/worktree_open.c
@@ -160,7 +160,7 @@ open_worktree(struct got_worktree **worktree, const ch
"could not parse work tree format version number");
goto done;
}
- if (version != GOT_WORKTREE_FORMAT_VERSION) {
+ if (version > GOT_WORKTREE_FORMAT_VERSION) {
err = got_error(GOT_ERR_WORKTREE_VERS);
goto done;
}
@@ -171,6 +171,7 @@ open_worktree(struct got_worktree **worktree, const ch
goto done;
}
(*worktree)->lockfd = -1;
+ (*worktree)->format_version = version;
(*worktree)->root_path = realpath(path, NULL);
if ((*worktree)->root_path == NULL) {
@@ -363,3 +364,9 @@ got_worktree_get_path_prefix(struct got_worktree *work
{
return worktree->path_prefix;
}
+
+int
+got_worktree_get_format_version(struct got_worktree *worktree)
+{
+ return worktree->format_version;
+}
got/cvg info: print work tree version