LinuxCommandLibrary

git-mergetool--lib

Helper library for git mergetool scripts

SYNOPSIS

source git-mergetool--lib
(Sourced internally by git mergetool; not directly executable)

DESCRIPTION

The git-mergetool--lib is a shell script library used internally by Git's git mergetool command. It provides common functions and utilities for handling three-way file merges during conflict resolution in Git repositories.

It defines key functions such as merge_mode, which determines the merge strategy (e.g., diff3 or combined); launch_merge_tool, which invokes external merge tools like vimdiff, meld, or kdiff3; and helpers for tool configuration, path management, and exit status handling.

Sourced at runtime by git-mergetool, it reads Git configuration from sections like mergetool.* and merge.tool to select and launch appropriate tools. It supports prompts for overwriting local/remote files, binary file handling, and trust settings to skip confirmation dialogs.

This library ensures consistent behavior across merge tools, abstracting low-level operations like temporary file creation in $GIT_MERGE_WORK_DIR or .git/MERGE_MODE. It is not intended for direct execution but enhances git mergetool's extensibility and portability.

CAVEATS

Not a standalone command; designed for sourcing only. Direct execution may produce no output or errors. Relies on Git environment variables like $GIT_PREFIX and config settings.

KEY FUNCTIONS

Provides help, list_merge_tools, valid_tool, merge_mode, launch_merge_tool, and cleanup routines.

CONFIGURATION

Uses mergetool..path, mergetool..cmd, mergetool.prompt, and merge.tool from git config.

HISTORY

Introduced in Git 1.5.0 (2007) alongside git mergetool for modular merge support. Evolved with Git releases to add tool-specific options, prompt behaviors (Git 1.6+), and worktree integration (Git 2.5+).

SEE ALSO

Copied to clipboard