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

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

From
Simon 'corecode' Schubert <corecode@fs.ei.tum.de>
Date
Dec 4, 2008, 18:48 UTC
Message-ID
<49382612.3010207@fs.ei.tum.de>

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 <corecode@fs.ei.tum.de>
---
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
  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")
+		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"'
  		apply_status=$?
  		;;
  	t)
-- 
1.6.1.rc1.45.g123ed.dirty
Next: Jeff King
Message 1 of 13 in “Allow passing of --directory to git-am.”
  1. Allow passing of --directory to git-am.Simon 'corecode' Schubert, Dec 4, 2008
  2. Jeff KingDec 4, 2008
  3. Junio C HamanoDec 4, 2008
  4. Simon 'corecode' SchubertDec 4, 2008
  5. Junio C HamanoDec 4, 2008
  6. Junio C HamanoDec 4, 2008
  7. git-am: propagate -C/-p as wellJunio C Hamano, Dec 4, 2008
  8. Simon 'corecode' SchubertDec 4, 2008
  9. Junio C HamanoDec 5, 2008
  10. Simon 'corecode' SchubertDec 5, 2008
  11. Jakub NarebskiDec 4, 2008
  12. Simon 'corecode' SchubertDec 4, 2008
  13. Jakub NarebskiDec 4, 2008

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.