git/list[1] front-page[2] threads[3] people[4] search[5] about
 

diff alias which used to work in version 2.27, failing from version 2.28 onwards

From
RAReverdell Auriane <auriane.reverdell@cscs.ch>
Date
Aug 24, 2023, 10:19 UTC
Message-ID
<31866645d2ac4cb1be17e35fae742cb2@cscs.ch>
Hi,
To output the diff of a specific commit, I created the alias dici (see below), git dici 12345 or git dici to output the diff of the HEAD:
[alias]
    dici = !git diff ${1:-HEAD}^..${1:-HEAD}
a trace for this alias gives (same trace for both git 2.27 and 2.28!):
14:38:45.275964 git.c:439               trace: built-in: git diff a2028e7b^..a2028e7b a2028e7b 
The commit number is put again at the end of the command (the wanted alias is supposed to output only `git diff a2028e7b^..a2028e7b`), this was accepted by version 2.27 but not by the version 2.28. For now, my temporary fix is adding a bash comment at the end of the alias:
[alias]
    dici = "!git diff ${1:-HEAD}^..${1:-HEAD} #"
Note: the first alias still doesn't work with the latest git versions (tested with 2.40.0, 2.39.2, 2.37.5).
Is that expected behavior? if yes, how is the right/clean way to discard the command line argument of the alias?
Thanks in advance!
Auriane
Next: Jeff King
Message 1 of 3 in “diff alias which used to work in version 2.27, failing from version 2.28 onwards”
  1. Reverdell AurianeAug 24, 2023
  2. Jeff KingAug 24, 2023
  3. Mikael MagnussonSep 9, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.