{"thread":{"id":"48561","subject":"unexpected \"unresolved merge conflict\" for a new file","startedAt":"2018-05-24T11:37:12Z","lastAt":"2018-05-25T07:22:39Z","messageCount":3,"participants":["Michal Hocko","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"348419","messageId":"20180524113657.GD20441@dhcp22.suse.cz","threadId":"48561","inReplyTo":null,"subject":"unexpected \"unresolved merge conflict\" for a new file","fromName":"Michal Hocko","fromEmail":"mhocko@kernel.org","sentAt":"2018-05-24T11:36:57Z","receivedAt":"2018-05-24T11:37:12Z","isPatch":false,"sender":{"key":"mhocko@kernel.org","avatar":null},"body":"Hi,\n`git commit' fails on a newly added file with the following\n*\n* You have some suspicious patch lines:\n*\n* In Documentation/core-api/gfp_mask-from-fs-io.rst\n* unresolved merge conflict (line 27)\nDocumentation/core-api/gfp_mask-from-fs-io.rst:27:=======\n\n$ git status --porcelain \nA  Documentation/core-api/gfp_mask-from-fs-io.rst\n\n$ git --version \ngit version 2.17.0\n\nfrom debian.\n\nBtw. the suspicious line is\n$ sed -n '27p' Documentation/core-api/gfp_mask-from-fs-io.rst\n=======\n\nI believe this is a bug because a new file cannot have a conflict by\ndefinition and also there are no <<<<< in the file so there is no\nunresolved conflict there. So I guess the heuristic should be more\nclever.\n\nThanks!\n-- \nMichal Hocko\nSUSE Labs\n"},{"id":"348463","messageId":"20180524171120.GC14876@sigill.intra.peff.net","threadId":"48561","inReplyTo":"20180524113657.GD20441@dhcp22.suse.cz","subject":"Re: unexpected \"unresolved merge conflict\" for a new file","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-05-24T17:11:20Z","receivedAt":"2018-05-24T17:11:27Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, May 24, 2018 at 01:36:57PM +0200, Michal Hocko wrote:\n\n> `git commit' fails on a newly added file with the following\n> *\n> * You have some suspicious patch lines:\n> *\n> * In Documentation/core-api/gfp_mask-from-fs-io.rst\n> * unresolved merge conflict (line 27)\n> Documentation/core-api/gfp_mask-from-fs-io.rst:27:=======\n\nThis message isn't generated by git itself, but rather by a pre-commit\nhook. You can skip the hook by running \"git commit --no-verify\".\n\nAs for the false positive in the hook logic, I can't say more without\nhaving seen the hook source. :) Do you know where you got it from?\n\n(Googling for \"suspicious patch lines\" turns up some hits, but with\nvarying provenance).\n\n-Peff\n"},{"id":"348519","messageId":"20180525072234.GD11881@dhcp22.suse.cz","threadId":"48561","inReplyTo":"20180524171120.GC14876@sigill.intra.peff.net","subject":"Re: unexpected \"unresolved merge conflict\" for a new file","fromName":"Michal Hocko","fromEmail":"mhocko@kernel.org","sentAt":"2018-05-25T07:22:34Z","receivedAt":"2018-05-25T07:22:39Z","isPatch":false,"sender":{"key":"mhocko@kernel.org","avatar":null},"body":"On Thu 24-05-18 13:11:20, Jeff King wrote:\n> On Thu, May 24, 2018 at 01:36:57PM +0200, Michal Hocko wrote:\n> \n> > `git commit' fails on a newly added file with the following\n> > *\n> > * You have some suspicious patch lines:\n> > *\n> > * In Documentation/core-api/gfp_mask-from-fs-io.rst\n> > * unresolved merge conflict (line 27)\n> > Documentation/core-api/gfp_mask-from-fs-io.rst:27:=======\n> \n> This message isn't generated by git itself, but rather by a pre-commit\n> hook. You can skip the hook by running \"git commit --no-verify\".\n> \n> As for the false positive in the hook logic, I can't say more without\n> having seen the hook source. :) Do you know where you got it from?\n> \n> (Googling for \"suspicious patch lines\" turns up some hits, but with\n> varying provenance).\n\nOhh, I see. I must have installed this one loooong time ago. Attached\nfor reference. I will just drop it. Sorry about tht noise.\n-- \nMichal Hocko\nSUSE Labs\n\n\n#!/bin/sh\n#\n# An example hook script to verify what is about to be committed.\n# Called by git-commit with no arguments.  The hook should\n# exit with non-zero status after issuing an appropriate message if\n# it wants to stop the commit.\n#\n# To enable this hook, make this file executable.\n\n# This is slightly modified from Andrew Morton's Perfect Patch.\n# Lines you introduce should not have trailing whitespace.\n# Also check for an indentation that has SP before a TAB.\n\nif git-rev-parse --verify HEAD 2>/dev/null\nthen\n\tgit-diff-index -p -M --cached HEAD --\nelse\n\t# NEEDSWORK: we should produce a diff with an empty tree here\n\t# if we want to do the same verification for the initial import.\n\t:\nfi |\nperl -e '\n    my $found_bad = 0;\n    my $filename;\n    my $reported_filename = \"\";\n    my $lineno;\n    sub bad_line {\n\tmy ($why, $line) = @_;\n\tif (!$found_bad) {\n\t    print STDERR \"*\\n\";\n\t    print STDERR \"* You have some suspicious patch lines:\\n\";\n\t    print STDERR \"*\\n\";\n\t    $found_bad = 1;\n\t}\n\tif ($reported_filename ne $filename) {\n\t    print STDERR \"* In $filename\\n\";\n\t    $reported_filename = $filename;\n\t}\n\tprint STDERR \"* $why (line $lineno)\\n\";\n\tprint STDERR \"$filename:$lineno:$line\\n\";\n    }\n    while (<>) {\n\tif (m|^diff --git a/(.*) b/\\1$|) {\n\t    $filename = $1;\n\t    next;\n\t}\n\tif (/^@@ -\\S+ \\+(\\d+)/) {\n\t    $lineno = $1 - 1;\n\t    next;\n\t}\n\tif (/^ /) {\n\t    $lineno++;\n\t    next;\n\t}\n\tif (s/^\\+//) {\n\t    $lineno++;\n\t    chomp;\n\t    if (/\\s$/) {\n\t\tbad_line(\"trailing whitespace\", $_);\n\t    }\n\t    if (/^\\s* \\t/) {\n\t\tbad_line(\"indent SP followed by a TAB\", $_);\n\t    }\n\t    if (/^([<>])\\1{6} |^={7}$/) {\n\t\tbad_line(\"unresolved merge conflict\", $_);\n\t    }\n\t}\n    }\n    exit($found_bad);\n'\n"}]}