2 * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include <sys/queue.h>
25 #include "got_error.h"
26 #include "got_repository.h"
27 #include "got_object.h"
31 struct got_delta_base *
32 got_delta_base_open(const char *path_packfile, int type, off_t offset,
35 struct got_delta_base *base;
37 base = calloc(1, sizeof(*base));
41 base->path_packfile = strdup(path_packfile);
42 if (base->path_packfile == NULL) {
47 base->offset = offset;
53 got_delta_base_close(struct got_delta_base *base)
55 free(base->path_packfile);
60 const struct got_error *
61 got_delta_chain_get_base_type(int *type, struct got_delta_chain *deltas)
63 struct got_delta_base *base;
66 /* Find the last base in the chain. It should be a plain object. */
67 SIMPLEQ_FOREACH(base, &deltas->entries, entry) {
69 if (base->type == GOT_OBJ_TYPE_COMMIT ||
70 base->type == GOT_OBJ_TYPE_TREE ||
71 base->type == GOT_OBJ_TYPE_BLOB ||
72 base->type == GOT_OBJ_TYPE_TAG) {
73 if (n != deltas->nentries)
74 return got_error(GOT_ERR_BAD_DELTA_CHAIN);
80 return got_error(GOT_ERR_BAD_DELTA_CHAIN);
83 const struct got_error *
84 got_delta_apply(struct got_repository *repo, FILE *infile, size_t size,
85 struct got_object *base_obj, FILE *outfile)
87 return got_error(GOT_ERR_NOT_IMPL);