git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* gitattributes filter: add new %r that expands to repository root
@ 2021-01-22 17:11 Calum McConnell
  0 siblings, 0 replies; only message in thread
From: Calum McConnell @ 2021-01-22 17:11 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 2080 bytes --]

Dear Git Maintainers,

When building content filters with gitattributes, for instance to ensure
git stores the plain-text rather than the binary form of data in certain
formats, it is often advantageous to separate the filters into separate
scripts.  However, as the $PWD where content filters are executed is
unspecified (at least, unspecified in the git documentation I could find),
so the path to scripts needs to be specified as an absolute path.  That
means that the guide for setting up a repository which uses scripts to
filter content cannot simply consist of "copy-paste the following lines to
your .git/config file", and it means that the otherwise safe operation of
moving a git repository from one folder to another is decidedly unsafe.

To fix this, I propose the addition of a "%r" sequence, similar to the
existing "%f", which expands to the repository root (as opposed to the
path of the file undergoing filtering).  This would enable calls to
content filter scripts to be (for instance) stored in a root /scripts
folder, and the git-config value to be "sh %r/scripts/erase-all-secret-
plots".  If backwards compatibility is a serious concern, the sequence
could only be expanded if it occurs at the beginning of the first two
words.

I believe that would be simple to implement, and would be willing to do so
myself, but wanted to get your views first.  

Another useful addition, but one that would be less simple to implement
would be the creation of a way for a set of default keys to be added to
all repositories that clone from a certain remote.  This could take the
form of a .gitconfig-defaultkeys file in the root of the repository, which
is appended to .git/config on clone, if there are core structural reasons
that prevent a configuration file (even one with a restricted set of
permitted keys) from being included in the tracked repository itself.

This is my first message to the git mailing list, so apologies if I
did/said something wrong/stupid/obvious! Please give me feedback.

Thank you,
Calum McConnell


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-23 16:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 17:11 gitattributes filter: add new %r that expands to repository root Calum McConnell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).