]> git.ipfire.org Git - thirdparty/git.git/commitdiff
whatchanged: require --i-still-use-this
authorJunio C Hamano <gitster@pobox.com>
Mon, 12 May 2025 19:03:09 +0000 (12:03 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 May 2025 22:29:37 +0000 (15:29 -0700)
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>
builtin/log.c
t/t4013-diff-various.sh
t/t4202-log.sh

index 04a6ef97bc1442a5038fa835e99e7c9ff3348554..0f98ac8a348208764ada3795b85fac670d5d5315 100644 (file)
@@ -113,6 +113,13 @@ struct log_config {
        int fmt_patch_name_max;
        char *fmt_pretty;
        char *default_date_mode;
+
+       /*
+        * Note: git_log_config() does not touch this member and that
+        * is very deliberate.  This member is only to be used to
+        * resurrect whatchanged that is deprecated.
+        */
+       int i_still_use_this;
 };
 
 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,
                OPT__QUIET(&quiet, N_("suppress diff output")),
                OPT_BOOL(0, "source", &source, N_("show source")),
                OPT_BOOL(0, "use-mailmap", &mailmap, N_("use mail map file")),
+               OPT_HIDDEN_BOOL(0, "i-still-use-this", &cfg->i_still_use_this,
+                               "<use this deprecated command>"),
                OPT_ALIAS(0, "mailmap", "use-mailmap"),
                OPT_CALLBACK_F(0, "clear-decorations", NULL, NULL,
                               N_("clear all previously-defined decoration filters"),
@@ -656,6 +665,10 @@ int cmd_whatchanged(int argc,
        opt.def = "HEAD";
        opt.revarg_opt = REVARG_COMMITTISH;
        cmd_log_init(argc, argv, prefix, &rev, &opt, &cfg);
+
+       if (!cfg.i_still_use_this)
+               you_still_use_that("git whatchanged");
+
        if (!rev.diffopt.output_format)
                rev.diffopt.output_format = DIFF_FORMAT_RAW;
 
index 3855d68dbc0a64797ddbd665e675aa3d1549defc..8caab2ee383cefde573ce65f52cb5415e21f8338 100755 (executable)
@@ -203,11 +203,19 @@ do
        test_expect_success "git $cmd # magic is ${magic:-(not used)}" '
                {
                        echo "$ git $cmd"
+
+                       case "$cmd" in
+                       whatchanged | whatchanged" "*)
+                               run="whatchanged --i-still-use-this"
+                               run="$run ${cmd#whatchanged}" ;;
+                       *)
+                               run=$cmd ;;
+                       esac &&
                        case "$magic" in
                        "")
-                               GIT_PRINT_SHA1_ELLIPSIS=yes git $cmd ;;
+                               GIT_PRINT_SHA1_ELLIPSIS=yes git $run ;;
                        noellipses)
-                               git $cmd ;;
+                               git $run ;;
                        esac |
                        sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
                            -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
 diff-tree -R --stat --compact-summary initial mode
 EOF
 
+test_expect_success 'whatchanged needs --i-still-use-this' '
+       test_must_fail git whatchanged >message 2>&1 &&
+       test_grep "nominated for removal" message
+'
+
 test_expect_success 'log -m matches pure log' '
        git log master >result &&
        process_diffs result >expected &&
index 51f7beb59f88c8fba384acf7c4772e255b612dbf..ce4c7ab2af238ce01427c4d0b69b46c8deeefc32 100755 (executable)
@@ -490,6 +490,7 @@ for cmd in show whatchanged reflog format-patch
 do
        case "$cmd" in
        format-patch) myarg="HEAD~.." ;;
+       whatchanged) myarg=--i-still-use-this ;;
        *) myarg= ;;
        esac
 
@@ -1202,19 +1203,22 @@ test_expect_success 'reflog is expected format' '
 '
 
 test_expect_success 'whatchanged is expected format' '
+       whatchanged="whatchanged --i-still-use-this" &&
        git log --no-merges --raw >expect &&
-       git whatchanged >actual &&
+       git $whatchanged >actual &&
        test_cmp expect actual
 '
 
 test_expect_success 'log.abbrevCommit configuration' '
+       whatchanged="whatchanged --i-still-use-this" &&
+
        git log --abbrev-commit >expect.log.abbrev &&
        git log --no-abbrev-commit >expect.log.full &&
        git log --pretty=raw >expect.log.raw &&
        git reflog --abbrev-commit >expect.reflog.abbrev &&
        git reflog --no-abbrev-commit >expect.reflog.full &&
-       git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
-       git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
+       git $whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
+       git $whatchanged --no-abbrev-commit >expect.whatchanged.full &&
 
        test_config log.abbrevCommit true &&
 
@@ -1231,9 +1235,9 @@ test_expect_success 'log.abbrevCommit configuration' '
        git reflog --no-abbrev-commit >actual &&
        test_cmp expect.reflog.full actual &&
 
-       git whatchanged >actual &&
+       git $whatchanged >actual &&
        test_cmp expect.whatchanged.abbrev actual &&
-       git whatchanged --no-abbrev-commit >actual &&
+       git $whatchanged --no-abbrev-commit >actual &&
        test_cmp expect.whatchanged.full actual
 '