Skip to content

Commit 731a2c7

Browse files
committed
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 <[email protected]>
1 parent ab4d188 commit 731a2c7

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

builtin/log.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ struct log_config {
113113
int fmt_patch_name_max;
114114
char *fmt_pretty;
115115
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;
116123
};
117124

118125
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,
267274
OPT__QUIET(&quiet, N_("suppress diff output")),
268275
OPT_BOOL(0, "source", &source, N_("show source")),
269276
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>"),
270279
OPT_ALIAS(0, "mailmap", "use-mailmap"),
271280
OPT_CALLBACK_F(0, "clear-decorations", NULL, NULL,
272281
N_("clear all previously-defined decoration filters"),
@@ -656,6 +665,10 @@ int cmd_whatchanged(int argc,
656665
opt.def = "HEAD";
657666
opt.revarg_opt = REVARG_COMMITTISH;
658667
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+
659672
if (!rev.diffopt.output_format)
660673
rev.diffopt.output_format = DIFF_FORMAT_RAW;
661674

t/t4013-diff-various.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,19 @@ do
203203
test_expect_success "git $cmd # magic is ${magic:-(not used)}" '
204204
{
205205
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 &&
206214
case "$magic" in
207215
"")
208-
GIT_PRINT_SHA1_ELLIPSIS=yes git $cmd ;;
216+
GIT_PRINT_SHA1_ELLIPSIS=yes git $run ;;
209217
noellipses)
210-
git $cmd ;;
218+
git $run ;;
211219
esac |
212220
sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
213221
-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
454462
diff-tree -R --stat --compact-summary initial mode
455463
EOF
456464

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+
457470
test_expect_success 'log -m matches pure log' '
458471
git log master >result &&
459472
process_diffs result >expected &&

t/t4202-log.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ for cmd in show whatchanged reflog format-patch
490490
do
491491
case "$cmd" in
492492
format-patch) myarg="HEAD~.." ;;
493+
whatchanged) myarg=--i-still-use-this ;;
493494
*) myarg= ;;
494495
esac
495496

@@ -1202,19 +1203,22 @@ test_expect_success 'reflog is expected format' '
12021203
'
12031204

12041205
test_expect_success 'whatchanged is expected format' '
1206+
whatchanged="whatchanged --i-still-use-this" &&
12051207
git log --no-merges --raw >expect &&
1206-
git whatchanged >actual &&
1208+
git $whatchanged >actual &&
12071209
test_cmp expect actual
12081210
'
12091211

12101212
test_expect_success 'log.abbrevCommit configuration' '
1213+
whatchanged="whatchanged --i-still-use-this" &&
1214+
12111215
git log --abbrev-commit >expect.log.abbrev &&
12121216
git log --no-abbrev-commit >expect.log.full &&
12131217
git log --pretty=raw >expect.log.raw &&
12141218
git reflog --abbrev-commit >expect.reflog.abbrev &&
12151219
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 &&
12181222
12191223
test_config log.abbrevCommit true &&
12201224
@@ -1231,9 +1235,9 @@ test_expect_success 'log.abbrevCommit configuration' '
12311235
git reflog --no-abbrev-commit >actual &&
12321236
test_cmp expect.reflog.full actual &&
12331237
1234-
git whatchanged >actual &&
1238+
git $whatchanged >actual &&
12351239
test_cmp expect.whatchanged.abbrev actual &&
1236-
git whatchanged --no-abbrev-commit >actual &&
1240+
git $whatchanged --no-abbrev-commit >actual &&
12371241
test_cmp expect.whatchanged.full actual
12381242
'
12391243

0 commit comments

Comments
 (0)