summaryrefslogtreecommitdiff
path: root/src/fetchhead.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2013-11-20 12:54:24 +0100
committerVicent Marti <tanoku@gmail.com>2013-11-20 12:54:24 +0100
commit4b0a36e881506a02b43a4ae3c19c93c919b36eeb (patch)
tree026182fa30273a4c1649928b6db3fc5335bd1ea4 /src/fetchhead.c
parent29d7242b1dcd1f09a63417abd648a6217b85d301 (diff)
parent43cb8b32428b1b29994874349ec22eb5372e152c (diff)
downloadlibgit2-4b0a36e881506a02b43a4ae3c19c93c919b36eeb.tar.gz
Merge branch 'development'
Diffstat (limited to 'src/fetchhead.c')
-rw-r--r--src/fetchhead.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/fetchhead.c b/src/fetchhead.c
index 4dcebb857..67089d13d 100644
--- a/src/fetchhead.c
+++ b/src/fetchhead.c
@@ -74,6 +74,7 @@ static int fetchhead_ref_write(
{
char oid[GIT_OID_HEXSZ + 1];
const char *type, *name;
+ int head = 0;
assert(file && fetchhead_ref);
@@ -87,11 +88,16 @@ static int fetchhead_ref_write(
GIT_REFS_TAGS_DIR) == 0) {
type = "tag ";
name = fetchhead_ref->ref_name + strlen(GIT_REFS_TAGS_DIR);
+ } else if (!git__strcmp(fetchhead_ref->ref_name, GIT_HEAD_FILE)) {
+ head = 1;
} else {
type = "";
name = fetchhead_ref->ref_name;
}
+ if (head)
+ return git_filebuf_printf(file, "%s\t\t%s\n", oid, fetchhead_ref->remote_url);
+
return git_filebuf_printf(file, "%s\t%s\t%s'%s' of %s\n",
oid,
(fetchhead_ref->is_merge) ? "" : "not-for-merge",
@@ -112,7 +118,7 @@ int git_fetchhead_write(git_repository *repo, git_vector *fetchhead_refs)
if (git_buf_joinpath(&path, repo->path_repository, GIT_FETCH_HEAD_FILE) < 0)
return -1;
- if (git_filebuf_open(&file, path.ptr, GIT_FILEBUF_FORCE) < 0) {
+ if (git_filebuf_open(&file, path.ptr, GIT_FILEBUF_FORCE, GIT_REFS_FILE_MODE) < 0) {
git_buf_free(&path);
return -1;
}
@@ -124,7 +130,7 @@ int git_fetchhead_write(git_repository *repo, git_vector *fetchhead_refs)
git_vector_foreach(fetchhead_refs, i, fetchhead_ref)
fetchhead_ref_write(&file, fetchhead_ref);
- return git_filebuf_commit(&file, GIT_REFS_FILE_MODE);
+ return git_filebuf_commit(&file);
}
static int fetchhead_ref_parse(