am: read from the right mailbox when started from a subdirectory
PATCH 1/3 am: read from the right mailbox when started from a subdirectory
An earlier commit c149184 (allow git-am to run in a subdirectory) taught git-am to start from a subdirectory by going up to the root of the work tree byitself, but it did not adjust the path to read the mbox from when it did so.
---
* This is a fixed-up version of an earlier patch I sent to Jeff and the list, and should be considered as a bugfix.
git-am.sh | 25 ++++++++++++++++- t/t4150-am-subdir.sh | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 2 deletions(-) create mode 100755 t/t4150-am-subdir.sh
git-am.sh +23 -2
@@ -24,6 +24,7 @@ r,resolved to be used after a patch failure skip skip the current patch" . git-sh-setup +prefix=$(git rev-parse --show-prefix) set_reflog_action am require_work_tree cd_to_toplevel
@@ -124,7 +125,8 @@ reread_subject () { } prec=4 -dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= +dotest="${prefix}.dotest" +sign= utf8=t keep= skip= interactive= resolved= binary= resolvemsg= resume= git_apply_opt=
@@ -150,7 +152,8 @@ do --skip) skip=t ;; -d|--dotest) - shift; dotest=$1;; + shift + case "$1" in /*) dotest=$1;; *) dotest="$prefix$1" ;; esac ;; --resolvemsg) shift; resolvemsg=$1 ;; --whitespace)
@@ -206,6 +209,24 @@ else # Start afresh. mkdir -p "$dotest" || exit + if test -n "$prefix" && test $# != 0 + then + first=t + for arg + do + test -n "$first" && { + set x + first= + } + case "$arg" in + /*) + set "$@" "$arg" ;; + *) + set "$@" "$prefix$arg" ;; + esac + done + shift + fi git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || { rm -fr "$dotest" exit 1
t/t4150-am-subdir.sh new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
1.5.4.3.529.gb25fb
PATCH 2/3 am: remove support for -d .dotest
It has been supported for a long time, but I do not think this feature has been in use in the real world at all. We would eventually move this out of the toplevel of the work tree and to somewhere under $GIT_DIR, so let's remove the command line option to specify the location now.
--- git-am.sh | 14 +++++--------- 1 files changed, 5 insertions(+), 9 deletions(-)
git-am.sh +5 -9
@@ -9,7 +9,7 @@ git-am [options] <mbox>|<Maildir>... git-am [options] --resolved git-am [options] --skip -- -d,dotest= use <dir> and not .dotest +d,dotest= (removed -- do not use) i,interactive run interactively b,binary pass --allo-binary-replacement to git-apply 3,3way allow fall back on 3way merging if needed
@@ -50,10 +50,6 @@ stop_here_user_resolve () { then cmdline="$cmdline -3" fi - if test '.dotest' != "$dotest" - then - cmdline="$cmdline -d=$dotest" - fi echo "When you have resolved this problem run \"$cmdline --resolved\"." echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"."
@@ -125,7 +121,7 @@ reread_subject () { } prec=4 -dotest="${prefix}.dotest" +dotest=".dotest" sign= utf8=t keep= skip= interactive= resolved= binary= resolvemsg= resume= git_apply_opt=
@@ -152,8 +148,8 @@ do --skip) skip=t ;; -d|--dotest) - shift - case "$1" in /*) dotest=$1;; *) dotest="$prefix$1" ;; esac ;; + die "-d option is not longer supported. Do not use." + ;; --resolvemsg) shift; resolvemsg=$1 ;; --whitespace)
@@ -189,7 +185,7 @@ then 0,) # No file input but without resume parameters; catch # user error to feed us a patch from standard input - # when there is already .dotest. This is somewhat + # when there is already $dotest. This is somewhat # unreliable -- stdin could be /dev/null for example # and the caller did not intend to feed us a patch but # wanted to continue unattended.
Signature · 1 line
1.5.4.3.529.gb25fb
PATCH 3/3 am: --rebasing
The new option --rebasing is used internally for rebase to tell am that it is being used for its purpose. This would leave .dotest/rebasing to help "completion" scripts tell if the ongoing operation is am or rebase.
Also the option at the same time stands for --binary, -3 and -k which are always given when rebase drives am as its backend.
Using the information "am" leaves, git-completion.bash tells ongoing rebase and am apart.
--- contrib/completion/git-completion.bash | 10 +++++++++- git-am.sh | 13 +++++++++++-- git-rebase.sh | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-)
contrib/completion/git-completion.bash +9 -1
@@ -70,7 +70,15 @@ __git_ps1 () local b if [ -d "$g/../.dotest" ] then - r="|AM/REBASE" + if test -f "$g/../.dotest/rebasing" + then + r="|REBASE" + elif test -f "$g/../.dotest/applying" + then + r="|AM" + else + r="|AM/REBASE" + fi b="$(git symbolic-ref HEAD 2>/dev/null)" elif [ -f "$g/.dotest-merge/interactive" ] then
git-am.sh +11 -2
@@ -21,7 +21,8 @@ C= pass it through git-apply p= pass it through git-apply resolvemsg= override error message when patch failure occurs r,resolved to be used after a patch failure -skip skip the current patch" +skip skip the current patch +rebasing (internal use for git-rebase)" . git-sh-setup prefix=$(git rev-parse --show-prefix)
@@ -122,7 +123,7 @@ reread_subject () { prec=4 dotest=".dotest" -sign= utf8=t keep= skip= interactive= resolved= binary= +sign= utf8=t keep= skip= interactive= resolved= binary= rebasing= resolvemsg= resume= git_apply_opt=
@@ -147,6 +148,8 @@ do resolved=t ;; --skip) skip=t ;; + --rebasing) + rebasing=t threeway=t keep=t binary=t ;; -d|--dotest) die "-d option is not longer supported. Do not use." ;;
@@ -237,6 +240,12 @@ else echo "$utf8" >"$dotest/utf8" echo "$keep" >"$dotest/keep" echo 1 >"$dotest/next" + if test -n "$rebasing" + then + : >"$dotest/rebasing" + else + : >"$dotest/applying" + fi fi case "$resolved" in
git-rebase.sh +1 -1
@@ -376,7 +376,7 @@ fi if test -z "$do_merge" then git format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD | - git am $git_am_opt --binary -3 -k --resolvemsg="$RESOLVEMSG" && + git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" && move_to_original_branch ret=$? test 0 != $ret -a -d .dotest &&
Signature · 1 line
1.5.4.3.529.gb25fb
Re: [PATCH 2/3] am: remove support for -d .dotest
In reply to Junio C Hamanogit-am.sh do · line 151
Quoted 7 lines · Junio C Hamano
git-am.sh +1
-2@@ -152,8 +148,8 @@ do --skip) skip=t ;; -d|--dotest) - shift - case "$1" in /*) dotest=$1;; *) dotest="$prefix$1" ;; esac ;; + die "-d option is not longer supported. Do not use."
s/not longer/no longer/
Also, probably want to remove mention of the option from Documentation/git-am.txt as well.
j.