[PATCH 12/16] git-submodule: avoid sed input with no newline

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some versions of sed don't like this, and give no output at
all. Instead, we can use git-config to pare down the matches
for us.

The content of the last three lines of the patch aren't
changed at all; they merely fix a bogus 7-space indentation.

Signed-off-by: Jeff King <peff@xxxxxxxx>
---
And this is safe because of the --literal-match from the last patch.

 git-submodule.sh |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index ceb2295..fb01d94 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -71,13 +71,12 @@ resolve_relative_url ()
 module_name()
 {
 	# Do we have "submodule.<something>.path = $1" defined in .gitmodules file?
-	re=$(printf '%s' "$1" | sed -e 's/[].[^$\\*]/\\&/g')
-	name=$( GIT_CONFIG=.gitmodules \
-		git config --get-regexp '^submodule\..*\.path$' |
-		sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' )
-       test -z "$name" &&
-       die "No submodule mapping found in .gitmodules for path '$path'"
-       echo "$name"
+	name=$(git config --literal-match -f .gitmodules \
+		--get-regexp 'submodule\..*\.path$' "$1" |
+		sed -e 's/submodule\.//' -e 's/\.path.*//')
+	test -z "$name" &&
+	die "No submodule mapping found in .gitmodules for path '$path'"
+	echo "$name"
 }
 
 #
-- 
1.5.4.4.543.g30fdd.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux