<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<article lang="en" id="git-sh-setup(1)">
<articleinfo>
    <title>git-sh-setup(1)</title>
        <indexterm>
                <primary>git-sh-setup(1)</primary>
        </indexterm>
</articleinfo>
<simplesect id="_name">
<title>NAME</title>
<simpara>git-sh-setup - Common git shell script setup code</simpara>
</simplesect>
<simplesect id="_synopsis">
<title>SYNOPSIS</title>
<simpara><emphasis>. "$(git --exec-path)/git-sh-setup"</emphasis></simpara>
</simplesect>
<simplesect id="_description">
<title>DESCRIPTION</title>
<simpara>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.</simpara>
<simpara>The <emphasis>git-sh-setup</emphasis> scriptlet is designed to be sourced (using
<literal>.</literal>) by other shell scripts to set up some variables pointing at
the normal git directories and a few helper shell functions.</simpara>
<simpara>Before sourcing it, your script should set up a few variables;
<literal>USAGE</literal> (and <literal>LONG_USAGE</literal>, if any) is used to define message
given by <literal>usage()</literal> shell function.  <literal>SUBDIRECTORY_OK</literal> can be set
if the script can run from a subdirectory of the working tree
(some commands do not).</simpara>
<simpara>The scriptlet sets <literal>GIT_DIR</literal> and <literal>GIT_OBJECT_DIRECTORY</literal> shell
variables, but does <emphasis role="strong">not</emphasis> export them to the environment.</simpara>
</simplesect>
<simplesect id="_functions">
<title>FUNCTIONS</title>
<variablelist>
<varlistentry>
<term>
die
</term>
<listitem>
<simpara>
        exit after emitting the supplied error message to the
        standard error stream.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
usage
</term>
<listitem>
<simpara>
        die with the usage message.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
set_reflog_action
</term>
<listitem>
<simpara>
        set the message that will be recorded to describe the
        end-user action in the reflog, when the script updates a
        ref.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
git_editor
</term>
<listitem>
<simpara>
        runs an editor of user&#8217;s choice (GIT_EDITOR, core.editor, VISUAL or
        EDITOR) on a given file, but error out if no editor is specified
        and the terminal is dumb.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
is_bare_repository
</term>
<listitem>
<simpara>
        outputs <literal>true</literal> or <literal>false</literal> to the standard output stream
        to indicate if the repository is a bare repository
        (i.e. without an associated working tree).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
cd_to_toplevel
</term>
<listitem>
<simpara>
        runs chdir to the toplevel of the working tree.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
require_work_tree
</term>
<listitem>
<simpara>
        checks if the repository is a bare repository, and dies
        if so.  Used by scripts that require working tree
        (e.g. <literal>checkout</literal>).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
get_author_ident_from_commit
</term>
<listitem>
<simpara>
        outputs code for use with eval to set the GIT_AUTHOR_NAME,
        GIT_AUTHOR_EMAIL and GIT_AUTHOR_DATE variables for a given commit.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_author">
<title>Author</title>
<simpara>Written by Linus Torvalds &lt;<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>&gt;</simpara>
</simplesect>
<simplesect id="_documentation">
<title>Documentation</title>
<simpara>Documentation by Junio C Hamano and the git-list &lt;<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>&gt;.</simpara>
</simplesect>
<simplesect id="_git">
<title>GIT</title>
<simpara>Part of the <xref linkend="git(1)"/> suite</simpara>
</simplesect>
</article>
