git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Parkins <andyparkins@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] Add --patchdepth parameter to git-am.sh
Date: Mon, 5 Feb 2007 19:24:38 +0000	[thread overview]
Message-ID: <200702051924.39205.andyparkins@gmail.com> (raw)
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

  parent reply	other threads:[~2007-02-05 19:28 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-05  6:48 Deprecation/Removal schedule Junio C Hamano
2007-02-05  6:57 ` Shawn O. Pearce
2007-02-05  9:33 ` Jakub Narebski
2007-02-05 10:11   ` Jakub Narebski
2007-02-05 10:25     ` Shawn O. Pearce
2007-02-05 15:50   ` Alex Riesen
2007-02-05 19:45     ` Shawn O. Pearce
2007-02-05 22:49       ` Alex Riesen
2007-02-05 22:55         ` Shawn O. Pearce
2007-02-06 10:20           ` Alex Riesen
2007-02-06 10:45             ` Johannes Schindelin
2007-02-06 11:00               ` Jeff King
2007-02-06 11:03                 ` Johannes Schindelin
2007-02-06 13:09                   ` Alex Riesen
2007-02-06 13:24                     ` Johannes Schindelin
2007-02-06 13:32                       ` Alex Riesen
2007-02-06 13:01               ` Alex Riesen
2007-02-05 12:00 ` Mark Wooding
2007-02-05 12:45 ` Johannes Schindelin
2007-02-05 15:53 ` Alex Riesen
2007-02-05 16:26 ` Linus Torvalds
2007-02-05 17:56   ` Junio C Hamano
2007-02-05 19:24 ` Andy Parkins [this message]
2007-02-05 19:37   ` [PATCH] Add --patchdepth parameter to git-am.sh Shawn O. Pearce
2007-02-07  8:27   ` Junio C Hamano
2007-02-07  9:44     ` Jakub Narebski
2007-02-07  9:59     ` Andy Parkins
2007-02-06 14:55 ` Deprecation/Removal schedule Andreas Ericsson
2007-02-06 15:26   ` Alex Riesen
2007-02-06 15:33     ` Johannes Schindelin
2007-02-07  7:12 ` Junio C Hamano
2007-02-07  8:33   ` Jakub Narebski
2007-02-07  9:33     ` Johannes Schindelin
2007-02-07 10:13       ` Jakub Narebski
2007-02-07  9:37     ` Junio C Hamano
2007-02-07 11:10   ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200702051924.39205.andyparkins@gmail.com \
    --to=andyparkins@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).