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

[RFD] git-run-with-user-path

From
Junio C Hamano <junkio@cox.net>
Date
May 15, 2005, 20:27 UTC
Message-ID
<7vu0l4s08s.fsf_-_@assigned-by-dhcp.cox.net>
In-Reply-To
<7v4qd5vxao.fsf@assigned-by-dhcp.cox.net>

Petr, I have not written the implementation yet, but do you think Cogito would find something like this useful? I've seen some patch to add running from subdirectory support to cg-add in the mailing list and I assume Cogito is in the process of being enhanced in this area.

JIT has been supporting running from the subdirectory from the day one, but has been using a bit different mechanism. If we can agree on a core-ish helper (I consider this just as non-core as git-diff-helper is), I would want to switch to use something like this one.

This _deliberately_ conflates the user-path canonicalization with the ignore-list processing discussed recently on the list. When you think about it, they are very closely related and handling them at the same place makes more sense than having them separately. It is a way to munge paths given by users and "find -print0 | xargs -0" into a form appropriate for core GIT consumption. Similar reasoning with which you accepted the use of cg-Xignore by David Greaves in cg-commit.

Linus, and everybody else, suggestions and comments?
------------

git-run-with-user-path(1) ========================= v0.1, May 2005

NAME ---- git-run-with-user-path - Run command from the top after canonicalizing paths.

SYNOPSIS -------- 'git-run-with-user-path' [options] <command> <argument>... '--' <path>...

DESCRIPTION ----------- This command takes a <command>, zero or more <argument> and zero or more <path> arguments. <path> arguments name objects on the filesystem, <command> is typically a core GIT command, and <argument> are the initial arguments to the <command>.

It first finds the project top directory (the directory that corresponds to the top of the tree structure GIT_INDEX_FILE describes), and canonicalizes the given <path> to be relative to the project top. It then chdir(2)'s to the project top directory and runs the given <command>, with <argument> and these canonicalized <path> arguments.

This is useful for the Porcelain layer to run core GIT commands from subdirectories. For example, if linux-2.6.git tree is checked out in /usr/src/linux, you can do:

    $ cd /usr/src/linux/fs
    $ ... work in fs directory making changes ...
    $ git-run-with-user-path git-diff-tree -r HEAD -- ext? ../include/linux
    $ find ext? ! -type d -print0 |
      xargs -0 git-run-with-user-path git-update-cache --add -- --
The above is roughly equivalent to:
    $ cd /usr/src/linux
    $ git-diff-tree -r HEAD fs/ext? include/linux
    $ find fs/ext? include/linux ! -type d -print0 |
      xargs git-update-cache --add --

OPTIONS ------- --no-ignore::

	By default, the path arguments are filtered with the
	same ignore rules Porcelain layers use.  With
	--no-ignore flag, there is no such filtering done.

Author ------ Written by Junio C Hamano <junkio@cox.net>

Documentation -------------- Documentation by Junio C Hamano.

GIT --- Part of the link:git.html[git] suite

Previous: Junio C HamanoNext: Matthias Urlichs
Message 13 of 18 in “Ignore file filter”
  1. Ignore file filterDavid Greaves, May 12, 2005
  2. Petr BaudisMay 13, 2005
  3. David GreavesMay 14, 2005
  4. Junio C HamanoMay 14, 2005
  5. Petr BaudisMay 14, 2005
  6. David GreavesMay 14, 2005
  7. [RFD] Ignore rulesPetr Baudis, May 14, 2005
  8. David GreavesMay 14, 2005
  9. Junio C HamanoMay 14, 2005
  10. Jon SeymourMay 15, 2005
  11. Junio C HamanoMay 15, 2005
  12. Junio C HamanoMay 15, 2005
  13. [RFD] git-run-with-user-pathJunio C Hamano, May 15, 2005
  14. Matthias UrlichsMay 16, 2005
  15. David GreavesMay 16, 2005
  16. Petr BaudisMay 14, 2005
  17. David GreavesMay 14, 2005
  18. David GreavesMay 13, 2005

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.