Commit fdf001a7fe7090e3571dfbbfd1d49159c2416756

Stefan Sperling 2018-03-11T12:28:15

add a proper definition for the worktree head

diff --git a/lib/got_worktree_priv.h b/lib/got_worktree_priv.h
index 3d62098..206bddf 100644
--- a/lib/got_worktree_priv.h
+++ b/lib/got_worktree_priv.h
@@ -37,6 +37,7 @@ struct got_worktree {
 #define GOT_WORKTREE_REPOSITORY		"repository"
 #define GOT_WORKTREE_PATH_PREFIX	"path-prefix"
 #define GOT_WORKTREE_BASE_COMMIT	"base-commit"
+#define GOT_WORKTREE_HEAD		"head"
 #define GOT_WORKTREE_LOCK		"lock"
 #define GOT_WORKTREE_FORMAT		"format"
 
diff --git a/lib/worktree.c b/lib/worktree.c
index d4385a5..39e5396 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -173,7 +173,7 @@ got_worktree_init(const char *path, struct got_reference *head_ref,
 	if (err)
 		goto done;
 
-	/* Create an empty base commit file. */
+	/* Set base commit to empty. */
 	err = create_meta_file(gotpath, GOT_WORKTREE_BASE_COMMIT, NULL);
 	if (err)
 		goto done;
@@ -184,7 +184,7 @@ got_worktree_init(const char *path, struct got_reference *head_ref,
 		err = got_error(GOT_ERR_NO_MEM);
 		goto done;
 	}
-	err = create_meta_file(gotpath, GOT_REF_HEAD, refstr);
+	err = create_meta_file(gotpath, GOT_WORKTREE_HEAD, refstr);
 	if (err)
 		goto done;
 
diff --git a/regress/worktree/worktree_test.c b/regress/worktree/worktree_test.c
index fc19621..5bacfa8 100644
--- a/regress/worktree/worktree_test.c
+++ b/regress/worktree/worktree_test.c
@@ -81,7 +81,7 @@ remove_meta_file(const char *worktree_path, const char *name)
 static int
 remove_worktree(const char *worktree_path)
 {
-	if (!remove_meta_file(worktree_path, GOT_REF_HEAD))
+	if (!remove_meta_file(worktree_path, GOT_WORKTREE_HEAD))
 		return 0;
 	if (!remove_meta_file(worktree_path, GOT_WORKTREE_FILE_INDEX))
 		return 0;
@@ -170,7 +170,7 @@ worktree_init(const char *repo_path)
 		goto done;
 
 	/* Ensure required files were created. */
-	if (!check_meta_file_exists(worktree_path, GOT_REF_HEAD))
+	if (!check_meta_file_exists(worktree_path, GOT_WORKTREE_HEAD))
 		goto done;
 	if (!check_meta_file_exists(worktree_path, GOT_WORKTREE_LOCK))
 		goto done;
@@ -274,7 +274,7 @@ worktree_init_exists(const char *repo_path)
 
 	/* Create files which got_worktree_init() will try to create as well. */
 	if (!obstruct_meta_file_and_init(&ok, repo, worktree_path,
-	    GOT_REF_HEAD))
+	    GOT_WORKTREE_HEAD))
 		goto done;
 	if (!obstruct_meta_file_and_init(&ok, repo, worktree_path,
 	    GOT_WORKTREE_LOCK))