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

Re: Missing git options

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Feb 6, 2018, 18:27 UTC
Message-ID
<20180206182755.GD104086@aiede.svl.corp.google.com>
In-Reply-To
<C6AF93BC-048F-4944-AB87-36AC2A5C5466@schwarz-online.org>
Hi,
Martin Häcker wrote:
>> Am 06.02.2018 um 01:43 schrieb brian m. carlson <sandals@crustytoothpaste.net>:
Show 8 quoted lines
>> I think this is likely to cause problems.  Many people use git log with
>> --pretty to format commit hashes or messages into other programs.  I'm
>> aware of multiple tools that will simply break if --graph or --patch
>> become the default.  Requiring people to retrofit their tools to use
>> --no-graph or --no-patch is likely to be a burden.
>
> While I share your concern, this is something that will completely
> freeze development of the git tui which I cannot imagine is wanted.

On the contrary, we take things on a case by case basis. Brian described a cost to your proposed change and you described a benefit; the next step would be to figure out a way to accomplish what you're aiming to do in a way that maximizes the benefit and minimizes the cost.

In other words, it is not that we never change default output formats, but we do care a lot about helping existing users. One way of doing that is to provide more convenient machine-readable versions of some commands so that it is obvious to script writers what to use.

As Stefan Beller mentioned, "git log" is in interesting case, in that the scripting commands exist:

 - "git rev-list" to list commits satisfying some criteria
 - "git diff-tree --stdin" to show information about those commits

But these commands were not sufficiently discoverable and easy to use, so people end up using "git log" for scripting anyway. We provide

 - "git log --format" to produce log output with a fixed format, and
   in particular
 - "git log --format=raw" to print raw objects

It's perfectly normal and common to change what "git log --format=medium" (the default format) prints, as long as we take into account the effect on existing users. In particular:

 - Some scripts do not care about the *exact* format from "git log"
   but are using the output for a particular purpose (e.g. to generate
   release notes that they distribute along with compiler output).
   If these scripts start _sometimes_ using --graph instead based on
   configuration, this would be disruptive to some users.
 - Making --format suppress `log.graph` configuration feels confusing
   and hard to explain to me.  --graph --format=<x> would mean something
   different from -c log.graph=true --format=<x>, except when <x> =
   medium, or "--format=medium" would mean something different from not
   specifying --format at all even though medium is the default format.
In that context, it feels simpler to me to use aliases:
	[alias]
		l = log --oneline --graph --patch

That way, it does not confuse scripts, and even better, it is easier to type, as "git l".

I would be happy to see some documentation pointing users to the alias feature for this purpose.

As an example of changing the default "git log" format, see the history in "git log --grep=decorate". I am all for that kind of change, but I don't think --graph or --patch falls into this category.

Thanks and hope that helps, Jonathan

Previous: Duy Nguyen
Message 8 of 8 in “Missing git options”
  1. Martin HäckerFeb 5, 2018
  2. Stefan BellerFeb 5, 2018
  3. Junio C HamanoFeb 5, 2018
  4. Ævar Arnfjörð BjarmasonFeb 5, 2018
  5. brian m. carlsonFeb 6, 2018
  6. Martin HäckerFeb 6, 2018
  7. Duy NguyenFeb 6, 2018
  8. Jonathan NiederFeb 6, 2018

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.