[RFD] git-run-with-user-path
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:41:57
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 [off-list ref]
Documentation
--------------
Documentation by Junio C Hamano.
GIT
---
Part of the link:git.html[git] suite