midx-write: pass down repository to write_midx_file[_only]
In a previous commit, we passed the repository field to all subcommands in the `builtin/` directory. Utilize this to pass the repository field down to the `write_midx_file[_only]` functions to remove the usage of `the_repository` global variables. With this, all usage of global variables in `midx-write.c` is removed, hence, remove the `USE_THE_REPOSITORY_VARIABLE` guard from the file. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
dfa7c68245
commit
2fed09aa9b
@@ -120,7 +120,7 @@ static void read_packs_from_stdin(struct string_list *to)
|
|||||||
|
|
||||||
static int cmd_multi_pack_index_write(int argc, const char **argv,
|
static int cmd_multi_pack_index_write(int argc, const char **argv,
|
||||||
const char *prefix,
|
const char *prefix,
|
||||||
struct repository *repo UNUSED)
|
struct repository *repo)
|
||||||
{
|
{
|
||||||
struct option *options;
|
struct option *options;
|
||||||
static struct option builtin_multi_pack_index_write_options[] = {
|
static struct option builtin_multi_pack_index_write_options[] = {
|
||||||
@@ -165,7 +165,7 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
|
|||||||
|
|
||||||
read_packs_from_stdin(&packs);
|
read_packs_from_stdin(&packs);
|
||||||
|
|
||||||
ret = write_midx_file_only(opts.object_dir, &packs,
|
ret = write_midx_file_only(repo, opts.object_dir, &packs,
|
||||||
opts.preferred_pack,
|
opts.preferred_pack,
|
||||||
opts.refs_snapshot, opts.flags);
|
opts.refs_snapshot, opts.flags);
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = write_midx_file(opts.object_dir, opts.preferred_pack,
|
ret = write_midx_file(repo, opts.object_dir, opts.preferred_pack,
|
||||||
opts.refs_snapshot, opts.flags);
|
opts.refs_snapshot, opts.flags);
|
||||||
|
|
||||||
free(opts.refs_snapshot);
|
free(opts.refs_snapshot);
|
||||||
|
|||||||
@@ -1569,7 +1569,7 @@ int cmd_repack(int argc,
|
|||||||
unsigned flags = 0;
|
unsigned flags = 0;
|
||||||
if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL, 0))
|
if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL, 0))
|
||||||
flags |= MIDX_WRITE_INCREMENTAL;
|
flags |= MIDX_WRITE_INCREMENTAL;
|
||||||
write_midx_file(repo_get_object_directory(the_repository),
|
write_midx_file(the_repository, repo_get_object_directory(the_repository),
|
||||||
NULL, NULL, flags);
|
NULL, NULL, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
22
midx-write.c
22
midx-write.c
@@ -1,5 +1,3 @@
|
|||||||
#define USE_THE_REPOSITORY_VARIABLE
|
|
||||||
|
|
||||||
#include "git-compat-util.h"
|
#include "git-compat-util.h"
|
||||||
#include "abspath.h"
|
#include "abspath.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@@ -1505,24 +1503,22 @@ cleanup:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_midx_file(const char *object_dir,
|
int write_midx_file(struct repository *r, const char *object_dir,
|
||||||
const char *preferred_pack_name,
|
const char *preferred_pack_name,
|
||||||
const char *refs_snapshot,
|
const char *refs_snapshot, unsigned flags)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
return write_midx_internal(the_repository, object_dir, NULL, NULL,
|
return write_midx_internal(r, object_dir, NULL, NULL,
|
||||||
preferred_pack_name, refs_snapshot, flags);
|
preferred_pack_name, refs_snapshot,
|
||||||
|
flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_midx_file_only(const char *object_dir,
|
int write_midx_file_only(struct repository *r, const char *object_dir,
|
||||||
struct string_list *packs_to_include,
|
struct string_list *packs_to_include,
|
||||||
const char *preferred_pack_name,
|
const char *preferred_pack_name,
|
||||||
const char *refs_snapshot,
|
const char *refs_snapshot, unsigned flags)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
return write_midx_internal(the_repository, object_dir, packs_to_include,
|
return write_midx_internal(r, object_dir, packs_to_include, NULL,
|
||||||
NULL, preferred_pack_name, refs_snapshot,
|
preferred_pack_name, refs_snapshot, flags);
|
||||||
flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int expire_midx_packs(struct repository *r, const char *object_dir, unsigned flags)
|
int expire_midx_packs(struct repository *r, const char *object_dir, unsigned flags)
|
||||||
|
|||||||
10
midx.h
10
midx.h
@@ -123,15 +123,13 @@ int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, i
|
|||||||
* Variant of write_midx_file which writes a MIDX containing only the packs
|
* Variant of write_midx_file which writes a MIDX containing only the packs
|
||||||
* specified in packs_to_include.
|
* specified in packs_to_include.
|
||||||
*/
|
*/
|
||||||
int write_midx_file(const char *object_dir,
|
int write_midx_file(struct repository *r, const char *object_dir,
|
||||||
const char *preferred_pack_name,
|
const char *preferred_pack_name, const char *refs_snapshot,
|
||||||
const char *refs_snapshot,
|
|
||||||
unsigned flags);
|
unsigned flags);
|
||||||
int write_midx_file_only(const char *object_dir,
|
int write_midx_file_only(struct repository *r, const char *object_dir,
|
||||||
struct string_list *packs_to_include,
|
struct string_list *packs_to_include,
|
||||||
const char *preferred_pack_name,
|
const char *preferred_pack_name,
|
||||||
const char *refs_snapshot,
|
const char *refs_snapshot, unsigned flags);
|
||||||
unsigned flags);
|
|
||||||
void clear_midx_file(struct repository *r);
|
void clear_midx_file(struct repository *r);
|
||||||
int verify_midx_file(struct repository *r, const char *object_dir, unsigned flags);
|
int verify_midx_file(struct repository *r, const char *object_dir, unsigned flags);
|
||||||
int expire_midx_packs(struct repository *r, const char *object_dir, unsigned flags);
|
int expire_midx_packs(struct repository *r, const char *object_dir, unsigned flags);
|
||||||
|
|||||||
Reference in New Issue
Block a user