git-svn --ignore-paths

后端 未结 7 1584
悲哀的现实
悲哀的现实 2021-02-01 04:27

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

7条回答
  •  抹茶落季
    2021-02-01 04:59

    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!

    1. Open the git-svn script in a text editor. My script was /libexec/git-core/git-svn.
    2. Locate the is_path_ignored subroutine.
    3. Add a print statement above the first return statement, as follows...
    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.

提交回复
热议问题