Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-08-19 21:42:48 +0400
committerRussell Belfer <rb@github.com>2013-08-21 03:14:23 +0400
commit0f0f565507565520759bffc22976c583497ec01f (patch)
tree5b3bf0956720df4dc1694dcad9d8b2b6ed28f98a /src/refdb_fs.c
parent5e1fb2828a496d70c5c200b01e2fb0062268f468 (diff)
Don't try to pack symbolic refs
If there were symbolic refs among the loose refs then the code to create packed-refs would fail trying to parse the OID out of them (where Git just skips trying to pack them). This fixes it.
Diffstat (limited to 'src/refdb_fs.c')
-rw-r--r--src/refdb_fs.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index acd82594b..658bebb61 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -316,6 +316,12 @@ static int loose_lookup_to_packfile(
if (reference_read(&ref_file, NULL, backend->path, name, NULL) < 0)
return -1;
+ /* skip symbolic refs */
+ if (!git__prefixcmp(git_buf_cstr(&ref_file), GIT_SYMREF)) {
+ git_buf_free(&ref_file);
+ return 0;
+ }
+
git_buf_rtrim(&ref_file);
name_len = strlen(name);
@@ -355,6 +361,9 @@ static int _dirent_loose_load(void *data, git_buf *full_path)
if (loose_lookup_to_packfile(&ref, backend, file_path) < 0)
return -1;
+ if (!ref)
+ return 0;
+
git_strmap_insert2(
backend->refcache.packfile, ref->name, ref, old_ref, err);
if (err < 0) {
@@ -460,7 +469,7 @@ static int loose_lookup(
if (error < 0)
goto done;
- if (git__prefixcmp((const char *)(ref_file.ptr), GIT_SYMREF) == 0) {
+ if (git__prefixcmp(git_buf_cstr(&ref_file), GIT_SYMREF) == 0) {
git_buf_rtrim(&ref_file);
if ((target = loose_parse_symbolic(&ref_file)) == NULL) {