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

Re: Deprecating git diff ..; dealing with other ranges

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 11, 2019, 13:19 UTC
Message-ID
<nycvar.QRO.7.76.6.1903111412280.41@tvgsbejvaqbjf.bet>
In-Reply-To
<20190311093751.GA31092@archbookpro.localdomain>
Hi Denton,
On Mon, 11 Mar 2019, Denton Liu wrote:
Show 27 quoted lines
> I was in the process of deprecating `git diff <commit>..<commit>` as
> discussed here[1]. However, I ran into a weird case that I'm not sure
> how to deal with.
> 
> In t3430-rebase-merges.sh:382, we have the following test case which
> invokes git diff:
> 
> 	test_expect_success 'with --autosquash and --exec' '
> 		git checkout -b with-exec H &&
> 		echo Booh >B.t &&
> 		test_tick &&
> 		git commit --fixup B B.t &&
> 		write_script show.sh <<-\EOF &&
> 		subject="$(git show -s --format=%s HEAD)"
> =>		content="$(git diff HEAD^! | tail -n 1)"
> 		echo "$subject: $content"
> 		EOF
> 		test_tick &&
> 		git rebase -ir --autosquash --exec ./show.sh A >actual &&
> 		grep "B: +Booh" actual &&
> 		grep "E: +Booh" actual &&
> 		grep "G: +G" actual
> 	'
> 
> It gets caught in my attempt to only deprecate ..'s. Technically, it's
> undocumented behaviour and it only happens to work because git-diff
> accept ranges but it doesn't operate in an intuitive way.

I beg to differ. `git diff <commit>^!` does exactly what I want: it shows the diff between the commit's first parent and the commit.

And I would not necessarily call this a "range". It is a short-hand. Can't you allow short-hands in `git diff`, and disallow only ranges that have an explicit `..` in them? You might need to record that somewhere, but I think that should be easy enough.

Ciao, Johannes

Show 13 quoted lines
> 
> I was just wondering what we should do about this case? Should we
> deprecate all invocations of `git diff <range>` except for the special
> case of `git diff <commit>...<commit>`, or should we _only_ deprecate
> `git diff <commit>..<commit>` and allow all other forms of ranges, even
> though it was undocumented behaviour?
> 
> Thanks,
> 
> Denton
> 
> [1]: https://public-inbox.org/git/xmqqmumy6mxe.fsf@gitster-ct.c.googlers.com/
> 
Previous: Denton LiuNext: Elijah Newren
Message 2 of 14 in “Deprecating git diff ..; dealing with other ranges”
  1. Denton LiuMar 11, 2019
  2. Johannes SchindelinMar 11, 2019
  3. Elijah NewrenMar 11, 2019
  4. Junio C HamanoMar 12, 2019
  5. Andreas SchwabMar 12, 2019
  6. Ævar Arnfjörð BjarmasonMar 12, 2019
  7. Johannes SixtMar 13, 2019
  8. Elijah NewrenMar 18, 2019
  9. Michal SuchánekMar 18, 2019
  10. Elijah NewrenMar 18, 2019
  11. Ævar Arnfjörð BjarmasonMar 18, 2019
  12. Duy NguyenMar 13, 2019
  13. Andreas SchwabMar 13, 2019
  14. Junio C HamanoMar 12, 2019

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.