Re: [RFD] Ignore rules
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:41:57
quoted
quoted
quoted
quoted
"JS" == Jon Seymour [off-list ref] writes:
JS> Is there value in:
JS> a. pushing the ignore logic into the core git tools such as git-ls-files
When there is an agreed upon Porcelain layer ignore logic,
git-ls-files --others --exclude-from=... should be changed so
that it uses the same file format and same semantics, and
probably use the default ignore file without being explicitly
told. Otherwise things would get quite confusing, so yes, I see
value in there.
I do not however think this should apply to things like
"git-update-cache --add"; because even though user may say
"git-update-cache --add *" and wish it to ignore things on the
ignore list, that is not how shell parameter expansion works.
I would like to see a git-path-helper command that can act as
filter between "find -print0" and "xargs -0" like this:
find * -print0 |
git-path-helper -z --ignore-file=.git/info/ignore |
xargs -r -0 git-update-cache --add --
I envision that we should not even need --ignore-file parameter,
once we have "an agreed upon Porcelain layer ignore logic". It
should read the "agreed upon" location, somewhere under the
$GIT_DIR and perform the "agreed upon" filtering logic.
I further envision that this would work from anywhere in the
work tree, not only from the directory that corresponds to the
top of the tree structure GIT_INDEX_FILE describes. For
example, in linux-2.6 git tree, you _ought_ to be able to say
something like this:
cd fs
find ext? ../include/linux -type f -print0 |
git-path-helper -z |
xargs -r -0 git-update-cache --add --
The git-path-helper command could internally run getpwd() and
find out the top directory (in this case, the parent directory
of our current working directory "fs"), then canonicalize the
incoming filenames (either relative to getpwd() or the full
filesystem path) to paths relative to the top directory, apply
the ignore filter and send the surviving paths downstream.
Anything downstream driven with xargs -0 would get relative
paths suitable for core GIT consumption.
JS> b. including the current ignore .* rule as a default ignore rule that
JS> can be overridden by a .gitignore file
Knowing the number of places that assume .* are irrelevant, I
would not be looking forward to doing that myself, but that
behaviour would be ideal.