File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -58,9 +58,14 @@ cd_to_toplevel::
58
58
runs chdir to the toplevel of the working tree.
59
59
60
60
require_work_tree::
61
- checks if the repository is a bare repository, and dies
62
- if so. Used by scripts that require working tree
63
- (e.g. `checkout`).
61
+ checks if the current directory is within the working tree
62
+ of the repository, and otherwise dies.
63
+
64
+ require_work_tree_exists::
65
+ checks if the working tree associated with the repository
66
+ exists, and otherwise dies. Often done before calling
67
+ cd_to_toplevel, which is impossible to do if there is no
68
+ working tree.
64
69
65
70
get_author_ident_from_commit::
66
71
outputs code for use with eval to set the GIT_AUTHOR_NAME,
Original file line number Diff line number Diff line change @@ -140,6 +140,13 @@ cd_to_toplevel () {
140
140
}
141
141
}
142
142
143
+ require_work_tree_exists () {
144
+ if test " z$( git rev-parse --is-bare-repository) " ! = zfalse
145
+ then
146
+ die " fatal: $0 cannot be used without a working tree."
147
+ fi
148
+ }
149
+
143
150
require_work_tree () {
144
151
test " $( git rev-parse --is-inside-work-tree 2> /dev/null) " = true ||
145
152
die " fatal: $0 cannot be used without a working tree."
You can’t perform that action at this time.
0 commit comments