Commit f5baf295a400cb72814473d46c190451e43f5672

Stefan Sperling 2018-03-11T13:06:45

read base commit hash when worktree is opened

diff --git a/lib/got_worktree_priv.h b/lib/got_worktree_priv.h
index bc1edd3..cef7d3d 100644
--- a/lib/got_worktree_priv.h
+++ b/lib/got_worktree_priv.h
@@ -18,6 +18,7 @@ struct got_worktree {
 	char *path_worktree_root;
 	char *path_repo;
 	char *path_prefix;
+	char *base_commit;
 
 	/*
 	 * File descriptor for the lock file, open while a work tree is open.
diff --git a/lib/worktree.c b/lib/worktree.c
index eb722ed..b9b67fb 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -288,6 +288,12 @@ got_worktree_open(struct got_worktree **worktree, const char *path)
 		goto done;
 	err = read_meta_file(&(*worktree)->path_prefix, path_got,
 	    GOT_WORKTREE_PATH_PREFIX);
+	if (err)
+		goto done;
+
+	err = read_meta_file(&(*worktree)->base_commit, path_got,
+	    GOT_WORKTREE_BASE_COMMIT);
+	if (err)
 		goto done;
 
 done: