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

Re: [PATCH v5 4/4] commit: Add commit.verbose configuration

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 16, 2014, 22:25 UTC
Message-ID
<xmqq38f4pk4t.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20140616201037.GA37953@sirius.local>
Caleb Thompson <caleb@calebthompson.io> writes:
Show 20 quoted lines
>> Again, what are we testing, exactly?
>>
>> We do not want to see "^diff --git" in the output file, in other
>> words, we want to make sure "^diff --git" does not appear in the
>> output.
>>
>> So
>>
>>         write_script check-for-no-diff <<-\EOF
>>         ! grep '^diff --git' "$@"
>>	EOF
>>
>> should be the most natural way to express what we are testing, no?
>
> I did consider that. The reason I didn't propose that is that it doesn't catch
> the unlikely case that the $1 only contains a "diff --git" line or that $1 is
> empty.
>
> Those are rather unreasonable concerns, so I'm happy to use the much more
> readable version as you propose.

If it only has "diff --git", then the grep will find a hit, exits with success, the script yields the opposite and "git commit" will fail, which is what we want, so that is OK. "$1 is empty" may or may not be an error, depending on your settings, I guess (i.e. can't we squelch the "# helpful instruction" lines altogether?)?

If the editor input is expected to be very stable, we could even do something like:

	write_script check-editor-input <<-\EOF
	diff expect "$1" >&2
        EOF
and then catch any deviation from the norm with something like:
	cat >expect <<-\EOF &&
        ... expected editor input comes here ...
        EOF
        test_set_editor "$PWD/check-editor-input &&
	git commit --amend

but if the editor input may easily be affected by volatile things like blob object names given in the diff output by "commit -v" or untracked cruft in the working tree listed in the status output, then it would add unnecessary maintenance burden (every time earlier parts of the test scripts are updated, the expected output may have to change to adjust to these non-essential details), so it is a judgment call.

Thanks.
Previous: Caleb ThompsonNext: Jeremiah Mahler
Message 24 of 28 in “commit: Add commit.verbose configuration”
  1. 0/4 commit: Add commit.verbose configurationCaleb Thompson, Jun 12, 2014
  2. 1/4 commit test: Use test_config instead of git-configCaleb Thompson, Jun 12, 2014
  3. 2/4 commit test: Use write_scriptCaleb Thompson, Jun 12, 2014
  4. Jeff KingJun 13, 2014
  5. Caleb ThompsonJun 13, 2014
  6. Jeff KingJun 13, 2014
  7. 3/4 commit test: test_set_editor in each testCaleb Thompson, Jun 12, 2014
  8. Jeff KingJun 13, 2014
  9. Caleb ThompsonJun 13, 2014
  10. Jakub NarębskiJun 13, 2014
  11. Caleb ThompsonJun 13, 2014
  12. Jakub NarębskiJun 13, 2014
  13. Jeff KingJun 13, 2014
  14. Junio C HamanoJun 13, 2014
  15. Jeff KingJun 13, 2014
  16. Caleb ThompsonJun 16, 2014
  17. Junio C HamanoJun 16, 2014
  18. 4/4 commit: Add commit.verbose configurationCaleb Thompson, Jun 12, 2014
  19. Junio C HamanoJun 13, 2014
  20. Caleb ThompsonJun 16, 2014
  21. Caleb ThompsonJun 16, 2014
  22. Junio C HamanoJun 16, 2014
  23. Caleb ThompsonJun 16, 2014
  24. Junio C HamanoJun 16, 2014
  25. Jeremiah MahlerJun 12, 2014
  26. Caleb ThompsonJun 13, 2014
  27. Jeremiah MahlerJun 14, 2014
  28. Junio C HamanoJun 16, 2014

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.