whatchanged: require --i-still-use-this
The documentation of "git whatchanged" is pretty explicit that the command was retained for historical reasons to help those whose fingers cannot be retrained. Let's see if they still are finding it hard to type "git log --raw" instead of "git whatchanged" by marking the command as "nominated for removal", and require "--i-still-use-this" on the command line. Adjust the tests so that the option is passed when we invoke the command. In addition, we test that the command fails when "--i-still-use-this" is not given. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
May 12, 2025 at 12:03 UTC
731a2c7ddae9226d384163efc77090003be63a13
3 files changed
+37
-7
builtin/log.c
+13
@@ -113,6 +113,13 @@ struct log_config {
113
int fmt_patch_name_max;
114
char *fmt_pretty;
115
char *default_date_mode;
116
+
117
+ /*
118
+ * Note: git_log_config() does not touch this member and that
119
+ * is very deliberate. This member is only to be used to
120
+ * resurrect whatchanged that is deprecated.
121
+ */
122
+ int i_still_use_this;
123
};
124
125
static void log_config_init(struct log_config *cfg)
@@ -267,6 +274,8 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
274
OPT__QUIET(&quiet, N_("suppress diff output")),
275
OPT_BOOL(0, "source", &source, N_("show source")),
276
OPT_BOOL(0, "use-mailmap", &mailmap, N_("use mail map file")),
277
+ OPT_HIDDEN_BOOL(0, "i-still-use-this", &cfg->i_still_use_this,
278
+ "<use this deprecated command>"),
279
OPT_ALIAS(0, "mailmap", "use-mailmap"),
280
OPT_CALLBACK_F(0, "clear-decorations", NULL, NULL,
281
N_("clear all previously-defined decoration filters"),
@@ -656,6 +665,10 @@ int cmd_whatchanged(int argc,
665
opt.def = "HEAD";
666
opt.revarg_opt = REVARG_COMMITTISH;
667
cmd_log_init(argc, argv, prefix, &rev, &opt, &cfg);
668
+
669
+ if (!cfg.i_still_use_this)
670
+ you_still_use_that("git whatchanged");
671
+
672
if (!rev.diffopt.output_format)
673
rev.diffopt.output_format = DIFF_FORMAT_RAW;
674
t/t4013-diff-various.sh
+15
-2
@@ -203,11 +203,19 @@ do
203
test_expect_success "git $cmd # magic is ${magic:-(not used)}" '
204
{
205
echo "$ git $cmd"
206
+
207
+ case "$cmd" in
208
+ whatchanged | whatchanged" "*)
209
+ run="whatchanged --i-still-use-this"
210
+ run="$run ${cmd#whatchanged}" ;;
211
+ *)
212
+ run=$cmd ;;
213
+ esac &&
214
case "$magic" in
215
"")
208
- GIT_PRINT_SHA1_ELLIPSIS=yes git $cmd ;;
216
+ GIT_PRINT_SHA1_ELLIPSIS=yes git $run ;;
217
noellipses)
210
- git $cmd ;;
218
+ git $run ;;
219
esac |
220
sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
221
-e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
@@ -454,6 +462,11 @@ diff-tree --stat --compact-summary initial mode
462
diff-tree -R --stat --compact-summary initial mode
463
EOF
464
465
+test_expect_success 'whatchanged needs --i-still-use-this' '
466
+ test_must_fail git whatchanged >message 2>&1 &&
467
+ test_grep "nominated for removal" message
468
+'
469
+
470
test_expect_success 'log -m matches pure log' '
471
git log master >result &&
472
process_diffs result >expected &&
t/t4202-log.sh
+9
-5
@@ -490,6 +490,7 @@ for cmd in show whatchanged reflog format-patch
490
do
491
case "$cmd" in
492
format-patch) myarg="HEAD~.." ;;
493
+ whatchanged) myarg=--i-still-use-this ;;
494
*) myarg= ;;
495
esac
496
@@ -1202,19 +1203,22 @@ test_expect_success 'reflog is expected format' '
1203
'
1204
1205
test_expect_success 'whatchanged is expected format' '
1206
+ whatchanged="whatchanged --i-still-use-this" &&
1207
git log --no-merges --raw >expect &&
1206
- git whatchanged >actual &&
1208
+ git $whatchanged >actual &&
1209
test_cmp expect actual
1210
'
1211
1212
test_expect_success 'log.abbrevCommit configuration' '
1213
+ whatchanged="whatchanged --i-still-use-this" &&
1214
+
1215
git log --abbrev-commit >expect.log.abbrev &&
1216
git log --no-abbrev-commit >expect.log.full &&
1217
git log --pretty=raw >expect.log.raw &&
1218
git reflog --abbrev-commit >expect.reflog.abbrev &&
1219
git reflog --no-abbrev-commit >expect.reflog.full &&
1216
- git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
1217
- git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
1220
+ git $whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
1221
+ git $whatchanged --no-abbrev-commit >expect.whatchanged.full &&
1222
1223
test_config log.abbrevCommit true &&
1224
@@ -1231,9 +1235,9 @@ test_expect_success 'log.abbrevCommit configuration' '
1235
git reflog --no-abbrev-commit >actual &&
1236
test_cmp expect.reflog.full actual &&
1237
1234
- git whatchanged >actual &&
1238
+ git $whatchanged >actual &&
1239
test_cmp expect.whatchanged.abbrev actual &&
1236
- git whatchanged --no-abbrev-commit >actual &&
1240
+ git $whatchanged --no-abbrev-commit >actual &&
1241
test_cmp expect.whatchanged.full actual
1242
'
1243