summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2010-12-17 20:03:20 +0100
committernulltoken <emeric.fermas@gmail.com>2010-12-17 20:03:20 +0100
commit2899093835b3aac641e594f717142fcce065c479 (patch)
treea880c7a7f12196b747a4058a1e1b6cda2827d5ae /src
parentd13e7e02a8b3fdcfe0e633fcbfc2521f502eb74e (diff)
downloadlibgit2-2899093835b3aac641e594f717142fcce065c479.tar.gz
Prettified HEAD symlink generation.
Diffstat (limited to 'src')
-rw-r--r--src/repository.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/repository.c b/src/repository.c
index df154828f..0759c0c26 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -39,6 +39,10 @@
#define GIT_INDEX_FILE "index"
#define GIT_HEAD_FILE "HEAD"
+#define GIT_SYMREF "ref: "
+#define GIT_REFS_HEADS "refs/heads/"
+#define GIT_BRANCH_MASTER "master"
+
static const int default_table_size = 32;
static const double max_load_factor = 0.65;
@@ -743,11 +747,15 @@ int git_repository_init__create_head(const char* head_path)
{
git_file fd;
int error = GIT_SUCCESS;
- const char* head_content = "ref: refs/heads/master\n";
+ char head_symlink[50];
+ int len;
+
+ len = sprintf(head_symlink, "%s %s%s\n", GIT_SYMREF, GIT_REFS_HEADS, GIT_BRANCH_MASTER);
+
if ((fd = gitfo_creat(head_path, S_IREAD | S_IWRITE)) < 0)
return GIT_ERROR;
- error = gitfo_write(fd, (void*)head_content, strlen(head_content));
+ error = gitfo_write(fd, (void*)head_symlink, strlen(head_symlink));
if (error < GIT_SUCCESS)
goto cleanup;