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

Re: [PATCH] symref support for import scripts

From
Junio C Hamano <junkio@cox.net>
Date
Nov 16, 2005, 19:43 UTC
Message-ID
<7vu0ec7502.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<1132165648.4024.6.camel@dv>
Pavel Roskin <proski@gnu.org> writes:
> Fix git import script not to assume that .git/HEAD is a symlink.
>
> Signed-off-by: Pavel Roskin <proski@gnu.org>
Thanks.

Martin and Matthias, are these OK with you two? All of the changes look trivially correct, so I'll take them.

Show 17 quoted lines
> diff --git a/git-cvsimport.perl b/git-cvsimport.perl
> index 7bd9136..efe1934 100755
> --- a/git-cvsimport.perl
> +++ b/git-cvsimport.perl
> @@ -437,7 +437,11 @@ unless(-d $git_dir) {
>  		       "Either use the correct '-o branch' option,\n".
>  		       "or import to a new repository.\n";
>  
> -	$last_branch = basename(readlink("$git_dir/HEAD"));
> +	open(F, "git-symbolic-ref HEAD |") or
> +		die "Cannot run git-symbolic-ref: $!\n";
> +	chomp ($last_branch = <F>);
> +	$last_branch = basename($last_branch);
> +	close(F);
>  	unless($last_branch) {
>  		warn "Cannot read the last branch name: $! -- assuming 'master'\n";
>  		$last_branch = "master";

This part, before or after Pavel's fixes, seems to refuse a branch named 'topic/#1'. This is not a problem for import scripts that name their own branches based on what is in the foreign SCM and flatten their the branch namespaces, but I'd prefer a comment about the issue somewhere around this code, to prevent people from copying and pasting the use of "basename()". There is a corresponding piece in svnimport as well.

Previous: Pavel RoskinNext: Matthias Urlichs
Message 2 of 4 in “symref support for import scripts”
  1. symref support for import scriptsPavel Roskin, Nov 16, 2005
  2. Junio C HamanoNov 16, 2005
  3. Matthias UrlichsNov 16, 2005
  4. Junio C HamanoNov 16, 2005

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.