{"thread":{"id":"2557","subject":"[PATCH] symref support for import scripts","startedAt":"2005-11-16T18:27:28Z","lastAt":"2005-11-16T20:26:42Z","messageCount":4,"participants":["Pavel Roskin","Junio C Hamano","Matthias Urlichs"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"12028","messageId":"1132165648.4024.6.camel@dv","threadId":"2557","inReplyTo":null,"subject":"[PATCH] symref support for import scripts","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2005-11-16T18:27:28Z","receivedAt":"2005-11-16T18:27:28Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Fix git import script not to assume that .git/HEAD is a symlink.\n\nSigned-off-by: Pavel Roskin <proski@gnu.org>\n\ndiff --git a/git-archimport.perl b/git-archimport.perl\nindex e22c816..23becb7 100755\n--- a/git-archimport.perl\n+++ b/git-archimport.perl\n@@ -410,8 +410,7 @@ foreach my $ps (@psets) {\n     open  HEAD, \">$git_dir/refs/heads/$ps->{branch}\";\n     print HEAD $commitid;\n     close HEAD;\n-    unlink (\"$git_dir/HEAD\");\n-    symlink(\"refs/heads/$ps->{branch}\",\"$git_dir/HEAD\");\n+    system('git-update-ref', 'HEAD', \"$ps->{branch}\");\n \n     # tag accordingly\n     ptag($ps->{id}, $commitid); # private tag\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 7bd9136..efe1934 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -437,7 +437,11 @@ unless(-d $git_dir) {\n \t\t       \"Either use the correct '-o branch' option,\\n\".\n \t\t       \"or import to a new repository.\\n\";\n \n-\t$last_branch = basename(readlink(\"$git_dir/HEAD\"));\n+\topen(F, \"git-symbolic-ref HEAD |\") or\n+\t\tdie \"Cannot run git-symbolic-ref: $!\\n\";\n+\tchomp ($last_branch = <F>);\n+\t$last_branch = basename($last_branch);\n+\tclose(F);\n \tunless($last_branch) {\n \t\twarn \"Cannot read the last branch name: $! -- assuming 'master'\\n\";\n \t\t$last_branch = \"master\";\n@@ -829,8 +833,7 @@ if($orig_branch) {\n \tprint \"DONE; creating $orig_branch branch\\n\" if $opt_v;\n \tsystem(\"cp\",\"$git_dir/refs/heads/$opt_o\",\"$git_dir/refs/heads/master\")\n \t\tunless -f \"$git_dir/refs/heads/master\";\n-\tunlink(\"$git_dir/HEAD\");\n-\tsymlink(\"refs/heads/$orig_branch\",\"$git_dir/HEAD\");\n+\tsystem('git-update-ref', 'HEAD', \"$orig_branch\");\n \tunless ($opt_i) {\n \t\tsystem('git checkout');\n \t\tdie \"checkout failed: $?\\n\" if $?;\ndiff --git a/git-svnimport.perl b/git-svnimport.perl\nindex af13fdd..45d77c5 100755\n--- a/git-svnimport.perl\n+++ b/git-svnimport.perl\n@@ -216,7 +216,11 @@ unless(-d $git_dir) {\n \t-f \"$git_dir/svn2git\"\n \t\tor die \"'$git_dir/svn2git' does not exist.\\n\".\n \t\t       \"You need that file for incremental imports.\\n\";\n-\t$last_branch = basename(readlink(\"$git_dir/HEAD\"));\n+\topen(F, \"git-symbolic-ref HEAD |\") or\n+\t\tdie \"Cannot run git-symbolic-ref: $!\\n\";\n+\tchomp ($last_branch = <F>);\n+\t$last_branch = basename($last_branch);\n+\tclose(F);\n \tunless($last_branch) {\n \t\twarn \"Cannot read the last branch name: $! -- assuming 'master'\\n\";\n \t\t$last_branch = \"master\";\n@@ -766,8 +770,7 @@ if($orig_branch) {\n \tprint \"DONE; creating $orig_branch branch\\n\" if $opt_v and (not defined $opt_l or $opt_l > 0);\n \tsystem(\"cp\",\"$git_dir/refs/heads/$opt_o\",\"$git_dir/refs/heads/master\")\n \t\tunless -f \"$git_dir/refs/heads/master\";\n-\tunlink(\"$git_dir/HEAD\");\n-\tsymlink(\"refs/heads/$orig_branch\",\"$git_dir/HEAD\");\n+\tsystem('git-update-ref', 'HEAD', \"$orig_branch\");\n \tunless ($opt_i) {\n \t\tsystem('git checkout');\n \t\tdie \"checkout failed: $?\\n\" if $?;\n\n\n-- \nRegards,\nPavel Roskin\n"},{"id":"12034","messageId":"7vu0ec7502.fsf@assigned-by-dhcp.cox.net","threadId":"2557","inReplyTo":"1132165648.4024.6.camel@dv","subject":"Re: [PATCH] symref support for import scripts","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-16T19:43:41Z","receivedAt":"2005-11-16T19:43:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pavel Roskin <proski@gnu.org> writes:\n\n> Fix git import script not to assume that .git/HEAD is a symlink.\n>\n> Signed-off-by: Pavel Roskin <proski@gnu.org>\n\nThanks.\n\nMartin and Matthias, are these OK with you two?  All of the\nchanges look trivially correct, so I'll take them.\n\n> diff --git a/git-cvsimport.perl b/git-cvsimport.perl\n> index 7bd9136..efe1934 100755\n> --- a/git-cvsimport.perl\n> +++ b/git-cvsimport.perl\n> @@ -437,7 +437,11 @@ unless(-d $git_dir) {\n>  \t\t       \"Either use the correct '-o branch' option,\\n\".\n>  \t\t       \"or import to a new repository.\\n\";\n>  \n> -\t$last_branch = basename(readlink(\"$git_dir/HEAD\"));\n> +\topen(F, \"git-symbolic-ref HEAD |\") or\n> +\t\tdie \"Cannot run git-symbolic-ref: $!\\n\";\n> +\tchomp ($last_branch = <F>);\n> +\t$last_branch = basename($last_branch);\n> +\tclose(F);\n>  \tunless($last_branch) {\n>  \t\twarn \"Cannot read the last branch name: $! -- assuming 'master'\\n\";\n>  \t\t$last_branch = \"master\";\n\nThis part, before or after Pavel's fixes, seems to refuse a\nbranch named 'topic/#1'.  This is not a problem for import\nscripts that name their own branches based on what is in the\nforeign SCM and flatten their the branch namespaces, but I'd\nprefer a comment about the issue somewhere around this code, to\nprevent people from copying and pasting the use of \"basename()\".\nThere is a corresponding piece in svnimport as well.\n"},{"id":"12036","messageId":"20051116195737.GE27727@kiste.smurf.noris.de","threadId":"2557","inReplyTo":"7vu0ec7502.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] symref support for import scripts","fromName":"Matthias Urlichs","fromEmail":"smurf@smurf.noris.de","sentAt":"2005-11-16T19:57:37Z","receivedAt":"2005-11-16T19:57:37Z","isPatch":true,"sender":{"key":"matthias@urlichs.de","avatar":"https://gravatar.com/avatar/2708905af227313eba6f2b2ae0f7d0259b5ac5d71baef58fe5a13c699ce0bbf0?d=mp&s=160"},"body":"Hi,\n\nJunio C Hamano:\n> Martin and Matthias, are these OK with you two?  All of the\n> changes look trivially correct, so I'll take them.\n> \nIMHO: That code needs to vanish anyway.\n\nThe only reason we have to read HEAD is that, at the end of the\nday^Wimport, whatever HEAD points to may have been updated. Thus,\nwe need to merge forward, to get the index back into sync.\n\nThe only thing we want to do with HEAD, in order to accomplish that,\nis to find the SHA1 it points to, before and after the import.\nNo use of git-symbolic-ref is necessary for that.\n\nAll the deref code was a good idea when we actually modified the\nchecked-out index and/or tree while importing, but that does not happen\nany more.\n\n-- \nMatthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de\nDisclaimer: The quote was selected randomly. Really. | http://smurf.noris.de\n - -\nA good supervisor can step on your toes without messing up your shine.\n"},{"id":"12043","messageId":"7v8xvo730d.fsf@assigned-by-dhcp.cox.net","threadId":"2557","inReplyTo":"20051116195737.GE27727@kiste.smurf.noris.de","subject":"Re: [PATCH] symref support for import scripts","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-16T20:26:42Z","receivedAt":"2005-11-16T20:26:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthias Urlichs <smurf@smurf.noris.de> writes:\n\n> The only thing we want to do with HEAD, in order to accomplish that,\n> is to find the SHA1 it points to, before and after the import.\n> No use of git-symbolic-ref is necessary for that.\n\nTrue.  'git-rev-parse --verify HEAD^0' would be sufficient.\n"}]}