diff options
| author | Edward Thomson <ethomson@github.com> | 2016-07-14 16:23:24 -0400 |
|---|---|---|
| committer | Edward Thomson <ethomson@github.com> | 2016-08-04 15:12:04 -0400 |
| commit | 8f09a98e1809dcdfd9d25b8268657bac4d942e6a (patch) | |
| tree | 25f4b977d9a9055569d95a5ba5b038dfbfb01d6a /src/odb_pack.c | |
| parent | d2794b0e37e98206b991ba4c8639ddf53c03bdb9 (diff) | |
| download | libgit2-8f09a98e1809dcdfd9d25b8268657bac4d942e6a.tar.gz | |
odb: freshen existing objects when writing
When writing an object, we calculate its OID and see if it exists in the
object database. If it does, we need to freshen the file that contains
it.
Diffstat (limited to 'src/odb_pack.c')
| -rw-r--r-- | src/odb_pack.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/odb_pack.c b/src/odb_pack.c index 005d07264..3b52b6be6 100644 --- a/src/odb_pack.c +++ b/src/odb_pack.c @@ -363,6 +363,18 @@ static int pack_backend__read_header( return git_packfile_resolve_header(len_p, type_p, e.p, e.offset); } +static int pack_backend__freshen( + git_odb_backend *backend, const git_oid *oid) +{ + struct git_pack_entry e; + int error; + + if ((error = pack_entry_find(&e, (struct pack_backend *)backend, oid)) < 0) + return error; + + return git_futils_touch(e.p->pack_name); +} + static int pack_backend__read( void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid) @@ -560,6 +572,7 @@ static int pack_backend__alloc(struct pack_backend **out, size_t initial_size) backend->parent.refresh = &pack_backend__refresh; backend->parent.foreach = &pack_backend__foreach; backend->parent.writepack = &pack_backend__writepack; + backend->parent.freshen = &pack_backend__freshen; backend->parent.free = &pack_backend__free; *out = backend; |
