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

Re: [PATCH] t1300: document some aesthetic failures of the config editor

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 28, 2018, 16:33 UTC
Message-ID
<nycvar.QRO.7.76.6.1803281220100.77@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz>
In-Reply-To
<20130329195155.GA19994@sigill.intra.peff.net>
Hi Peff,
On Fri, 29 Mar 2013, Jeff King wrote:
Show 27 quoted lines
> Subject: [PATCH] t1300: document some aesthetic failures of the config editor
>
> [...]
> 
> diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
> index 3c96fda..213e5a8 100755
> --- a/t/t1300-repo-config.sh
> +++ b/t/t1300-repo-config.sh
> @@ -1087,4 +1087,34 @@ test_expect_success 'barf on incomplete string' '
>  	grep " line 3 " error
>  '
>  
> +# good section hygiene
> +test_expect_failure 'unsetting the last key in a section removes header' '
> +	cat >.git/config <<-\EOF &&
> +	[section]
> +	# some intervening lines
> +	# that should also be dropped
> +
> +	key = value
> +	EOF
> +
> +	>expect &&
> +
> +	git config --unset section.key &&
> +	test_cmp expect .git/config
> +'

This would have been good on its own. This documents what a user may expect, and it is a reasonable expectation.

However, Junio, what you suggested in addition *and squashed in before merging to `master`*, is not a reasonable expectation. If you are asking *code* to determine that in a config like this, the second line is a comment belonging to the section, and the first line is not, that is totally unreasonable:

        # some generic comment on the configuration file itself
        # a comment specific to this "section" section.
        [section]
        # some intervening lines
        # that should also be dropped
        key = value
        # please be careful when you update the above variable
Worse: it does *not* demonstrate a known breakage, at least not precisely,
as what you ask here *is not technically possible*. Not even with NLP, at
least if you drive for 100%. It's just not.
And your example is not even complete, as this is a totally valid config:
	[core]
		; These settings affect many Git operations; be careful
		; what you change here
		key = value

Obviously, your example gives the impression that `git config --unset core.key` shoud *delete* that comment (that obviously is intended to document the section, not the `key` value).

And this is bad, really bad. And this comment does not make it better:
	I think we may not attain that ideal without some natural language
	processing of the comments. But hey, no reason not to shoot for the
	stars. :)
There *is* a reason, a very good reason *not* to shoot for the stars.

Think about it. The `test_expect_failure` function is intended to demonstrate bugs, and once those bugs are fixed, the _failure should be turned into _success. And if somebody looks for work, they can look for test_expect_failure and find tons of micro-projects.

What you did there was to change some valid demonstration of a bug that can be fixed to something that cannot be fixed. So if an occasional lurker comes along, sees what you expect to be fixed, they would have said "Whoa!" and you lost a contribution.

Let's avoid such a "shoot for the stars [... and get nothing, not even an incremental improvement in return...]" in the future.

On a positive note: I just finished work on a set of patches addressing this: https://github.com/git/git/compare/master...dscho:empty-config-section (I plan on submitting this tomorrow)

Ciao, Dscho

P.S.: While I am already raising awareness about unintended consequences, let me also add this: that "cute" feature that unambiguous abbreviations of options are allowed bit me royally today. Try this: `git config --remove section.key`. And then be surprised that it does not work, even if you have that entry. The reason? The option `--remove` is a unique abbreviation of `--remove-section`, so even if I clearly meant `--unset`, that feature (that every Git user I tell about it is very surprised to hear about, so it is not like it is helping a lot of users) has the unintended consequence of being completely wrong. It would have been better to tell me that there is no `--remove` option.

Previous: Jeff KingNext: Jeff King
Message 10 of 13 in “Minor bug in git branch --set-upstream-to adding superfluous branch section to config”
  1. Phil HaackMar 29, 2013
  2. Jeff KingMar 29, 2013
  3. Thomas RastMar 29, 2013
  4. Jeff KingMar 29, 2013
  5. t1300: document some aesthetic failures of the config editorJeff King, Mar 29, 2013
  6. Junio C HamanoMar 29, 2013
  7. Jeff KingMar 29, 2013
  8. Junio C HamanoMar 29, 2013
  9. Jeff KingMar 30, 2013
  10. Johannes SchindelinMar 28, 2018
  11. Jeff KingMar 28, 2018
  12. Junio C HamanoMar 29, 2013
  13. Junio C HamanoMar 29, 2013

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.