在git中为同一个文件应用多个过滤器 [英] Apply multiple filters for same files in git

查看:189
本文介绍了在git中为同一个文件应用多个过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Git来管理本地文件的版本控制,最后必须检入另一个版本控制系统。现在我遇到了大多数C代码文件的一些问题:


  1. 它们在标题注释中都有一个自动版本历史

  2. 大多数文件被EasyCode或EasyCase注释混乱了

现在我简单地创建了两个git过滤器历史和EasyTool清理代码,然后签入Git。如何用两个过滤器过滤所有C和H文件?



多次指定命令不起作用,并且过滤器命令的连接既不我至少没有找到正确的语法)。

这是我第一次尝试:

  *。c filter = History 
* .c filter = EasyTool#这一次获胜,History未被执行

然后我尝试了这样的事情:

  *。c filter = History EasyTool #第一个胜利,其他分隔符都不能工作


解决方案

不要以为你可以用这种方式链接过滤器。

最简单的方法是编写一个封装程序,它将依次调用(至少通过shell脚本中的管道) 。
(如是有可能将一个程序的输出重定向到不同操作系统中其他程序的输入?)。

I am using Git for version control of local files, which finally have to be checked in into another version control system. Now I am experiencing some problems with most of the C code files:

  1. They all have an automatic version history in their header comment
  2. Most of the files are cluttered by EasyCode or EasyCase comments

I now simply created two git filters "History" and "EasyTool" to clean up the code before being checked in to Git. How is it possible to filter all C and H files with both of the filters?

Specifying the commands multiple times does not work and concatenation of the filter command does neither (or I at least did not find the correct syntax).

This was my first try:

*.c  filter=History
*.c  filter=EasyTool           # This one wins, "History" is not executed

Then I tried something like this:

*.c  filter=History EasyTool   # The first wins, other separators work neither

解决方案

I don't think you can chain filters that way.

The simplest way would be to write a wrapper which would call both sequentially (at least through a pipe in a shell script).
(as in "
Is it possible to redirect output of one program to input of other program in different operational systems?").

这篇关于在git中为同一个文件应用多个过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆