* [PATCH 0/4] Fix longstanding "git am" bug @ 2008-12-05 2:22 Junio C Hamano 2008-12-05 2:22 ` [PATCH 1/4] git-am --whitespace: do not lose the command line option Junio C Hamano 0 siblings, 1 reply; 7+ messages in thread From: Junio C Hamano @ 2008-12-05 2:22 UTC (permalink / raw) To: git Simon Schubert rerolled a patch to add "git am --directory=<dir>" from three months ago, which is a good complement to existing "git am -p<n>", but it had the same issue of duplicating an existing bug to the new feature. Let's fix the existing bug first, before accepting any new feature, which will happen after 1.6.1 goes final. Junio C Hamano (4): git-am --whitespace: do not lose the command line option git-am: propagate -C<n>, -p<n> options as well git-am: propagate --3way options as well Test that git-am does not lose -C/-p/--whitespace options git-am.sh | 15 +++++++++---- t/t4252-am-options.sh | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ t/t4252/am-test-1-1 | 19 +++++++++++++++++ t/t4252/am-test-1-2 | 21 +++++++++++++++++++ t/t4252/am-test-2-1 | 19 +++++++++++++++++ t/t4252/am-test-2-2 | 21 +++++++++++++++++++ t/t4252/am-test-3-1 | 19 +++++++++++++++++ t/t4252/am-test-3-2 | 21 +++++++++++++++++++ t/t4252/am-test-4-1 | 19 +++++++++++++++++ t/t4252/am-test-4-2 | 22 ++++++++++++++++++++ t/t4252/file-1-0 | 7 ++++++ t/t4252/file-2-0 | 7 ++++++ 12 files changed, 239 insertions(+), 5 deletions(-) create mode 100755 t/t4252-am-options.sh create mode 100644 t/t4252/am-test-1-1 create mode 100644 t/t4252/am-test-1-2 create mode 100644 t/t4252/am-test-2-1 create mode 100644 t/t4252/am-test-2-2 create mode 100644 t/t4252/am-test-3-1 create mode 100644 t/t4252/am-test-3-2 create mode 100644 t/t4252/am-test-4-1 create mode 100644 t/t4252/am-test-4-2 create mode 100644 t/t4252/file-1-0 create mode 100644 t/t4252/file-2-0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/4] git-am --whitespace: do not lose the command line option 2008-12-05 2:22 [PATCH 0/4] Fix longstanding "git am" bug Junio C Hamano @ 2008-12-05 2:22 ` Junio C Hamano 2008-12-05 2:22 ` [PATCH 2/4] git-am: propagate -C<n>, -p<n> options as well Junio C Hamano 0 siblings, 1 reply; 7+ messages in thread From: Junio C Hamano @ 2008-12-05 2:22 UTC (permalink / raw) To: git When you start "git am --whitespace=fix" and the patch application process is interrupted by an unapplicable patch early in the series, after fixing the offending patch, the remainder of the patch should be processed still with --whitespace=fix when restarted with "git am --resolved" (or dropping the offending patch with "git am --skip"). The breakage was introduced by the commit 67dad68 (add -C[NUM] to git-am, 2007-02-08); this should fix it. Signed-off-by: Junio C Hamano <gitster@pobox.com> --- git-am.sh | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/git-am.sh b/git-am.sh index aa60261..1bf70d4 100755 --- a/git-am.sh +++ b/git-am.sh @@ -121,7 +121,7 @@ It does not apply to blobs recorded in its index." prec=4 dotest="$GIT_DIR/rebase-apply" -sign= utf8=t keep= skip= interactive= resolved= rebasing= abort= +sign= utf8=t keep= skip= interactive= resolved= rebasing= abort= ws= resolvemsg= resume= git_apply_opt= @@ -156,7 +156,7 @@ do --resolvemsg) shift; resolvemsg=$1 ;; --whitespace) - git_apply_opt="$git_apply_opt $1=$2"; shift ;; + ws="--whitespace=$2"; shift ;; -C|-p) git_apply_opt="$git_apply_opt $1$2"; shift ;; --) @@ -283,7 +283,7 @@ if test "$(cat "$dotest/keep")" = t then keep=-k fi -ws=`cat "$dotest/whitespace"` +ws=$(cat "$dotest/whitespace") if test "$(cat "$dotest/sign")" = t then SIGNOFF=`git var GIT_COMMITTER_IDENT | sed -e ' @@ -454,7 +454,7 @@ do case "$resolved" in '') - git apply $git_apply_opt --index "$dotest/patch" + git apply $git_apply_opt $ws --index "$dotest/patch" apply_status=$? ;; t) -- 1.6.1.rc1.60.g1d1d7 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] git-am: propagate -C<n>, -p<n> options as well 2008-12-05 2:22 ` [PATCH 1/4] git-am --whitespace: do not lose the command line option Junio C Hamano @ 2008-12-05 2:22 ` Junio C Hamano 2008-12-05 2:22 ` [PATCH 3/4] git-am: propagate --3way " Junio C Hamano 2008-12-05 12:21 ` [PATCH 2/4] git-am: propagate -C<n>, -p<n> options as well Johannes Schindelin 0 siblings, 2 replies; 7+ messages in thread From: Junio C Hamano @ 2008-12-05 2:22 UTC (permalink / raw) To: git These options are meant to deal with patches that do not apply cleanly due to the differences between the version the patch was based on and the version "git am" is working on. Because a series of patches applied in the same "git am" run tends to come from the same source, it is more useful to propagate these options after the application stops. Signed-off-by: Junio C Hamano <gitster@pobox.com> --- git-am.sh | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/git-am.sh b/git-am.sh index 1bf70d4..ed54e71 100755 --- a/git-am.sh +++ b/git-am.sh @@ -121,7 +121,7 @@ It does not apply to blobs recorded in its index." prec=4 dotest="$GIT_DIR/rebase-apply" -sign= utf8=t keep= skip= interactive= resolved= rebasing= abort= ws= +sign= utf8=t keep= skip= interactive= resolved= rebasing= abort= resolvemsg= resume= git_apply_opt= @@ -156,7 +156,7 @@ do --resolvemsg) shift; resolvemsg=$1 ;; --whitespace) - ws="--whitespace=$2"; shift ;; + git_apply_opt="$git_apply_opt $1=$2"; shift ;; -C|-p) git_apply_opt="$git_apply_opt $1$2"; shift ;; --) @@ -247,10 +247,10 @@ else exit 1 } - # -s, -u, -k and --whitespace flags are kept for the - # resuming session after a patch failure. + # -s, -u, -k, --whitespace, -C and -p flags are kept + # for the resuming session after a patch failure. # -3 and -i can and must be given when resuming. - echo " $ws" >"$dotest/whitespace" + echo " $git_apply_opt" >"$dotest/apply_opt_extra" echo "$sign" >"$dotest/sign" echo "$utf8" >"$dotest/utf8" echo "$keep" >"$dotest/keep" @@ -283,7 +283,7 @@ if test "$(cat "$dotest/keep")" = t then keep=-k fi -ws=$(cat "$dotest/whitespace") +git_apply_opt=$(cat "$dotest/apply_opt_extra") if test "$(cat "$dotest/sign")" = t then SIGNOFF=`git var GIT_COMMITTER_IDENT | sed -e ' @@ -454,7 +454,7 @@ do case "$resolved" in '') - git apply $git_apply_opt $ws --index "$dotest/patch" + git apply $git_apply_opt --index "$dotest/patch" apply_status=$? ;; t) -- 1.6.1.rc1.60.g1d1d7 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/4] git-am: propagate --3way options as well 2008-12-05 2:22 ` [PATCH 2/4] git-am: propagate -C<n>, -p<n> options as well Junio C Hamano @ 2008-12-05 2:22 ` Junio C Hamano 2008-12-05 2:23 ` [PATCH 4/4] Test that git-am does not lose -C/-p/--whitespace options Junio C Hamano 2008-12-05 12:21 ` [PATCH 2/4] git-am: propagate -C<n>, -p<n> options as well Johannes Schindelin 1 sibling, 1 reply; 7+ messages in thread From: Junio C Hamano @ 2008-12-05 2:22 UTC (permalink / raw) To: git The reasoning is the same as the previous patch, where we made -C<n> and -p<n> propagate across a failure. Signed-off-by: Junio C Hamano <gitster@pobox.com> --- git-am.sh | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/git-am.sh b/git-am.sh index ed54e71..13c02d6 100755 --- a/git-am.sh +++ b/git-am.sh @@ -247,10 +247,11 @@ else exit 1 } - # -s, -u, -k, --whitespace, -C and -p flags are kept + # -s, -u, -k, --whitespace, -3, -C and -p flags are kept # for the resuming session after a patch failure. - # -3 and -i can and must be given when resuming. + # -i can and must be given when resuming. echo " $git_apply_opt" >"$dotest/apply_opt_extra" + echo "$threeway" >"$dotest/threeway" echo "$sign" >"$dotest/sign" echo "$utf8" >"$dotest/utf8" echo "$keep" >"$dotest/keep" @@ -283,6 +284,10 @@ if test "$(cat "$dotest/keep")" = t then keep=-k fi +if test "$(cat "$dotest/threeway")" = t +then + threeway=t +fi git_apply_opt=$(cat "$dotest/apply_opt_extra") if test "$(cat "$dotest/sign")" = t then -- 1.6.1.rc1.60.g1d1d7 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] Test that git-am does not lose -C/-p/--whitespace options 2008-12-05 2:22 ` [PATCH 3/4] git-am: propagate --3way " Junio C Hamano @ 2008-12-05 2:23 ` Junio C Hamano 0 siblings, 0 replies; 7+ messages in thread From: Junio C Hamano @ 2008-12-05 2:23 UTC (permalink / raw) To: git These tests make sure that "git am" does not lose command line options specified when it was started, after it is interrupted by a patch that does not apply earlier in the series. Signed-off-by: Junio C Hamano <gitster@pobox.com> --- t/t4252-am-options.sh | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ t/t4252/am-test-1-1 | 19 +++++++++++++++++ t/t4252/am-test-1-2 | 21 +++++++++++++++++++ t/t4252/am-test-2-1 | 19 +++++++++++++++++ t/t4252/am-test-2-2 | 21 +++++++++++++++++++ t/t4252/am-test-3-1 | 19 +++++++++++++++++ t/t4252/am-test-3-2 | 21 +++++++++++++++++++ t/t4252/am-test-4-1 | 19 +++++++++++++++++ t/t4252/am-test-4-2 | 22 ++++++++++++++++++++ t/t4252/file-1-0 | 7 ++++++ t/t4252/file-2-0 | 7 ++++++ 11 files changed, 229 insertions(+), 0 deletions(-) create mode 100755 t/t4252-am-options.sh create mode 100644 t/t4252/am-test-1-1 create mode 100644 t/t4252/am-test-1-2 create mode 100644 t/t4252/am-test-2-1 create mode 100644 t/t4252/am-test-2-2 create mode 100644 t/t4252/am-test-3-1 create mode 100644 t/t4252/am-test-3-2 create mode 100644 t/t4252/am-test-4-1 create mode 100644 t/t4252/am-test-4-2 create mode 100644 t/t4252/file-1-0 create mode 100644 t/t4252/file-2-0 diff --git a/t/t4252-am-options.sh b/t/t4252-am-options.sh new file mode 100755 index 0000000..1a1946d --- /dev/null +++ b/t/t4252-am-options.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +test_description='git am not losing options' +. ./test-lib.sh + +tm="$TEST_DIRECTORY/t4252" + +test_expect_success setup ' + cp "$tm/file-1-0" file-1 && + cp "$tm/file-2-0" file-2 && + git add file-1 file-2 && + test_tick && + git commit -m initial && + git tag initial +' + +test_expect_success 'interrupted am --whitespace=fix' ' + rm -rf .git/rebase-apply && + git reset --hard initial && + test_must_fail git am --whitespace=fix "$tm"/am-test-1-? && + git am --skip && + grep 3 file-1 && + grep "^Six$" file-2 +' + +test_expect_success 'interrupted am -C1' ' + rm -rf .git/rebase-apply && + git reset --hard initial && + test_must_fail git am -C1 "$tm"/am-test-2-? && + git am --skip && + grep 3 file-1 && + grep "^Three$" file-2 +' + +test_expect_success 'interrupted am -p2' ' + rm -rf .git/rebase-apply && + git reset --hard initial && + test_must_fail git am -p2 "$tm"/am-test-3-? && + git am --skip && + grep 3 file-1 && + grep "^Three$" file-2 +' + +test_expect_success 'interrupted am -C1 -p2' ' + rm -rf .git/rebase-apply && + git reset --hard initial && + test_must_fail git am -p2 -C1 "$tm"/am-test-4-? && + cat .git/rebase-apply/apply_opt_extra && + git am --skip && + grep 3 file-1 && + grep "^Three$" file-2 +' + +test_done diff --git a/t/t4252/am-test-1-1 b/t/t4252/am-test-1-1 new file mode 100644 index 0000000..b0c09dc --- /dev/null +++ b/t/t4252/am-test-1-1 @@ -0,0 +1,19 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Three + +Application of this should be rejected because the first line in the +context does not match. + +diff --git i/file-1 w/file-1 +index 06e567b..10f8342 100644 +--- i/file-1 ++++ w/file-1 +@@ -1,6 +1,6 @@ + One + 2 +-3 ++Three + 4 + 5 + 6 diff --git a/t/t4252/am-test-1-2 b/t/t4252/am-test-1-2 new file mode 100644 index 0000000..1b874ae --- /dev/null +++ b/t/t4252/am-test-1-2 @@ -0,0 +1,21 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Six + +Applying this patch with --whitespace=fix should lose +the trailing whitespace after "Six". + +diff --git i/file-2 w/file-2 +index 06e567b..b6f3a16 100644 +--- i/file-2 ++++ w/file-2 +@@ -1,7 +1,7 @@ + 1 + 2 +-3 ++Three + 4 + 5 +-6 ++Six + 7 diff --git a/t/t4252/am-test-2-1 b/t/t4252/am-test-2-1 new file mode 100644 index 0000000..feda94a --- /dev/null +++ b/t/t4252/am-test-2-1 @@ -0,0 +1,19 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Three + +Application of this should be rejected even with -C1 because the +preimage line in the context does not match. + +diff --git i/file-1 w/file-1 +index 06e567b..10f8342 100644 +--- i/file-1 ++++ w/file-1 +@@ -1,6 +1,6 @@ + 1 + 2 +-Tres ++Three + 4 + 5 + 6 diff --git a/t/t4252/am-test-2-2 b/t/t4252/am-test-2-2 new file mode 100644 index 0000000..2ac6600 --- /dev/null +++ b/t/t4252/am-test-2-2 @@ -0,0 +1,21 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Six + +Applying this patch with -C1 should be successful even though +the first line in the context does not match. + +diff --git i/file-2 w/file-2 +index 06e567b..b6f3a16 100644 +--- i/file-2 ++++ w/file-2 +@@ -1,7 +1,7 @@ + One + 2 +-3 ++Three + 4 + 5 +-6 ++Six + 7 diff --git a/t/t4252/am-test-3-1 b/t/t4252/am-test-3-1 new file mode 100644 index 0000000..608e5ab --- /dev/null +++ b/t/t4252/am-test-3-1 @@ -0,0 +1,19 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Three + +Application of this should be rejected even with -p2 because the +preimage line in the context does not match. + +diff --git i/junk/file-1 w/junk/file-1 +index 06e567b..10f8342 100644 +--- i/junk/file-1 ++++ w/junk/file-1 +@@ -1,6 +1,6 @@ + 1 + 2 +-Tres ++Three + 4 + 5 + 6 diff --git a/t/t4252/am-test-3-2 b/t/t4252/am-test-3-2 new file mode 100644 index 0000000..0081b96 --- /dev/null +++ b/t/t4252/am-test-3-2 @@ -0,0 +1,21 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Six + +Applying this patch with -p2 should be successful even though +the patch is against a wrong level. + +diff --git i/junk/file-2 w/junk/file-2 +index 06e567b..b6f3a16 100644 +--- i/junk/file-2 ++++ w/junk/file-2 +@@ -1,7 +1,7 @@ + 1 + 2 +-3 ++Three + 4 + 5 +-6 ++Six + 7 diff --git a/t/t4252/am-test-4-1 b/t/t4252/am-test-4-1 new file mode 100644 index 0000000..e48cd6c --- /dev/null +++ b/t/t4252/am-test-4-1 @@ -0,0 +1,19 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Three + +Application of this should be rejected even with -C1 -p2 because +the preimage line in the context does not match. + +diff --git i/junk/file-1 w/junk/file-1 +index 06e567b..10f8342 100644 +--- i/junk/file-1 ++++ w/junk/file-1 +@@ -1,6 +1,6 @@ + 1 + 2 +-Tres ++Three + 4 + 5 + 6 diff --git a/t/t4252/am-test-4-2 b/t/t4252/am-test-4-2 new file mode 100644 index 0000000..0e69bfa --- /dev/null +++ b/t/t4252/am-test-4-2 @@ -0,0 +1,22 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Six + +Applying this patch with -C1 -p2 should be successful even though +the patch is against a wrong level and the first context line does +not match. + +diff --git i/junk/file-2 w/junk/file-2 +index 06e567b..b6f3a16 100644 +--- i/junk/file-2 ++++ w/junk/file-2 +@@ -1,7 +1,7 @@ + One + 2 +-3 ++Three + 4 + 5 +-6 ++Six + 7 diff --git a/t/t4252/file-1-0 b/t/t4252/file-1-0 new file mode 100644 index 0000000..06e567b --- /dev/null +++ b/t/t4252/file-1-0 @@ -0,0 +1,7 @@ +1 +2 +3 +4 +5 +6 +7 diff --git a/t/t4252/file-2-0 b/t/t4252/file-2-0 new file mode 100644 index 0000000..06e567b --- /dev/null +++ b/t/t4252/file-2-0 @@ -0,0 +1,7 @@ +1 +2 +3 +4 +5 +6 +7 -- 1.6.1.rc1.60.g1d1d7 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/4] git-am: propagate -C<n>, -p<n> options as well 2008-12-05 2:22 ` [PATCH 2/4] git-am: propagate -C<n>, -p<n> options as well Junio C Hamano 2008-12-05 2:22 ` [PATCH 3/4] git-am: propagate --3way " Junio C Hamano @ 2008-12-05 12:21 ` Johannes Schindelin 2008-12-05 19:18 ` Junio C Hamano 1 sibling, 1 reply; 7+ messages in thread From: Johannes Schindelin @ 2008-12-05 12:21 UTC (permalink / raw) To: Junio C Hamano; +Cc: git Hi, On Thu, 4 Dec 2008, Junio C Hamano wrote: > - echo " $ws" >"$dotest/whitespace" > + echo " $git_apply_opt" >"$dotest/apply_opt_extra" >From the other scripts, it appears we have sort of a convention to use dashes instead of underscores for file names (see e.g. $dotest/patch-merge-tmp-dir). Other than that, the whole series looks good to me. Thanks for the work, especially the tests, Dscho ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/4] git-am: propagate -C<n>, -p<n> options as well 2008-12-05 12:21 ` [PATCH 2/4] git-am: propagate -C<n>, -p<n> options as well Johannes Schindelin @ 2008-12-05 19:18 ` Junio C Hamano 0 siblings, 0 replies; 7+ messages in thread From: Junio C Hamano @ 2008-12-05 19:18 UTC (permalink / raw) To: Johannes Schindelin; +Cc: git Johannes Schindelin <Johannes.Schindelin@gmx.de> writes: > On Thu, 4 Dec 2008, Junio C Hamano wrote: > >> - echo " $ws" >"$dotest/whitespace" >> + echo " $git_apply_opt" >"$dotest/apply_opt_extra" > >>From the other scripts, it appears we have sort of a convention to use > dashes instead of underscores for file names (see e.g. > $dotest/patch-merge-tmp-dir). You are right. And there is no reason to call it "extra" either. git-am.sh | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git c/git-am.sh w/git-am.sh index 13c02d6..4b157fe 100755 --- c/git-am.sh +++ w/git-am.sh @@ -250,7 +250,7 @@ else # -s, -u, -k, --whitespace, -3, -C and -p flags are kept # for the resuming session after a patch failure. # -i can and must be given when resuming. - echo " $git_apply_opt" >"$dotest/apply_opt_extra" + echo " $git_apply_opt" >"$dotest/apply-opt" echo "$threeway" >"$dotest/threeway" echo "$sign" >"$dotest/sign" echo "$utf8" >"$dotest/utf8" @@ -288,7 +288,7 @@ if test "$(cat "$dotest/threeway")" = t then threeway=t fi -git_apply_opt=$(cat "$dotest/apply_opt_extra") +git_apply_opt=$(cat "$dotest/apply-opt") if test "$(cat "$dotest/sign")" = t then SIGNOFF=`git var GIT_COMMITTER_IDENT | sed -e ' ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-12-05 19:20 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-12-05 2:22 [PATCH 0/4] Fix longstanding "git am" bug Junio C Hamano 2008-12-05 2:22 ` [PATCH 1/4] git-am --whitespace: do not lose the command line option Junio C Hamano 2008-12-05 2:22 ` [PATCH 2/4] git-am: propagate -C<n>, -p<n> options as well Junio C Hamano 2008-12-05 2:22 ` [PATCH 3/4] git-am: propagate --3way " Junio C Hamano 2008-12-05 2:23 ` [PATCH 4/4] Test that git-am does not lose -C/-p/--whitespace options Junio C Hamano 2008-12-05 12:21 ` [PATCH 2/4] git-am: propagate -C<n>, -p<n> options as well Johannes Schindelin 2008-12-05 19:18 ` Junio C Hamano
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).