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

Re: [PATCH v3 0/8] builtin: implement, document and test url-parse

From
Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
Date
May 3, 2026, 19:36 UTC
Message-ID
<6c0a1601cd379bcdc87b4fe3b854166a@matheusmoreira.com>
In-Reply-To
<20260503172838.GA22957@tb-raspi4>
> Reviewers comment: Nicely done.
Thank you!
Show 6 quoted lines
> More a question to myself, may be, about t9904 (and may be other parts)
> I have in mind that the parser learned to handle
>
> file://server/share/repo
> correctly under Windows.
> I don't know if this needs to be addressed here or in a follow-up commit ?

I'd be happy to revisit this in a follow-up. It's been a while since I used MSYS but I do remember the fact it rewrites paths internally. I wasn't sure how to handle it properly in the tests.

The problematic test case is:
    test_must_fail git url-parse "/abs/path" 2>err &&
      test_grep "is not a URL" err &&
      test_grep "file:///abs/path" err

MSYS bash rewrites /abs/path to C:/Program Files/Git/abs/path before git even runs. This edge case caused the error message:

    fatal: 'C:/Program Files/Git/abs/path' is not a URL;
    if you meant a local repository, use a 'file://' URL
    with an absolute path

The test_grep "is not a URL" passed but test_grep "file:///abs/path" failed because the suggestion did not contain the literal string "file:///abs/path". The drive letter broke the tool's absolute path recognition: it was printing the generic error message.

The fix was to use has_dos_drive_prefix() to recognize the edge case. However, that led to the generation of error messages containing paths that I wasn't sure if I could depend on in the test suite, such as:

    file:///C:/Program Files/Git/abs/path
So I decided to relax the test case just a little:
    test_must_fail git url-parse "/abs/path" 2>err &&
      test_grep "is not a URL" err &&
      test_grep "file:///" err

The "file:///" checks that the path was properly recognized and that the friendlier error message was printed, all while avoiding the hard coding of a "C:/Program Files/Git" prefix that may or may not vary depending on testing environment.

In any case, the parser already handles it correctly.
It decomposes:
    file://server/share/repo
As:
  - scheme: file
  - host:   server
  - path:   /share/repo
Which is the correct interpretation.

On Windows, connect.c then takes that data and reconstructs the UNC path \\server\share\repo for the filesystem. So the UNC reconstruction happens downstream in connect.c, not directly in the url-parse builtin or url_parse logic.

    Matheus
Previous: Torsten BögershausenNext: Junio C Hamano
Message 42 of 44 in “builtin: implement, document and test url-parse”
  1. 00/13 builtin: implement, document and test url-parseMatheus Moreira via GitGitGadget, Apr 28, 2024
  2. 01/13 url: move helper function to URL header and sourceMatheus Afonso Martins Moreira via GitGitGadget, Apr 28, 2024
  3. 02/13 urlmatch: define url_parse functionMatheus Afonso Martins Moreira via GitGitGadget, Apr 28, 2024
  4. Ghanshyam ThakkarMay 1, 2024
  5. Torsten BögershausenMay 2, 2024
  6. 03/13 builtin: create url-parse commandMatheus Afonso Martins Moreira via GitGitGadget, Apr 28, 2024
  7. 04/13 url-parse: add URL parsing helper functionMatheus Afonso Martins Moreira via GitGitGadget, Apr 28, 2024
  8. 05/13 url-parse: enumerate possible URL componentsMatheus Afonso Martins Moreira via GitGitGadget, Apr 28, 2024
  9. 06/13 url-parse: define component extraction helper fnMatheus Afonso Martins Moreira via GitGitGadget, Apr 28, 2024
  10. 07/13 url-parse: define string to component converter fnMatheus Afonso Martins Moreira via GitGitGadget, Apr 28, 2024
  11. 08/13 url-parse: define usage and optionsMatheus Afonso Martins Moreira via GitGitGadget, Apr 28, 2024
  12. 09/13 url-parse: parse options given on the command lineMatheus Afonso Martins Moreira via GitGitGadget, Apr 28, 2024
  13. 10/13 url-parse: validate all given git URLsMatheus Afonso Martins Moreira via GitGitGadget, Apr 28, 2024
  14. 11/13 url-parse: output URL components selected by userMatheus Afonso Martins Moreira via GitGitGadget, Apr 28, 2024
  15. 12/13 Documentation: describe the url-parse builtinMatheus Afonso Martins Moreira via GitGitGadget, Apr 28, 2024
  16. Ghanshyam ThakkarApr 30, 2024
  17. 13/13 tests: add tests for the new url-parse builtinMatheus Afonso Martins Moreira via GitGitGadget, Apr 28, 2024
  18. Torsten BögershausenApr 29, 2024
  19. Reply to community feedbackMatheus Afonso Martins Moreira, Apr 29, 2024
  20. Torsten BögershausenApr 30, 2024
  21. 0/8 builtin: implement, document and test url-parseMatheus Moreira via GitGitGadget, May 1, 2026
  22. 1/8 connect: rename enum protocol to url_schemeMatheus Afonso Martins Moreira via GitGitGadget, May 1, 2026
  23. 2/8 url: move url_is_local_not_ssh to url.hMatheus Afonso Martins Moreira via GitGitGadget, May 1, 2026
  24. 3/8 url: move scheme detection to URL header/sourceMatheus Afonso Martins Moreira via GitGitGadget, May 1, 2026
  25. 4/8 url: return URL_SCHEME_UNKNOWN instead of dyingMatheus Afonso Martins Moreira via GitGitGadget, May 1, 2026
  26. 5/8 urlmatch: define url_parse functionMatheus Afonso Martins Moreira via GitGitGadget, May 1, 2026
  27. 6/8 builtin: create url-parse commandMatheus Afonso Martins Moreira via GitGitGadget, May 1, 2026
  28. 7/8 doc: describe the url-parse builtinMatheus Afonso Martins Moreira via GitGitGadget, May 1, 2026
  29. 8/8 t9904: add tests for the new url-parse builtinMatheus Afonso Martins Moreira via GitGitGadget, May 1, 2026
  30. 0/8 builtin: implement, document and test url-parseMatheus Moreira via GitGitGadget, May 2, 2026
  31. 1/8 connect: rename enum protocol to url_schemeMatheus Afonso Martins Moreira via GitGitGadget, May 2, 2026
  32. 2/8 url: move url_is_local_not_ssh to url.hMatheus Afonso Martins Moreira via GitGitGadget, May 2, 2026
  33. 3/8 url: move scheme detection to URL header/sourceMatheus Afonso Martins Moreira via GitGitGadget, May 2, 2026
  34. 4/8 url: return URL_SCHEME_UNKNOWN instead of dyingMatheus Afonso Martins Moreira via GitGitGadget, May 2, 2026
  35. 5/8 urlmatch: define url_parse functionMatheus Afonso Martins Moreira via GitGitGadget, May 2, 2026
  36. 6/8 builtin: create url-parse commandMatheus Afonso Martins Moreira via GitGitGadget, May 2, 2026
  37. 7/8 doc: describe the url-parse builtinMatheus Afonso Martins Moreira via GitGitGadget, May 2, 2026
  38. 8/8 t9904: add tests for the new url-parse builtinMatheus Afonso Martins Moreira via GitGitGadget, May 2, 2026
  39. Junio C HamanoMay 3, 2026
  40. Matheus Afonso Martins MoreiraMay 3, 2026
  41. Torsten BögershausenMay 3, 2026
  42. Matheus Afonso Martins MoreiraMay 3, 2026
  43. Junio C HamanoMay 12, 2026
  44. Torsten BögershausenMay 12, 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.