Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] cvsserver: Make always-binary mode a config file option

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:57

Junio C Hamano [off-list ref] writes:
Andy Parkins [off-list ref] writes:
quoted
Erm, yes, I know that.  But who is going to set that switch?
This isn't real CVS where the repository records that
information.  At the moment git does not know whether any
given file is binary or text.
What do you think I have been hacking around pathattr stuff
today for ;-)? 
A bit more clarification.  Although I won't be hacking on it
anymore since it is almost my bedtime,...

I think the 4 patch series I sent out tonight was fun but
slightly misdesigned.  I should have made the classification of
paths and actions on them separate sections.  That is, instead
of saying:

	[pathattr "a/v"]
        	path = "*.mpg"
                path = "*.mp3"
                path = "*.jpg"
		conv_i = none
                conv_o = none
	[pathattr "text"]
        	path = "*" ; all the rest
                conv_i = crlf
                conv_o = crlf

we should make two kinds of configuration.  Classification of
paths is property of the project and does not depend on where
the user uses the paths from the project:

	[pathattr "a/v"]
        	path = "*.mpg"
                path = "*.mp3"
                path = "*.jpg"
	[pathattr "text"]
        	path = "*" ; all the rest

while how they are handled can be platform dependent.  On UNIX,
you might have this in $HOME/.gitconfig:

	[handler "a/v"]
        	pretty = "cmd xine %s" ; nb. there is no 'cmd' yet...
	[handler "text"]
		pretty = "pipe fmt -"

while on another system, you might have:

	[handler "a/v"]
        	pretty = "cmd mediaplayer %s"
	[handler "text"]
                conv_i = crlf
                conv_o = crlf

One thing to note is that [pathattr "kind"] may need to behave
like existing .gitignore in that they are read from directories,
but [handler "kind"] does not have to.

We probably need to expose pathattr_lookup(path) to scripts, and
cvsserver could use that interface to query.  The interface may
look like this:

	$ git pathattr --lookup porn.mpg
        a/v
        $ git config --get handler.a/v
	cmd xine %s

and kopts_from_path would look like:

	sub kopts_from_path {
        	my ($path) = shift;
                my $kind = `git pathattr $path`;
		my $conv_o = `git config --get "handler.$kind"`

                if ($conv_o eq 'crlf') {
			return '-kb';
		}
		return '';
	}

Hmm?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help