'\" t
.\"     Title: git-mergetool--lib
.\"    Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\"      Date: 04/20/2026
.\"    Manual: Git Manual
.\"    Source: Git 2.54.0
.\"  Language: English
.\"
.TH "GIT\-MERGETOOL\-\-LIB" "1" "04/20/2026" "Git 2\&.54\&.0" "Git Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
git-mergetool--lib \- Common Git merge tool shell scriptlets
.SH "SYNOPSIS"
.sp
.nf
\fITOOL_MODE=(diff|merge) \&. "$(git \-\-exec\-path)/git\-mergetool\-\-lib"\fR
.fi
.SH "DESCRIPTION"
.sp
This is not a command the end user would want to run\&. Ever\&. This documentation is meant for people who are studying the Porcelain\-ish scripts and/or are writing new ones\&.
.sp
The \fIgit\-mergetool\-\-lib\fR scriptlet is designed to be sourced (using \&.) by other shell scripts to set up functions for working with Git merge tools\&.
.sp
Before sourcing \fIgit\-mergetool\-\-lib\fR, your script must set \fBTOOL_MODE\fR to define the operation mode for the functions listed below\&. \fIdiff\fR and \fImerge\fR are valid values\&.
.SH "FUNCTIONS"
.PP
get_merge_tool
.RS 4
Returns a merge tool\&. The return code is 1 if we returned a guessed merge tool, else 0\&.
\fI$GIT_MERGETOOL_GUI\fR
may be set to
\fItrue\fR
to search for the appropriate guitool\&.
.RE
.PP
get_merge_tool_cmd
.RS 4
Returns the custom command for a merge tool\&.
.RE
.PP
get_merge_tool_path
.RS 4
Returns the custom path for a merge tool\&.
.RE
.PP
initialize_merge_tool
.RS 4
Brings merge tool specific functions into scope so they can be used or overridden\&.
.RE
.PP
run_merge_tool
.RS 4
Launches a merge tool given the tool name and a true/false flag to indicate whether a merge base is present\&.
\fI$MERGED\fR,
\fI$LOCAL\fR,
\fI$REMOTE\fR, and
\fI$BASE\fR
must be defined for use by the merge tool\&.
.RE
.SH "GIT"
.sp
Part of the \fBgit\fR(1) suite
