2007-09-11 03:03:15 +00:00
|
|
|
#ifndef BUNDLE_H
|
|
|
|
#define BUNDLE_H
|
|
|
|
|
2020-07-28 20:23:39 +00:00
|
|
|
#include "strvec.h"
|
2017-05-01 02:28:59 +00: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 09:57:32 +00:00
|
|
|
#include "string-list.h"
|
2007-09-11 03:03:15 +00:00
|
|
|
|
|
|
|
struct bundle_header {
|
2020-07-29 23:14:20 +00: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 09:57:32 +00:00
|
|
|
struct string_list prerequisites;
|
|
|
|
struct string_list references;
|
2020-06-19 17:56:00 +00:00
|
|
|
const struct git_hash_algo *hash_algo;
|
2007-09-11 03:03:15 +00: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 09:57:32 +00: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-13 22:19:31 +00:00
|
|
|
int is_bundle(const char *path, int quiet);
|
2007-09-11 03:03:15 +00:00
|
|
|
int read_bundle_header(const char *path, struct bundle_header *header);
|
2019-01-24 13:11:51 +00:00
|
|
|
int create_bundle(struct repository *r, const char *path,
|
2020-08-12 01:04:11 +00:00
|
|
|
int argc, const char **argv, struct strvec *pack_options,
|
2020-07-29 23:14:20 +00:00
|
|
|
int version);
|
2018-11-10 05:49:01 +00:00
|
|
|
int verify_bundle(struct repository *r, struct bundle_header *header, int verbose);
|
2011-09-18 23:52:32 +00:00
|
|
|
#define BUNDLE_VERBOSE 1
|
2021-08-26 14:05:47 +00: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().
|
|
|
|
*/
|
2018-11-10 05:49:01 +00:00
|
|
|
int unbundle(struct repository *r, struct bundle_header *header,
|
|
|
|
int bundle_fd, int flags);
|
2007-09-11 03:03:15 +00:00
|
|
|
int list_bundle_refs(struct bundle_header *header,
|
|
|
|
int argc, const char **argv);
|
|
|
|
|
|
|
|
#endif
|