Merge branch 'jc/you-still-use-whatchanged'

"git whatchanged" that is longer to type than "git log --raw"
which is its modern rough equivalent has outlived its usefulness
more than 10 years ago.  Plan to deprecate and remove it.

* jc/you-still-use-whatchanged:
  whatschanged: list it in BreakingChanges document
  whatchanged: remove when built with WITH_BREAKING_CHANGES
  whatchanged: require --i-still-use-this
  tests: prepare for a world without whatchanged
  doc: prepare for a world without whatchanged
  you-still-use-that??: help deprecating commands for removal
This commit is contained in:
Junio C Hamano
2025-06-25 14:07:35 -07:00
21 changed files with 152 additions and 39 deletions

View File

@@ -183,6 +183,14 @@ These features will be removed.
timeframe, in preference to its synonym "--annotate-stdin". Git 3.0
removes the support for "--stdin" altogether.
* The git-whatchanged(1) command has outlived its usefulness more than
10 years ago, and takes more keystrokes to type than its rough
equivalent `git log --raw`. We have nominated the command for
removal, have changed the command to refuse to work unless the
`--i-still-use-this` option is given, and asked the users to report
when they do so. So far there hasn't been a single complaint.
+
The command will be removed.
== Superseded features that will not be deprecated

View File

@@ -510,7 +510,12 @@ lint-docs-meson:
awk "/^manpages = {$$/ {flag=1 ; next } /^}$$/ { flag=0 } flag { gsub(/^ \047/, \"\"); gsub(/\047 : [157],\$$/, \"\"); print }" meson.build | \
grep -v -e '#' -e '^$$' | \
sort >tmp-meson-diff/meson.adoc && \
ls git*.adoc scalar.adoc | grep -v -e git-bisect-lk2009.adoc -e git-pack-redundant.adoc -e git-tools.adoc >tmp-meson-diff/actual.adoc && \
ls git*.adoc scalar.adoc | \
grep -v -e git-bisect-lk2009.adoc \
-e git-pack-redundant.adoc \
-e git-tools.adoc \
-e git-whatchanged.adoc \
>tmp-meson-diff/actual.adoc && \
if ! cmp tmp-meson-diff/meson.adoc tmp-meson-diff/actual.adoc; then \
echo "Meson man pages differ from actual man pages:"; \
diff -u tmp-meson-diff/meson.adoc tmp-meson-diff/actual.adoc; \

View File

@@ -83,13 +83,13 @@ int cmd_walken(int argc, const char **argv, const char *prefix)
}
----
Also add the relevant line in `builtin.h` near `cmd_whatchanged()`:
Also add the relevant line in `builtin.h` near `cmd_version()`:
----
int cmd_walken(int argc, const char **argv, const char *prefix, struct repository *repo);
----
Include the command in `git.c` in `commands[]` near the entry for `whatchanged`,
Include the command in `git.c` in `commands[]` near the entry for `version`,
maintaining alphabetical ordering:
----

View File

@@ -68,9 +68,15 @@ format.encodeEmailHeaders::
Defaults to true.
format.pretty::
ifndef::with-breaking-changes[]
The default pretty format for log/show/whatchanged command.
See linkgit:git-log[1], linkgit:git-show[1],
linkgit:git-whatchanged[1].
endif::with-breaking-changes[]
ifdef::with-breaking-changes[]
The default pretty format for log/show command.
See linkgit:git-log[1], linkgit:git-show[1].
endif::with-breaking-changes[]
format.thread::
The default threading style for 'git format-patch'. Can be

View File

@@ -1,6 +1,13 @@
log.abbrevCommit::
If true, makes linkgit:git-log[1], linkgit:git-show[1], and
linkgit:git-whatchanged[1] assume `--abbrev-commit`. You may
If true, makes
ifndef::with-breaking-changes[]
linkgit:git-log[1], linkgit:git-show[1], and
linkgit:git-whatchanged[1]
endif::with-breaking-changes[]
ifdef::with-breaking-changes[]
linkgit:git-log[1] and linkgit:git-show[1]
endif::with-breaking-changes[]
assume `--abbrev-commit`. You may
override this option with `--no-abbrev-commit`.
log.date::

View File

@@ -8,8 +8,14 @@ git-whatchanged - Show logs with differences each commit introduces
SYNOPSIS
--------
[verse]
'git whatchanged' <option>...
[synopsis]
git whatchanged <option>...
WARNING
-------
`git whatchanged` has been deprecated and is scheduled for removal in
a future version of Git, as it is merely `git log` with different
default; `whatchanged` is not even shorter to type than `log --raw`.
DESCRIPTION
-----------

View File

@@ -158,7 +158,6 @@ manpages = {
'git-verify-tag.adoc' : 1,
'git-version.adoc' : 1,
'git-web--browse.adoc' : 1,
'git-whatchanged.adoc' : 1,
'git-worktree.adoc' : 1,
'git-write-tree.adoc' : 1,
'git.adoc' : 1,
@@ -207,6 +206,7 @@ manpages = {
manpages_breaking_changes = {
'git-pack-redundant.adoc' : 1,
'git-whatchanged.adoc' : 1,
}
if not get_option('breaking_changes')

View File

@@ -62,7 +62,12 @@ ifndef::git-rev-list[]
--notes[=<ref>]::
Show the notes (see linkgit:git-notes[1]) that annotate the
commit, when showing the commit log message. This is the default
ifndef::with-breaking-changes[]
for `git log`, `git show` and `git whatchanged` commands when
endif::with-breaking-changes[]
ifdef::with-breaking-changes[]
for `git log` and `git show` commands when
endif::with-breaking-changes[]
there is no `--pretty`, `--format`, or `--oneline` option given
on the command line.
+

View File

@@ -1100,8 +1100,13 @@ Commit Formatting
ifdef::git-rev-list[]
Using these options, linkgit:git-rev-list[1] will act similar to the
more specialized family of commit log tools: linkgit:git-log[1],
linkgit:git-show[1], and linkgit:git-whatchanged[1]
more specialized family of commit log tools:
ifndef::with-breaking-changes[]
linkgit:git-log[1], linkgit:git-show[1], and linkgit:git-whatchanged[1].
endif::with-breaking-changes[]
ifdef::with-breaking-changes[]
linkgit:git-log[1] and linkgit:git-show[1].
endif::with-breaking-changes[]
endif::git-rev-list[]
include::pretty-options.adoc[]

View File

@@ -440,7 +440,7 @@ understanding these differences can be beneficial.
* blame (only matters when one or more -C flags are passed)
* and annotate
* log
* whatchanged
* whatchanged (may not exist anymore)
* ls-files
* diff-index
* diff-tree

View File

@@ -4240,7 +4240,7 @@ command `git`. The source side of a builtin is
- an entry in `BUILTIN_OBJECTS` in the `Makefile`.
Sometimes, more than one builtin is contained in one source file. For
example, `cmd_whatchanged()` and `cmd_log()` both reside in `builtin/log.c`,
example, `cmd_show()` and `cmd_log()` both reside in `builtin/log.c`,
since they share quite a bit of code. In that case, the commands which are
_not_ named like the `.c` file in which they live have to be listed in
`BUILT_INS` in the `Makefile`.

View File

@@ -113,6 +113,15 @@ struct log_config {
int fmt_patch_name_max;
char *fmt_pretty;
char *default_date_mode;
#ifndef WITH_BREAKING_CHANGES
/*
* 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;
#endif
};
static void log_config_init(struct log_config *cfg)
@@ -267,6 +276,10 @@ 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")),
#ifndef WITH_BREAKING_CHANGES
OPT_HIDDEN_BOOL(0, "i-still-use-this", &cfg->i_still_use_this,
"<use this deprecated command>"),
#endif
OPT_ALIAS(0, "mailmap", "use-mailmap"),
OPT_CALLBACK_F(0, "clear-decorations", NULL, NULL,
N_("clear all previously-defined decoration filters"),
@@ -633,6 +646,7 @@ static int git_log_config(const char *var, const char *value,
return git_diff_ui_config(var, value, ctx, cb);
}
#ifndef WITH_BREAKING_CHANGES
int cmd_whatchanged(int argc,
const char **argv,
const char *prefix,
@@ -656,6 +670,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;
@@ -665,6 +683,7 @@ int cmd_whatchanged(int argc,
log_config_release(&cfg);
return ret;
}
#endif
static void show_tagger(const char *buf, struct rev_info *rev)
{

View 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();

View File

@@ -460,6 +460,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"

2
git.c
View File

@@ -646,7 +646,9 @@ static struct cmd_struct commands[] = {
{ "verify-pack", cmd_verify_pack },
{ "verify-tag", cmd_verify_tag, RUN_SETUP },
{ "version", cmd_version },
#ifndef WITH_BREAKING_CHANGES
{ "whatchanged", cmd_whatchanged, RUN_SETUP },
#endif
{ "worktree", cmd_worktree, RUN_SETUP },
{ "write-tree", cmd_write_tree, RUN_SETUP },
};

View File

@@ -206,14 +206,30 @@ do
expect="$TEST_DIRECTORY/t4013/diff.$test"
actual="$pfx-diff.$test"
test_expect_success "git $cmd # magic is ${magic:-(not used)}" '
case "$cmd" in
whatchanged | whatchanged" "*)
prereq=!WITH_BREAKING_CHANGES
;;
*)
prereq=;;
esac
test_expect_success $prereq "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\"/"
@@ -460,6 +476,11 @@ diff-tree --stat --compact-summary initial mode
diff-tree -R --stat --compact-summary initial mode
EOF
test_expect_success !WITH_BREAKING_CHANGES '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 &&

View File

@@ -486,10 +486,16 @@ test_expect_success !FAIL_PREREQS 'log with various grep.patternType configurati
)
'
for cmd in show whatchanged reflog format-patch
cmds="show reflog format-patch"
if test_have_prereq !WITH_BREAKING_CHANGES
then
cmds="$cmds whatchanged"
fi
for cmd in $cmds
do
case "$cmd" in
format-patch) myarg="HEAD~.." ;;
whatchanged) myarg=--i-still-use-this ;;
*) myarg= ;;
esac
@@ -1201,20 +1207,27 @@ test_expect_success 'reflog is expected format' '
test_cmp expect actual
'
test_expect_success 'whatchanged is expected format' '
test_expect_success !WITH_BREAKING_CHANGES '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 &&
if test_have_prereq !WITH_BREAKING_CHANGES
then
git $whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
git $whatchanged --no-abbrev-commit >expect.whatchanged.full
fi &&
test_config log.abbrevCommit true &&
@@ -1231,10 +1244,13 @@ test_expect_success 'log.abbrevCommit configuration' '
git reflog --no-abbrev-commit >actual &&
test_cmp expect.reflog.full actual &&
git whatchanged >actual &&
test_cmp expect.whatchanged.abbrev actual &&
git whatchanged --no-abbrev-commit >actual &&
test_cmp expect.whatchanged.full actual
if test_have_prereq !WITH_BREAKING_CHANGES
then
git $whatchanged >actual &&
test_cmp expect.whatchanged.abbrev actual &&
git $whatchanged --no-abbrev-commit >actual &&
test_cmp expect.whatchanged.full actual
fi
'
test_expect_success '--abbrev-commit with core.abbrev=false' '

View File

@@ -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

View File

@@ -120,7 +120,7 @@ test_expect_success 'A: create pack from stdin' '
INPUT_END
git fast-import --export-marks=marks.out <input &&
git whatchanged main
git log --raw main
'
test_expect_success 'A: verify pack' '
@@ -279,7 +279,7 @@ test_expect_success 'A: verify marks import does not crash' '
INPUT_END
git fast-import --import-marks=marks.out <input &&
git whatchanged verify--import-marks
git log --raw verify--import-marks
'
test_expect_success 'A: verify pack' '
@@ -652,7 +652,7 @@ test_expect_success 'C: incremental import create pack from stdin' '
INPUT_END
git fast-import <input &&
git whatchanged branch
git log --raw branch
'
test_expect_success 'C: verify pack' '
@@ -715,7 +715,7 @@ test_expect_success 'D: inline data in commit' '
INPUT_END
git fast-import <input &&
git whatchanged branch
git log --raw branch
'
test_expect_success 'D: verify pack' '
@@ -882,7 +882,7 @@ test_expect_success 'H: deletall, add 1' '
INPUT_END
git fast-import <input &&
git whatchanged H
git log --raw H
'
test_expect_success 'H: verify pack' '
@@ -2066,7 +2066,7 @@ test_expect_success 'Q: commit notes' '
INPUT_END
git fast-import <input &&
git whatchanged notes-test
git log --raw notes-test
'
test_expect_success 'Q: verify pack' '

View File

@@ -76,7 +76,7 @@ INPUT_END
test_expect_success 'set up main branch' '
git fast-import <input &&
git whatchanged main
git log --raw main
'
commit4=$(git rev-parse refs/heads/main)

12
usage.c
View File

@@ -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"));
}