git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* quoting in get_author_ident_from_commit
@ 2010-09-22 21:23 Uwe Kleine-König
  2010-09-23  9:22 ` [PATCH] get_author_ident_from_commit(): remove useless quoting Uwe Kleine-König
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2010-09-22 21:23 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

Hello,

I wonder about the quoting done in get_author_ident_from_commit's sed
script.

It first does 's/'\''/'\''\\'\'\''/g', then 's/'\''/'\''\'\'\''/g' (the
latter once for each resulting line).
What sed actually sees is:

	s/'/'\\''/g
	s/'/'\''/g 

The second instruction only substitutes a single quote by three single
quotes because \' is just interpreted as '.

So I think just removing the three occurences of the second substitute
command just can be removed, as ''' effectively is the same as '.

Do I miss something?

(The first command was introduced in
aa66c7ec77d474b737da607d6cb2d07f56628def, the second was introduced with
git commit -m in fec3ef101c0f18bbf2400423dc70e686e9d25b0)

Thanks
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* [PATCH] get_author_ident_from_commit(): remove useless quoting
  2010-09-22 21:23 quoting in get_author_ident_from_commit Uwe Kleine-König
@ 2010-09-23  9:22 ` Uwe Kleine-König
  2010-09-27  4:15   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2010-09-23  9:22 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

The command 's/'\''/'\''\'\'\''/g' only triples single quotes:

	$ echo "What's up?" | sed 's/'\''/'\''\'\'\''/g'
	What'''s up?

This doesn't hurt as compared to a single single quote it only adds an
empty string, but it makes the script needlessly complicated and hard to
understand.  The useful quoting is done by s/'\''/'\''\\'\'\''/g at the
beginning of the script and only once for all three variables.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 git-sh-setup.sh |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 6131670..8d54b73 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -151,17 +151,14 @@ get_author_ident_from_commit () {
 		s/'\''/'\''\\'\'\''/g
 		h
 		s/^author \([^<]*\) <[^>]*> .*$/\1/
-		s/'\''/'\''\'\'\''/g
 		s/.*/GIT_AUTHOR_NAME='\''&'\''/p
 
 		g
 		s/^author [^<]* <\([^>]*\)> .*$/\1/
-		s/'\''/'\''\'\'\''/g
 		s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
 
 		g
 		s/^author [^<]* <[^>]*> \(.*\)$/\1/
-		s/'\''/'\''\'\'\''/g
 		s/.*/GIT_AUTHOR_DATE='\''&'\''/p
 
 		q
-- 
1.7.2.3

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

* Re: [PATCH] get_author_ident_from_commit(): remove useless quoting
  2010-09-23  9:22 ` [PATCH] get_author_ident_from_commit(): remove useless quoting Uwe Kleine-König
@ 2010-09-27  4:15   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2010-09-27  4:15 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: git

Uwe Kleine-König  <u.kleine-koenig@pengutronix.de> writes:

> The command 's/'\''/'\''\'\'\''/g' only triples single quotes:
>
> 	$ echo "What's up?" | sed 's/'\''/'\''\'\'\''/g'
> 	What'''s up?
>
> This doesn't hurt as compared to a single single quote it only adds an
> empty string, but it makes the script needlessly complicated and hard to
> understand.

Interesting.  I think this was an ancient misconversion that dates back to
June 2005 ;-)

Thanks.

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

end of thread, other threads:[~2010-09-27  4:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-22 21:23 quoting in get_author_ident_from_commit Uwe Kleine-König
2010-09-23  9:22 ` [PATCH] get_author_ident_from_commit(): remove useless quoting Uwe Kleine-König
2010-09-27  4:15   ` 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).