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

Re: Git's inconsistent command line options

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 26, 2015, 17:56 UTC
Message-ID
<xmqqio822atc.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CAE1pOi3e8KS9x5yD7CZLESvhXy1oXmQEgUnEFjww7L6JOdZ1Jg@mail.gmail.com>
Hilco Wijbenga <hilco.wijbenga@gmail.com> writes:
Show 18 quoted lines
> On 25 August 2015 at 16:43, Junio C Hamano <gitster@pobox.com> wrote:
>> I do not see a good way to do such a safe transition with command
>> words approach, *unless* we are going to introduce new commands,
>> i.e. "git list-tag", "git create-tag", etc.
>
> Perhaps we could introduce a more explicit notion (in .git/config) of
> a Git API version (or, perhaps more accurate, a Git CLI API version)?
> ...
> I think that from a user's point of view this could work quite well.
> Obviously, (worst case scenario) Git commands might have to support up
> to 3 APIs at the same time (previous [2], current [3], and future [4]
> for Git 3.x) so from a code maintenance POV it would certainly
> introduce complexity and probably some duplication of code. I'm
> hopeful it would be limited to CL argument processing but I suspect
> that when Git code calls other Git code (especially in the Bash based
> commands) there might be some more complexity there.
>
> Would something like that be feasible?

A bigger issue you need to think about is what to do to scripts people have. Your approach forces them to update a script to delete a tag and do something else to say something silly like this:

	#!/bin/sh
        # My Script
	case "$(git config core.apiVersion)" in
        "" | 2)
		git tag -d "$1"
                do something else on "$1" using v2 API
                ;;
        3)
		git tag delete "$1"
                do something else on "$1" using v3 API
                ;;
	*)
        	echo >&2 "sorry, I do not know what Git you are using"
		exit 1
                ;;
	esac

So, it may be feasible to implement, but I do not think it would be useful to do so.

Instead, if you really want to invent the multi-version world, you would rather want to have something more like this:

	#!/bin/sh
        # My Script
	GIT_API_VERSION=2
	export GIT_API_VERSION
	git tag -d "$1"
        do something else on "$1" using v2 API

But notice that I said "if you really want to". I personally think it is a road to madness.

Previous: Hilco WijbengaNext: Jacob Keller
Message 8 of 25 in “Git's inconsistent command line options”
  1. Graeme GeldenhuysAug 25, 2015
  2. Junio C HamanoAug 25, 2015
  3. Jacob KellerAug 25, 2015
  4. Stefan BellerAug 25, 2015
  5. Jacob KellerAug 25, 2015
  6. Junio C HamanoAug 25, 2015
  7. Hilco WijbengaAug 26, 2015
  8. Junio C HamanoAug 26, 2015
  9. Jacob KellerAug 26, 2015
  10. Junio C HamanoAug 26, 2015
  11. Philip OakleyAug 26, 2015
  12. Jacob KellerAug 26, 2015
  13. Jacob KellerAug 26, 2015
  14. Jacob KellerAug 26, 2015
  15. Andreas SchwabAug 26, 2015
  16. Jacob KellerAug 26, 2015
  17. Duy NguyenAug 31, 2015
  18. Barry WarsawAug 31, 2015
  19. David AguilarSep 1, 2015
  20. Barry WarsawSep 1, 2015
  21. Junio C HamanoSep 1, 2015
  22. Barry WarsawSep 1, 2015
  23. Stefan BellerSep 1, 2015
  24. Michael J GruberSep 9, 2015
  25. Michael J GruberSep 9, 2015

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.