[git-users] Second user defined filter on add or checkout

2015-04-02 Thread Uwe Bieling
Hi,

I'm using a filter for rcs-keywords expansion. Now i want to use a second 
filter to clean some data inside the project on the same file. 

Are there any posibilities to run the keywords expansion first and after 
this my filter? I don't want to modify the original keywords-filter, 
because it's not mine and i don't want to get troubles with updates of this 
filter.

Bye,

Uwe

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Second user defined filter on add or checkout

2015-04-02 Thread Konstantin Khomoutov
On Thu, 2 Apr 2015 03:21:05 -0700 (PDT)
Uwe Bieling a.1.psychi0...@spamgourmet.com wrote:

 I'm using a filter for rcs-keywords expansion. Now i want to use a
 second filter to clean some data inside the project on the same file. 
 
 Are there any posibilities to run the keywords expansion first and
 after this my filter? I don't want to modify the original
 keywords-filter, because it's not mine and i don't want to get
 troubles with updates of this filter.

Create a wrapper script which calls the first printer program and pipes
its output to the second filter program (which has its stdout connected
to that of the script interpreter and then specify the script as a
filter instead of the original one.

In the simplest case, if you have

  *.cfilter=rcs-keywords
  
  [filter rcs-keywords]
  clean = rcs-remove
  smudge = rcs-expand

You could then write a shell script

  #!/bin/sh
  
  set -e -u
  
  usage(fd) {
echo 'Usage: myscript {clean|smudge}'
  }
  
  if [ $# -ne 1 ];
usage 2
exit 1
  fi
  
  case $1 in
clean)
  myfilter -clean | rcs-remove
;;
smudge)
  rcs-expand | myfilter -smudge
;;
help)
  usage
  exit 0
;;
*)
  usage 2
  exit 1
;;
  esac

And then change the definition in .gitattributes:

  *.cfilter=complex
  
  [filter complex]
  clean = ~/bin/complex-git-filter clean
  smudge = ~/bin/complex-git-filter smudge

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.