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

[PATCH 2/3] merge: --no-verify to bypass pre-merge hook

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Sep 5, 2012, 13:39 UTC
Message-ID
<2b6dd795b58f6303e1c1fac242825fe95f150b34.1346851863.git.git@drmicha.warpmail.net>
In-Reply-To
<cover.1346851863.git.git@drmicha.warpmail.net>

Analogous to commit, introduce a '--no-verify' option which bypasses the pre-merge hook. The shorthand '-n' is taken by the (non-existing) '--no-stat' already.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-merge.txt     | 2 +-
 Documentation/githooks.txt      | 2 +-
 Documentation/merge-options.txt | 4 ++++
 builtin/merge.c                 | 4 +++-
 4 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index 20f9228..8816865 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git merge' [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
-	[-s <strategy>] [-X <strategy-option>]
+	[--no-verify] [-s <strategy>] [-X <strategy-option>]
 	[--[no-]rerere-autoupdate] [-m <msg>] [<commit>...]
 'git merge' <msg> HEAD <commit>...
 'git merge' --abort
diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
index 3fae643..e20bfe0 100644
--- a/Documentation/githooks.txt
+++ b/Documentation/githooks.txt
@@ -91,7 +91,7 @@ pre-merge
 
 This hook is invoked by 'git merge' when doing an automatic merge
 commit; it is equivalent to 'pre-commit' for a non-automatic commit
-for a merge.
+for a merge, and can be bypassed with the `\--no-verify` option. 
 
 prepare-commit-msg
 ~~~~~~~~~~~~~~~~~~
diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt
index 0bcbe0a..93e2e61 100644
--- a/Documentation/merge-options.txt
+++ b/Documentation/merge-options.txt
@@ -70,6 +70,10 @@ merge.
 With --no-squash perform the merge and commit the result. This
 option can be used to override --squash.
 
+--no-verify::
+	This option bypasses the pre-merge and commit-msg hooks.
+	See also linkgit:githooks[5].
+
 -s <strategy>::
 --strategy=<strategy>::
 	Use the given merge strategy; can be supplied more than
diff --git a/builtin/merge.c b/builtin/merge.c
index 7c09e0b..4d36a00 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -60,6 +60,7 @@ static const char *branch;
 static char *branch_mergeoptions;
 static int option_renormalize;
 static int verbosity;
+static int no_verify;
 static int allow_rerere_auto;
 static int abort_current_merge;
 static int show_progress = -1;
@@ -198,6 +199,7 @@ static struct option builtin_merge_options[] = {
 		N_("allow fast-forward (default)")),
 	OPT_BOOLEAN(0, "ff-only", &fast_forward_only,
 		N_("abort if fast-forward is not possible")),
+	OPT_BOOLEAN(0, "no-verify", &no_verify, "bypass pre-merge hook"),
 	OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
 	OPT_CALLBACK('s', "strategy", &use_strategies, N_("strategy"),
 		N_("merge strategy to use"), option_parse_strategy),
@@ -900,7 +902,7 @@ static void prepare_to_commit(struct commit_list *remoteheads)
 	const char *comment = _(merge_editor_comment);
 	const char *index_file = get_index_file();
 
-	if (run_hook(index_file, "pre-merge", NULL))
+	if (!no_verify && run_hook(index_file, "pre-merge", NULL))
 		abort_commit(remoteheads, NULL);
 	/*
 	 * Re-read the index as pre-merge hook could have updated it,
-- 
1.7.12.406.gafd3f81
Previous: Michael J GruberNext: Michael J Gruber
Message 11 of 16 in “pre-merge-hook”
  1. 0/3 pre-merge-hookMichael J Gruber, Sep 5, 2012
  2. 1/3 git-merge: Honor pre-merge hookMichael J Gruber, Sep 5, 2012
  3. Michael HaggertySep 5, 2012
  4. Michael J GruberSep 6, 2012
  5. Michael HaggertySep 6, 2012
  6. 0/4 pre-commit hook for mergesMichael J Gruber, Sep 6, 2012
  7. 1/4 merge: document prepare-commit-msg hook usageMichael J Gruber, Sep 6, 2012
  8. 2/4 git-merge: Honor pre-commit hook based on configMichael J Gruber, Sep 6, 2012
  9. 3/4 merge: --no-verify to bypass pre-commit hookMichael J Gruber, Sep 6, 2012
  10. 4/4 t7503: add tests for pre-commit hook (merge)Michael J Gruber, Sep 6, 2012
  11. 2/3 merge: --no-verify to bypass pre-merge hookMichael J Gruber, Sep 5, 2012
  12. 3/3 t7503: add tests for pre-merge-hookMichael J Gruber, Sep 5, 2012
  13. Junio C HamanoSep 6, 2012
  14. Michael J GruberSep 6, 2012
  15. Junio C HamanoSep 6, 2012
  16. Michael J GruberSep 7, 2012

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.