From: Jeff King <peff@peff.net>
To: Reverdell Auriane <auriane.reverdell@cscs.ch>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: diff alias which used to work in version 2.27, failing from version 2.28 onwards
Date: Thu, 24 Aug 2023 10:32:11 -0400 [thread overview]
Message-ID: <20230824143211.GA3108100@coredump.intra.peff.net> (raw)
In-Reply-To: <31866645d2ac4cb1be17e35fae742cb2@cscs.ch>
On Thu, Aug 24, 2023 at 10:19:18AM +0000, Reverdell Auriane wrote:
> 14:38:45.275964 git.c:439 trace: built-in: git diff a2028e7b^..a2028e7b a2028e7b
> [...]
> Is that expected behavior? if yes, how is the right/clean way to
> discard the command line argument of the alias?
Yes, that's expected. Your alias was always a little broken by adding
the extra argument, but "git diff" got a little more careful about its
input in 8bfcb3a690 (git diff: improve range handling, 2020-06-12),
which as part of v2.28.
The usual way for manipulating arguments in a shell snippet is to make a
function, like:
[alias]
dici = "!f() { git diff ${1:-HEAD}^..${1:-HEAD}; }; f"
Then Git ends up running "f a2028e7b", and the shell does the rest. It's
obviously a bit more verbose to write, but you're free to do even more
manipulation (e.g., using the first non-option argument as the rev and
taking the rest as options).
All that said, there is a shorthand that may make your alias obsolete.
From "git help revisions":
<rev>^-<n>, e.g. HEAD^-, HEAD^-2
Equivalent to <rev>^<n>..<rev>, with <n> = 1 if not given.
So just:
git diff a2028e7b^-
does what you want.
-Peff
next prev parent reply other threads:[~2023-08-24 14:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-24 10:19 diff alias which used to work in version 2.27, failing from version 2.28 onwards Reverdell Auriane
2023-08-24 14:32 ` Jeff King [this message]
2023-09-09 18:45 ` Mikael Magnusson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230824143211.GA3108100@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=auriane.reverdell@cscs.ch \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).