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

Re: [PATCH 10/10] t5710: use proper file:// URIs for absolute paths

From
Christian Couder <christian.couder@gmail.com>
Date
Apr 3, 2026, 08:16 UTC
Message-ID
<CAP8UFD3CMwTjC36Grhb6_6q0SBWtTwBX4_kM5sf+peTgd7P3dA@mail.gmail.com>
In-Reply-To
<xmqqa4vlu1ij.fsf@gitster.g>
On Thu, Apr 2, 2026 at 11:58 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 30 quoted lines
>
> Christian Couder <christian.couder@gmail.com> writes:
>
> > +# On Windows, 'pwd' returns a path like 'D:/foo/bar'. Prepend '/' to turn
> > +# it into '/D:/foo/bar', which is what git expects in file:// URLs on Windows.
> > +# On Unix, the path already starts with '/', so this is a no-op.
> > +pwd_path=$(pwd)
> > +case "$pwd_path" in
> > +[a-zA-Z]:*) pwd_path="/$pwd_path" ;;
> > +esac
> > +PWD_URL="file://$pwd_path"
> > +# Same as PWD_URL but with spaces percent-encoded, for use in URL patterns.
> > +ENCODED_PWD_URL="file://$(echo "$pwd_path" | sed "s/ /%20/g")"
>
> Two comments.
>
>  - I was a bit surprised that these are not given as functions but
>    as variables, as a caller that chdirs around in the trash
>    directory would want a URL that points at its current working
>    directory (the expectation is from "pwd" in the name PWD_URL).
>    But a variable based interface "Here is the URL that corresponds
>    to the trash directory" is OK and probably easier to use than
>    "give me the URL corresponding to my current working directory",
>    simply because it allows a caller to append some string to it to
>    come up with a URL for any subdirectory on its own without
>    actually going there.  But in that case, the name PWD_URL would
>    become misleading, as it is PWD as of the moment the variable
>    gets defined, and the true meaning of the variable is not "URL
>    for the current directory", but "URL for the trash directory" is
>    more usable definition.
Right. I will use something like the following then:

TRASH_DIRECTORY_URL="file://$pwd_path" ENCODED_TRASH_DIRECTORY_URL="file://$encoded_path"

Show 6 quoted lines
>  - Is it sufficient to only special case SP?  My repository may be
>    $HOME/w/git.git, for example, and the trash repository may be
>    "$HOME/w/git.git/t/trash directory.t5710/", so you need to cope
>    with SP between "trash" and "directory" the test framework adds
>    (to force you to be careful), but the test framework does not
>    control what can be in the leading $HOME part.

I think it's quite unlikely for users to have strange characters in $HOME, but OK let's be cautious and encode a larger set than just space characters. And to be extra safe, let's also skip all the tests if we detect a special character not in the larger set.

So something like:
# Allowed characters: alphanumeric, standard path/URI (_ . ~ / : -),
and those percent-encoded below (% space = ; ,)
case "$pwd_path" in
*[!a-zA-Z0-9_.~/:%\ =,;-]*)
        skip_all="PWD contains unsupported special characters"
        test_done
        ;;
esac

encoded_path=$(printf "%s" "$pwd_path" | sed -e 's/%/%25/g' -e 's/ /%20/g' -e 's/=/%3D/g' -e 's/;/%3B/g' -e 's/,/%2C/g')

Previous: Junio C HamanoNext: Christian Couder
Message 17 of 35 in “Prepare for advertised remotes auto-configure via URL allowlist”
  1. 00/10 Prepare for advertised remotes auto-configure via URL allowlistChristian Couder, Apr 2, 2026
  2. 01/10 promisor-remote: try accepted remotes before others in get_direct()Christian Couder, Apr 2, 2026
  3. Patrick SteinhardtApr 2, 2026
  4. Christian CouderApr 7, 2026
  5. Junio C HamanoApr 7, 2026
  6. 02/10 promisor-remote: pass config entry to all_fields_match() directlyChristian Couder, Apr 2, 2026
  7. 03/10 promisor-remote: clarify that a remote is ignoredChristian Couder, Apr 2, 2026
  8. 04/10 promisor-remote: reject empty name or URL in advertised remoteChristian Couder, Apr 2, 2026
  9. Patrick SteinhardtApr 2, 2026
  10. 05/10 promisor-remote: refactor should_accept_remote() control flowChristian Couder, Apr 2, 2026
  11. 06/10 promisor-remote: refactor has_control_char()Christian Couder, Apr 2, 2026
  12. 07/10 promisor-remote: refactor accept_from_server()Christian Couder, Apr 2, 2026
  13. 08/10 promisor-remote: keep accepted promisor_info structs aliveChristian Couder, Apr 2, 2026
  14. 09/10 promisor-remote: remove the 'accepted' strvecChristian Couder, Apr 2, 2026
  15. 10/10 t5710: use proper file:// URIs for absolute pathsChristian Couder, Apr 2, 2026
  16. Junio C HamanoApr 2, 2026
  17. Christian CouderApr 3, 2026
  18. Christian CouderApr 7, 2026
  19. Patrick SteinhardtApr 2, 2026
  20. Junio C HamanoApr 2, 2026
  21. Christian CouderApr 7, 2026
  22. 00/10 Prepare for advertised remotes auto-configure via URL allowlistChristian Couder, Apr 7, 2026
  23. 01/10 promisor-remote: try accepted remotes before others in get_direct()Christian Couder, Apr 7, 2026
  24. 02/10 promisor-remote: pass config entry to all_fields_match() directlyChristian Couder, Apr 7, 2026
  25. Junio C HamanoApr 7, 2026
  26. 03/10 promisor-remote: clarify that a remote is ignoredChristian Couder, Apr 7, 2026
  27. Junio C HamanoApr 7, 2026
  28. 04/10 promisor-remote: reject empty name or URL in advertised remoteChristian Couder, Apr 7, 2026
  29. Junio C HamanoApr 7, 2026
  30. 05/10 promisor-remote: refactor should_accept_remote() control flowChristian Couder, Apr 7, 2026
  31. 06/10 promisor-remote: refactor has_control_char()Christian Couder, Apr 7, 2026
  32. 07/10 promisor-remote: refactor accept_from_server()Christian Couder, Apr 7, 2026
  33. 08/10 promisor-remote: keep accepted promisor_info structs aliveChristian Couder, Apr 7, 2026
  34. 09/10 promisor-remote: remove the 'accepted' strvecChristian Couder, Apr 7, 2026
  35. 10/10 t5710: use proper file:// URIs for absolute pathsChristian Couder, Apr 7, 2026

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.