0
     �ÂÁÀ      File not found.
     	�Âa–Ðz¾””ÔD¨ 	ÅíÀ½pM©‹FÿÁ      	File not found.
  #   ˆl–Ým_Jµ!®Å8 ¸Ë·ú˜´oÀ„ß¿Â *œ    # git-mergetool--lib is a shell library for common merge tool functions

: ${MERGE_TOOLS_DIR=$(git --exec-path)/mergetools}

IFS='
'

mode_ok () {
	if diff_mode
	then
		can_diff
	elif merge_mode
	then
		can_merge
	else
		false
	fi
}

is_available () {
	merge_tool_path=$(translate_merge_tool_path "$1") &&
	type "$merge_tool_path" >/dev/null 2>&1
}

list_config_tools () {
	section=$1
	line_prefix=${2:-}

	git config --get-regexp $section'\..*\.cmd' |
	while read -r key value
	do
		toolname=${key#$section.}
		toolname=${toolname%.cmd}

		printf "%s%s\n" "$line_prefix" "$toolname"
	done
}

show_tool_names () {
	condition=${1:-true} per_line_prefix=${2:-} preamble=${3:-}
	not_found_msg=${4:-}
	extra_content=${5:-}

	shown_any=
	( cd "$MERGE_TOOLS_DIR" && ls ) | {
		while read scriptname
		do
			setup_tool "$scriptname" 2>/dev/null
			# We need an actual line feed here
			variants="$variants
$(list_tool_variants)"
		done
		variants="$(echo "$variants" | sort -u)"

		for toolname in $variants
		do
			if setup_tool "$toolname" 2>/dev/null &&
				(eval "$condition" "$toolname")
			then
				if test -n "$preamble"
				then
					printf "%s\n" "$preamble"
					preamble=
				fi
				shown_any=yes
				printf "%s%-15s  %s\n" "$per_line_prefix" "$toolname" $(diff_mode && diff_cmd_help "$toolname" || merge_cmd_help "$toolname")
			fi
		done

		if test -n "$extra_content"
		then
			if test -n "$preamble"
			then
				# Note: no '\n' here since we don't want a
				# blank line if there is no initial content.
				printf "%s" "$preamble"
				preamble=
			fi
			shown_any=yes
			printf "\n%s\n" "$extra_content"
		fi

		if test -n "$preamble" && test -n "$not_found_msg"
		then
			printf "%s\n" "$not_found_msg"
		fi

		test -n "$shown_any"
	}
}

diff_mode () {
	test "$TOOL_MODE" = diff
}

merge_mode () {
	test "$TOOL_MODE" = merge
}

get_gui_default () {
	if diff_mode
	then
		GUI_DEFAULT_KEY="difftool.guiDefault"
	else
		GUI_DEFAULT_KEY="mergetool.guiDefault"
	fi
	GUI_DEFAULT_CONFIG_LCASE=$(git config --default false --get "$GUI_DEFAULT_KEY" | tr 'A-Z' 'a-z')
	if test "$GUI_DEFAULT_CONFIG_LCASE" = "auto"
	then
		if test -n "$DISPLAY"
		then
			GUI_DEFAULT=true
		else
			GUI_DEFAULT=false
		fi
	else
		GUI_DEFAULT=$(git config --default false --bool --get "$GUI_DEFAULT_KEY")
		subshell_exit_status=$?
		if test $subshell_exit_status -ne 0
		then
			exit $subshell_exit_status
		fi
	fi
	echo $GUI_DEFAULT
}

gui_mode () {
	if test -z "$GIT_MERGETOOL_GUI"
	then
		GIT_MERGETOOL_GUI=$(get_gui_default)
		if test $? -ne 0
		then
			exit 2
		fi
	fi
	test "$GIT_MERGETOOL_GUI" = true
}

translate_merge_tool_path () {
	echo "$1"
}

check_unchanged () {
	if test "$MERGED" -nt "$BACKUP"
	then
		return 0
	else
		while true
		do
			echo "$MERGED seems unchanged."
			printf "Was the merge successful [y/n]? "
			read answer || return 1
			case "$answer" in
			y*|Y*) return 0 ;;
			n*|N*) return 1 ;;
			esac
		done
	fi
}

valid_tool () {
	setup_tool "$1" 2>/dev/null && return 0
	cmd=$(get_merge_tool_cmd "$1")
	test -n "$cmd"
}

setup_user_tool () {
	merge_tool_cmd=$(get_merge_tool_cmd "$tool")
	test -n "$merge_tool_cmd" || return 1

	diff_cmd () {
		( eval $merge_tool_cmd )
	}

	merge_cmd () {
		( eval $merge_tool_cmd )
	}

	list_tool_variants () {
		echo "$tool"
	}
}

setup_tool () {
	tool="$1"

	# Fallback definitions, to be overridden by tools.
	can_merge () {
		return 0
	}

	can_diff () {
		return 0
	}

	diff_cmd () {
		return 1
	}

	diff_cmd_help () {
		return 0
	}

	merge_cmd () {
		return 1
	}

	merge_cmd_help () {
		return 0
	}

	hide_resolved_enabled () {
		return 0
	}

	translate_merge_tool_path () {
		echo "$1"
	}

	list_tool_variants () {
		echo "$tool"
	}

	# Most tools' exit codes cannot be trusted, so By default we ignore
	# their exit code and check the merged file's modification time in
	# check_unchanged() to determine whether or not the merge was
	# successful.  The return value from run_merge_cmd, b