git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] pre-commit hook: complain about conflict markers.

From
Junio C Hamano <junkio@cox.net>
Date
Apr 19, 2006, 21:59 UTC
Message-ID
<7vpsjd5iqw.fsf_-_@assigned-by-dhcp.cox.net>
In-Reply-To
<7v8xq16y31.fsf@assigned-by-dhcp.cox.net>

Several <<< or === or >>> characters at the beginning of a line is very likely to be leftover conflict markers from a failed automerge the user resolved incorrectly, so detect them.

As usual, this can be defeated with "git commit --no-verify" if you really do want to have those files, just like changes that introduce trailing whitespaces.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 templates/hooks--pre-commit |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
6be63d37efc766756922a9b96ed8fe7a332f133a
diff --git a/templates/hooks--pre-commit b/templates/hooks--pre-commit
index 43d3b6e..723a9ef 100644
--- a/templates/hooks--pre-commit
+++ b/templates/hooks--pre-commit
@@ -61,6 +61,9 @@ perl -e '
 	    if (/^\s* 	/) {
 		bad_line("indent SP followed by a TAB", $_);
 	    }
+	    if (/^(?:[<>=]){7}/) {
+		bad_line("unresolved merge conflict", $_);
+	    }
 	}
     }
     exit($found_bad);
-- 
1.3.0.g2c4a
Previous: Junio C HamanoNext: Carl Worth
Message 5 of 11 in “Add git-unresolve <paths>...”
  1. Add git-unresolve <paths>...Junio C Hamano, Apr 19, 2006
  2. Carl WorthApr 19, 2006
  3. Junio C HamanoApr 19, 2006
  4. git-merge: a bit more readable user guidance.Junio C Hamano, Apr 19, 2006
  5. pre-commit hook: complain about conflict markers.Junio C Hamano, Apr 19, 2006
  6. Carl WorthApr 19, 2006
  7. Junio C HamanoApr 19, 2006
  8. Carl WorthApr 20, 2006
  9. Junio C HamanoApr 19, 2006
  10. Carl WorthApr 20, 2006
  11. Junio C HamanoApr 20, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.