git-svn --ignore-paths [英] git-svn --ignore-paths
问题描述
现在,我正努力使用--ignore-paths选项到git-svn几个小时,试图从大型存储库中只读取某些标签。
我想在dev上开始读取,看起来像
> svn ls http://192.168.0.2/svn/repo/corporation/dev
branches /
tags /
trunk /
$ b 完整标记集的存储库目录列表如下所示:
> svn ls http://192.168.0.2/svn/repo/corporation/dev/tags
Acme-4.x /
Acme-5.0 /
Acme-5.1 /
Acme -5.2 /
Acme-5.3 /
Acme-5.4 /
Acme-5.5 /
Acme-5.6 /
Acme-5.7 /
Acme-5.8 /
Acme-5.9 /
我想在Acme-5.5之前忽略所有的标签。 / b>
我尝试初始化并获取:
> git svn init http://192.168.0.2/svn/repo/corporation/dev
> git config svn.authorsfile ../users.txt
> git svn fetch --ignore-paths =Acme-4.x | Acme-5.0 | Acme-5.1 | Acme-5.2 | Acme-5.3 | Acme-5.4
不幸的是,我仍然看到在Acme-4.x标记中发生了取值。这些提取在控制台上通过诸如
一个ACME4.4 / source / database / mssql / components / functions /vssver.scc
我试过了一堆正则表达式的变体,包括标签我想忽略,这一两个小时后变成了完全正则表达式的颠簸和绝望。我为git-svn-init提供了--ignore-paths选项,都无济于事。
有人会评论正则表达式的原因不要取消在ignores-regex中指定的路径。
谢谢。
div>我今天遇到同样的问题:我的正则表达式根本无法匹配...
请确保您知道目标路径的实际外观如何。我正在对提供给我的正则表达式的路径结构做出不正确的假设。
要找出路径的样子, make git- svn会输出到控制台的每个路径,因为它会测试它们:
注意:为防万一,请将git-svn文件首先!
- 在文本编辑器中打开git-svn脚本。我的脚本是
< git-dir> / libexec / git-core / git-svn
。 - 找到
is_path_ignored
子程序。 - 在第一个<$ c之上添加一个
print
$ c> return 语句,如下所示... - Open the git-svn script in a text editor. My script was
<git-dir>/libexec/git-core/git-svn
. - Locate the
is_path_ignored
subroutine. - Add a
print
statement above the firstreturn
statement, as follows...
sub is_path_ignored {
my($ self,$ path)= @_;
打印STDERR$ path\\\
; //< - **添加此行**
如果in_dot_git($ path)返回1;
返回1(如果已定义)($ self-> {ignore_regex})&&
$ path =〜m!$ self-> {ignore_regex} !;
返回0,除非定义($ _ ignore_regex);
返回1如果$ path =〜m!$ _ ignore_regex!o;
返回0;
$ b现在使用 git-svn
再次使用 - ignore-paths
开关。
我意识到,不是像 trunk / baz
它实际上使用 bar / trunk / baz
因此,而不是
- ignore-paths ='^(?:主干|分行|标记)/ baz'
我需要使用
- ignore-paths ='^ bar /(?: trunk | branches | tags)/ baz'
不要忘记从git-svn脚本中删除 print
语句。
I'm struggling for a number of hours now with the --ignore-paths option to git-svn, in an attempt to fetch only certain tags from a large repository.
I want to start the fetch at dev, which looks like
> svn ls http://192.168.0.2/svn/repo/corporation/dev
branches/
tags/
trunk/
The repository directory listing for the complete set of tags looks like this:
> svn ls http://192.168.0.2/svn/repo/corporation/dev/tags
Acme-4.x/
Acme-5.0/
Acme-5.1/
Acme-5.2/
Acme-5.3/
Acme-5.4/
Acme-5.5/
Acme-5.6/
Acme-5.7/
Acme-5.8/
Acme-5.9/
I want to ignore all tags before Acme-5.5.
I attempt to initialize and fetch thusly:
> git svn init http://192.168.0.2/svn/repo/corporation/dev
> git config svn.authorsfile ../users.txt
> git svn fetch --ignore-paths="Acme-4.x|Acme-5.0|Acme-5.1|Acme-5.2|Acme-5.3|Acme-5.4"
Unfortunately, I still see fetches occuring in the Acme-4.x tag. The fetches are manifested on the console by telltale paths such as
A ACME4.4/source/database/mssql/components/functions/vssver.scc
I've tried a bunch of variations on the regex, including full paths to the tags I want to ignore, which after an hour or two turned into utter regex thrashing and desperation. I've provided the --ignore-paths option to git-svn-init, all to no avail.
Would someone be kind enough to comment on why the regex's are not suppressing fetches on the paths specified in the ignores-regex.
Thanks.
解决方案 I was having this same problem today: my regexp would just never match...
Make sure you know what the target paths actually look like. I was making an incorrect assumption about the structure of the paths that were being fed to my regexp.
To find out what the paths look like, make git-svn output each path to the console as it tests them:
NOTE: Just in case, make a backup copy of the git-svn file first!
sub is_path_ignored {
my ($self, $path) = @_;
print STDERR "$path\n"; //<-- **ADD THIS LINE**
return 1 if in_dot_git($path);
return 1 if defined($self->{ignore_regex}) &&
$path =~ m!$self->{ignore_regex}!;
return 0 unless defined($_ignore_regex);
return 1 if $path =~ m!$_ignore_regex!o;
return 0;
}
Now use git-svn
again with the --ignore-paths
switch.
I realised that instead of paths like trunk/baz
it was actually using bar/trunk/baz
So instead of
--ignore-paths='^(?:trunk|branches|tags)/baz'
I needed to use
--ignore-paths='^bar/(?:trunk|branches|tags)/baz'
Don't forget to remove the print
statement from the git-svn script.
这篇关于git-svn --ignore-paths的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!