you-still-use-that??: help deprecating commands for removal

Commands slated for removal like "git pack-redundant" now require an explicit "--i-still-use-this" option to run. This is to discourage casual use and surface their pending deprecation to users. The warning message is long, so factor it into a helper function you_still_use_that() to simplify reuse by other commands. Also add a missing test to ensure this enforcement works for "pack-redundant". Helped-by: Elijah Newren <newren@gmail.com> [en: log message] Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed May 12, 2025 at 12:03 UTC 4511d56e1a4c09abbe0c6b513fd858072b55cbd8
4 files changed +21 -8
builtin/pack-redundant.c
+2 -8
@@ -625,14 +625,8 @@ int cmd_pack_redundant(int argc, const char **argv, const char *prefix UNUSED, s
625 break;
626 }
627
628 - if (!i_still_use_this) {
629 - fputs(_("'git pack-redundant' is nominated for removal.\n"
630 - "If you still use this command, please add an extra\n"
631 - "option, '--i-still-use-this', on the command line\n"
632 - "and let us know you still use it by sending an e-mail\n"
633 - "to <git@vger.kernel.org>. Thanks.\n"), stderr);
634 - die(_("refusing to run without --i-still-use-this"));
635 - }
628 + if (!i_still_use_this)
629 + you_still_use_that("git pack-redundant");
630
631 if (load_all_packs)
632 load_all();
git-compat-util.h
+2
@@ -703,6 +703,8 @@ void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
703
704 void show_usage_if_asked(int ac, const char **av, const char *err);
705
706 +NORETURN void you_still_use_that(const char *command_name);
707 +
708 #ifndef NO_OPENSSL
709 #ifdef APPLE_COMMON_CRYPTO
710 #include "compat/apple-common-crypto.h"
t/t5323-pack-redundant.sh
+5
@@ -45,6 +45,11 @@ fi
45 main_repo=main.git
46 shared_repo=shared.git
47
48 +test_expect_success 'pack-redundant needs --i-still-use-this' '
49 + test_must_fail git pack-redundant >message 2>&1 &&
50 + test_grep "nominated for removal" message
51 +'
52 +
53 git_pack_redundant='git pack-redundant --i-still-use-this'
54
55 # Create commits in <repo> and assign each commit's oid to shell variables
usage.c
+12
@@ -372,3 +372,15 @@ void bug_fl(const char *file, int line, const char *fmt, ...)
372 trace2_cmd_error_va(fmt, ap);
373 va_end(ap);
374 }
375 +
376 +NORETURN void you_still_use_that(const char *command_name)
377 +{
378 + fprintf(stderr,
379 + _("'%s' is nominated for removal.\n"
380 + "If you still use this command, please add an extra\n"
381 + "option, '--i-still-use-this', on the command line\n"
382 + "and let us know you still use it by sending an e-mail\n"
383 + "to <git@vger.kernel.org>. Thanks.\n"),
384 + command_name);
385 + die(_("refusing to run without --i-still-use-this"));
386 +}