git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Remove perl dependency from git-submodule.sh
@ 2012-05-31  8:48 Fredrik Gustafsson
  2012-05-31  9:07 ` Ævar Arnfjörð Bjarmason
  2012-05-31  9:19 ` Johannes Sixt
  0 siblings, 2 replies; 9+ messages in thread
From: Fredrik Gustafsson @ 2012-05-31  8:48 UTC (permalink / raw)
  To: git; +Cc: jens.lehmann, gitster, iveqy

Rewrote a perl section in sh.

The code may be a bit slower (doing grep on strings instead of using
perl-lists).

Signed-off-by: Fredrik Gustafsson <iveqy@iveqy.com>
---
 git-submodule.sh |   35 ++++++++++++++++++-----------------
 1 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index f46862f..d3dfb24 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -73,24 +73,25 @@ resolve_relative_url ()
 #
 module_list()
 {
+	unmerged=
+	null_sha1=0000000000000000000000000000000000000000
 	git ls-files --error-unmatch --stage -- "$@" |
-	perl -e '
-	my %unmerged = ();
-	my ($null_sha1) = ("0" x 40);
-	while (<STDIN>) {
-		chomp;
-		my ($mode, $sha1, $stage, $path) =
-			/^([0-7]+) ([0-9a-f]{40}) ([0-3])\t(.*)$/;
-		next unless $mode eq "160000";
-		if ($stage ne "0") {
-			if (!$unmerged{$path}++) {
-				print "$mode $null_sha1 U\t$path\n";
-			}
-			next;
-		}
-		print "$_\n";
-	}
-	'
+	while read mode sha1 stage path
+	do
+		if test $mode -eq 160000
+		then
+			if test $stage -ne 0
+			then
+				if test -z "$(echo $unmerged | grep "|$path|")"
+					then
+					echo "$mode $null_sha1 U\t$path"
+				fi
+				unmerged="$unmerged|$path|"
+			else
+				echo "$mode $sha1 $stage\t$path"
+			fi
+		fi
+	done
 }
 
 #
-- 
1.7.5.1180.g4bfe7.dirty

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-05-31 19:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-31  8:48 [PATCH] Remove perl dependency from git-submodule.sh Fredrik Gustafsson
2012-05-31  9:07 ` Ævar Arnfjörð Bjarmason
2012-05-31 10:37   ` Fredrik Gustafsson
2012-05-31  9:19 ` Johannes Sixt
2012-05-31 10:40   ` Fredrik Gustafsson
2012-05-31 11:25     ` Johannes Sixt
2012-05-31 17:49     ` Junio C Hamano
2012-05-31 18:48       ` Fredrik Gustafsson
2012-05-31 19:26         ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).