From: Junio C Hamano <hidden> Date: 2016-06-15 22:45:38
Junio C Hamano [off-list ref] writes:
"David D. Kilzer" [off-list ref] writes:
quoted
With diff.renames = copies, a 3-way merge (e.g. "git rebase") would
fail with the following error:
By the way, I think the real issue with this one is that we currently do
not disable diff.renames configuration while rebase internally runs
"format-patch" to feed "am -3".
The end user configuration for "diff" should not affect the result
produced by the higher level command that is related to "diff" only
because internally it is implemented in terms of it.
For that matter, I have a feeling that format-patch should not even look
at diff.renames, but we seem to have been doing this for a long time so
there is no easy way to fix this thinko.
In any case, here is a much straightforward fix for "rebase".
Running "am -3" on a copying patch would still need a patch to the
index-info codepath, and my earlier comment on it still stands, but it is
irrelevant/orthogonal to your particular test script.
git-rebase.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
From: David D. Kilzer <hidden> Date: 2016-06-15 22:49:09
With diff.renames = copies, a rebase with a file move will fail with
the following error:
fatal: mode change for <file>, which is not in current HEAD
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0001.
The bug is that git rebase does not disable diff.renames when it runs
format-patch internally to feed into "am -3". The fix is simply to
include a --no-renames argument to format-patch to override any local
diff.renames setting.
Fix by Junio C Hamano. Test case by David D. Kilzer.
Signed-off-by: David D. Kilzer <redacted>
---
git-rebase.sh | 2 +-
t/t3400-rebase.sh | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletions(-)
@@ -155,4 +155,21 @@ test_expect_success 'Rebase a commit that sprinkles CRs in' 'gitdiff--exit-codefile-with-cr:CRHEAD:CR'+test_expect_success'rebase a single file move with diff.renames = copies''+gitconfigdiff.renamescopies&&+gitcheckoutmaster&&+echo1>Y&&+gitaddY&&+test_tick&&+gitcommit-m"prepare file move"&&+gitcheckout-bfilemoveHEAD^&&+echo1>Y&&+gitaddY&&+mkdirD&&+gitmvAD/A&&+test_tick&&+gitcommit-mfilemove&&+GIT_TRACE=1gitrebasemaster+'+ test_done
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:09
David D. Kilzer wrote:
With diff.renames = copies, a rebase with a file move will fail with
the following error:
fatal: mode change for <file>, which is not in current HEAD
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0001.
I would think that the following works fine:
git init test-repo &&
cd test-repo &&
echo hello >greeting.txt &&
git add greeting.txt &&
git commit -m base &&
git checkout -b move &&
git mv greeting.txt moved.txt &&
git commit -m move &&
git checkout master &&
echo hi >greeting.txt &&
git add greeting.txt &&
git commit -m change &&
git checkout move &&
echo '[diff] renames = copies' >>.git/config &&
git rebase master
What am I doing wrong?
On the other hand I find Junio’s explanation[1] compelling
already on its own.
The end user configuration for "diff" should not affect the
result produced by the higher level command that is related to
"diff" only because internally it is implemented in terms of
it.
In cases where a patch copies a file that was then removed on the
mainline, my intuition says ‘rebase’ without some extra flag should
accept the change without complaint. Of course, this intuition is
totally warped --- I tend to think of rebase as diff + apply.
Patch does not apply to master or maint, due to conflict with
v1.7.1-rc0~37^2~5 (rebase: support automatic notes copying,
2010-03-12). One sneaky way to avoid this kind of thing would be to
insert new tests at some logical point in the middle of a test script.
Test nitpicks:
quoted hunk
+++ b/t/t3400-rebase.sh
@@ -155,4 +155,21 @@ test_expect_success 'Rebase a commit that sprinkles CRs in' 'gitdiff--exit-codefile-with-cr:CRHEAD:CR'+test_expect_success'rebase a single file move with diff.renames = copies''+gitconfigdiff.renamescopies&&
Use
test_when_finished "git config --unset diff.renames" &&
to shelter future tests from the effect of this one.
From: David D. Kilzer <hidden> Date: 2016-06-15 22:49:10
On Jonathan Nieder wrote:
David D. Kilzer wrote:
quoted
With diff.renames = copies, a rebase with a file move will fail with
the following error:
fatal: mode change for <file>, which is not in current HEAD
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0001.
I would think that the following works fine:
git init test-repo &&
cd test-repo &&
echo hello >greeting.txt &&
git add greeting.txt &&
git commit -m base &&
git checkout -b move &&
git mv greeting.txt moved.txt &&
git commit -m move &&
git checkout master &&
echo hi >greeting.txt &&
git add greeting.txt &&
git commit -m change &&
git checkout move &&
echo '[diff] renames = copies' >>.git/config &&
git rebase master
What am I doing wrong?
Given the following tree:
B' topic
/
A---B master
A: New file "F1" is committed.
B: New file "F2" is committed.
B': New file "F2" is committed (identical in content to "F2" on B), and "F1" is
renamed to "F3".
When the topic branch is rebased onto master with diff.renames=copies, git fails
when attempting to build a fake ancestor for F1. The key to reproducing the bug
is to have an identical new file added on both B and B'.
My original patch in <http://marc.info/?l=git&m=122635667614099&w=2> addressed
this in builtin-apply.c, but Junio didn't like this approach as noted in
<http://marc.info/?l=git&m=122636097120953&w=2>.
Patch does not apply to master or maint, due to conflict with
v1.7.1-rc0~37^2~5 (rebase: support automatic notes copying,
2010-03-12). One sneaky way to avoid this kind of thing would be to
insert new tests at some logical point in the middle of a test script.
Sorry about that--I forgot to rebase it to maint before sending it.
Test nitpicks:
Thanks! I'll make the requested changes in the next patch.
This wants to notice that Y was already added so the top patch can be
simplified to include only a rename.
Actually, this is the key to reproducing the bug!
Can you explain why this test will fail without your patch?
Here is a stand-alone script that reproduces the bug:
git init test-repo &&
cd test-repo &&
echo hello > F1 &&
git add F1 &&
git commit -m "A" &&
git checkout -b topic &&
echo hi > F2 &&
git add F2 &&
git mv F1 F3 &&
git commit -m "B'" &&
git checkout master &&
echo hi > F2 &&
git add F2 &&
git commit -m "B" &&
git checkout topic &&
git config diff.renames copies &&
GIT_TRACE=1 git rebase master
Note that the test case in my patch depended on "F1" (which was "A") being
committed by an earlier test.
Dave
Got it. This patch just treats the symptoms in my opinion, and if
you read Junio’s message carefully, I think he was also suggesting
that git apply should still be fixed.
Something like this series would fix both. Please feel free to pick
it up and take it in whatever direction you like.
Hope that helps.
Jonathan Nieder (3):
t4150 (am): style tweaks
t4150 (am): futureproof against failing tests
t3400 (rebase): whitespace cleanup
Junio C Hamano (2):
Teach "apply --index-info" to handle rename patches
rebase: protect against diff.renames configuration
builtin/apply.c | 3 +-
git-rebase.sh | 2 +-
t/t3400-rebase.sh | 204 ++++++++++++++++++--------------
t/t4150-am.sh | 334 +++++++++++++++++++++++++++++++++++-----------------
t/test-lib.sh | 4 +
5 files changed, 345 insertions(+), 202 deletions(-)
--
1.7.2.rc3
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:10
Most tests in t4150 begin by navigating to a sane state and
applying some patch:
git checkout first &&
git am patch1
If a previous test left behind unmerged files or a .git/rebase-apply
directory, they are untouched and the test fails, causing later tests
to fail, too. This is not a problem in practice because none of the
tests leave a mess behind.
But as a futureproofing measure, it is still best to avoid the problem
and clean up at the start of each test. In particular, this
simplifies the process of adding new tests that are known to fail.
Signed-off-by: Jonathan Nieder <redacted>
---
t/t4150-am.sh | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 47 insertions(+), 1 deletions(-)
@@ -132,6 +134,8 @@ test_expect_success 'am applies patch correctly' '' test_expect_success'am applies patch e-mail not in a mbox''+rm-fr.git/rebase-apply&&+gitreset--hard&&gitcheckoutfirst&&gitampatch1.eml&&!test-d.git/rebase-apply&&
@@ -141,6 +145,8 @@ test_expect_success 'am applies patch e-mail not in a mbox' '' test_expect_success'am applies patch e-mail not in a mbox with CRLF''+rm-fr.git/rebase-apply&&+gitreset--hard&&gitcheckoutfirst&&gitampatch1-crlf.eml&&!test-d.git/rebase-apply&&
@@ -268,6 +289,8 @@ test_expect_success 'am --resolved works' '' test_expect_success'am takes patches from a Pine mailbox''+rm-fr.git/rebase-apply&&+gitreset--hard&&gitcheckoutfirst&&catpinepatch1|gitam&&!test-d.git/rebase-apply&&
@@ -275,11 +298,16 @@ test_expect_success 'am takes patches from a Pine mailbox' '' test_expect_success'am fails on mail without patch''+rm-fr.git/rebase-apply&&+gitreset--hard&&test_must_failgitam<failmail&&-rm-r.git/rebase-apply/+gitam--abort&&+!test-d.git/rebase-apply' test_expect_success'am fails on empty patch''+rm-fr.git/rebase-apply&&+gitreset--hard&&echo"---">>failmail&&test_must_failgitam<failmail&&gitam--skip&&
@@ -288,6 +316,8 @@ test_expect_success 'am fails on empty patch' ' test_expect_success'am works from stdin in subdirectory''rm-frsubdir&&+rm-fr.git/rebase-apply&&+gitreset--hard&&gitcheckoutfirst&&(mkdir-psubdir&&
@@ -299,6 +329,8 @@ test_expect_success 'am works from stdin in subdirectory' ' test_expect_success'am works from file (relative path given) in subdirectory''rm-frsubdir&&+rm-fr.git/rebase-apply&&+gitreset--hard&&gitcheckoutfirst&&(mkdir-psubdir&&
@@ -310,6 +342,8 @@ test_expect_success 'am works from file (relative path given) in subdirectory' ' test_expect_success'am works from file (absolute path given) in subdirectory''rm-frsubdir&&+rm-fr.git/rebase-apply&&+gitreset--hard&&gitcheckoutfirst&&P=$(pwd)&&(
@@ -321,6 +355,8 @@ test_expect_success 'am works from file (absolute path given) in subdirectory' '' test_expect_success'am --committer-date-is-author-date''+rm-fr.git/rebase-apply&&+gitreset--hard&&gitcheckoutfirst&&test_tick&&gitam--committer-date-is-author-datepatch1&&
@@ -345,6 +383,8 @@ test_expect_success 'am without --committer-date-is-author-date' '# by test_tick that uses -0700 timezone; if this feature does not# work, we will see that instead of +0000. test_expect_success'am --ignore-date''+rm-fr.git/rebase-apply&&+gitreset--hard&&gitcheckoutfirst&&test_tick&&gitam--ignore-datepatch1&&
@@ -355,6 +395,8 @@ test_expect_success 'am --ignore-date' ' test_expect_success'am into an unborn branch''gitrev-parsefirst^{tree}>expected&&+rm-fr.git/rebase-apply&&+gitreset--hard&&rm-frsubdir&&mkdirsubdir&&gitformat-patch--numbered-files-osubdir-1first&&
@@ -371,6 +413,8 @@ test_expect_success 'am into an unborn branch' '' test_expect_success'am newline in subject''+rm-fr.git/rebase-apply&&+gitreset--hard&&gitcheckoutfirst&&test_tick&&sed-e"s/second/second \\\n foo/"patch1>patchnl&&
@@ -379,6 +423,8 @@ test_expect_success 'am newline in subject' '' test_expect_success'am -q is quiet''+rm-fr.git/rebase-apply&&+gitreset--hard&&gitcheckoutfirst&&test_tick&&gitam-q<patch1>output.out2>&1&&
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:10
From: Junio C Hamano <redacted>
Date: Mon, 10 Nov 2008 15:49:03 -0800
With v1.5.3.2~14 (apply --index-info: fall back to current index for
mode changes, 2007-09-17), git apply learned to stop worrying
about the lack of diff index line when a file already present in the
current index had no content change.
But it still worries too much: for rename patches, it is checking
that both the old and new filename are present in the current
index. This makes no sense, since a file rename generally
involves creating a file there was none before.
So just check the old filename.
Noticed while trying to use “git rebase” with diff.renames = copies.
[jn: add tests]
Reported-by: David D. Kilzer <redacted>
Signed-off-by: Jonathan Nieder <redacted>
---
builtin/apply.c | 3 +--
t/t4150-am.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 2 deletions(-)
@@ -2979,8 +2979,7 @@ static void build_fake_ancestor(struct patch *list, const char *filename)elseif(get_sha1(patch->old_sha1_prefix,sha1))/* git diff has no index line for mode/type changes */if(!patch->lines_added&&!patch->lines_deleted){-if(get_current_sha1(patch->new_name,sha1)||-get_current_sha1(patch->old_name,sha1))+if(get_current_sha1(patch->old_name,sha1))die("mode change for %s, which is not ""in current HEAD",name);sha1_ptr=sha1;
@@ -116,6 +116,18 @@ test_expect_success setup 'gitcommit-m"added another file"&&gitformat-patch--stdoutmaster>lorem-move.patch&&++gitcheckout-brename&&+gitmvfilerenamed&&+gitcommit-m"renamed a file"&&++gitformat-patch-M--stdoutlorem>rename.patch&&++gitreset--softlorem^&&+gitcommit-m"renamed a file and added another"&&++gitformat-patch-M--stdoutlorem^>rename-add.patch&&+# reset timeunsettest_tick&&test_tick
@@ -246,8 +258,42 @@ test_expect_success 'am -3 falls back to 3-way merge' 'gitdiff--exit-codelorem'+test_expect_success'am can rename a file''+grep"^rename from"rename.patch&&+rm-fr.git/rebase-apply&&+gitreset--hard&&+gitcheckoutlorem^0&&+gitamrename.patch&&+!test-d.git/rebase-apply&&+gitupdate-index--refresh&&+gitdiff--exit-coderename+'++test_expect_success'am -3 can rename a file''+grep"^rename from"rename.patch&&+rm-fr.git/rebase-apply&&+gitreset--hard&&+gitcheckoutlorem^0&&+gitam-3rename.patch&&+!test-d.git/rebase-apply&&+gitupdate-index--refresh&&+gitdiff--exit-coderename+'++test_expect_success'am -3 can rename a file after falling back to 3-way merge''+grep"^rename from"rename-add.patch&&+rm-fr.git/rebase-apply&&+gitreset--hard&&+gitcheckoutlorem^0&&+gitam-3rename-add.patch&&+!test-d.git/rebase-apply&&+gitupdate-index--refresh&&+gitdiff--exit-coderename+'+ test_expect_success'am -3 -q is quiet''rm-fr.git/rebase-apply&&+gitcheckout-florem2&&gitresetmaster2--hard&&sed-n-e"3,\$p"msg>file&&head-n9msg>>file&&
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:10
This test used 5-space indents since it was added in 2005, but
recently the temptation to use tabs to indent has been too
strong, resulting in uneven whitespace. Switch over completely
to tabs.
While at it, use a more modern style for consistency with other
tests:
- names of tests go on the same line as test_expect_success;
- extra whitespace after > redirection operators is removed.
Signed-off-by: Jonathan Nieder <redacted>
---
t/t3400-rebase.sh | 182 +++++++++++++++++++++++++++--------------------------
1 files changed, 92 insertions(+), 90 deletions(-)
@@ -14,140 +14,142 @@ GIT_AUTHOR_NAME=author@nameGIT_AUTHOR_EMAIL=bogus@email@addressexportGIT_AUTHOR_NAMEGIT_AUTHOR_EMAIL-test_expect_success\-'prepare repository with topic branches'\-'gitconfigcore.logAllRefUpdatestrue&&-echoFirst>A&&-gitupdate-index--addA&&-gitcommit-m"Add A."&&-gitcheckout-bmy-topic-branch&&-echoSecond>B&&-gitupdate-index--addB&&-gitcommit-m"Add B."&&-gitcheckout-fmaster&&-echoThird>>A&&-gitupdate-indexA&&-gitcommit-m"Modify A."&&-gitcheckout-bsidemy-topic-branch&&-echoSide>>C&&-gitaddC&&-gitcommit-m"Add C"&&-gitcheckout-bnonlinearmy-topic-branch&&-echoEdit>>B&&-gitaddB&&-gitcommit-m"Modify B"&&-gitmergeside&&-gitcheckout-bupstream-merged-nonlinear&&-gitmergemaster&&-gitcheckout-fmy-topic-branch&&-gittagtopic+test_expect_success'prepare repository with topic branches''+gitconfigcore.logAllRefUpdatestrue&&+echoFirst>A&&+gitupdate-index--addA&&+gitcommit-m"Add A."&&+gitcheckout-bmy-topic-branch&&+echoSecond>B&&+gitupdate-index--addB&&+gitcommit-m"Add B."&&+gitcheckout-fmaster&&+echoThird>>A&&+gitupdate-indexA&&+gitcommit-m"Modify A."&&+gitcheckout-bsidemy-topic-branch&&+echoSide>>C&&+gitaddC&&+gitcommit-m"Add C"&&+gitcheckout-bnonlinearmy-topic-branch&&+echoEdit>>B&&+gitaddB&&+gitcommit-m"Modify B"&&+gitmergeside&&+gitcheckout-bupstream-merged-nonlinear&&+gitmergemaster&&+gitcheckout-fmy-topic-branch&&+gittagtopic' test_expect_success'rebase on dirty worktree''-echodirty>>A&&-test_must_failgitrebasemaster'+echodirty>>A&&+test_must_failgitrebasemaster+' test_expect_success'rebase on dirty cache''-gitaddA&&-test_must_failgitrebasemaster'+gitaddA&&+test_must_failgitrebasemaster+' test_expect_success'rebase against master''-gitreset--hardHEAD&&-gitrebasemaster'+gitreset--hardHEAD&&+gitrebasemaster+' test_expect_success'rebase against master twice''-gitrebasemaster>out&&-grep"Current branch my-topic-branch is up to date"out+gitrebasemaster>out&&+grep"Current branch my-topic-branch is up to date"out' test_expect_success'rebase against master twice with --force''-gitrebase--force-rebasemaster>out&&-grep"Current branch my-topic-branch is up to date, rebase forced"out+gitrebase--force-rebasemaster>out&&+grep"Current branch my-topic-branch is up to date, rebase forced"out' test_expect_success'rebase against master twice from another branch''-gitcheckoutmy-topic-branch^&&-gitrebasemastermy-topic-branch>out&&-grep"Current branch my-topic-branch is up to date"out+gitcheckoutmy-topic-branch^&&+gitrebasemastermy-topic-branch>out&&+grep"Current branch my-topic-branch is up to date"out' test_expect_success'rebase fast-forward to master''-gitcheckoutmy-topic-branch^&&-gitrebasemy-topic-branch>out&&-grep"Fast-forwarded HEAD to my-topic-branch"out+gitcheckoutmy-topic-branch^&&+gitrebasemy-topic-branch>out&&+grep"Fast-forwarded HEAD to my-topic-branch"out'-test_expect_success\-'the rebase operation should not have destroyed author information'\-'! (git log | grep "Author:" | grep "<>")'+test_expect_success'the rebase operation should not have destroyed author information''+!(gitlog|grep"Author:"|grep"<>")+'-test_expect_success\-'the rebase operation should not have destroyed author information (2)'\-"git log -1 | grep 'Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>'"+test_expect_success'the rebase operation should not have destroyed author information (2)'"+gitlog-1|+grep'Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>'+" test_expect_success'HEAD was detached during rebase''-test$(gitrev-parseHEAD@{1})!=$(gitrev-parsemy-topic-branch@{1})+test$(gitrev-parseHEAD@{1})!=$(gitrev-parsemy-topic-branch@{1})' test_expect_success'rebase after merge master''-gitreset--hardtopic&&-gitmergemaster&&-gitrebasemaster&&-!(gitshow|grep"^Merge:")+gitreset--hardtopic&&+gitmergemaster&&+gitrebasemaster&&+!(gitshow|grep"^Merge:")' test_expect_success'rebase of history with merges is linearized''-gitcheckoutnonlinear&&-test4=$(gitrev-listmaster..|wc-l)&&-gitrebasemaster&&-test3=$(gitrev-listmaster..|wc-l)+gitcheckoutnonlinear&&+test4=$(gitrev-listmaster..|wc-l)&&+gitrebasemaster&&+test3=$(gitrev-listmaster..|wc-l)'-test_expect_success\-'rebase of history with merges after upstream merge is linearized''-gitcheckoutupstream-merged-nonlinear&&-test5=$(gitrev-listmaster..|wc-l)&&-gitrebasemaster&&-test3=$(gitrev-listmaster..|wc-l)+test_expect_success'rebase of history with merges after upstream merge is linearized''+gitcheckoutupstream-merged-nonlinear&&+test5=$(gitrev-listmaster..|wc-l)&&+gitrebasemaster&&+test3=$(gitrev-listmaster..|wc-l)' test_expect_success'rebase a single mode change''-gitcheckoutmaster&&-echo1>X&&-gitaddX&&-test_tick&&-gitcommit-mprepare&&-gitcheckout-bmodechangeHEAD^&&-echo1>X&&-gitaddX&&-test_chmod+xA&&-test_tick&&-gitcommit-mmodechange&&-GIT_TRACE=1gitrebasemaster+gitcheckoutmaster&&+echo1>X&&+gitaddX&&+test_tick&&+gitcommit-mprepare&&+gitcheckout-bmodechangeHEAD^&&+echo1>X&&+gitaddX&&+test_chmod+xA&&+test_tick&&+gitcommit-mmodechange&&+GIT_TRACE=1gitrebasemaster' test_expect_success'Show verbose error when HEAD could not be detached''-:>B&&-test_must_failgitrebasetopic2>output.err>output.out&&-grep"Untracked working tree file .B. would be overwritten"output.err+>B&&+test_must_failgitrebasetopic2>output.err>output.out&&+grep"Untracked working tree file .B. would be overwritten"output.err' rm-fB test_expect_success'dump usage when upstream arg is missing''-gitcheckout-busagetopic&&-test_must_failgitrebase2>error1&&-grep"[Uu]sage"error1&&-test_must_failgitrebase--abort2>error2&&-grep"No rebase in progress"error2&&-test_must_failgitrebase--ontomaster2>error3&&-grep"[Uu]sage"error3&&-!grep"can.t shift"error3+gitcheckout-busagetopic&&+test_must_failgitrebase2>error1&&+grep"[Uu]sage"error1&&+test_must_failgitrebase--abort2>error2&&+grep"No rebase in progress"error2&&+test_must_failgitrebase--ontomaster2>error3&&+grep"[Uu]sage"error3&&+!grep"can.t shift"error3' test_expect_success'rebase -q is quiet''-gitcheckout-bquiettopic&&-gitrebase-qmaster>output.out2>&1&&-test!-soutput.out+gitcheckout-bquiettopic&&+gitrebase-qmaster>output.out2>&1&&+test!-soutput.out' test_expect_success'Rebase a commit that sprinkles CRs in''
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:10
From: Junio C Hamano <redacted>
Date: Mon, 10 Nov 2008 16:15:49 -0800
We currently do not disable diff.renames configuration while rebase
internally runs "format-patch" to feed "am -3".
The end user configuration for "diff" should not affect the result
produced by the higher level command that is related to "diff" only
because internally it is implemented in terms of it.
For that matter, I have a feeling that format-patch should not even look
at diff.renames, but we seem to have been doing this for a long time so
there is no easy way to fix this thinko.
In any case, here is a much straightforward fix for "rebase".
[jn: with test case from David]
Reported-by: David D. Kilzer <redacted>
Signed-off-by: Jonathan Nieder <redacted>
---
git-rebase.sh | 2 +-
t/t3400-rebase.sh | 24 +++++++++++++++++++++++-
2 files changed, 24 insertions(+), 2 deletions(-)
@@ -128,6 +137,19 @@ test_expect_success 'rebase a single mode change' 'GIT_TRACE=1gitrebasemaster'+test_expect_success'rebase is not broken by diff.renames''+gitconfigdiff.renamescopies&&+test_when_finished"git config --unset diff.renames"&&+gitcheckoutfilemove&&+GIT_TRACE=1gitrebaseforce-3way+'++test_expect_success'setup: recover''+test_might_failgitrebase--abort&&+gitreset--hard&&+gitcheckoutmodechange+'+ test_expect_success'Show verbose error when HEAD could not be detached''>B&&test_must_failgitrebasetopic2>output.err>output.out&&
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:10
Place setup commands in test_expect_success blocks. This makes the
rare event of the setup commands breaking on some platform easier to
diagnose, and more importantly, it visually distinguishes where
each test begins and ends.
Instead of running test -z against the result of "git diff" command
substitution, use "git diff --exit-code", to improve output when
running with the "-v" option.
Use test_cmp in place of "test $(foo) = $(bar)" for similar reasons.
Remove whitespace after the > and < redirection operators for
consistency with other tests.
The order of arguments to test_cmp is "test_cmp expected actual".
Signed-off-by: Jonathan Nieder <redacted>
---
t/t4150-am.sh | 240 +++++++++++++++++++++++++++++++--------------------------
t/test-lib.sh | 4 +
2 files changed, 136 insertions(+), 108 deletions(-)
@@ -71,11 +76,13 @@ test_expect_success setup 'test_tick&&gitcommit-mfirst&&gittagfirst&&+echoworld>>file&&gitaddfile&&test_tick&&gitcommit-s-Fmsg&&gittagsecond&&+gitformat-patch--stdoutfirst>patch1&&{echo"X-Fake-Field: Line One"&&
@@ -89,33 +96,37 @@ test_expect_success setup 'echo"X-Fake-Field: Line Three"&&gitformat-patch--stdoutfirst|sed-e"1d"}|append_cr>patch1-crlf.eml&&+sed-n-e"3,\$p"msg>file&&gitaddfile&&test_tick&&gitcommit-mthird&&+gitformat-patch--stdoutfirst>patch2&&+gitcheckout-blorem&&sed-n-e"11,\$p"msg>file&&head-n9msg>>file&&test_tick&&gitcommit-a-m"moved stuff"&&+echogoodbye>another&&gitaddanother&&test_tick&&gitcommit-m"added another file"&&-gitformat-patch--stdoutmaster>lorem-move.patch-'-# reset time-unsettest_tick-test_tick+gitformat-patch--stdoutmaster>lorem-move.patch&&+# reset time+unsettest_tick&&+test_tick+' test_expect_success'am applies patch correctly''gitcheckoutfirst&&test_tick&&gitam<patch1&&!test-d.git/rebase-apply&&-test-z"$(gitdiffsecond)"&&+gitdiff--exit-codesecond&&test"$(gitrev-parsesecond)"="$(gitrev-parseHEAD)"&&test"$(gitrev-parsesecond^)"="$(gitrev-parseHEAD^)"'
@@ -124,7 +135,7 @@ test_expect_success 'am applies patch e-mail not in a mbox' 'gitcheckoutfirst&&gitampatch1.eml&&!test-d.git/rebase-apply&&-test-z"$(gitdiffsecond)"&&+gitdiff--exit-codesecond&&test"$(gitrev-parsesecond)"="$(gitrev-parseHEAD)"&&test"$(gitrev-parsesecond^)"="$(gitrev-parseHEAD^)"'
@@ -133,20 +144,23 @@ test_expect_success 'am applies patch e-mail not in a mbox with CRLF' 'gitcheckoutfirst&&gitampatch1-crlf.eml&&!test-d.git/rebase-apply&&-test-z"$(gitdiffsecond)"&&+gitdiff--exit-codesecond&&test"$(gitrev-parsesecond)"="$(gitrev-parseHEAD)"&&test"$(gitrev-parsesecond^)"="$(gitrev-parseHEAD^)"'-GIT_AUTHOR_NAME="Another Thor"-GIT_AUTHOR_EMAIL="a.thor@example.com"-GIT_COMMITTER_NAME="Co M Miter"-GIT_COMMITTER_EMAIL="c.miter@example.com"-exportGIT_AUTHOR_NAMEGIT_AUTHOR_EMAILGIT_COMMITTER_NAMEGIT_COMMITTER_EMAIL+test_expect_success'setup: new author and committer''+GIT_AUTHOR_NAME="Another Thor"&&+GIT_AUTHOR_EMAIL="a.thor@example.com"&&+GIT_COMMITTER_NAME="Co M Miter"&&+GIT_COMMITTER_EMAIL="c.miter@example.com"&&+exportGIT_AUTHOR_NAMEGIT_AUTHOR_EMAILGIT_COMMITTER_NAMEGIT_COMMITTER_EMAIL+' compare(){-test"$(gitcat-filecommit"$2"|grep"^$1 ")"=\-"$(gitcat-filecommit"$3"|grep"^$1 ")"+a=$(gitcat-filecommit"$2"|grep"^$1 ")&&+b=$(gitcat-filecommit"$3"|grep"^$1 ")&&+test"$a"="$b"} test_expect_success'am changes committer and keeps author''
@@ -242,14 +264,14 @@ test_expect_success 'am --resolved works' 'gitaddfile&&gitam--resolved&&!test-d.git/rebase-apply&&-testgoodbye="$(catanother)"+test_cmpexpectedanother' test_expect_success'am takes patches from a Pine mailbox''gitcheckoutfirst&&catpinepatch1|gitam&&!test-d.git/rebase-apply&&-test-z"$(gitdiffmaster^..HEAD)"+gitdiff--exit-codemaster^..HEAD' test_expect_success'am fails on mail without patch''
@@ -272,7 +294,7 @@ test_expect_success 'am works from stdin in subdirectory' 'cdsubdir&&gitam<../patch1)&&-test-z"$(gitdiffsecond)"+gitdiff--exit-codesecond' test_expect_success'am works from file (relative path given) in subdirectory''
@@ -283,7 +305,7 @@ test_expect_success 'am works from file (relative path given) in subdirectory' 'cdsubdir&&gitam../patch1)&&-test-z"$(gitdiffsecond)"+gitdiff--exit-codesecond' test_expect_success'am works from file (absolute path given) in subdirectory''
@@ -295,7 +317,7 @@ test_expect_success 'am works from file (absolute path given) in subdirectory' 'cdsubdir&&gitam"$P/patch1")&&-test-z"$(gitdiffsecond)"+gitdiff--exit-codesecond' test_expect_success'am --committer-date-is-author-date''
@@ -313,9 +335,9 @@ test_expect_success 'am without --committer-date-is-author-date' 'test_tick&&gitampatch1&&gitcat-filecommitHEAD|sed-e"/^\$/q">head1&&-at=$(sed-ne"/^author /s/.*> //p"head1)&&-ct=$(sed-ne"/^committer /s/.*> //p"head1)&&-test"$at"!="$ct"+sed-ne"/^author /s/.*> //p"head1>at&&+sed-ne"/^committer /s/.*> //p"head1>ct&&+!test_cmpatct'# This checks for +0000 because TZ is set to UTC and that should
@@ -327,37 +349,39 @@ test_expect_success 'am --ignore-date' 'test_tick&&gitam--ignore-datepatch1&&gitcat-filecommitHEAD|sed-e"/^\$/q">head1&&-at=$(sed-ne"/^author /s/.*> //p"head1)&&-echo"$at"|grep"+0000"+sed-ne"/^author /s/.*> //p"head1>at&&+grep"+0000"at' test_expect_success'am into an unborn branch''+gitrev-parsefirst^{tree}>expected&&rm-frsubdir&&-mkdir-psubdir&&+mkdirsubdir&&gitformat-patch--numbered-files-osubdir-1first&&(cdsubdir&&gitinit&&gitam1)&&-result=$(-cdsubdir&&gitrev-parseHEAD^{tree}+(+cdsubdir&&+gitrev-parseHEAD^{tree}>../actual)&&-test"z$result"="z$(gitrev-parsefirst^{tree})"+test_cmpexpectedactual' test_expect_success'am newline in subject''gitcheckoutfirst&&test_tick&&-sed-e"s/second/second \\\n foo/"patch1>patchnl&&-gitam<patchnl>output.out2>&1&&+sed-e"s/second/second \\\n foo/"patch1>patchnl&&+gitam<patchnl>output.out2>&1&&grep"^Applying: second \\\n foo$"output.out' test_expect_success'am -q is quiet''gitcheckoutfirst&&test_tick&&-gitam-q<patch1>output.out2>&1&&+gitam-q<patch1>output.out2>&1&&!test-soutput.out'
Got it. This patch just treats the symptoms in my opinion, and if
you read Junio’s message carefully, I think he was also suggesting
that git apply should still be fixed.
Thanks! At the time I needed to fix the issue and continue working. I didn't
have time to investigate it further (which is why it sat for about 18 months).
Something like this series would fix both. Please feel free to pick
it up and take it in whatever direction you like.
Is this comment to me or Junio? As a part-time contributor, I'm not sure what
my options are here. :)
Heya,
On Fri, Jul 23, 2010 at 12:06, Jonathan Nieder [off-list ref] wrote:
The end user configuration for "diff" should not affect the result
produced by the higher level command that is related to "diff" only
because internally it is implemented in terms of it.
Almost completely unrelated and perhaps not relevant, I seem to recall
that if you set 'ui.color' to 'always' you will get unapplyable
patches because 'git format-patch' will include the color in it's
output. Perhaps it should --no-color as well, while we're fixing it?
--
Cheers,
Sverre Rabbelier
Heya,
On Fri, Jul 23, 2010 at 12:06, Jonathan Nieder [off-list ref] wrote:
The end user configuration for "diff" should not affect the result
produced by the higher level command that is related to "diff" only
because internally it is implemented in terms of it.
Almost completely unrelated and perhaps not relevant, I seem to recall
that if you set 'ui.color' to 'always' you will get unapplyable
patches because 'git format-patch' will include the color in it's
output. Perhaps it should --no-color as well, while we're fixing it?
--
Cheers,
Sverre Rabbelier
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:10
David D. Kilzer wrote:
On Fri, July 23, 2010 at 10:01:03 AM, Jonathan Nieder wrote:
quoted
Something like this series would fix both. Please feel free to pick
it up and take it in whatever direction you like.
Is this comment to me or Junio? As a part-time contributor, I'm not sure what
my options are here. :)
It is to the world at large, or more precisely, anyone who is interested.
I only meant that I am not planning to keep track of what happens to
those patches in the future. Ideally someone else (maybe you ;-))
will take care of pinging if a patch gets forgotten or improving the
patches if some obvious change suggests itself.
Thanks for the initial ping, by the way.