From bb034f839a396cf0660024a59bbff61f8ef0c5af Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 4 Mar 2008 00:25:04 -0800 Subject: 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. Signed-off-by: Junio C Hamano --- 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 diff --git a/git-am.sh b/git-am.sh index a2c6fea47a..2b5bbb772a 100755 --- a/git-am.sh +++ b/git-am.sh @@ -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 diff --git a/t/t4150-am-subdir.sh b/t/t4150-am-subdir.sh new file mode 100755 index 0000000000..929d2cbd87 --- /dev/null +++ b/t/t4150-am-subdir.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +test_description='git am running from a subdirectory' + +. ./test-lib.sh + +test_expect_success setup ' + echo hello >world && + git add world && + test_tick && + git commit -m initial && + git tag initial && + echo goodbye >world && + git add world && + test_tick && + git commit -m second && + git format-patch --stdout HEAD^ >patchfile && + : >expect +' + +test_expect_success 'am regularly from stdin' ' + git checkout initial && + git am actual && + diff -u expect actual +' + +test_expect_success 'am regularly from file' ' + git checkout initial && + git am patchfile && + git diff master >actual && + diff -u expect actual +' + +test_expect_success 'am regularly from stdin in subdirectory' ' + rm -fr subdir && + git checkout initial && + ( + mkdir -p subdir && + cd subdir && + git am <../patchfile + ) && + git diff master>actual && + diff -u expect actual +' + +test_expect_success 'am regularly from file in subdirectory' ' + rm -fr subdir && + git checkout initial && + ( + mkdir -p subdir && + cd subdir && + git am ../patchfile + ) && + git diff master >actual && + diff -u expect actual +' + +test_expect_success 'am regularly from file in subdirectory with full path' ' + rm -fr subdir && + git checkout initial && + P=$(pwd) && + ( + mkdir -p subdir && + cd subdir && + git am "$P/patchfile" + ) && + git diff master >actual && + diff -u expect actual +' + +test_done -- cgit v1.2.3 From e72c74062c01855372add133fe8dcc0bd22bad20 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 4 Mar 2008 00:25:05 -0800 Subject: 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. Signed-off-by: Junio C Hamano --- Documentation/git-am.txt | 6 +----- git-am.sh | 14 +++++--------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt index e640fc75cd..2387a8d6c2 100644 --- a/Documentation/git-am.txt +++ b/Documentation/git-am.txt @@ -9,7 +9,7 @@ git-am - Apply a series of patches from a mailbox SYNOPSIS -------- [verse] -'git-am' [--signoff] [--dotest=] [--keep] [--utf8 | --no-utf8] +'git-am' [--signoff] [--keep] [--utf8 | --no-utf8] [--3way] [--interactive] [--binary] [--whitespace=