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

[PATCH] Remove perl dependency from git-submodule.sh

From
Fredrik Gustafsson <iveqy@iveqy.com>
Date
May 31, 2012, 08:48 UTC
Message-ID
<1338454126-30441-1-git-send-email-iveqy@iveqy.com>
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
Next: Ævar Arnfjörð Bjarmason
Message 1 of 9 in “Remove perl dependency from git-submodule.sh”
  1. Remove perl dependency from git-submodule.shFredrik Gustafsson, May 31, 2012
  2. Ævar Arnfjörð BjarmasonMay 31, 2012
  3. Fredrik GustafssonMay 31, 2012
  4. Johannes SixtMay 31, 2012
  5. Fredrik GustafssonMay 31, 2012
  6. Johannes SixtMay 31, 2012
  7. Junio C HamanoMay 31, 2012
  8. Fredrik GustafssonMay 31, 2012
  9. Junio C HamanoMay 31, 2012

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.