Thread (5 messages) flat view 5 messages, 3 authors, 2016-06-15

Re: [PATCH] Allow passing of --directory to git-am.

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:45:44

Simon 'corecode' Schubert [off-list ref] writes:
quoted hunk ↗ jump to hunk
We need to play some shell tricks to be able to pass directory names
which contain spaces and/or quotes.

Signed-off-by: Simon 'corecode' Schubert <redacted>
---

Boyd Stephen Smith Jr. wrote:
 > I'm thinking your sed line doesn't do what you think it does.
 > You probably want something like:
 > bss@monster:~$ echo "don't" | sed -e "s/'/'\\\\''/g"
 > don'\''t

Thanks, I clearly did not test this well enough.

  git-am.sh |    8 +++++---
  1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index aa60261..3baff4e 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -16,6 +16,7 @@ s,signoff       add a Signed-off-by line to the commit message
  u,utf8          recode into utf8 (default)
  k,keep          pass -k flag to git-mailinfo
  whitespace=     pass it through git-apply
+directory=      pass it through git-apply
Shouldn't it be

+ directory=      pass it through git-apply

to have it aligned like the rest of it?

By the way, your patch looks whitespace damaged, although only context
for the above chunk was wrapped...
quoted hunk ↗ jump to hunk
  C=              pass it through git-apply
  p=              pass it through git-apply
  resolvemsg=     override error message when patch failure occurs
@@ -155,8 +156,9 @@ do
  		;;
  	--resolvemsg)
  		shift; resolvemsg=$1 ;;
-	--whitespace)
-		git_apply_opt="$git_apply_opt $1=$2"; shift ;;
+	--whitespace|--directory)
+		quot=$(echo "$2" | sed -e "s/'/'\\\''/g")
Why not simply use "git rev-parse --sq"?
quoted hunk ↗ jump to hunk
+		git_apply_opt="$git_apply_opt $1='$quot'"; shift ;;
  	-C|-p)
  		git_apply_opt="$git_apply_opt $1$2"; shift ;;
  	--)
@@ -454,7 +456,7 @@ do

  	case "$resolved" in
  	'')
-		git apply $git_apply_opt --index "$dotest/patch"
+		eval git apply $git_apply_opt --index '"$dotest/patch"'
Why eval?
  		apply_status=$?
  		;;
  	t)
-- 
1.6.1.rc1.45.g123ed.dirty
Hmmm... 

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help