1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
\r
4 <article lang="en" id="git-sh-setup(1)">
\r
6 <title>git-sh-setup(1)</title>
\r
8 <primary>git-sh-setup(1)</primary>
\r
11 <simplesect id="_name">
\r
13 <simpara>git-sh-setup - Common git shell script setup code</simpara>
\r
15 <simplesect id="_synopsis">
\r
16 <title>SYNOPSIS</title>
\r
18 <literallayout><emphasis>. "$(git --exec-path)/git-sh-setup"</emphasis></literallayout>
\r
21 <simplesect id="_description">
\r
22 <title>DESCRIPTION</title>
\r
23 <simpara>This is not a command the end user would want to run. Ever.
\r
24 This documentation is meant for people who are studying the
\r
25 Porcelain-ish scripts and/or are writing new ones.</simpara>
\r
26 <simpara>The <emphasis>git sh-setup</emphasis> scriptlet is designed to be sourced (using
\r
27 <emphasis>.</emphasis>) by other shell scripts to set up some variables pointing at
\r
28 the normal git directories and a few helper shell functions.</simpara>
\r
29 <simpara>Before sourcing it, your script should set up a few variables;
\r
30 <emphasis>USAGE</emphasis> (and <emphasis>LONG_USAGE</emphasis>, if any) is used to define message
\r
31 given by <emphasis>usage()</emphasis> shell function. <emphasis>SUBDIRECTORY_OK</emphasis> can be set
\r
32 if the script can run from a subdirectory of the working tree
\r
33 (some commands do not).</simpara>
\r
34 <simpara>The scriptlet sets <emphasis>GIT_DIR</emphasis> and <emphasis>GIT_OBJECT_DIRECTORY</emphasis> shell
\r
35 variables, but does <emphasis role="strong">not</emphasis> export them to the environment.</simpara>
\r
37 <simplesect id="_functions">
\r
38 <title>FUNCTIONS</title>
\r
46 exit after emitting the supplied error message to the
\r
47 standard error stream.
\r
57 die with the usage message.
\r
67 set the message that will be recorded to describe the
\r
68 end-user action in the reflog, when the script updates a
\r
79 runs an editor of user's choice (GIT_EDITOR, core.editor, VISUAL or
\r
80 EDITOR) on a given file, but error out if no editor is specified
\r
81 and the terminal is dumb.
\r
91 outputs <emphasis>true</emphasis> or <emphasis>false</emphasis> to the standard output stream
\r
92 to indicate if the repository is a bare repository
\r
93 (i.e. without an associated working tree).
\r
103 runs chdir to the toplevel of the working tree.
\r
113 checks if the current directory is within the working tree
\r
114 of the repository, and otherwise dies.
\r
120 require_work_tree_exists
\r
124 checks if the working tree associated with the repository
\r
125 exists, and otherwise dies. Often done before calling
\r
126 cd_to_toplevel, which is impossible to do if there is no
\r
133 require_clean_work_tree <action> [<hint>]
\r
137 checks that the working tree and index associated with the
\r
138 repository have no uncommitted changes to tracked files.
\r
139 Otherwise it emits an error message of the form <emphasis>Cannot
\r
140 <action>: <reason>. <hint></emphasis>, and dies. Example:
\r
142 <screen>require_clean_work_tree rebase "Please commit or stash them."</screen>
\r
147 get_author_ident_from_commit
\r
151 outputs code for use with eval to set the GIT_AUTHOR_NAME,
\r
152 GIT_AUTHOR_EMAIL and GIT_AUTHOR_DATE variables for a given commit.
\r
158 <simplesect id="_git">
\r
160 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
\r