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

Re: [PATCH v1 2/4] fsmonitor: update GIT_TEST_FSMONITOR support

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 14, 2018, 17:03 UTC
Message-ID
<xmqqd0tgc8pn.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<xmqqmuskc8wj.fsf@gitster-ct.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 36 quoted lines
> Ben Peart <benpeart@microsoft.com> writes:
>
>> +if test -n "$GIT_FSMONITOR_TEST"
>> +then
>> +	if test -n "$GIT_TEST_FSMONITOR"
>> +	then
>> +		echo "warning: the GIT_FSMONITOR_TEST variable has been renamed to GIT_TEST_FSMONITOR"
>> +	else
>> +		echo "error: the GIT_FSMONITOR_TEST variable has been renamed to GIT_TEST_FSMONITOR"
>> +		exit 1
>> +	fi
>> +fi
>
> I would have expected that, because we are now doing multiple pairs
> of variables in a single series, we would add a helper function that
> can be called like so:
>
> 	check_var_migration GIT_FSMONITOR_TEST GIT_TEST_FSMONITOR
>
> in the earliest step.  Perhaps something like this.
>
> check_var_migration () {
> 	old_name=$1 new_name=$2
> 	eval "old_isset=\${${old_name}:+isset}"
> 	eval "new_isset=\${${new_name}:+isset}"
> 	case "$old_isset,$new_isset" in
> 	isset,)
> 		echo >&2 "error: $old_name is now $new_name"
> 		exit 1 ;;
> 	isset,isset)
> 		# enable this, once $old_name no longer is valid anywhere
> 		# echo >&2 "warning: $old_name is now $new_name"
> 		# echo >&2 "hint: remove $old_name"
> 		;;
> 	esac
> }

Alternatively, we could do this, to warn and then migrate the value given to the old variable automatically to the new variable and let the test proceed.

check_var_migration () {
	old_name=$1 new_name=$2
	eval "old_isset=\${${old_name}:+isset}"
	eval "new_isset=\${${new_name}:+isset}"
	case "$old_isset,$new_isset" in
	isset,)
		echo >&2 "warning: $old_name is now $new_name"
		echo >&2 "hint: set $new_name too during the transition period"
		eval "$new_name=\$$old_name"
		;;
	isset,isset)
		# do this later
		# echo >&2 "warning: $old_name is now $new_name"
		# echo >&2 "hint: remove $old_name"
		;;
	esac
}
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 33 in “Cleanup pass on special test setups”
  1. 0/4 Cleanup pass on special test setupsBen Peart, Sep 14, 2018
  2. 1/4 correct typo/spelling error in t/READMEBen Peart, Sep 14, 2018
  3. 2/4 fsmonitor: update GIT_TEST_FSMONITOR supportBen Peart, Sep 14, 2018
  4. Junio C HamanoSep 14, 2018
  5. Junio C HamanoSep 14, 2018
  6. Junio C HamanoSep 14, 2018
  7. Ben PeartSep 14, 2018
  8. Junio C HamanoSep 14, 2018
  9. 0/5 Cleanup pass on special test setupsBen Peart, Sep 14, 2018
  10. 1/5 correct typo/spelling error in t/READMEBen Peart, Sep 14, 2018
  11. Jonathan NiederSep 14, 2018
  12. 2/5 preload-index: teach GIT_FORCE_PRELOAD_TEST to take a booleanBen Peart, Sep 14, 2018
  13. Jonathan NiederSep 14, 2018
  14. Junio C HamanoSep 14, 2018
  15. 3/5 fsmonitor: update GIT_TEST_FSMONITOR supportBen Peart, Sep 14, 2018
  16. 4/5 read-cache: update TEST_GIT_INDEX_VERSION supportBen Peart, Sep 14, 2018
  17. Junio C HamanoSep 14, 2018
  18. Junio C HamanoSep 14, 2018
  19. 5/5 preload-index: update GIT_FORCE_PRELOAD_TEST supportBen Peart, Sep 14, 2018
  20. 3/4 read-cache: update TEST_GIT_INDEX_VERSION supportBen Peart, Sep 14, 2018
  21. 4/4 preload-index: update GIT_FORCE_PRELOAD_TEST supportBen Peart, Sep 14, 2018
  22. 0/5 Cleanup pass on special test setupsBen Peart, Sep 18, 2018
  23. 1/5 t/README: correct spelling of "uncommon"Ben Peart, Sep 18, 2018
  24. 2/5 preload-index: use git_env_bool() not getenv() for customizationBen Peart, Sep 18, 2018
  25. 3/5 fsmonitor: update GIT_TEST_FSMONITOR supportBen Peart, Sep 18, 2018
  26. SZEDER GáborSep 28, 2018
  27. Ben PeartSep 28, 2018
  28. Ben PeartSep 28, 2018
  29. Junio C HamanoSep 28, 2018
  30. 4/5 read-cache: update TEST_GIT_INDEX_VERSION supportBen Peart, Sep 18, 2018
  31. 5/5 preload-index: update GIT_FORCE_PRELOAD_TEST supportBen Peart, Sep 18, 2018
  32. Re*: [PATCH v3 0/5] Cleanup pass on special test setupsJunio C Hamano, Sep 20, 2018
  33. Ben PeartSep 25, 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.