add more special refs which live directly in .git
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
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);