mirror of
https://github.com/git/git.git
synced 2026-03-29 11:00:07 +02:00
git-whatchanged(1) is deprecated and you need to pass
`--i-still-use-this` in order to force it to work as before.
There are two affected users, or usages:
1. people who use the command in scripts; and
2. people who are used to using it interactively.
For (1) the replacement is straightforward.[1] But people in (2) might
like the name or be really used to typing it.[3]
An obvious first thought is to suggest aliasing `whatchanged` to the
git-log(1) equivalent.[1] But this doesn’t work and is awkward since you
cannot shadow builtins via aliases.
Now you are left in an uncomfortable limbo; your alias won’t work until
the command is removed for good.
Let’s lift this limitation by allowing *deprecated* builtins to be
shadowed by aliases.
The only observed demand for aliasing has been for git-whatchanged(1),
not for git-pack-redundant(1). But let’s be consistent and treat all
deprecated commands the same.
[1]:
git log --raw --no-merges
With a minor caveat: you get different outputs if you happen to
have empty commits (no changes)[2]
[2]: https://lore.kernel.org/git/20250825085428.GA367101@coredump.intra.peff.net/
[3]: https://lore.kernel.org/git/BL3P221MB0449288C8B0FA448A227FD48833AA@BL3P221MB0449.NAMP221.PROD.OUTLOOK.COM/
Based-on-patch-by: Jeff King <peff@peff.net>
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
45 lines
2.4 KiB
Plaintext
45 lines
2.4 KiB
Plaintext
alias.*::
|
|
Command aliases for the linkgit:git[1] command wrapper - e.g.
|
|
after defining `alias.last = cat-file commit HEAD`, the invocation
|
|
`git last` is equivalent to `git cat-file commit HEAD`. To avoid
|
|
confusion and troubles with script usage, aliases that
|
|
hide existing Git commands are ignored except for deprecated
|
|
commands. Arguments are split by
|
|
spaces, the usual shell quoting and escaping are supported.
|
|
A quote pair or a backslash can be used to quote them.
|
|
+
|
|
Note that the first word of an alias does not necessarily have to be a
|
|
command. It can be a command-line option that will be passed into the
|
|
invocation of `git`. In particular, this is useful when used with `-c`
|
|
to pass in one-time configurations or `-p` to force pagination. For example,
|
|
`loud-rebase = -c commit.verbose=true rebase` can be defined such that
|
|
running `git loud-rebase` would be equivalent to
|
|
`git -c commit.verbose=true rebase`. Also, `ps = -p status` would be a
|
|
helpful alias since `git ps` would paginate the output of `git status`
|
|
where the original command does not.
|
|
+
|
|
If the alias expansion is prefixed with an exclamation point,
|
|
it will be treated as a shell command. For example, defining
|
|
`alias.new = !gitk --all --not ORIG_HEAD`, the invocation
|
|
`git new` is equivalent to running the shell command
|
|
`gitk --all --not ORIG_HEAD`. Note:
|
|
+
|
|
* Shell commands will be executed from the top-level directory of a
|
|
repository, which may not necessarily be the current directory.
|
|
* `GIT_PREFIX` is set as returned by running `git rev-parse --show-prefix`
|
|
from the original current directory. See linkgit:git-rev-parse[1].
|
|
* Shell command aliases always receive any extra arguments provided to
|
|
the Git command-line as positional arguments.
|
|
** Care should be taken if your shell alias is a "one-liner" script
|
|
with multiple commands (e.g. in a pipeline), references multiple
|
|
arguments, or is otherwise not able to handle positional arguments
|
|
added at the end. For example: `alias.cmd = "!echo $1 | grep $2"`
|
|
called as `git cmd 1 2` will be executed as 'echo $1 | grep $2
|
|
1 2', which is not what you want.
|
|
** A convenient way to deal with this is to write your script
|
|
operations in an inline function that is then called with any
|
|
arguments from the command-line. For example `alias.cmd = "!c() {
|
|
echo $1 | grep $2 ; }; c" will correctly execute the prior example.
|
|
** Setting `GIT_TRACE=1` can help you debug the command being run for
|
|
your alias.
|