]> git.ipfire.org Git - thirdparty/git.git/commitdiff
you-still-use-that??: help deprecating commands for removal
authorJunio C Hamano <gitster@pobox.com>
Mon, 12 May 2025 19:03:06 +0000 (12:03 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 May 2025 20:11:43 +0000 (13:11 -0700)
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>
builtin/pack-redundant.c
git-compat-util.h
t/t5323-pack-redundant.sh
usage.c

index 3febe732f8e1c75c54248e1fdff9442051f312ea..6dc9e020c7461417bd603140fb8d19157839f81d 100644 (file)
@@ -625,14 +625,8 @@ int cmd_pack_redundant(int argc, const char **argv, const char *prefix UNUSED, s
                        break;
        }
 
-       if (!i_still_use_this) {
-               fputs(_("'git pack-redundant' is nominated for removal.\n"
-                       "If you still use this command, please add an extra\n"
-                       "option, '--i-still-use-this', on the command line\n"
-                       "and let us know you still use it by sending an e-mail\n"
-                       "to <git@vger.kernel.org>.  Thanks.\n"), stderr);
-               die(_("refusing to run without --i-still-use-this"));
-       }
+       if (!i_still_use_this)
+               you_still_use_that("git pack-redundant");
 
        if (load_all_packs)
                load_all();
index e123288e8f139328ad4e9f73a8c4f0bf027301e6..21cab99567e84952be3a103b113085675f424f0a 100644 (file)
@@ -703,6 +703,8 @@ void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
 
 void show_usage_if_asked(int ac, const char **av, const char *err);
 
+NORETURN void you_still_use_that(const char *command_name);
+
 #ifndef NO_OPENSSL
 #ifdef APPLE_COMMON_CRYPTO
 #include "compat/apple-common-crypto.h"
index 688cd9706c876a7edcaf0bcd642ae08ece188d4d..f2f20cfa4082cd7fada1a7c0d7cc34d31b2f9139 100755 (executable)
@@ -45,6 +45,11 @@ fi
 main_repo=main.git
 shared_repo=shared.git
 
+test_expect_success 'pack-redundant needs --i-still-use-this' '
+       test_must_fail git pack-redundant >message 2>&1 &&
+       test_grep "nominated for removal" message
+'
+
 git_pack_redundant='git pack-redundant --i-still-use-this'
 
 # Create commits in <repo> and assign each commit's oid to shell variables
diff --git a/usage.c b/usage.c
index 38b46bbbfe72089eb179b7caac6409faabac8d9b..4aaad2b553d43369d2e2c1c8503461548040c842 100644 (file)
--- a/usage.c
+++ b/usage.c
@@ -372,3 +372,15 @@ void bug_fl(const char *file, int line, const char *fmt, ...)
        trace2_cmd_error_va(fmt, ap);
        va_end(ap);
 }
+
+NORETURN void you_still_use_that(const char *command_name)
+{
+       fprintf(stderr,
+               _("'%s' is nominated for removal.\n"
+                 "If you still use this command, please add an extra\n"
+                 "option, '--i-still-use-this', on the command line\n"
+                 "and let us know you still use it by sending an e-mail\n"
+                 "to <git@vger.kernel.org>.  Thanks.\n"),
+               command_name);
+       die(_("refusing to run without --i-still-use-this"));
+}