@matheusbsbs / matheus-bagliano / commits / def2747d0e
Fork 0

Replace perl code with pure shell code

Signed-off-by: Simon 'corecode' Schubert <corecode@fs.ei.tum.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Simon 'corecode' Schubert committed Jan 29, 2007 at 09:09 UTC def2747d0e0b62e326564631fa5441bd1f270ee9
1 file changed +23 -44
git-clone.sh
+23 -44
@@ -66,48 +66,6 @@ Perhaps git-update-server-info needs to be run there?"
66 rm -f "$GIT_DIR/REMOTE_HEAD"
67 }
68
69 -# Read git-fetch-pack -k output and store the remote branches.
70 -copy_refs='
71 -use File::Path qw(mkpath);
72 -use File::Basename qw(dirname);
73 -my $git_dir = $ARGV[0];
74 -my $use_separate_remote = $ARGV[1];
75 -my $origin = $ARGV[2];
76 -
77 -my $branch_top = ($use_separate_remote ? "remotes/$origin" : "heads");
78 -my $tag_top = "tags";
79 -
80 -sub store {
81 - my ($sha1, $name, $top) = @_;
82 - $name = "$git_dir/refs/$top/$name";
83 - mkpath(dirname($name));
84 - open O, ">", "$name";
85 - print O "$sha1\n";
86 - close O;
87 -}
88 -
89 -open FH, "<", "$git_dir/CLONE_HEAD";
90 -while (<FH>) {
91 - my ($sha1, $name) = /^([0-9a-f]{40})\s(.*)$/;
92 - next if ($name =~ /\^\173/);
93 - if ($name eq "HEAD") {
94 - open O, ">", "$git_dir/REMOTE_HEAD";
95 - print O "$sha1\n";
96 - close O;
97 - next;
98 - }
99 - if ($name =~ s/^refs\/heads\///) {
100 - store($sha1, $name, $branch_top);
101 - next;
102 - }
103 - if ($name =~ s/^refs\/tags\///) {
104 - store($sha1, $name, $tag_top);
105 - next;
106 - }
107 -}
108 -close FH;
109 -'
110 -
69 quiet=
70 local=no
71 use_local=no
@@ -332,8 +290,29 @@ test -d "$GIT_DIR/refs/reference-tmp" && rm -fr "$GIT_DIR/refs/reference-tmp"
290 if test -f "$GIT_DIR/CLONE_HEAD"
291 then
292 # Read git-fetch-pack -k output and store the remote branches.
335 - @@PERL@@ -e "$copy_refs" "$GIT_DIR" "$use_separate_remote" "$origin" ||
336 - exit
293 + if [ -n "$use_separate_remote" ]
294 + then
295 + branch_top="remotes/$origin"
296 + else
297 + branch_top="heads"
298 + fi
299 + tag_top="tags"
300 + while read sha1 name
301 + do
302 + case "$name" in
303 + *'^{}')
304 + continue ;;
305 + HEAD)
306 + destname="REMOTE_HEAD" ;;
307 + refs/heads/*)
308 + destname="refs/$branch_top/${name#refs/heads/}" ;;
309 + refs/tags/*)
310 + destname="refs/$tag_top/${name#refs/tags/}" ;;
311 + *)
312 + continue ;;
313 + esac
314 + git-update-ref -m "clone: from $repo" "$destname" "$sha1" ""
315 + done < "$GIT_DIR/CLONE_HEAD"
316 fi
317
318 cd "$D" || exit