diff options
author | Ben Straub <bs@github.com> | 2013-09-16 16:12:31 -0700 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2013-09-16 16:12:31 -0700 |
commit | 549931679a77b280eb1f36afeda8930eb31d70f7 (patch) | |
tree | 2744e3e198ad146bae72f35369bbeb4f8028c8c3 /src/pack.c | |
parent | 1a68c168a6cdbe0db6e44fb582a7026a7d536c9d (diff) | |
parent | 8821c9aa5baf31e21c21825e8c91c765e6631e7f (diff) | |
download | libgit2-549931679a77b280eb1f36afeda8930eb31d70f7.tar.gz |
Merge branch 'development' into blame_rebased
Conflicts:
include/git2.h
Diffstat (limited to 'src/pack.c')
-rw-r--r-- | src/pack.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/pack.c b/src/pack.c index 7ce7099e0..e7fb9f1ae 100644 --- a/src/pack.c +++ b/src/pack.c @@ -329,8 +329,10 @@ static int pack_index_open(struct git_pack_file *p) memcpy(idx_name, p->pack_name, base_len); memcpy(idx_name + base_len, ".idx", sizeof(".idx")); - if ((error = git_mutex_lock(&p->lock)) < 0) + if ((error = git_mutex_lock(&p->lock)) < 0) { + git__free(idx_name); return error; + } if (p->index_version == -1) error = pack_index_check(idx_name, p); @@ -820,7 +822,7 @@ void git_packfile_free(struct git_pack_file *p) git_mwindow_free_all(&p->mwf); - if (p->mwf.fd != -1) + if (p->mwf.fd >= 0) p_close(p->mwf.fd); pack_index_free(p); @@ -903,7 +905,8 @@ static int packfile_open(struct git_pack_file *p) cleanup: giterr_set(GITERR_OS, "Invalid packfile '%s'", p->pack_name); - p_close(p->mwf.fd); + if (p->mwf.fd >= 0) + p_close(p->mwf.fd); p->mwf.fd = -1; git_mutex_unlock(&p->lock); @@ -1107,8 +1110,11 @@ static int pack_entry_find_offset( short_oid->id[0], short_oid->id[1], short_oid->id[2], lo, hi, p->num_objects); #endif - /* Use git.git lookup code */ +#ifdef GIT_USE_LOOKUP pos = sha1_entry_pos(index, stride, 0, lo, hi, p->num_objects, short_oid->id); +#else + pos = sha1_position(index, stride, lo, hi, short_oid->id); +#endif if (pos >= 0) { /* An object matching exactly the oid was found */ |