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

Re: [PATCH 1/3] t0301: fixes for windows compatibility

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 13, 2021, 01:04 UTC
Message-ID
<xmqq1r5ti8vn.fsf@gitster.g>
In-Reply-To
<20210912202830.25720-2-carenas@gmail.com>
Carlo Marcelo Arenas Belón  <carenas@gmail.com> writes:
Show 6 quoted lines
> In preparation for a future patch that will allow building with
> Unix Sockets in Windows, workaround a couple of issues from the
> Mingw-W64 compatibility layer.
>
> test -S is not able to detect that a file is a socket, so use
> test -f instead.
The cause deserves to be sympathized, but ...
Show 20 quoted lines
> +# in Windows, Unix Sockets look just like regular files
> +uname_s=$(uname -s)
> +case $uname_s in
> +*MINGW*)
> +	FLAG=-f
> +	;;
> +*)
> +	FLAG=-S
> +	;;
> +esac
> +
>  # don't leave a stale daemon running
>  test_atexit 'git credential-cache exit'
>  
> @@ -21,7 +32,7 @@ test_expect_success 'socket defaults to ~/.cache/git/credential/socket' '
>  		rmdir -p .cache/git/credential/
>  	" &&
>  	test_path_is_missing "$HOME/.git-credential-cache" &&
> -	test -S "$HOME/.cache/git/credential/socket"
> +	test $FLAG "$HOME/.cache/git/credential/socket"

This is horrible. Unlike the original, it is now impossible for a casual reader to tell what this thing is testing, because $FLAG is so generic a name that does not convey anything to readers.

Introduce a helper, say, "test_socket_exists", and replace "test -S" with it. In the implementation of that test_socket_exists() helper, you can hide the difference between -f and -S. In such a small scope, you can even call the variable $FLAG if you want, as it is so isolated.

> -	mkdir -p -m 700 "$HOME/.git-credential-cache/" &&
> +	mkdir -p "$HOME/.git-credential-cache/" &&
> +	chmod 700 "$HOME/.git-credential-cache/" &&

OK. This is the only use of "mkdir -m MODE" in the test suite. It is strange that you are OK with "mkdir && chmod 700" but not OK with "mkdir -m 700" (it just is illogical, but we have to live with it, as the real world may not be logical after all).

It is somewhat strange that we insist on mode 700 but the test does not have SANITY as its prerequisite. Does it really matter if we set the permission bits to close the directory from others? If not, our "portability clean-up" could just be to lose "-m 700" here.

Thanks.
Show 20 quoted lines
>  	check approve cache <<-\EOF &&
>  	protocol=https
>  	host=example.com
>  	username=store-user
>  	password=store-pass
>  	EOF
> -	test -S "$HOME/.git-credential-cache/socket"
> +	test $FLAG "$HOME/.git-credential-cache/socket"
>  '
>  
>  test_expect_success SYMLINKS 'use user socket if user directory is a symlink to a directory' '
> @@ -103,7 +115,7 @@ test_expect_success SYMLINKS 'use user socket if user directory is a symlink to
>  	username=store-user
>  	password=store-pass
>  	EOF
> -	test -S "$HOME/.git-credential-cache/socket"
> +	test $FLAG "$HOME/.git-credential-cache/socket"
>  '
>  
>  helper_test_timeout cache --timeout=1
Previous: Carlo Marcelo Arenas BelónNext: Bagas Sanjaya
Message 3 of 27 in “windows: allow building without NO_UNIX_SOCKETS”
  1. 0/3 windows: allow building without NO_UNIX_SOCKETSCarlo Marcelo Arenas Belón, Sep 12, 2021
  2. 1/3 t0301: fixes for windows compatibilityCarlo Marcelo Arenas Belón, Sep 12, 2021
  3. Junio C HamanoSep 13, 2021
  4. Bagas SanjayaSep 13, 2021
  5. Carlo ArenasSep 13, 2021
  6. Junio C HamanoSep 13, 2021
  7. 3/3 git-compat-util: include declaration for unix socketsCarlo Marcelo Arenas Belón, Sep 12, 2021
  8. 2/3 credential-cache: check for windows specific errorsCarlo Marcelo Arenas Belón, Sep 12, 2021
  9. Junio C HamanoSep 13, 2021
  10. 0/3 windows: allow building without NO_UNIX_SOCKETSCarlo Marcelo Arenas Belón, Sep 13, 2021
  11. 1/3 t0301: fixes for windows compatibilityCarlo Marcelo Arenas Belón, Sep 13, 2021
  12. Johannes SchindelinSep 13, 2021
  13. Junio C HamanoSep 13, 2021
  14. 2/3 credential-cache: check for windows specific errorsCarlo Marcelo Arenas Belón, Sep 13, 2021
  15. Johannes SchindelinSep 13, 2021
  16. 3/3 git-compat-util: include declaration for unix socketsCarlo Marcelo Arenas Belón, Sep 13, 2021
  17. Johannes SchindelinSep 13, 2021
  18. Johannes SchindelinSep 13, 2021
  19. 0/3 windows: allow building without NO_UNIX_SOCKETSCarlo Marcelo Arenas Belón, Sep 14, 2021
  20. 1/3 t0301: fixes for windows compatibilityCarlo Marcelo Arenas Belón, Sep 14, 2021
  21. Ævar Arnfjörð BjarmasonNov 2, 2021
  22. 2/3 credential-cache: check for windows specific errorsCarlo Marcelo Arenas Belón, Sep 14, 2021
  23. Junio C HamanoSep 14, 2021
  24. What should happen in credential-cache on recoverable error without SPAWN option?Junio C Hamano, Sep 14, 2021
  25. Jeff KingSep 14, 2021
  26. 3/3 git-compat-util: include declaration for unix sockets in windowsCarlo Marcelo Arenas Belón, Sep 14, 2021
  27. Junio C HamanoSep 14, 2021

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.