Skip to content

Commit 1536628

Browse files
committed
Teach core.bigfilethreashold to pack-objects
The pack-objects command should take notice of the object file and refrain from attempting to delta large ones, to be consistent with the fast-import command. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7ed863a commit 1536628

File tree

6 files changed

+14
-9
lines changed

6 files changed

+14
-9
lines changed

Documentation/config.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,6 @@ for most projects as source code and other text files can still
451451
be delta compressed, but larger binary media files won't be.
452452
+
453453
Common unit suffixes of 'k', 'm', or 'g' are supported.
454-
+
455-
Currently only linkgit:git-fast-import[1] honors this setting.
456454

457455
core.excludesfile::
458456
In addition to '.gitignore' (per-directory) and

builtin/pack-objects.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,8 +1142,12 @@ static void get_object_details(void)
11421142
sorted_by_offset[i] = objects + i;
11431143
qsort(sorted_by_offset, nr_objects, sizeof(*sorted_by_offset), pack_offset_sort);
11441144

1145-
for (i = 0; i < nr_objects; i++)
1146-
check_object(sorted_by_offset[i]);
1145+
for (i = 0; i < nr_objects; i++) {
1146+
struct object_entry *entry = sorted_by_offset[i];
1147+
check_object(entry);
1148+
if (big_file_threshold <= entry->size)
1149+
entry->no_try_delta = 1;
1150+
}
11471151

11481152
free(sorted_by_offset);
11491153
}

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ extern int core_compression_seen;
555555
extern size_t packed_git_window_size;
556556
extern size_t packed_git_limit;
557557
extern size_t delta_base_cache_limit;
558+
extern unsigned long big_file_threshold;
558559
extern int read_replace_refs;
559560
extern int fsync_object_files;
560561
extern int core_preload_index;

config.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,12 @@ static int git_default_core_config(const char *var, const char *value)
567567
return 0;
568568
}
569569

570+
if (!strcmp(var, "core.bigfilethreshold")) {
571+
long n = git_config_int(var, value);
572+
big_file_threshold = 0 < n ? n : 0;
573+
return 0;
574+
}
575+
570576
if (!strcmp(var, "core.packedgitlimit")) {
571577
packed_git_limit = git_config_int(var, value);
572578
return 0;

environment.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ int fsync_object_files;
3535
size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
3636
size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
3737
size_t delta_base_cache_limit = 16 * 1024 * 1024;
38+
unsigned long big_file_threshold = 512 * 1024 * 1024;
3839
const char *pager_program;
3940
int pager_use_color = 1;
4041
const char *editor_program;

fast-import.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ struct recent_command
284284
/* Configured limits on output */
285285
static unsigned long max_depth = 10;
286286
static off_t max_packsize;
287-
static uintmax_t big_file_threshold = 512 * 1024 * 1024;
288287
static int force_update;
289288
static int pack_compression_level = Z_DEFAULT_COMPRESSION;
290289
static int pack_compression_seen;
@@ -3053,10 +3052,6 @@ static int git_pack_config(const char *k, const char *v, void *cb)
30533052
max_packsize = git_config_ulong(k, v);
30543053
return 0;
30553054
}
3056-
if (!strcmp(k, "core.bigfilethreshold")) {
3057-
long n = git_config_int(k, v);
3058-
big_file_threshold = 0 < n ? n : 0;
3059-
}
30603055
return git_default_config(k, v, cb);
30613056
}
30623057

0 commit comments

Comments
 (0)