Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builtin/pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -5328,7 +5328,7 @@ int cmd_pack_objects(int argc,
if (!HAVE_THREADS && delta_search_threads != 1)
warning(_("no threads support, ignoring --threads"));
if (!pack_to_stdout && !pack_size_limit)
pack_size_limit = pack_size_limit_cfg;
pack_size_limit = cfg->pack_size_limit_cfg;
if (pack_to_stdout && pack_size_limit)
die(_("--max-pack-size cannot be used to build a pack for transfer"));
if (pack_size_limit && pack_size_limit < 1024*1024) {
Expand Down
35 changes: 28 additions & 7 deletions environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ static int zlib_compression_seen;

int trust_executable_bit = 1;
int has_symlinks = 1;
int minimum_abbrev = 4, default_abbrev = -1;
int assume_unchanged;
char *git_commit_encoding;
char *git_log_output_encoding;
Expand All @@ -67,7 +66,6 @@ enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
#endif
enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
int grafts_keep_true_parents;
unsigned long pack_size_limit_cfg;

#ifndef PROTECT_HFS_DEFAULT
#define PROTECT_HFS_DEFAULT 0
Expand Down Expand Up @@ -148,6 +146,26 @@ int repo_ignore_case(struct repository *repo)
0;
}

int repo_minimum_abbrev(struct repository *repo)
{
if (repo != the_repository)
repo = the_repository;

return repo->initialized
? repo_config_values(repo)->minimum_abbrev
: 4;
}

int repo_default_abbrev(struct repository *repo)
{
if (repo != the_repository)
repo = the_repository;

return repo->initialized
? repo_config_values(repo)->default_abbrev
: -1;
}

int have_git_dir(void)
{
return startup_info->have_repository
Expand Down Expand Up @@ -364,14 +382,14 @@ int git_default_core_config(const char *var, const char *value,
if (!value)
return config_error_nonbool(var);
if (!strcasecmp(value, "auto"))
default_abbrev = -1;
cfg->default_abbrev = -1;
else if (!git_parse_maybe_bool_text(value))
default_abbrev = GIT_MAX_HEXSZ;
cfg->default_abbrev = GIT_MAX_HEXSZ;
else {
int abbrev = git_config_int(var, value, ctx->kvi);
if (abbrev < minimum_abbrev)
if (abbrev < cfg->minimum_abbrev)
return error(_("abbrev length out of range: %d"), abbrev);
default_abbrev = abbrev;
cfg->default_abbrev = abbrev;
}
return 0;
}
Expand Down Expand Up @@ -704,7 +722,7 @@ int git_default_config(const char *var, const char *value,
}

if (!strcmp(var, "pack.packsizelimit")) {
pack_size_limit_cfg = git_config_ulong(var, value, ctx->kvi);
cfg->pack_size_limit_cfg = git_config_ulong(var, value, ctx->kvi);
return 0;
}

Expand Down Expand Up @@ -738,6 +756,9 @@ void repo_config_values_init(struct repo_config_values *cfg)
cfg->check_stat = 1;
cfg->zlib_compression_level = Z_BEST_SPEED;
cfg->pack_compression_level = Z_DEFAULT_COMPRESSION;
cfg->minimum_abbrev = 4;
cfg->default_abbrev = -1;
cfg->pack_size_limit_cfg = 0;
cfg->precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
cfg->core_sparse_checkout_cone = 0;
cfg->sparse_expect_files_outside_of_patterns = 0;
Expand Down
8 changes: 6 additions & 2 deletions environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ struct repo_config_values {
int check_stat;
int zlib_compression_level;
int pack_compression_level;
int minimum_abbrev;
int default_abbrev;
unsigned long pack_size_limit_cfg;
int precomposed_unicode;
int core_sparse_checkout_cone;
int warn_on_object_refname_ambiguity;
Expand Down Expand Up @@ -151,6 +154,9 @@ int repo_protect_ntfs(struct repository *repo);
*/
int repo_ignore_case(struct repository *repo);

int repo_minimum_abbrev(struct repository *repo);
int repo_default_abbrev(struct repository *repo);

void repo_config_values_init(struct repo_config_values *cfg);

int is_bare_repository(struct repository *repo);
Expand Down Expand Up @@ -180,11 +186,9 @@ int have_git_dir(void);
/* Environment bits from configuration mechanism */
extern int trust_executable_bit;
extern int has_symlinks;
extern int minimum_abbrev, default_abbrev;
extern int assume_unchanged;
extern char *apply_default_whitespace;
extern char *apply_default_ignorewhitespace;
extern unsigned long pack_size_limit_cfg;

enum rebase_setup_type {
AUTOREBASE_NEVER = 0,
Expand Down
7 changes: 4 additions & 3 deletions merge-ort.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ static void format_commit(struct strbuf *sb,
{
struct merge_remote_desc *desc;
struct pretty_print_context ctx = {0};
ctx.abbrev = DEFAULT_ABBREV;
ctx.abbrev = repo_default_abbrev(repo);

strbuf_addchars(sb, ' ', indent);
desc = merge_remote_util(commit);
Expand Down Expand Up @@ -2035,7 +2035,8 @@ static int merge_submodule(struct merge_options *opt,
util->flag = sub_flag;
util->abbrev = NULL;
if (!sub_not_initialized) {
abbrev = repo_find_unique_abbrev(&subrepo, b, DEFAULT_ABBREV);
abbrev = repo_find_unique_abbrev(&subrepo, b,
repo_default_abbrev(opt->repo));
util->abbrev = xstrdup(abbrev);
}
string_list_append(csub, path)->util = util;
Expand Down Expand Up @@ -5348,7 +5349,7 @@ static void merge_ort_internal(struct merge_options *opt,
} else {
strbuf_add_unique_abbrev(&merge_base_abbrev,
&merged_merge_bases->object.oid,
DEFAULT_ABBREV);
repo_default_abbrev(opt->repo));
ancestor_name = merge_base_abbrev.buf;
}

Expand Down
5 changes: 3 additions & 2 deletions object-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,7 @@ static int odb_transaction_files_write_object_stream(struct odb_transaction *bas
size_t size,
struct object_id *result_oid)
{
struct repo_config_values *cfg = repo_config_values(the_repository);
struct odb_transaction_files *transaction = container_of(base,
struct odb_transaction_files,
base);
Expand All @@ -1298,8 +1299,8 @@ static int odb_transaction_files_write_object_stream(struct odb_transaction *bas
* the difference between the inflated and on-disk size is limited
* to zlib compression and is sufficient for this check.
*/
if (state->nr_written && pack_size_limit_cfg &&
pack_size_limit_cfg < state->offset + size)
if (state->nr_written && cfg->pack_size_limit_cfg &&
cfg->pack_size_limit_cfg < state->offset + size)
flush_packfile_transaction(transaction);

CALLOC_ARRAY(idx, 1);
Expand Down
4 changes: 2 additions & 2 deletions object-name.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ struct object *repo_peel_to_type(struct repository *r,
struct object *o, enum object_type);

/* Convert to/from hex/sha1 representation */
#define MINIMUM_ABBREV minimum_abbrev
#define DEFAULT_ABBREV default_abbrev
#define MINIMUM_ABBREV repo_minimum_abbrev(the_repository)
#define DEFAULT_ABBREV repo_default_abbrev(the_repository)

/* used when the code does not know or care what the default abbrev is */
#define FALLBACK_DEFAULT_ABBREV 7
Expand Down
2 changes: 1 addition & 1 deletion replay.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static const char *short_commit_name(struct repository *repo,
struct commit *commit)
{
return repo_find_unique_abbrev(repo, &commit->object.oid,
DEFAULT_ABBREV);
repo_default_abbrev(repo));
}

static struct commit *peel_committish(struct repository *repo,
Expand Down
5 changes: 3 additions & 2 deletions sequencer.c
Original file line number Diff line number Diff line change
Expand Up @@ -5813,7 +5813,7 @@ static const char *label_oid(struct object_id *oid, const char *label,
label = p = state->buf.buf;

repo_find_unique_abbrev_r(the_repository, p, oid,
default_abbrev);
repo_default_abbrev(the_repository));

/*
* We may need to extend the abbreviated hash so that there is
Expand Down Expand Up @@ -5875,7 +5875,8 @@ static const char *label_oid(struct object_id *oid, const char *label,
strbuf_addch(buf, '-');
if (!buf->len) {
strbuf_addstr(buf, "rev-");
strbuf_add_unique_abbrev(buf, oid, default_abbrev);
strbuf_add_unique_abbrev(buf, oid,
repo_default_abbrev(the_repository));
}
label = buf->buf;

Expand Down
Loading