commit - 095892882c4ccc2f584998552200561f340e060f
commit + ec22038e8d0a46e692c6093e0a35503f4af398d7
blob - ef8ae1ec5efb0aad7e3b9f4f8f4e89e9bac27fbe
blob + d786edf4b5168f0bcc8ec952293302fd7b1fbece
--- lib/got_lib_worktree.h
+++ lib/got_lib_worktree.h
#define GOT_WORKTREE_BASE_COMMIT "base-commit"
#define GOT_WORKTREE_LOCK "lock"
#define GOT_WORKTREE_FORMAT "format"
+#define GOT_WORKTREE_UUID "uuid"
#define GOT_WORKTREE_FORMAT_VERSION 1
#define GOT_WORKTREE_INVALID_COMMIT_ID GOT_SHA1_STRING_ZERO
blob - f562feb7a7cf4e2dd35c901cfb0609510f5d442b
blob + 8c1bd06e6065b0f858659d184c602a62ff561fa4
--- lib/worktree.c
+++ lib/worktree.c
#include <zlib.h>
#include <fnmatch.h>
#include <libgen.h>
+#include <uuid.h>
#include "got_error.h"
#include "got_repository.h"
{
const struct got_error *err = NULL;
struct got_object_id *commit_id = NULL;
+ uuid_t uuid;
+ uint32_t uuid_status;
int obj_type;
char *path_got = NULL;
char *refstr = NULL;
char *formatstr = NULL;
char *absprefix = NULL;
char *basestr = NULL;
+ char *uuidstr = NULL;
err = got_ref_resolve(&commit_id, repo, head_ref);
if (err)
/* Store in-repository path prefix. */
err = create_meta_file(path_got, GOT_WORKTREE_PATH_PREFIX,
absprefix ? absprefix : prefix);
+ if (err)
+ goto done;
+
+ /* Generate UUID. */
+ uuid_create(&uuid, &uuid_status);
+ if (uuid_status != uuid_s_ok) {
+ err = got_error_uuid(uuid_status);
+ goto done;
+ }
+ uuid_to_string(&uuid, &uuidstr, &uuid_status);
+ if (uuid_status != uuid_s_ok) {
+ err = got_error_uuid(uuid_status);
+ goto done;
+ }
+ err = create_meta_file(path_got, GOT_WORKTREE_UUID, uuidstr);
if (err)
goto done;
free(refstr);
free(absprefix);
free(basestr);
+ free(uuidstr);
return err;
}
blob - 5d9dfdde2dc4af8c6097550fcfb0958cbc8a4331
blob + 82c5ca68b93d4bd4df9907d90eb3a32c1b5a12ed
--- regress/worktree/worktree_test.c
+++ regress/worktree/worktree_test.c
if (!remove_meta_file(worktree_path, GOT_WORKTREE_LOCK))
return 0;
if (!remove_meta_file(worktree_path, GOT_WORKTREE_FORMAT))
+ return 0;
+ if (!remove_meta_file(worktree_path, GOT_WORKTREE_UUID))
return 0;
if (!remove_got_dir(worktree_path))
return 0;
if (!check_meta_file_exists(worktree_path, GOT_WORKTREE_PATH_PREFIX))
goto done;
if (!check_meta_file_exists(worktree_path, GOT_WORKTREE_FORMAT))
+ goto done;
+ if (!check_meta_file_exists(worktree_path, GOT_WORKTREE_UUID))
goto done;
if (!remove_worktree(worktree_path))