object-store: migrate alternates struct and functions from cache.h

Migrate the struct alternate_object_database and all its related
functions to the object store as these functions are easier found in
that header. The migration is just a verbatim copy, no need to
include the object store header at any C file, because cache.h includes
repository.h which in turn includes the object-store.h

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pull/477/merge
Stefan Beller 5 years ago committed by Junio C Hamano
parent 90c62155d6
commit 0d4a132144
  1. 1
      builtin/clone.c
  2. 1
      builtin/count-objects.c
  3. 1
      builtin/fsck.c
  4. 1
      builtin/submodule--helper.c
  5. 51
      cache.h
  6. 51
      object-store.h
  7. 1
      packfile.c
  8. 1
      sha1_name.c
  9. 1
      submodule.c
  10. 1
      t/helper/test-ref-store.c
  11. 1
      tmp-objdir.c
  12. 1
      transport.c

@ -27,6 +27,7 @@
#include "connected.h"
#include "packfile.h"
#include "list-objects-filter-options.h"
#include "object-store.h"
/*
* Overall FIXMEs:

@ -11,6 +11,7 @@
#include "parse-options.h"
#include "quote.h"
#include "packfile.h"
#include "object-store.h"
static unsigned long garbage;
static off_t size_garbage;

@ -16,6 +16,7 @@
#include "streaming.h"
#include "decorate.h"
#include "packfile.h"
#include "object-store.h"
#define REACHABLE 0x0001
#define SEEN 0x0002

@ -16,6 +16,7 @@
#include "revision.h"
#include "diffcore.h"
#include "diff.h"
#include "object-store.h"
#define OPT_QUIET (1 << 0)
#define OPT_CACHED (1 << 1)

@ -1576,57 +1576,6 @@ extern int has_dirs_only_path(const char *name, int len, int prefix_len);
extern void schedule_dir_for_removal(const char *name, int len);
extern void remove_scheduled_dirs(void);
extern struct alternate_object_database {
struct alternate_object_database *next;
/* see alt_scratch_buf() */
struct strbuf scratch;
size_t base_len;
/*
* Used to store the results of readdir(3) calls when searching
* for unique abbreviated hashes. This cache is never
* invalidated, thus it's racy and not necessarily accurate.
* That's fine for its purpose; don't use it for tasks requiring
* greater accuracy!
*/
char loose_objects_subdir_seen[256];
struct oid_array loose_objects_cache;
char path[FLEX_ARRAY];
} *alt_odb_list;
extern void prepare_alt_odb(void);
extern char *compute_alternate_path(const char *path, struct strbuf *err);
typedef int alt_odb_fn(struct alternate_object_database *, void *);
extern int foreach_alt_odb(alt_odb_fn, void*);
/*
* Allocate a "struct alternate_object_database" but do _not_ actually
* add it to the list of alternates.
*/
struct alternate_object_database *alloc_alt_odb(const char *dir);
/*
* Add the directory to the on-disk alternates file; the new entry will also
* take effect in the current process.
*/
extern void add_to_alternates_file(const char *dir);
/*
* Add the directory to the in-memory list of alternates (along with any
* recursive alternates it points to), but do not modify the on-disk alternates
* file.
*/
extern void add_to_alternates_memory(const char *dir);
/*
* Returns a scratch strbuf pre-filled with the alternate object directory,
* including a trailing slash, which can be used to access paths in the
* alternate. Always use this over direct access to alt->scratch, as it
* cleans up any previous use of the scratch buffer.
*/
extern struct strbuf *alt_scratch_buf(struct alternate_object_database *alt);
struct pack_window {
struct pack_window *next;
unsigned char *base;

@ -1,6 +1,57 @@
#ifndef OBJECT_STORE_H
#define OBJECT_STORE_H
extern struct alternate_object_database {
struct alternate_object_database *next;
/* see alt_scratch_buf() */
struct strbuf scratch;
size_t base_len;
/*
* Used to store the results of readdir(3) calls when searching
* for unique abbreviated hashes. This cache is never
* invalidated, thus it's racy and not necessarily accurate.
* That's fine for its purpose; don't use it for tasks requiring
* greater accuracy!
*/
char loose_objects_subdir_seen[256];
struct oid_array loose_objects_cache;
char path[FLEX_ARRAY];
} *alt_odb_list;
void prepare_alt_odb(void);
char *compute_alternate_path(const char *path, struct strbuf *err);
typedef int alt_odb_fn(struct alternate_object_database *, void *);
int foreach_alt_odb(alt_odb_fn, void*);
/*
* Allocate a "struct alternate_object_database" but do _not_ actually
* add it to the list of alternates.
*/
struct alternate_object_database *alloc_alt_odb(const char *dir);
/*
* Add the directory to the on-disk alternates file; the new entry will also
* take effect in the current process.
*/
void add_to_alternates_file(const char *dir);
/*
* Add the directory to the in-memory list of alternates (along with any
* recursive alternates it points to), but do not modify the on-disk alternates
* file.
*/
void add_to_alternates_memory(const char *dir);
/*
* Returns a scratch strbuf pre-filled with the alternate object directory,
* including a trailing slash, which can be used to access paths in the
* alternate. Always use this over direct access to alt->scratch, as it
* cleans up any previous use of the scratch buffer.
*/
struct strbuf *alt_scratch_buf(struct alternate_object_database *alt);
struct raw_object_store {
/*
* Path to the repository's object store.

@ -13,6 +13,7 @@
#include "tag.h"
#include "tree-walk.h"
#include "tree.h"
#include "object-store.h"
char *odb_pack_name(struct strbuf *buf,
const unsigned char *sha1,

@ -10,6 +10,7 @@
#include "dir.h"
#include "sha1-array.h"
#include "packfile.h"
#include "object-store.h"
static int get_oid_oneline(const char *, struct object_id *, struct commit_list *);

@ -21,6 +21,7 @@
#include "remote.h"
#include "worktree.h"
#include "parse-options.h"
#include "object-store.h"
static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;
static struct string_list changed_submodule_names = STRING_LIST_INIT_DUP;

@ -1,6 +1,7 @@
#include "cache.h"
#include "refs.h"
#include "worktree.h"
#include "object-store.h"
static const char *notnull(const char *arg, const char *name)
{

@ -6,6 +6,7 @@
#include "strbuf.h"
#include "argv-array.h"
#include "quote.h"
#include "object-store.h"
struct tmp_objdir {
struct strbuf path;

@ -18,6 +18,7 @@
#include "sha1-array.h"
#include "sigchain.h"
#include "transport-internal.h"
#include "object-store.h"
static void set_upstreams(struct transport *transport, struct ref *refs,
int pretend)

Loading…
Cancel
Save