All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon 'corecode' Schubert <corecode@fs.ei.tum.de>
To: git@vger.kernel.org
Subject: [PATCH] Replace perl code with pure shell code
Date: Mon, 29 Jan 2007 09:09:25 +0100	[thread overview]
Message-ID: <45BDABB5.4070301@fs.ei.tum.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 2281 bytes --]

Signed-off-by: Simon 'corecode' Schubert <corecode@fs.ei.tum.de>
---
 git-clone.sh |   65 ++++++++++++++++++---------------------------------------
 1 files changed, 21 insertions(+), 44 deletions(-)

diff --git a/git-clone.sh b/git-clone.sh
index ced7dfb..b3c6fa4 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -66,48 +66,6 @@ Perhaps git-update-server-info needs to be run there?"
 	rm -f "$GIT_DIR/REMOTE_HEAD"
 }
 
-# Read git-fetch-pack -k output and store the remote branches.
-copy_refs='
-use File::Path qw(mkpath);
-use File::Basename qw(dirname);
-my $git_dir = $ARGV[0];
-my $use_separate_remote = $ARGV[1];
-my $origin = $ARGV[2];
-
-my $branch_top = ($use_separate_remote ? "remotes/$origin" : "heads");
-my $tag_top = "tags";
-
-sub store {
-	my ($sha1, $name, $top) = @_;
-	$name = "$git_dir/refs/$top/$name";
-	mkpath(dirname($name));
-	open O, ">", "$name";
-	print O "$sha1\n";
-	close O;
-}
-
-open FH, "<", "$git_dir/CLONE_HEAD";
-while (<FH>) {
-	my ($sha1, $name) = /^([0-9a-f]{40})\s(.*)$/;
-	next if ($name =~ /\^\173/);
-	if ($name eq "HEAD") {
-		open O, ">", "$git_dir/REMOTE_HEAD";
-		print O "$sha1\n";
-		close O;
-		next;
-	}
-	if ($name =~ s/^refs\/heads\///) {
-		store($sha1, $name, $branch_top);
-		next;
-	}
-	if ($name =~ s/^refs\/tags\///) {
-		store($sha1, $name, $tag_top);
-		next;
-	}
-}
-close FH;
-'
-
 quiet=
 local=no
 use_local=no
@@ -332,8 +290,27 @@ test -d "$GIT_DIR/refs/reference-tmp" && rm -fr "$GIT_DIR/refs/reference-tmp"
 if test -f "$GIT_DIR/CLONE_HEAD"
 then
 	# Read git-fetch-pack -k output and store the remote branches.
-	@@PERL@@ -e "$copy_refs" "$GIT_DIR" "$use_separate_remote" "$origin" ||
-	exit
+	if [ -n "$use_separate_remote" ]
+	then
+		branch_top="remotes/$origin"
+	else
+		branch_top="heads"
+	fi
+	tag_top="tags"
+	while read sha1 name
+	do
+		case "$name" in
+		HEAD)
+			destname="REMOTE_HEAD" ;;
+		refs/heads/*)
+			destname="refs/$branch_top/${name#refs/heads/}" ;;
+		refs/tags/*)
+			destname="refs/$tag_top/${name#refs/tags/}" ;;
+		*)
+			continue ;;
+		esac
+		git-update-ref -m "clone: from $repo" "$destname" "$sha1" ""
+	done < "$GIT_DIR/CLONE_HEAD"
 fi
 
 cd "$D" || exit
-- 
1.5.0.rc1.196.geebfb



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

             reply	other threads:[~2007-01-29  8:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-29  8:09 Simon 'corecode' Schubert [this message]
2007-01-29  8:56 ` [PATCH] Replace perl code with pure shell code Junio C Hamano
2007-01-29  9:18   ` Simon 'corecode' Schubert
2007-01-29  9:28     ` Shawn O. Pearce
2007-01-29 11:41 ` Randal L. Schwartz
2007-01-29 12:38   ` Nikolai Weibull
2007-01-29 12:53     ` Randal L. Schwartz
2007-01-29 13:17       ` Nikolai Weibull
2007-01-29 13:21         ` Randal L. Schwartz
2007-01-30 10:57       ` Junio C Hamano
2007-01-29 12:43   ` Jakub Narebski
2007-01-29 12:54     ` Randal L. Schwartz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45BDABB5.4070301@fs.ei.tum.de \
    --to=corecode@fs.ei.tum.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.