Commit 4df642d96698f559d3c086843ecd7c411f9963aa

Stefan Sperling 2017-11-05T13:54:45

add more special refs which live directly in .git

diff --git a/include/got_refs.h b/include/got_refs.h
index 15d2c60..874712f 100644
--- a/include/got_refs.h
+++ b/include/got_refs.h
@@ -41,6 +41,7 @@ struct got_reference {
 #define GOT_REF_HEAD		"HEAD"
 #define GOT_REF_ORIG_HEAD	"ORIG_HEAD"
 #define GOT_REF_MERGE_HEAD	"MERGE_HEAD"
+#define GOT_REF_FETCH_HEAD	"FETCH_HEAD"
 
 const struct got_error *
 got_ref_open(struct got_reference **, const char *, const char *);
diff --git a/lib/repository.c b/lib/repository.c
index 0272279..f96d838 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -29,9 +29,12 @@
 #define GOT_GIT_DIR	".git"
 
 /* Mandatory files and directories inside the git directory. */
-#define GOT_OBJECTS_DIR	"objects"
-#define GOT_REFS_DIR	"refs"
-#define GOT_HEAD_FILE	"HEAD"
+#define GOT_OBJECTS_DIR		"objects"
+#define GOT_REFS_DIR		"refs"
+#define GOT_HEAD_FILE		"HEAD"
+
+#define GOT_FETCH_HEAD_FILE	"FETCH_HEAD"
+#define GOT_ORIG_HEAD_FILE	"ORIG_HEAD"
 
 static char *
 get_path_git_dir(struct got_repository *repo)
@@ -138,7 +141,10 @@ got_repo_get_reference(struct got_reference **ref,
 	char *path_refs;
 
 	/* Some refs live in the .git directory. */
-	if (strcmp(refname, GOT_REF_HEAD) == 0)
+	if (strcmp(refname, GOT_REF_HEAD) == 0 ||
+	    strcmp(refname, GOT_REF_ORIG_HEAD) == 0 ||
+	    strcmp(refname, GOT_REF_MERGE_HEAD) == 0 ||
+	    strcmp(refname, GOT_REF_FETCH_HEAD) == 0)
 		path_refs = get_path_git_dir(repo);
 	else
 		path_refs = get_path_refs(repo);