Skip to content

Commit 7c075d3

Browse files
committed
Revert "Merge branch 'ua/some-builtins-wo-the-repository' into next"
This reverts commit b0520af, reversing changes made to 50707f2.
1 parent e13861b commit 7c075d3

16 files changed

+61
-110
lines changed

builtin/checkout-index.c

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
*/
77

8+
#define USE_THE_REPOSITORY_VARIABLE
89
#define DISABLE_SIGN_COMPARE_WARNINGS
910

1011
#include "builtin.h"
@@ -67,10 +68,10 @@ static void write_tempfile_record(const char *name, const char *prefix)
6768
}
6869
}
6970

70-
static int checkout_file(struct repository *repo, const char *name, const char *prefix)
71+
static int checkout_file(const char *name, const char *prefix)
7172
{
7273
int namelen = strlen(name);
73-
int pos = index_name_pos(repo->index, name, namelen);
74+
int pos = index_name_pos(the_repository->index, name, namelen);
7475
int has_same_name = 0;
7576
int is_file = 0;
7677
int is_skipped = 1;
@@ -80,8 +81,8 @@ static int checkout_file(struct repository *repo, const char *name, const char *
8081
if (pos < 0)
8182
pos = -pos - 1;
8283

83-
while (pos < repo->index->cache_nr) {
84-
struct cache_entry *ce =repo->index->cache[pos];
84+
while (pos <the_repository->index->cache_nr) {
85+
struct cache_entry *ce =the_repository->index->cache[pos];
8586
if (ce_namelen(ce) != namelen ||
8687
memcmp(ce->name, name, namelen))
8788
break;
@@ -136,13 +137,13 @@ static int checkout_file(struct repository *repo, const char *name, const char *
136137
return -1;
137138
}
138139

139-
static int checkout_all(struct repository *repo, const char *prefix, int prefix_length)
140+
static int checkout_all(const char *prefix, int prefix_length)
140141
{
141142
int i, errs = 0;
142143
struct cache_entry *last_ce = NULL;
143144

144-
for (i = 0; i < repo->index->cache_nr ; i++) {
145-
struct cache_entry *ce = repo->index->cache[i];
145+
for (i = 0; i < the_repository->index->cache_nr ; i++) {
146+
struct cache_entry *ce = the_repository->index->cache[i];
146147

147148
if (S_ISSPARSEDIR(ce->ce_mode)) {
148149
if (!ce_skip_worktree(ce))
@@ -155,8 +156,8 @@ static int checkout_all(struct repository *repo, const char *prefix, int prefix_
155156
* first entry inside the expanded sparse directory).
156157
*/
157158
if (ignore_skip_worktree) {
158-
ensure_full_index(repo->index);
159-
ce = repo->index->cache[i];
159+
ensure_full_index(the_repository->index);
160+
ce = the_repository->index->cache[i];
160161
}
161162
}
162163

@@ -212,7 +213,7 @@ static int option_parse_stage(const struct option *opt,
212213
int cmd_checkout_index(int argc,
213214
const char **argv,
214215
const char *prefix,
215-
struct repository *repo)
216+
struct repository *repo UNUSED)
216217
{
217218
int i;
218219
struct lock_file lock_file = LOCK_INIT;
@@ -252,19 +253,19 @@ int cmd_checkout_index(int argc,
252253
show_usage_with_options_if_asked(argc, argv,
253254
builtin_checkout_index_usage,
254255
builtin_checkout_index_options);
255-
repo_config(repo, git_default_config, NULL);
256+
git_config(git_default_config, NULL);
256257
prefix_length = prefix ? strlen(prefix) : 0;
257258

258-
prepare_repo_settings(repo);
259-
repo->settings.command_requires_full_index = 0;
259+
prepare_repo_settings(the_repository);
260+
the_repository->settings.command_requires_full_index = 0;
260261

261-
if (repo_read_index(repo) < 0) {
262+
if (repo_read_index(the_repository) < 0) {
262263
die("invalid cache");
263264
}
264265

265266
argc = parse_options(argc, argv, prefix, builtin_checkout_index_options,
266267
builtin_checkout_index_usage, 0);
267-
state.istate = repo->index;
268+
state.istate = the_repository->index;
268269
state.force = force;
269270
state.quiet = quiet;
270271
state.not_new = not_new;
@@ -284,8 +285,8 @@ int cmd_checkout_index(int argc,
284285
*/
285286
if (index_opt && !state.base_dir_len && !to_tempfile) {
286287
state.refresh_cache = 1;
287-
state.istate = repo->index;
288-
repo_hold_locked_index(repo, &lock_file,
288+
state.istate = the_repository->index;
289+
repo_hold_locked_index(the_repository, &lock_file,
289290
LOCK_DIE_ON_ERROR);
290291
}
291292

@@ -303,7 +304,7 @@ int cmd_checkout_index(int argc,
303304
if (read_from_stdin)
304305
die("git checkout-index: don't mix '--stdin' and explicit filenames");
305306
p = prefix_path(prefix, prefix_length, arg);
306-
err |= checkout_file(repo, p, prefix);
307+
err |= checkout_file(p, prefix);
307308
free(p);
308309
}
309310

@@ -325,15 +326,15 @@ int cmd_checkout_index(int argc,
325326
strbuf_swap(&buf, &unquoted);
326327
}
327328
p = prefix_path(prefix, prefix_length, buf.buf);
328-
err |= checkout_file(repo, p, prefix);
329+
err |= checkout_file(p, prefix);
329330
free(p);
330331
}
331332
strbuf_release(&unquoted);
332333
strbuf_release(&buf);
333334
}
334335

335336
if (all)
336-
err |= checkout_all(repo, prefix, prefix_length);
337+
err |= checkout_all(prefix, prefix_length);
337338

338339
if (pc_workers > 1)
339340
err |= run_parallel_checkout(&state, pc_workers, pc_threshold,
@@ -343,7 +344,7 @@ int cmd_checkout_index(int argc,
343344
return 1;
344345

345346
if (is_lock_file_locked(&lock_file) &&
346-
write_locked_index(repo->index, &lock_file, COMMIT_LOCK))
347+
write_locked_index(the_repository->index, &lock_file, COMMIT_LOCK))
347348
die("Unable to write new index file");
348349
return 0;
349350
}

builtin/for-each-ref.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define USE_THE_REPOSITORY_VARIABLE
12
#include "builtin.h"
23
#include "commit.h"
34
#include "config.h"
@@ -19,7 +20,7 @@ static char const * const for_each_ref_usage[] = {
1920
int cmd_for_each_ref(int argc,
2021
const char **argv,
2122
const char *prefix,
22-
struct repository *repo)
23+
struct repository *repo UNUSED)
2324
{
2425
struct ref_sorting *sorting;
2526
struct string_list sorting_options = STRING_LIST_INIT_DUP;
@@ -62,7 +63,7 @@ int cmd_for_each_ref(int argc,
6263

6364
format.format = "%(objectname) %(objecttype)\t%(refname)";
6465

65-
repo_config(repo, git_default_config, NULL);
66+
git_config(git_default_config, NULL);
6667

6768
/* Set default (refname) sorting */
6869
string_list_append(&sorting_options, "refname");

builtin/ls-files.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Copyright (C) Linus Torvalds, 2005
77
*/
88

9+
#define USE_THE_REPOSITORY_VARIABLE
910
#define DISABLE_SIGN_COMPARE_WARNINGS
1011

1112
#include "builtin.h"
@@ -244,13 +245,12 @@ static void show_submodule(struct repository *superproject,
244245
repo_clear(&subrepo);
245246
}
246247

247-
static void expand_objectsize(struct repository *repo, struct strbuf *line,
248-
const struct object_id *oid,
248+
static void expand_objectsize(struct strbuf *line, const struct object_id *oid,
249249
const enum object_type type, unsigned int padded)
250250
{
251251
if (type == OBJ_BLOB) {
252252
unsigned long size;
253-
if (oid_object_info(repo, oid, &size) < 0)
253+
if (oid_object_info(the_repository, oid, &size) < 0)
254254
die(_("could not get object info about '%s'"),
255255
oid_to_hex(oid));
256256
if (padded)
@@ -283,10 +283,10 @@ static void show_ce_fmt(struct repository *repo, const struct cache_entry *ce,
283283
else if (skip_prefix(format, "(objecttype)", &format))
284284
strbuf_addstr(&sb, type_name(object_type(ce->ce_mode)));
285285
else if (skip_prefix(format, "(objectsize:padded)", &format))
286-
expand_objectsize(repo, &sb, &ce->oid,
286+
expand_objectsize(&sb, &ce->oid,
287287
object_type(ce->ce_mode), 1);
288288
else if (skip_prefix(format, "(objectsize)", &format))
289-
expand_objectsize(repo, &sb, &ce->oid,
289+
expand_objectsize(&sb, &ce->oid,
290290
object_type(ce->ce_mode), 0);
291291
else if (skip_prefix(format, "(stage)", &format))
292292
strbuf_addf(&sb, "%d", ce_stage(ce));
@@ -348,7 +348,7 @@ static void show_ce(struct repository *repo, struct dir_struct *dir,
348348
}
349349
}
350350

351-
static void show_ru_info(struct repository *repo, struct index_state *istate)
351+
static void show_ru_info(struct index_state *istate)
352352
{
353353
struct string_list_item *item;
354354

@@ -370,7 +370,7 @@ static void show_ru_info(struct repository *repo, struct index_state *istate)
370370
if (!ui->mode[i])
371371
continue;
372372
printf("%s%06o %s %d\t", tag_resolve_undo, ui->mode[i],
373-
repo_find_unique_abbrev(repo, &ui->oid[i], abbrev),
373+
repo_find_unique_abbrev(the_repository, &ui->oid[i], abbrev),
374374
i + 1);
375375
write_name(path);
376376
}
@@ -567,7 +567,7 @@ static int option_parse_exclude_standard(const struct option *opt,
567567
int cmd_ls_files(int argc,
568568
const char **argv,
569569
const char *cmd_prefix,
570-
struct repository *repo)
570+
struct repository *repo UNUSED)
571571
{
572572
int require_work_tree = 0, show_tag = 0, i;
573573
char *max_prefix;
@@ -647,15 +647,15 @@ int cmd_ls_files(int argc,
647647
show_usage_with_options_if_asked(argc, argv,
648648
ls_files_usage, builtin_ls_files_options);
649649

650-
prepare_repo_settings(repo);
651-
repo->settings.command_requires_full_index = 0;
650+
prepare_repo_settings(the_repository);
651+
the_repository->settings.command_requires_full_index = 0;
652652

653653
prefix = cmd_prefix;
654654
if (prefix)
655655
prefix_len = strlen(prefix);
656-
repo_config(repo, git_default_config, NULL);
656+
git_config(git_default_config, NULL);
657657

658-
if (repo_read_index(repo) < 0)
658+
if (repo_read_index(the_repository) < 0)
659659
die("index file corrupt");
660660

661661
argc = parse_options(argc, argv, prefix, builtin_ls_files_options,
@@ -724,7 +724,7 @@ int cmd_ls_files(int argc,
724724
max_prefix = common_prefix(&pathspec);
725725
max_prefix_len = get_common_prefix_len(max_prefix);
726726

727-
prune_index(repo->index, max_prefix, max_prefix_len);
727+
prune_index(the_repository->index, max_prefix, max_prefix_len);
728728

729729
/* Treat unmatching pathspec elements as errors */
730730
if (pathspec.nr && error_unmatch)
@@ -748,13 +748,13 @@ int cmd_ls_files(int argc,
748748
*/
749749
if (show_stage || show_unmerged)
750750
die(_("options '%s' and '%s' cannot be used together"), "ls-files --with-tree", "-s/-u");
751-
overlay_tree_on_index(repo->index, with_tree, max_prefix);
751+
overlay_tree_on_index(the_repository->index, with_tree, max_prefix);
752752
}
753753

754-
show_files(repo, &dir);
754+
show_files(the_repository, &dir);
755755

756756
if (show_resolve_undo)
757-
show_ru_info(repo, repo->index);
757+
show_ru_info(the_repository->index);
758758

759759
if (ps_matched && report_path_error(ps_matched, &pathspec)) {
760760
fprintf(stderr, "Did you forget to 'git add'?\n");

builtin/pack-refs.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#define USE_THE_REPOSITORY_VARIABLE
2+
13
#include "builtin.h"
24
#include "config.h"
35
#include "gettext.h"
@@ -13,7 +15,7 @@ static char const * const pack_refs_usage[] = {
1315
int cmd_pack_refs(int argc,
1416
const char **argv,
1517
const char *prefix,
16-
struct repository *repo)
18+
struct repository *repo UNUSED)
1719
{
1820
struct ref_exclusions excludes = REF_EXCLUSIONS_INIT;
1921
struct string_list included_refs = STRING_LIST_INIT_NODUP;
@@ -37,7 +39,7 @@ int cmd_pack_refs(int argc,
3739
N_("references to exclude")),
3840
OPT_END(),
3941
};
40-
repo_config(repo, git_default_config, NULL);
42+
git_config(git_default_config, NULL);
4143
if (parse_options(argc, argv, prefix, opts, pack_refs_usage, 0))
4244
usage_with_options(pack_refs_usage, opts);
4345

@@ -50,7 +52,7 @@ int cmd_pack_refs(int argc,
5052
if (!pack_refs_opts.includes->nr)
5153
string_list_append(pack_refs_opts.includes, "refs/tags/*");
5254

53-
ret = refs_pack_refs(get_main_ref_store(repo), &pack_refs_opts);
55+
ret = refs_pack_refs(get_main_ref_store(the_repository), &pack_refs_opts);
5456

5557
clear_ref_exclusions(&excludes);
5658
string_list_clear(&included_refs, 0);

builtin/send-pack.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define USE_THE_REPOSITORY_VARIABLE
12
#include "builtin.h"
23
#include "config.h"
34
#include "hex.h"
@@ -150,7 +151,7 @@ static int send_pack_config(const char *k, const char *v,
150151
int cmd_send_pack(int argc,
151152
const char **argv,
152153
const char *prefix,
153-
struct repository *repo)
154+
struct repository *repo UNUSED)
154155
{
155156
struct refspec rs = REFSPEC_INIT_PUSH;
156157
const char *remote_name = NULL;
@@ -211,7 +212,7 @@ int cmd_send_pack(int argc,
211212
OPT_END()
212213
};
213214

214-
repo_config(repo, send_pack_config, NULL);
215+
git_config(send_pack_config, NULL);
215216
argc = parse_options(argc, argv, prefix, options, send_pack_usage, 0);
216217
if (argc > 0) {
217218
dest = argv[0];
@@ -316,7 +317,7 @@ int cmd_send_pack(int argc,
316317
set_ref_status_for_push(remote_refs, args.send_mirror,
317318
args.force_update);
318319

319-
ret = send_pack(repo, &args, fd, conn, remote_refs, &extra_have);
320+
ret = send_pack(the_repository, &args, fd, conn, remote_refs, &extra_have);
320321

321322
if (helper_status)
322323
print_helper_status(remote_refs);

builtin/verify-commit.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
* Based on git-verify-tag
77
*/
8+
#define USE_THE_REPOSITORY_VARIABLE
89
#include "builtin.h"
910
#include "config.h"
1011
#include "gettext.h"
@@ -32,15 +33,15 @@ static int run_gpg_verify(struct commit *commit, unsigned flags)
3233
return ret;
3334
}
3435

35-
static int verify_commit(struct repository *repo, const char *name, unsigned flags)
36+
static int verify_commit(const char *name, unsigned flags)
3637
{
3738
struct object_id oid;
3839
struct object *obj;
3940

40-
if (repo_get_oid(repo, name, &oid))
41+
if (repo_get_oid(the_repository, name, &oid))
4142
return error("commit '%s' not found.", name);
4243

43-
obj = parse_object(repo, &oid);
44+
obj = parse_object(the_repository, &oid);
4445
if (!obj)
4546
return error("%s: unable to read file.", name);
4647
if (obj->type != OBJ_COMMIT)
@@ -53,7 +54,7 @@ static int verify_commit(struct repository *repo, const char *name, unsigned fla
5354
int cmd_verify_commit(int argc,
5455
const char **argv,
5556
const char *prefix,
56-
struct repository *repo)
57+
struct repository *repo UNUSED)
5758
{
5859
int i = 1, verbose = 0, had_error = 0;
5960
unsigned flags = 0;
@@ -63,7 +64,7 @@ int cmd_verify_commit(int argc,
6364
OPT_END()
6465
};
6566

66-
repo_config(repo, git_default_config, NULL);
67+
git_config(git_default_config, NULL);
6768

6869
argc = parse_options(argc, argv, prefix, verify_commit_options,
6970
verify_commit_usage, PARSE_OPT_KEEP_ARGV0);
@@ -77,7 +78,7 @@ int cmd_verify_commit(int argc,
7778
* was received in the process of writing the gpg input: */
7879
signal(SIGPIPE, SIG_IGN);
7980
while (i < argc)
80-
if (verify_commit(repo, argv[i++], flags))
81+
if (verify_commit(argv[i++], flags))
8182
had_error = 1;
8283
return had_error;
8384
}

0 commit comments

Comments
 (0)