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

Re: [RFC 4/6] git-check-attr: Normalize paths

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 2, 2011, 17:24 UTC
Message-ID
<7v4o1zg20r.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1311849425-9057-5-git-send-email-mhagger@alum.mit.edu>
Michael Haggerty <mhagger@alum.mit.edu> writes:
Show 5 quoted lines
> 1. I'm not sure whether it is correct to fix this problem at the level
>    of git-check-attr, or whether the fix belongs in the API layer.
>    What is the convention for API functions?  Do they typically take
>    path names relative to the CWD or relative to the working tree
>    root, or ...?

I think passing down "prefix" (i.e. where your $(cwd) was relative to the root level of the working tree) and the user-supplied "pathspec" (which typically is relative to that original $(cwd)) is the canonical approach. The very original git worked only at the root level of the working tree, with paths specified relative to the root level of the tree, so many code do:

	- find out the root of the working tree;
        - note where the $(cwd) was in "prefix";
        - chdir to the root of the working tree;
	- prepend the "prefix" to user supplied pathspec;
        - forget all the complexity and work on the whole tree.

Then the "prefix" gets stripped away from the beginning of the paths when reporting.

Your patch from a cursory look seems to follow that pattern, which is good.

Previous: Michael HaggertyNext: Michael Haggerty
Message 6 of 15 in “[RFC 0/6] git-check-attr should work for relative paths”
  1. Michael HaggertyJul 28, 2011
  2. 1/6 git-check-attr: test that no output is written to stderrMichael Haggerty, Jul 28, 2011
  3. 2/6 git-check-attr: Demonstrate problems with unnormalized pathsMichael Haggerty, Jul 28, 2011
  4. 3/6 git-check-attr: Demonstrate problems with relative pathsMichael Haggerty, Jul 28, 2011
  5. 4/6 git-check-attr: Normalize pathsMichael Haggerty, Jul 28, 2011
  6. Junio C HamanoAug 2, 2011
  7. Michael HaggertyAug 4, 2011
  8. Junio C HamanoAug 4, 2011
  9. Michael HaggertyAug 5, 2011
  10. Junio C HamanoAug 5, 2011
  11. Michael HaggertyAug 7, 2011
  12. 5/6 test-path-utils: Add subcommand "absolute_path"Michael Haggerty, Jul 28, 2011
  13. 6/6 test-path-utils: Add subcommand "prefix_path"Michael Haggerty, Jul 28, 2011
  14. Junio C HamanoAug 2, 2011
  15. Michael HaggertyAug 4, 2011

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.