2007-09-11 11:03:15 +08:00
|
|
|
#ifndef BUNDLE_H
|
|
|
|
#define BUNDLE_H
|
|
|
|
|
2020-07-29 04:23:39 +08:00
|
|
|
#include "strvec.h"
|
2017-05-01 10:28:59 +08:00
|
|
|
#include "cache.h"
|
bundle: remove "ref_list" in favor of string-list.c API
Move away from the "struct ref_list" in bundle.c in favor of the
almost identical string-list.c API.
That API fits this use-case perfectly, but did not exist in its
current form when this code was added in 2e0afafebd (Add git-bundle:
move objects and references by archive, 2007-02-22), with hindsight we
could have used the path-list API, which later got renamed to
string-list. See 8fd2cb4069 (Extract helper bits from
c-merge-recursive work, 2006-07-25)
We need to change "name" to "string" and "oid" to "util" to make this
conversion, but other than that the APIs are pretty much identical for
what bundle.c made use of.
Let's also replace the memset(..,0,...) pattern with a more idiomatic
"INIT" macro, and finally add a *_release() function so to free the
allocated memory.
Before this the add_to_ref_list() would leak memory, now e.g. "bundle
list-heads" reports no memory leaks at all under valgrind.
In the bundle_header_init() function we're using a clever trick to
memcpy() what we'd get from the corresponding
BUNDLE_HEADER_INIT. There is a concurrent series to make use of that
pattern more generally, see [1].
1. https://lore.kernel.org/git/cover-0.5-00000000000-20210701T104855Z-avarab@gmail.com/
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-07-02 17:57:32 +08:00
|
|
|
#include "string-list.h"
|
2022-03-10 00:01:39 +08:00
|
|
|
#include "list-objects-filter-options.h"
|
2007-09-11 11:03:15 +08:00
|
|
|
|
|
|
|
struct bundle_header {
|
2020-07-30 07:14:20 +08:00
|
|
|
unsigned version;
|
bundle: remove "ref_list" in favor of string-list.c API
Move away from the "struct ref_list" in bundle.c in favor of the
almost identical string-list.c API.
That API fits this use-case perfectly, but did not exist in its
current form when this code was added in 2e0afafebd (Add git-bundle:
move objects and references by archive, 2007-02-22), with hindsight we
could have used the path-list API, which later got renamed to
string-list. See 8fd2cb4069 (Extract helper bits from
c-merge-recursive work, 2006-07-25)
We need to change "name" to "string" and "oid" to "util" to make this
conversion, but other than that the APIs are pretty much identical for
what bundle.c made use of.
Let's also replace the memset(..,0,...) pattern with a more idiomatic
"INIT" macro, and finally add a *_release() function so to free the
allocated memory.
Before this the add_to_ref_list() would leak memory, now e.g. "bundle
list-heads" reports no memory leaks at all under valgrind.
In the bundle_header_init() function we're using a clever trick to
memcpy() what we'd get from the corresponding
BUNDLE_HEADER_INIT. There is a concurrent series to make use of that
pattern more generally, see [1].
1. https://lore.kernel.org/git/cover-0.5-00000000000-20210701T104855Z-avarab@gmail.com/
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-07-02 17:57:32 +08:00
|
|
|
struct string_list prerequisites;
|
|
|
|
struct string_list references;
|
2020-06-20 01:56:00 +08:00
|
|
|
const struct git_hash_algo *hash_algo;
|
2022-03-10 00:01:39 +08:00
|
|
|
struct list_objects_filter_options filter;
|
2007-09-11 11:03:15 +08:00
|
|
|
};
|
|
|
|
|
bundle: remove "ref_list" in favor of string-list.c API
Move away from the "struct ref_list" in bundle.c in favor of the
almost identical string-list.c API.
That API fits this use-case perfectly, but did not exist in its
current form when this code was added in 2e0afafebd (Add git-bundle:
move objects and references by archive, 2007-02-22), with hindsight we
could have used the path-list API, which later got renamed to
string-list. See 8fd2cb4069 (Extract helper bits from
c-merge-recursive work, 2006-07-25)
We need to change "name" to "string" and "oid" to "util" to make this
conversion, but other than that the APIs are pretty much identical for
what bundle.c made use of.
Let's also replace the memset(..,0,...) pattern with a more idiomatic
"INIT" macro, and finally add a *_release() function so to free the
allocated memory.
Before this the add_to_ref_list() would leak memory, now e.g. "bundle
list-heads" reports no memory leaks at all under valgrind.
In the bundle_header_init() function we're using a clever trick to
memcpy() what we'd get from the corresponding
BUNDLE_HEADER_INIT. There is a concurrent series to make use of that
pattern more generally, see [1].
1. https://lore.kernel.org/git/cover-0.5-00000000000-20210701T104855Z-avarab@gmail.com/
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-07-02 17:57:32 +08:00
|
|
|
#define BUNDLE_HEADER_INIT \
|
|
|
|
{ \
|
|
|
|
.prerequisites = STRING_LIST_INIT_DUP, \
|
|
|
|
.references = STRING_LIST_INIT_DUP, \
|
|
|
|
}
|
|
|
|
void bundle_header_init(struct bundle_header *header);
|
|
|
|
void bundle_header_release(struct bundle_header *header);
|
|
|
|
|
2011-10-14 06:19:31 +08:00
|
|
|
int is_bundle(const char *path, int quiet);
|
2007-09-11 11:03:15 +08:00
|
|
|
int read_bundle_header(const char *path, struct bundle_header *header);
|
2022-05-17 04:11:05 +08:00
|
|
|
int read_bundle_header_fd(int fd, struct bundle_header *header,
|
|
|
|
const char *report_path);
|
2019-01-24 21:11:51 +08:00
|
|
|
int create_bundle(struct repository *r, const char *path,
|
2020-08-12 09:04:11 +08:00
|
|
|
int argc, const char **argv, struct strvec *pack_options,
|
2020-07-30 07:14:20 +08:00
|
|
|
int version);
|
2018-11-10 13:49:01 +08:00
|
|
|
int verify_bundle(struct repository *r, struct bundle_header *header, int verbose);
|
2021-08-26 22:05:47 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unbundle after reading the header with read_bundle_header().
|
|
|
|
*
|
|
|
|
* We'll invoke "git index-pack --stdin --fix-thin" for you on the
|
|
|
|
* provided `bundle_fd` from read_bundle_header().
|
2021-09-05 15:34:43 +08:00
|
|
|
*
|
|
|
|
* Provide "extra_index_pack_args" to pass any extra arguments
|
|
|
|
* (e.g. "-v" for verbose/progress), NULL otherwise. The provided
|
|
|
|
* "extra_index_pack_args" (if any) will be strvec_clear()'d for you.
|
2021-08-26 22:05:47 +08:00
|
|
|
*/
|
2018-11-10 13:49:01 +08:00
|
|
|
int unbundle(struct repository *r, struct bundle_header *header,
|
2021-09-05 15:34:43 +08:00
|
|
|
int bundle_fd, struct strvec *extra_index_pack_args);
|
2007-09-11 11:03:15 +08:00
|
|
|
int list_bundle_refs(struct bundle_header *header,
|
|
|
|
int argc, const char **argv);
|
|
|
|
|
|
|
|
#endif
|