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

DESCRIPTION

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

FUNCTIONS

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

GIT

84       Part of the git(1) suite
85
86
87
88Git 2.33.1                        2021-10-12                   GIT-SH-SETUP(1)
Impressum