Skip to content

Commit 2fed09a

Browse files
KarthikNayakgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dfa7c68 commit 2fed09a

File tree

4 files changed

+17
-23
lines changed

4 files changed

+17
-23
lines changed

builtin/multi-pack-index.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static void read_packs_from_stdin(struct string_list *to)
120120

121121
static int cmd_multi_pack_index_write(int argc, const char **argv,
122122
const char *prefix,
123-
struct repository *repo UNUSED)
123+
struct repository *repo)
124124
{
125125
struct option *options;
126126
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,
165165

166166
read_packs_from_stdin(&packs);
167167

168-
ret = write_midx_file_only(opts.object_dir, &packs,
168+
ret = write_midx_file_only(repo, opts.object_dir, &packs,
169169
opts.preferred_pack,
170170
opts.refs_snapshot, opts.flags);
171171

@@ -176,7 +176,7 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
176176

177177
}
178178

179-
ret = write_midx_file(opts.object_dir, opts.preferred_pack,
179+
ret = write_midx_file(repo, opts.object_dir, opts.preferred_pack,
180180
opts.refs_snapshot, opts.flags);
181181

182182
free(opts.refs_snapshot);

builtin/repack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,7 @@ int cmd_repack(int argc,
15691569
unsigned flags = 0;
15701570
if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL, 0))
15711571
flags |= MIDX_WRITE_INCREMENTAL;
1572-
write_midx_file(repo_get_object_directory(the_repository),
1572+
write_midx_file(the_repository, repo_get_object_directory(the_repository),
15731573
NULL, NULL, flags);
15741574
}
15751575

midx-write.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#define USE_THE_REPOSITORY_VARIABLE
2-
31
#include "git-compat-util.h"
42
#include "abspath.h"
53
#include "config.h"
@@ -1505,24 +1503,22 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
15051503
return result;
15061504
}
15071505

1508-
int write_midx_file(const char *object_dir,
1506+
int write_midx_file(struct repository *r, const char *object_dir,
15091507
const char *preferred_pack_name,
1510-
const char *refs_snapshot,
1511-
unsigned flags)
1508+
const char *refs_snapshot, unsigned flags)
15121509
{
1513-
return write_midx_internal(the_repository, object_dir, NULL, NULL,
1514-
preferred_pack_name, refs_snapshot, flags);
1510+
return write_midx_internal(r, object_dir, NULL, NULL,
1511+
preferred_pack_name, refs_snapshot,
1512+
flags);
15151513
}
15161514

1517-
int write_midx_file_only(const char *object_dir,
1515+
int write_midx_file_only(struct repository *r, const char *object_dir,
15181516
struct string_list *packs_to_include,
15191517
const char *preferred_pack_name,
1520-
const char *refs_snapshot,
1521-
unsigned flags)
1518+
const char *refs_snapshot, unsigned flags)
15221519
{
1523-
return write_midx_internal(the_repository, object_dir, packs_to_include,
1524-
NULL, preferred_pack_name, refs_snapshot,
1525-
flags);
1520+
return write_midx_internal(r, object_dir, packs_to_include, NULL,
1521+
preferred_pack_name, refs_snapshot, flags);
15261522
}
15271523

15281524
int expire_midx_packs(struct repository *r, const char *object_dir, unsigned flags)

midx.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,13 @@ int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, i
123123
* Variant of write_midx_file which writes a MIDX containing only the packs
124124
* specified in packs_to_include.
125125
*/
126-
int write_midx_file(const char *object_dir,
127-
const char *preferred_pack_name,
128-
const char *refs_snapshot,
126+
int write_midx_file(struct repository *r, const char *object_dir,
127+
const char *preferred_pack_name, const char *refs_snapshot,
129128
unsigned flags);
130-
int write_midx_file_only(const char *object_dir,
129+
int write_midx_file_only(struct repository *r, const char *object_dir,
131130
struct string_list *packs_to_include,
132131
const char *preferred_pack_name,
133-
const char *refs_snapshot,
134-
unsigned flags);
132+
const char *refs_snapshot, unsigned flags);
135133
void clear_midx_file(struct repository *r);
136134
int verify_midx_file(struct repository *r, const char *object_dir, unsigned flags);
137135
int expire_midx_packs(struct repository *r, const char *object_dir, unsigned flags);

0 commit comments

Comments
 (0)