Skip to content

Commit f846bbf

Browse files
author
Linus Torvalds
committed
git-pack-objects: make "--window=x" semantics more logical.
A zero disables delta generation (like before), but we make the window be one bigger than specified, since we use one entry for the one to be tested (it used to be that "--window=1" was meaningless, since we'd have used up the single-entry window with the entry to be tested, and had no chance of actually ever finding a delta). The default window remains at 10, but now it really means "test the 10 closest objects", not "test the 9 closest objects".
1 parent 75c42d8 commit f846bbf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pack-objects.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ struct object_entry {
2626
static struct object_entry **sorted_by_sha, **sorted_by_type;
2727
static struct object_entry *objects = NULL;
2828
static int nr_objects = 0, nr_alloc = 0;
29-
static int delta_window = 10;
3029
static const char *base_name;
3130

3231
struct myfile {
@@ -364,6 +363,7 @@ static void find_deltas(struct object_entry **list, int window)
364363
int main(int argc, char **argv)
365364
{
366365
char line[128];
366+
int window = 10;
367367
int i;
368368

369369
for (i = 1; i < argc; i++) {
@@ -372,7 +372,7 @@ int main(int argc, char **argv)
372372
if (*arg == '-') {
373373
if (!strncmp("--window=", arg, 9)) {
374374
char *end;
375-
delta_window = strtoul(arg+9, &end, 0);
375+
window = strtoul(arg+9, &end, 0);
376376
if (!arg[9] || *end)
377377
usage(pack_usage);
378378
continue;
@@ -399,8 +399,8 @@ int main(int argc, char **argv)
399399

400400
sorted_by_sha = create_sorted_list(sha1_sort);
401401
sorted_by_type = create_sorted_list(type_size_sort);
402-
if (delta_window)
403-
find_deltas(sorted_by_type, delta_window);
402+
if (window)
403+
find_deltas(sorted_by_type, window+1);
404404

405405
write_pack_file();
406406
write_index_file();

0 commit comments

Comments
 (0)