git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Allow fancy globs in git-svn init branches

From
EWEric Wong <normalperson@yhbt.net>
Date
Sep 18, 2012, 20:46 UTC
Message-ID
<20120918204654.GA22856@dcvr.yhbt.net>
In-Reply-To
<1347925598-23907-1-git-send-email-ammon.riley@gmail.com>
Ammon Riley <ammon.riley@gmail.com> wrote:
Show 35 quoted lines
> Branches passed to 'git-svn init' via the -b/--branches flag
> automatically had a /* appended to them.  When the branch contained
> a fancy glob with a {} pattern, this is incorrect behaviour, and
> leads to odd branches being created in the git repository.
> 
> Signed-off-by: Ammon Riley <ammon.riley@gmail.com>
> ---
>  git-svn.perl                         |  2 +-
>  t/t9141-git-svn-multiple-branches.sh | 12 ++++++++++++
>  2 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/git-svn.perl b/git-svn.perl
> index 0d77ffb..f8e8558 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -1678,7 +1678,7 @@ sub complete_url_ls_init {
>  	my $remote_path = join_paths( $gs->path, $repo_path );
>  	$remote_path =~ s{%([0-9A-F]{2})}{chr hex($1)}ieg;
>  	$remote_path =~ s#^/##g;
> -	$remote_path .= "/*" if $remote_path !~ /\*/;
> +	$remote_path .= "/*" if $remote_path !~ m#\*|\{[^/]+\}#;
>  	my ($n) = ($switch =~ /^--(\w+)/);
>  	if (length $pfx && $pfx !~ m#/$#) {
>  		die "--prefix='$pfx' must have a trailing slash '/'\n";
> diff --git a/t/t9141-git-svn-multiple-branches.sh b/t/t9141-git-svn-multiple-branches.sh
> index 3cd0671..1b872a9 100755
> --- a/t/t9141-git-svn-multiple-branches.sh
> +++ b/t/t9141-git-svn-multiple-branches.sh
> @@ -119,4 +119,16 @@ test_expect_success 'create new branches and tags' '
>  		svn_cmd up && test -e tags_B/Tag2/a.file )
>  '
>  
> +test_expect_success 'clone multiple branch paths using fancy glob' '
> +	git svn clone -T trunk \
> +		      -b b_one/{first} --branches b_two \

I'm concerned encouraging this can cause confusion on the command-line for bash users.

In bash, "b_one/{first}" will be passed as-is (and hardly anybody will have a repo with '{word}' in the path)

However, unless quoted on the command-line, a likely case of: "b_one/{first,second}" will expand to: "b_one/first" "b_one/second"

...which causes "b_one/second" to be interpreted as the destination directory. A knowledgeable bash user can avoid this by using: -b=b_one/{first,second} to avoid this situation.

But with the above invocation, no explicit support is needed for command-line parsing in git-svn.

Previous: Ammon RileyNext: Ammon Riley
Message 2 of 4 in “Allow fancy globs in git-svn init branches”
  1. Allow fancy globs in git-svn init branchesAmmon Riley, Sep 17, 2012
  2. Eric WongSep 18, 2012
  3. Ammon RileySep 18, 2012
  4. Eric WongSep 19, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.