Skip to content

Commit c3b5847

Browse files
committed
pack-redundant: gauge the usage before proposing its removal
The subcommand is unusably slow and the reason why nobody reports it as a performance bug is suspected to be the absense of users. Let's show a big message that asks the user to tell us that they still care about the command when an attempt is made to run the command, with an escape hatch to override it with a command line option. In a few releases, we may turn it into an error and keep it for a few more releases before finally removing it (during the whole time, the plan to remove it would be interrupted by end user raising hand). Reviewed-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1c52ecf commit c3b5847

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

builtin/pack-redundant.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ static void load_all(void)
554554
int cmd_pack_redundant(int argc, const char **argv, const char *prefix)
555555
{
556556
int i;
557+
int i_still_use_this = 0;
557558
struct pack_list *min = NULL, *red, *pl;
558559
struct llist *ignore;
559560
struct object_id *oid;
@@ -580,12 +581,24 @@ int cmd_pack_redundant(int argc, const char **argv, const char *prefix)
580581
alt_odb = 1;
581582
continue;
582583
}
584+
if (!strcmp(arg, "--i-still-use-this")) {
585+
i_still_use_this = 1;
586+
continue;
587+
}
583588
if (*arg == '-')
584589
usage(pack_redundant_usage);
585590
else
586591
break;
587592
}
588593

594+
if (!i_still_use_this) {
595+
fputs(_("'git pack-redundant' is nominated for removal.\n"
596+
"If you still use this command, please add an extra\n"
597+
"option, '--i-still-use-this', on the command line\n"
598+
"and let us know you still use it by sending an e-mail\n"
599+
"to <[email protected]>. Thanks.\n"), stderr);
600+
}
601+
589602
if (load_all_packs)
590603
load_all();
591604
else

t/t5323-pack-redundant.sh

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ relationship between packs and objects is as follows:
3939
master_repo=master.git
4040
shared_repo=shared.git
4141

42+
git_pack_redundant='git pack-redundant --i-still-use-this'
43+
4244
# Create commits in <repo> and assign each commit's oid to shell variables
4345
# given in the arguments (A, B, and C). E.g.:
4446
#
@@ -154,7 +156,7 @@ test_expect_success 'master: no redundant for pack 1, 2, 3' '
154156
EOF
155157
(
156158
cd "$master_repo" &&
157-
git pack-redundant --all >out &&
159+
$git_pack_redundant --all >out &&
158160
test_must_be_empty out
159161
)
160162
'
@@ -192,7 +194,7 @@ test_expect_success 'master: one of pack-2/pack-3 is redundant' '
192194
cat >expect <<-EOF &&
193195
P3:$P3
194196
EOF
195-
git pack-redundant --all >out &&
197+
$git_pack_redundant --all >out &&
196198
format_packfiles <out >actual &&
197199
test_cmp expect actual
198200
)
@@ -231,7 +233,7 @@ test_expect_success 'master: pack 2, 4, and 6 are redundant' '
231233
P4:$P4
232234
P6:$P6
233235
EOF
234-
git pack-redundant --all >out &&
236+
$git_pack_redundant --all >out &&
235237
format_packfiles <out >actual &&
236238
test_cmp expect actual
237239
)
@@ -266,7 +268,7 @@ test_expect_success 'master: pack-8 (subset of pack-1) is also redundant' '
266268
P6:$P6
267269
P8:$P8
268270
EOF
269-
git pack-redundant --all >out &&
271+
$git_pack_redundant --all >out &&
270272
format_packfiles <out >actual &&
271273
test_cmp expect actual
272274
)
@@ -284,9 +286,9 @@ test_expect_success 'master: clean loose objects' '
284286
test_expect_success 'master: remove redundant packs and pass fsck' '
285287
(
286288
cd "$master_repo" &&
287-
git pack-redundant --all | xargs rm &&
289+
$git_pack_redundant --all | xargs rm &&
288290
git fsck &&
289-
git pack-redundant --all >out &&
291+
$git_pack_redundant --all >out &&
290292
test_must_be_empty out
291293
)
292294
'
@@ -304,7 +306,7 @@ test_expect_success 'setup shared.git' '
304306
test_expect_success 'shared: all packs are redundant, but no output without --alt-odb' '
305307
(
306308
cd "$shared_repo" &&
307-
git pack-redundant --all >out &&
309+
$git_pack_redundant --all >out &&
308310
test_must_be_empty out
309311
)
310312
'
@@ -343,7 +345,7 @@ test_expect_success 'shared: show redundant packs in stderr for verbose mode' '
343345
P5:$P5
344346
P7:$P7
345347
EOF
346-
git pack-redundant --all --verbose >out 2>out.err &&
348+
$git_pack_redundant --all --verbose >out 2>out.err &&
347349
test_must_be_empty out &&
348350
grep "pack$" out.err | format_packfiles >actual &&
349351
test_cmp expect actual
@@ -356,9 +358,9 @@ test_expect_success 'shared: remove redundant packs, no packs left' '
356358
cat >expect <<-EOF &&
357359
fatal: Zero packs found!
358360
EOF
359-
git pack-redundant --all --alt-odb | xargs rm &&
361+
$git_pack_redundant --all --alt-odb | xargs rm &&
360362
git fsck &&
361-
test_must_fail git pack-redundant --all --alt-odb >actual 2>&1 &&
363+
test_must_fail $git_pack_redundant --all --alt-odb >actual 2>&1 &&
362364
test_cmp expect actual
363365
)
364366
'
@@ -386,7 +388,7 @@ test_expect_success 'shared: create new objects and packs' '
386388
test_expect_success 'shared: no redundant without --alt-odb' '
387389
(
388390
cd "$shared_repo" &&
389-
git pack-redundant --all >out &&
391+
$git_pack_redundant --all >out &&
390392
test_must_be_empty out
391393
)
392394
'
@@ -417,7 +419,7 @@ test_expect_success 'shared: no redundant without --alt-odb' '
417419
test_expect_success 'shared: one pack is redundant with --alt-odb' '
418420
(
419421
cd "$shared_repo" &&
420-
git pack-redundant --all --alt-odb >out &&
422+
$git_pack_redundant --all --alt-odb >out &&
421423
format_packfiles <out >actual &&
422424
test_line_count = 1 actual
423425
)
@@ -454,7 +456,7 @@ test_expect_success 'shared: ignore unique objects and all two packs are redunda
454456
Px1:$Px1
455457
Px2:$Px2
456458
EOF
457-
git pack-redundant --all --alt-odb >out <<-EOF &&
459+
$git_pack_redundant --all --alt-odb >out <<-EOF &&
458460
$X
459461
$Y
460462
$Z

0 commit comments

Comments
 (0)