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

[PATCH] Add --patchdepth parameter to git-am.sh

From
APAndy Parkins <andyparkins@gmail.com>
Date
Feb 5, 2007, 19:24 UTC
Message-ID
<200702051924.39205.andyparkins@gmail.com>
In-Reply-To
<7v8xfdnlqm.fsf@assigned-by-dhcp.cox.net>

If the series of patches you are applying via git-am was based in a different directory there was no way to strip the directory (as you would with git-apply).

This patch adds a --patchdepth option to git-am.sh whose argument is passed as a "-p" option to git-apply.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
I know git-apply isn't going anywhere, but git-applypatch is.  However, all
this talk of it made me remember this patch.
 git-am.sh |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index 1252f26..cb503fc 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -60,7 +60,7 @@ fall_back_3way () {
     mkdir "$dotest/patch-merge-tmp-dir"
 
     # First see if the patch records the index info that we can use.
-    git-apply -z --index-info "$dotest/patch" \
+    git-apply $patchdepth -z --index-info "$dotest/patch" \
 	>"$dotest/patch-merge-index-info" &&
     GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
     git-update-index -z --index-info <"$dotest/patch-merge-index-info" &&
@@ -70,7 +70,7 @@ fall_back_3way () {
 
     echo Using index info to reconstruct a base tree...
     if GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
-	git-apply $binary --cached <"$dotest/patch"
+	git-apply $patchdepth $binary --cached <"$dotest/patch"
     then
 	mv "$dotest/patch-merge-base+" "$dotest/patch-merge-base"
 	mv "$dotest/patch-merge-tmp-index" "$dotest/patch-merge-index"
@@ -106,7 +106,7 @@ It does not apply to blobs recorded in its index."
 }
 
 prec=4
-dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= ws= resolvemsg=
+dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= ws= resolvemsg= patchdepth=
 
 while case "$#" in 0) break;; esac
 do
@@ -147,6 +147,9 @@ do
 	--resolvemsg=*)
 	resolvemsg=$(echo "$1" | sed -e "s/^--resolvemsg=//"); shift ;;
 
+	--patchdepth=*)
+	patchdepth=-p$(echo "$1" | sed -e "s/^--patchdepth=//"); shift ;;
+
 	--)
 	shift; break ;;
 	-*)
@@ -389,12 +392,12 @@ do
 	fi
 
 	echo
-	echo "Applying '$SUBJECT'"
+	echo "Applying '$SUBJECT' at depth $patchdepth"
 	echo
 
 	case "$resolved" in
 	'')
-		git-apply $binary --index $ws "$dotest/patch"
+		git-apply $patchdepth $binary --index $ws "$dotest/patch"
 		apply_status=$?
 		;;
 	t)
-- 
1.5.0.rc1.gf4b6c
Previous: Junio C HamanoNext: Shawn O. Pearce
Message 23 of 36 in “Deprecation/Removal schedule”
  1. Junio C HamanoFeb 5, 2007
  2. Shawn O. PearceFeb 5, 2007
  3. Jakub NarebskiFeb 5, 2007
  4. Jakub NarebskiFeb 5, 2007
  5. Shawn O. PearceFeb 5, 2007
  6. Alex RiesenFeb 5, 2007
  7. Shawn O. PearceFeb 5, 2007
  8. Alex RiesenFeb 5, 2007
  9. Shawn O. PearceFeb 5, 2007
  10. Alex RiesenFeb 6, 2007
  11. Johannes SchindelinFeb 6, 2007
  12. Jeff KingFeb 6, 2007
  13. Johannes SchindelinFeb 6, 2007
  14. Alex RiesenFeb 6, 2007
  15. Johannes SchindelinFeb 6, 2007
  16. Alex RiesenFeb 6, 2007
  17. Alex RiesenFeb 6, 2007
  18. Mark WoodingFeb 5, 2007
  19. Johannes SchindelinFeb 5, 2007
  20. Alex RiesenFeb 5, 2007
  21. Linus TorvaldsFeb 5, 2007
  22. Junio C HamanoFeb 5, 2007
  23. Add --patchdepth parameter to git-am.shAndy Parkins, Feb 5, 2007
  24. Shawn O. PearceFeb 5, 2007
  25. Junio C HamanoFeb 7, 2007
  26. Jakub NarebskiFeb 7, 2007
  27. Andy ParkinsFeb 7, 2007
  28. Andreas EricssonFeb 6, 2007
  29. Alex RiesenFeb 6, 2007
  30. Johannes SchindelinFeb 6, 2007
  31. Junio C HamanoFeb 7, 2007
  32. Jakub NarebskiFeb 7, 2007
  33. Johannes SchindelinFeb 7, 2007
  34. Jakub NarebskiFeb 7, 2007
  35. Junio C HamanoFeb 7, 2007
  36. Johannes SchindelinFeb 7, 2007

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.