diff options
| author | Etienne Samson <samson.etienne@gmail.com> | 2019-02-02 19:00:49 +0100 |
|---|---|---|
| committer | Etienne Samson <samson.etienne@gmail.com> | 2019-09-05 10:27:00 +0200 |
| commit | 9b25cf152abf58e4a380e2b52fb1757715d660cd (patch) | |
| tree | 0ea11273ce1a0e30f3cbb1986fc235efb7144167 /src | |
| parent | 0a88c83d39e17550932ef99e7e5077c8f0d00e26 (diff) | |
| download | libgit2-9b25cf152abf58e4a380e2b52fb1757715d660cd.tar.gz | |
refdb: fix packed_delete clobbering some errors
In the case of a failed lookup, we'd paper over that by writing back
the packed-refs successfully.
Diffstat (limited to 'src')
| -rw-r--r-- | src/refdb_fs.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/refdb_fs.c b/src/refdb_fs.c index aab11033e..223602772 100644 --- a/src/refdb_fs.c +++ b/src/refdb_fs.c @@ -1100,22 +1100,27 @@ fail: static int packed_delete(refdb_fs_backend *backend, const char *ref_name) { size_t pack_pos; - int error; + int error, found = 0; if ((error = packed_reload(backend)) < 0) goto cleanup; - /* If a packed reference exists, remove it from the packfile and repack */ if ((error = git_sortedcache_wlock(backend->refcache)) < 0) goto cleanup; - if (!(error = git_sortedcache_lookup_index( - &pack_pos, backend->refcache, ref_name))) + /* If a packed reference exists, remove it from the packfile and repack if necessary */ + error = git_sortedcache_lookup_index(&pack_pos, backend->refcache, ref_name); + if (error == 0) { error = git_sortedcache_remove(backend->refcache, pack_pos); + found = 1; + } + if (error == GIT_ENOTFOUND) + error = 0; git_sortedcache_wunlock(backend->refcache); - error = packed_write(backend); + if (found) + error = packed_write(backend); cleanup: return error; |
