commit 65e3b818196debd0e5c6cc7c1f3182ee2d253fe2 from: Stefan Sperling date: Sun Mar 11 11:52:02 2018 UTC set base commit to invalid commit id when work tree is created commit - 0605801d8523648622fc2176fd0422d3d5a6ad57 commit + 65e3b818196debd0e5c6cc7c1f3182ee2d253fe2 blob - df56c0dec9b4f886d0894e14ad05aea9fde11040 blob + d207ee390d6e7f6252e01034122dc9e112bfd66d --- lib/got_sha1_priv.h +++ lib/got_sha1_priv.h @@ -14,5 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#define GOT_SHA1_STRING_ZERO "0000000000000000000000000000000000000000" + int got_parse_sha1_digest(uint8_t *, const char *); char *got_sha1_digest_to_str(const uint8_t *, char *, size_t); blob - 206bddffe16837ad2826addc8148245913869383 blob + bc1edd34d187f7078fd4a00b974cab027515c3cd --- lib/got_worktree_priv.h +++ lib/got_worktree_priv.h @@ -42,3 +42,4 @@ struct got_worktree { #define GOT_WORKTREE_FORMAT "format" #define GOT_WORKTREE_FORMAT_VERSION 1 +#define GOT_WORKTREE_INVALID_COMMIT_ID GOT_SHA1_STRING_ZERO blob - a84d489d174231aa2398640506134304ea5d1ba7 blob + eb722edb16fe07622e56476421c81acadc42234e --- lib/worktree.c +++ lib/worktree.c @@ -31,6 +31,7 @@ #include "got_worktree_priv.h" #include "got_path_priv.h" +#include "got_sha1_priv.h" static const struct got_error * create_meta_file(const char *path_got, const char *name, const char *content) @@ -174,8 +175,9 @@ got_worktree_init(const char *path, struct got_referen if (err) goto done; - /* Set base commit to empty. */ - err = create_meta_file(path_got, GOT_WORKTREE_BASE_COMMIT, NULL); + /* Save an invalid base commit hash. */ + err = create_meta_file(path_got, GOT_WORKTREE_BASE_COMMIT, + GOT_WORKTREE_INVALID_COMMIT_ID); if (err) goto done;