1GIT-SH-SETUP(1)                   Git Manual                   GIT-SH-SETUP(1)
2
3
4

NAME

6       git-sh-setup - Common Git shell script setup code
7

SYNOPSIS

9       . "$(git --exec-path)/git-sh-setup"
10
11

DESCRIPTION

13       This is not a command the end user would want to run. Ever. This
14       documentation is meant for people who are studying the Porcelain-ish
15       scripts and/or are writing new ones.
16
17       The git sh-setup scriptlet is designed to be sourced (using .) by other
18       shell scripts to set up some variables pointing at the normal Git
19       directories and a few helper shell functions.
20
21       Before sourcing it, your script should set up a few variables; USAGE
22       (and LONG_USAGE, if any) is used to define message given by usage()
23       shell function. SUBDIRECTORY_OK can be set if the script can run from a
24       subdirectory of the working tree (some commands do not).
25
26       The scriptlet sets GIT_DIR and GIT_OBJECT_DIRECTORY shell variables,
27       but does not export them to the environment.
28

FUNCTIONS

30       die
31           exit after emitting the supplied error message to the standard
32           error stream.
33
34       usage
35           die with the usage message.
36
37       set_reflog_action
38           set the message that will be recorded to describe the end-user
39           action in the reflog, when the script updates a ref.
40
41       git_editor
42           runs an editor of user’s choice (GIT_EDITOR, core.editor, VISUAL or
43           EDITOR) on a given file, but error out if no editor is specified
44           and the terminal is dumb.
45
46       is_bare_repository
47           outputs true or false to the standard output stream to indicate if
48           the repository is a bare repository (i.e. without an associated
49           working tree).
50
51       cd_to_toplevel
52           runs chdir to the toplevel of the working tree.
53
54       require_work_tree
55           checks if the current directory is within the working tree of the
56           repository, and otherwise dies.
57
58       require_work_tree_exists
59           checks if the working tree associated with the repository exists,
60           and otherwise dies. Often done before calling cd_to_toplevel, which
61           is impossible to do if there is no working tree.
62
63       require_clean_work_tree <action> [<hint>]
64           checks that the working tree and index associated with the
65           repository have no uncommitted changes to tracked files. Otherwise
66           it emits an error message of the form Cannot <action>: <reason>.
67           <hint>, and dies. Example:
68
69               require_clean_work_tree rebase "Please commit or stash them."
70
71
72       get_author_ident_from_commit
73           outputs code for use with eval to set the GIT_AUTHOR_NAME,
74           GIT_AUTHOR_EMAIL and GIT_AUTHOR_DATE variables for a given commit.
75
76       create_virtual_base
77           modifies the first file so only lines in common with the second
78           file remain. If there is insufficient common material, then the
79           first file is left empty. The result is suitable as a virtual base
80           input for a 3-way merge.
81

GIT

83       Part of the git(1) suite
84
85
86
87Git 1.8.3.1                       11/19/2018                   GIT-SH-SETUP(1)
Impressum