{"thread":{"id":"44553","subject":"cherry-pick -Xrenormalize fails with formerly CRLF files","startedAt":"2016-11-28T06:27:57Z","lastAt":"2016-11-29T00:27:42Z","messageCount":3,"participants":["Eevee (Lexy Munroe)","Torsten Bögershausen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"306471","messageId":"777ee899-4cfb-e3b4-da0d-793fde35e412@veekun.com","threadId":"44553","inReplyTo":null,"subject":"cherry-pick -Xrenormalize fails with formerly CRLF files","fromName":"Eevee (Lexy Munroe)","fromEmail":"eevee@veekun.com","sentAt":"2016-11-28T06:19:35Z","receivedAt":"2016-11-28T06:27:57Z","isPatch":false,"sender":{"key":"eevee@veekun.com","avatar":null},"body":"I'm working with a repo that used to be all CRLF.  At some point it was \nchanged to all LF, with `text=auto` in .gitattributes for the sake of \nWindows devs.  I'm on Linux and have never touched any twiddles relating \nto line endings.  I'm trying to cherry-pick some commits from before the \nswitchover.\n\nStraightforward cherry-picking causes entire files at a time to \nconflict, which I've seen before when switching from tabs to spaces.  So \nI tried -Xrenormalize and got:\n\n     fatal: CRLF would be replaced by LF in [path]\n\nThe error comes from check_safe_crlf, which warns if checksafe is \nCRLF_SAFE_WARN and dies if it's (presumably) CRLF_SAFE_FAIL.  The funny \nthing is that it's CRLF_SAFE_RENORMALIZE.\n\nI don't know what the semantics of this value are, but the caller \n(crlf_to_git) explicitly checks for CRLF_SAFE_RENORMALIZE and changes it \nto CRLF_SAFE_FALSE instead.  But that check only happens if crlf_action \nis CRLF_AUTO*, and for me it's CRLF_TEXT_INPUT.\n\nI moved the check to happen regardless of the value of crlf_action, and \nat least in this case, git appears to happily do the right thing.  So I \nthink this is a bug, but line endings are such a tangle that I'm really \nnot sure.  :)\n\nThe repository in question is ZDoom: https://github.com/rheit/zdoom\nI'm trying to cherry-pick commits from the 3dfloors3 branch (e.g., \n9fb2daf58e9d512170859302a1ac0ea9c2ec5993) onto a slightly outdated \nmaster, 6384e81d0f135a2c292ac3e874f6fe26093f45b1.\n"},{"id":"306495","messageId":"20161128155415.GA9966@tb-raspi","threadId":"44553","inReplyTo":"777ee899-4cfb-e3b4-da0d-793fde35e412@veekun.com","subject":"Re: cherry-pick -Xrenormalize fails with formerly CRLF files","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2016-11-28T15:54:15Z","receivedAt":"2016-11-28T15:54:36Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Sun, Nov 27, 2016 at 10:19:35PM -0800, Eevee (Lexy Munroe) wrote:\n> I'm working with a repo that used to be all CRLF.  At some point it\n> was changed to all LF, with `text=auto` in .gitattributes for the\n> sake of Windows devs.  I'm on Linux and have never touched any\n> twiddles relating to line endings.  I'm trying to cherry-pick some\n> commits from before the switchover.\n> \n> Straightforward cherry-picking causes entire files at a time to\n> conflict, which I've seen before when switching from tabs to spaces.\n> So I tried -Xrenormalize and got:\n> \n>     fatal: CRLF would be replaced by LF in [path]\n> \n\nWhich version of Git are you using, what does\ngit --version\nsay?\n\n\n> The error comes from check_safe_crlf, which warns if checksafe is\n> CRLF_SAFE_WARN and dies if it's (presumably) CRLF_SAFE_FAIL.  The\n> funny thing is that it's CRLF_SAFE_RENORMALIZE.\n> \n> I don't know what the semantics of this value are, but the caller\n> (crlf_to_git) explicitly checks for CRLF_SAFE_RENORMALIZE and\n> changes it to CRLF_SAFE_FALSE instead.  But that check only happens\n> if crlf_action is CRLF_AUTO*, and for me it's CRLF_TEXT_INPUT.\n> \n> I moved the check to happen regardless of the value of crlf_action,\n> and at least in this case, git appears to happily do the right\n> thing.  So I think this is a bug, but line endings are such a tangle\n> that I'm really not sure.  :)\n>\nI am not sure either.\nCould you send me the diff you made ?\ngit diff\n\nI am happy to look into it, (in the amount of time I have).\n\n> The repository in question is ZDoom: https://github.com/rheit/zdoom\n> I'm trying to cherry-pick commits from the 3dfloors3 branch (e.g.,\n> 9fb2daf58e9d512170859302a1ac0ea9c2ec5993) onto a slightly outdated\n> master, 6384e81d0f135a2c292ac3e874f6fe26093f45b1.\n\nThis is what I tried:\n\nuser@pc:~/NoBackup> cd zdoom/          9fb2daf58e9d512170859302a1ac0ea9c2ec5993                                      t9fb2daf5Note: checking out '9fb2daf58e9d512170859302a1ac0ea9c2ec5993'.02a1ac0ea9c2ec5993 \n\nYou are in 'detached HEAD' state. You can look around, make experimental\nchanges and commit them, and you can discard any commits you make in this\nstate without impacting any branches by performing another checkout.\n\nIf you want to create a new branch to retain commits you create, you may\ndo so (now or later) by using -b with the checkout command again. Example:\n\n  git checkout -b <new-branch-name>\n\nHEAD is now at 9fb2daf... - Force use of GL nodes when 3D floors are present. - Move MAPINFO line modification flags into P_AdjustLine().\nuser@pc:~/NoBackup/zdoom> git format-patch HEAD^..HEAD --stdout >9fb2daf.patch\nuser@pc:~/NoBackup/zdoom> git format-patch HEAD^..HEAD --stdout | tr -d \"\\r\" >9fb2daf-noCRLF.patch\nuser@pc:~/NoBackup/zdoom> git checkout 6384e81d0f135a2c292ac3e874f6fe26093f45b1\nPrevious HEAD position was 9fb2daf... - Force use of GL nodes when 3D floors are present. - Move MAPINFO line modification flags into P_AdjustLine().\nHEAD is now at 6384e81... - Add support for Skulltag ACS IsNetworkGame.\nuser@pc:~/NoBackup/zdoom> git cherry-pick 9fb2daf58e9d512170859302a1ac0ea9c2ec5993'.02a1ac0ea9c2ec5993\n> \nuser@pc:~/NoBackup/zdoom> git cherry-pick 9fb2daf58e9d512170859302a1ac0ea9c2ec5993\nerror: could not apply 9fb2daf... - Force use of GL nodes when 3D floors are present.\nhint: after resolving the conflicts, mark the corrected paths\nhint: with 'git add <paths>' or 'git rm <paths>'\nhint: and commit the result with 'git commit'\nuser@pc:~/NoBackup/zdoom> git status\nHEAD detached at 6384e81\nYou are currently cherry-picking commit 9fb2daf.\n  (fix conflicts and run \"git cherry-pick --continue\")\n  (use \"git cherry-pick --abort\" to cancel the cherry-pick operation)\n\nUnmerged paths:\n  (use \"git add <file>...\" to mark resolution)\n\n        both modified:   src/p_setup.cpp\n\nUntracked files:\n  (use \"git add <file>...\" to include in what will be committed)\n\n        9fb2daf-noCRLF.patch\n        9fb2daf.patch\n\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\nuser@pc:~/NoBackup/zdoom> git cherry-pick --abort\nuser@pc:~/NoBackup/zdoom> git am < 9fb2daf-noCRLF.patch \nApplying: - Force use of GL nodes when 3D floors are present. - Move MAPINFO line modification flags into P_AdjustLine().\nerror: patch failed: src/p_setup.cpp:1798\nerror: src/p_setup.cpp: patch does not apply\nPatch failed at 0001 - Force use of GL nodes when 3D floors are present. - Move MAPINFO line modification flags into P_AdjustLine().\nThe copy of the patch that failed is found in: .git/rebase-apply/patch\nWhen you have resolved this problem, run \"git am --continue\".\nIf you prefer to skip this patch, run \"git am --skip\" instead.\nTo restore the original branch and stop patching, run \"git am --abort\".\n\n\n\nThe patch did not apply, but for different reasons.\n\nCould you send us, what exactly you did, to help me out ?\n\n \n\n\n\n"},{"id":"306528","messageId":"76a7e155-f399-c9f8-c69e-8164e0735dfb@veekun.com","threadId":"44553","inReplyTo":"20161128155415.GA9966@tb-raspi","subject":"Re: cherry-pick -Xrenormalize fails with formerly CRLF files","fromName":"Eevee (Lexy Munroe)","fromEmail":"eevee@veekun.com","sentAt":"2016-11-29T00:27:34Z","receivedAt":"2016-11-29T00:27:42Z","isPatch":false,"sender":{"key":"eevee@veekun.com","avatar":null},"body":"On 11/28/2016 07:54 AM, Torsten Bögershausen wrote:\n> On Sun, Nov 27, 2016 at 10:19:35PM -0800, Eevee (Lexy Munroe) wrote:\n>> I'm working with a repo that used to be all CRLF.  At some point it\n>> was changed to all LF, with `text=auto` in .gitattributes for the\n>> sake of Windows devs.  I'm on Linux and have never touched any\n>> twiddles relating to line endings.  I'm trying to cherry-pick some\n>> commits from before the switchover.\n>>\n>> Straightforward cherry-picking causes entire files at a time to\n>> conflict, which I've seen before when switching from tabs to spaces.\n>> So I tried -Xrenormalize and got:\n>>\n>>     fatal: CRLF would be replaced by LF in [path]\n>>\n>\n> Which version of Git are you using, what does\n> git --version\n> say?\n\nOh, sorry.  2.10.2, but I also tried building next (c8190e7) with the \nsame result.\n\n>> The error comes from check_safe_crlf, which warns if checksafe is\n>> CRLF_SAFE_WARN and dies if it's (presumably) CRLF_SAFE_FAIL.  The\n>> funny thing is that it's CRLF_SAFE_RENORMALIZE.\n>>\n>> I don't know what the semantics of this value are, but the caller\n>> (crlf_to_git) explicitly checks for CRLF_SAFE_RENORMALIZE and\n>> changes it to CRLF_SAFE_FALSE instead.  But that check only happens\n>> if crlf_action is CRLF_AUTO*, and for me it's CRLF_TEXT_INPUT.\n>>\n>> I moved the check to happen regardless of the value of crlf_action,\n>> and at least in this case, git appears to happily do the right\n>> thing.  So I think this is a bug, but line endings are such a tangle\n>> that I'm really not sure.  :)\n>>\n> I am not sure either.\n> Could you send me the diff you made ?\n> git diff\n>\n> I am happy to look into it, (in the amount of time I have).\n\nIt's pretty straightforward:\n\ndiff --git a/convert.c b/convert.c\nindex be91358..f9ff6a5 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -275,6 +275,8 @@ static int crlf_to_git(const char *path, const char \n*src, size_t len,\n         /* Optimization: No CRLF? Nothing to convert, regardless. */\n         convert_crlf_into_lf = !!stats.crlf;\n\n+       if (checksafe == SAFE_CRLF_RENORMALIZE)\n+               checksafe = SAFE_CRLF_FALSE;\n         if (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT \n|| crlf_action == CRLF_AUTO_CRLF) {\n                 if (convert_is_binary(len, &stats))\n                         return 0;\n\n(The new lines are copied from the block immediately following, just \npast where the context ends.)\n\n>> The repository in question is ZDoom: https://github.com/rheit/zdoom\n>> I'm trying to cherry-pick commits from the 3dfloors3 branch (e.g.,\n>> 9fb2daf58e9d512170859302a1ac0ea9c2ec5993) onto a slightly outdated\n>> master, 6384e81d0f135a2c292ac3e874f6fe26093f45b1.\n>\n> This is what I tried:\n>\n> ...\n>\n> The patch did not apply, but for different reasons.\n>\n> Could you send us, what exactly you did, to help me out ?\n\nI did notice it works when there's a conflict, but I thought I \nspecifically named a commit that applied cleanly.  Apparently not, \nsorry.  Try ddba3dd325054e71d48634cb19708cb7bcd8f20b:\n\neevee@perushian ~/dev-foreign/zdoom.git/src ⚘ git checkout -b \ngit-renormalize-test 6384e81d0f135a2c292ac3e874f6fe26093f45b1\nSwitched to a new branch 'git-renormalize-test'\neevee@perushian ~/dev-foreign/zdoom.git/src ⚘ git cherry-pick \n-Xrenormalize ddba3dd325054e71d48634cb19708cb7bcd8f20b\nfatal: CRLF would be replaced by LF in src/r_plane.cpp.\n\n"}]}