mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
Merge branch 'ac/prune-wo-the-repository'
Some code paths in the "git prune" used to ignore passed in repository object and used the_repository singleton instance instead, which has been corrected. * ac/prune-wo-the-repository: builtin/prune: stop depending on 'the_repository' repository: move 'repository_format_precious_objects' to repo scope
This commit is contained in:
@@ -1005,7 +1005,7 @@ int cmd_gc(int argc,
|
||||
if (opts.detach <= 0 && !skip_foreground_tasks)
|
||||
gc_foreground_tasks(&opts, &cfg);
|
||||
|
||||
if (!repository_format_precious_objects) {
|
||||
if (!the_repository->repository_format_precious_objects) {
|
||||
struct child_process repack_cmd = CHILD_PROCESS_INIT;
|
||||
|
||||
repack_cmd.git_cmd = 1;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#define USE_THE_REPOSITORY_VARIABLE
|
||||
#define DISABLE_SIGN_COMPARE_WARNINGS
|
||||
|
||||
#include "builtin.h"
|
||||
@@ -64,7 +63,7 @@ static void perform_reachability_traversal(struct rev_info *revs)
|
||||
return;
|
||||
|
||||
if (show_progress)
|
||||
progress = start_delayed_progress(the_repository,
|
||||
progress = start_delayed_progress(revs->repo,
|
||||
_("Checking connectivity"), 0);
|
||||
mark_reachable_objects(revs, 1, expire, progress);
|
||||
stop_progress(&progress);
|
||||
@@ -78,7 +77,7 @@ static int is_object_reachable(const struct object_id *oid,
|
||||
|
||||
perform_reachability_traversal(revs);
|
||||
|
||||
obj = lookup_object(the_repository, oid);
|
||||
obj = lookup_object(revs->repo, oid);
|
||||
return obj && (obj->flags & SEEN);
|
||||
}
|
||||
|
||||
@@ -99,8 +98,7 @@ static int prune_object(const struct object_id *oid, const char *fullpath,
|
||||
if (st.st_mtime > expire)
|
||||
return 0;
|
||||
if (show_only || verbose) {
|
||||
enum object_type type = oid_object_info(the_repository, oid,
|
||||
NULL);
|
||||
enum object_type type = oid_object_info(revs->repo, oid, NULL);
|
||||
printf("%s %s\n", oid_to_hex(oid),
|
||||
(type > 0) ? type_name(type) : "unknown");
|
||||
}
|
||||
@@ -154,7 +152,7 @@ static void remove_temporary_files(const char *path)
|
||||
int cmd_prune(int argc,
|
||||
const char **argv,
|
||||
const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
struct repository *repo)
|
||||
{
|
||||
struct rev_info revs;
|
||||
int exclude_promisor_objects = 0;
|
||||
@@ -173,20 +171,19 @@ int cmd_prune(int argc,
|
||||
expire = TIME_MAX;
|
||||
save_commit_buffer = 0;
|
||||
disable_replace_refs();
|
||||
repo_init_revisions(the_repository, &revs, prefix);
|
||||
|
||||
argc = parse_options(argc, argv, prefix, options, prune_usage, 0);
|
||||
|
||||
if (repository_format_precious_objects)
|
||||
repo_init_revisions(repo, &revs, prefix);
|
||||
if (repo->repository_format_precious_objects)
|
||||
die(_("cannot prune in a precious-objects repo"));
|
||||
|
||||
while (argc--) {
|
||||
struct object_id oid;
|
||||
const char *name = *argv++;
|
||||
|
||||
if (!repo_get_oid(the_repository, name, &oid)) {
|
||||
struct object *object = parse_object_or_die(the_repository, &oid,
|
||||
name);
|
||||
if (!repo_get_oid(repo, name, &oid)) {
|
||||
struct object *object = parse_object_or_die(repo, &oid, name);
|
||||
add_pending_object(&revs, object, "");
|
||||
}
|
||||
else
|
||||
@@ -200,16 +197,16 @@ int cmd_prune(int argc,
|
||||
revs.exclude_promisor_objects = 1;
|
||||
}
|
||||
|
||||
for_each_loose_file_in_objdir(repo_get_object_directory(the_repository),
|
||||
for_each_loose_file_in_objdir(repo_get_object_directory(repo),
|
||||
prune_object, prune_cruft, prune_subdir, &revs);
|
||||
|
||||
prune_packed_objects(show_only ? PRUNE_PACKED_DRY_RUN : 0);
|
||||
remove_temporary_files(repo_get_object_directory(the_repository));
|
||||
s = mkpathdup("%s/pack", repo_get_object_directory(the_repository));
|
||||
remove_temporary_files(repo_get_object_directory(repo));
|
||||
s = mkpathdup("%s/pack", repo_get_object_directory(repo));
|
||||
remove_temporary_files(s);
|
||||
free(s);
|
||||
|
||||
if (is_repository_shallow(the_repository)) {
|
||||
if (is_repository_shallow(repo)) {
|
||||
perform_reachability_traversal(&revs);
|
||||
prune_shallow(show_only ? PRUNE_SHOW_ONLY : 0);
|
||||
}
|
||||
|
||||
@@ -1240,7 +1240,7 @@ int cmd_repack(int argc,
|
||||
po_args.depth = xstrdup_or_null(opt_depth);
|
||||
po_args.threads = xstrdup_or_null(opt_threads);
|
||||
|
||||
if (delete_redundant && repository_format_precious_objects)
|
||||
if (delete_redundant && the_repository->repository_format_precious_objects)
|
||||
die(_("cannot delete packs in a precious-objects repo"));
|
||||
|
||||
die_for_incompatible_opt3(unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE), "-A",
|
||||
|
||||
@@ -37,7 +37,6 @@ int ignore_case;
|
||||
int assume_unchanged;
|
||||
int is_bare_repository_cfg = -1; /* unspecified */
|
||||
int warn_on_object_refname_ambiguity = 1;
|
||||
int repository_format_precious_objects;
|
||||
char *git_commit_encoding;
|
||||
char *git_log_output_encoding;
|
||||
char *apply_default_whitespace;
|
||||
|
||||
@@ -189,8 +189,6 @@ extern enum object_creation_mode object_creation_mode;
|
||||
|
||||
extern int grafts_keep_true_parents;
|
||||
|
||||
extern int repository_format_precious_objects;
|
||||
|
||||
const char *get_log_output_encoding(void);
|
||||
const char *get_commit_output_encoding(void);
|
||||
|
||||
|
||||
@@ -284,6 +284,7 @@ int repo_init(struct repository *repo,
|
||||
repo_set_ref_storage_format(repo, format.ref_storage_format);
|
||||
repo->repository_format_worktree_config = format.worktree_config;
|
||||
repo->repository_format_relative_worktrees = format.relative_worktrees;
|
||||
repo->repository_format_precious_objects = format.precious_objects;
|
||||
|
||||
/* take ownership of format.partial_clone */
|
||||
repo->repository_format_partial_clone = format.partial_clone;
|
||||
|
||||
@@ -151,6 +151,7 @@ struct repository {
|
||||
/* Configurations */
|
||||
int repository_format_worktree_config;
|
||||
int repository_format_relative_worktrees;
|
||||
int repository_format_precious_objects;
|
||||
|
||||
/* Indicate if a repository has a different 'commondir' from 'gitdir' */
|
||||
unsigned different_commondir:1;
|
||||
|
||||
5
setup.c
5
setup.c
@@ -753,7 +753,8 @@ static int check_repository_format_gently(const char *gitdir, struct repository_
|
||||
die("%s", err.buf);
|
||||
}
|
||||
|
||||
repository_format_precious_objects = candidate->precious_objects;
|
||||
the_repository->repository_format_precious_objects = candidate->precious_objects;
|
||||
|
||||
string_list_clear(&candidate->unknown_extensions, 0);
|
||||
string_list_clear(&candidate->v1_only_extensions, 0);
|
||||
|
||||
@@ -1864,6 +1865,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
|
||||
the_repository->repository_format_partial_clone =
|
||||
repo_fmt.partial_clone;
|
||||
repo_fmt.partial_clone = NULL;
|
||||
the_repository->repository_format_precious_objects =
|
||||
repo_fmt.precious_objects;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -114,4 +114,11 @@ test_expect_success 'update-server-info does not crash with -h' '
|
||||
test_grep "[Uu]sage: git update-server-info " usage
|
||||
'
|
||||
|
||||
test_expect_success 'prune does not crash with -h' '
|
||||
test_expect_code 129 git prune -h >usage &&
|
||||
test_grep "[Uu]sage: git prune " usage &&
|
||||
test_expect_code 129 nongit git prune -h >usage &&
|
||||
test_grep "[Uu]sage: git prune " usage
|
||||
'
|
||||
|
||||
test_done
|
||||
|
||||
Reference in New Issue
Block a user