From 74866d75793559e8b351a17100679f83b96972ca Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Fri, 7 Oct 2016 11:18:48 -0700 Subject: git: make super-prefix option Add a super-prefix environment variable 'GIT_INTERNAL_SUPER_PREFIX' which can be used to specify a path from above a repository down to its root. When such a super-prefix is specified, the paths reported by Git are prefixed with it to make them relative to that directory "above". The paths given by the user on the command line (e.g. "git subcmd --output-file=path/to/a/file" and pathspecs) are taken relative to the directory "above" to match. The immediate use of this option is by commands which have a --recurse-submodule option in order to give context to submodules about how they were invoked. This option is currently only allowed for builtins which support a super-prefix. Signed-off-by: Brandon Williams Reviewed-by: Stefan Beller Signed-off-by: Junio C Hamano --- Documentation/git.txt | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Documentation') diff --git a/Documentation/git.txt b/Documentation/git.txt index 7913fc251..2188ae605 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -13,6 +13,7 @@ SYNOPSIS [--exec-path[=]] [--html-path] [--man-path] [--info-path] [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] [--git-dir=] [--work-tree=] [--namespace=] + [--super-prefix=] [] DESCRIPTION @@ -601,6 +602,11 @@ foo.bar= ...`) sets `foo.bar` to the empty string. details. Equivalent to setting the `GIT_NAMESPACE` environment variable. +--super-prefix=:: + Currently for internal use only. Set a prefix which gives a path from + above a repository down to its root. One use is to give submodules + context about the superproject that invoked it. + --bare:: Treat the repository as a bare repository. If GIT_DIR environment is not set, it is set to the current working -- cgit v1.2.1 From e77aa336f116e8ff8a72d034494b3a476b78c3ee Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Fri, 7 Oct 2016 11:18:49 -0700 Subject: ls-files: optionally recurse into submodules Allow ls-files to recognize submodules in order to retrieve a list of files from a repository's submodules. This is done by forking off a process to recursively call ls-files on all submodules. Use top-level --super-prefix option to pass a path to the submodule which it can use to prepend to output or pathspec matching logic. Signed-off-by: Brandon Williams Reviewed-by: Stefan Beller Signed-off-by: Junio C Hamano --- Documentation/git-ls-files.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Documentation') diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt index 0d933ac35..ea01d45e5 100644 --- a/Documentation/git-ls-files.txt +++ b/Documentation/git-ls-files.txt @@ -18,7 +18,8 @@ SYNOPSIS [--exclude-per-directory=] [--exclude-standard] [--error-unmatch] [--with-tree=] - [--full-name] [--abbrev] [--] [...] + [--full-name] [--recurse-submodules] + [--abbrev] [--] [...] DESCRIPTION ----------- @@ -137,6 +138,11 @@ a space) at the start of each line: option forces paths to be output relative to the project top directory. +--recurse-submodules:: + Recursively calls ls-files on each submodule in the repository. + Currently there is only support for the --cached mode without a + pathspec. + --abbrev[=]:: Instead of showing the full 40-byte hexadecimal object lines, show only a partial prefix. -- cgit v1.2.1 From 75a6315f7416a2fd559d0b0c7352b4f1cd10e186 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Fri, 7 Oct 2016 11:18:51 -0700 Subject: ls-files: add pathspec matching for submodules Pathspecs can be a bit tricky when trying to apply them to submodules. The main challenge is that the pathspecs will be with respect to the superproject and not with respect to paths in the submodule. The approach this patch takes is to pass in the identical pathspec from the superproject to the submodule in addition to the submodule-prefix, which is the path from the root of the superproject to the submodule, and then we can compare an entry in the submodule prepended with the submodule-prefix to the pathspec in order to determine if there is a match. This patch also permits the pathspec logic to perform a prefix match against submodules since a pathspec could refer to a file inside of a submodule. Due to limitations in the wildmatch logic, a prefix match is only done literally. If any wildcard character is encountered we'll simply punt and produce a false positive match. More accurate matching will be done once inside the submodule. This is due to the superproject not knowing what files could exist in the submodule. Signed-off-by: Brandon Williams Reviewed-by: Stefan Beller Signed-off-by: Junio C Hamano --- Documentation/git-ls-files.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Documentation') diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt index ea01d45e5..446209e20 100644 --- a/Documentation/git-ls-files.txt +++ b/Documentation/git-ls-files.txt @@ -140,8 +140,7 @@ a space) at the start of each line: --recurse-submodules:: Recursively calls ls-files on each submodule in the repository. - Currently there is only support for the --cached mode without a - pathspec. + Currently there is only support for the --cached mode. --abbrev[=]:: Instead of showing the full 40-byte hexadecimal object -- cgit v1.2.1