Skip to content

Commit 4511d56

Browse files
committed
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 <[email protected]> [en: log message] Signed-off-by: Junio C Hamano <[email protected]>
1 parent d50a5e8 commit 4511d56

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

builtin/pack-redundant.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -625,14 +625,8 @@ int cmd_pack_redundant(int argc, const char **argv, const char *prefix UNUSED, s
625625
break;
626626
}
627627

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 <[email protected]>. 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");
636630

637631
if (load_all_packs)
638632
load_all();

git-compat-util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,8 @@ void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
703703

704704
void show_usage_if_asked(int ac, const char **av, const char *err);
705705

706+
NORETURN void you_still_use_that(const char *command_name);
707+
706708
#ifndef NO_OPENSSL
707709
#ifdef APPLE_COMMON_CRYPTO
708710
#include "compat/apple-common-crypto.h"

t/t5323-pack-redundant.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ fi
4545
main_repo=main.git
4646
shared_repo=shared.git
4747

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+
4853
git_pack_redundant='git pack-redundant --i-still-use-this'
4954

5055
# Create commits in <repo> and assign each commit's oid to shell variables

usage.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,3 +372,15 @@ void bug_fl(const char *file, int line, const char *fmt, ...)
372372
trace2_cmd_error_va(fmt, ap);
373373
va_end(ap);
374374
}
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 <[email protected]>. Thanks.\n"),
384+
command_name);
385+
die(_("refusing to run without --i-still-use-this"));
386+
}

0 commit comments

Comments
 (0)