Skip to content

Commit

Permalink
Merge branch 'jc/require-work-tree-exists'
Browse files Browse the repository at this point in the history
* jc/require-work-tree-exists:
  require-work-tree wants more than what its name says
  • Loading branch information
Junio C Hamano committed May 26, 2011
2 parents 1dcfb2a + e2eb527 commit 0a2a5d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Documentation/git-sh-setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@ cd_to_toplevel::
runs chdir to the toplevel of the working tree.

require_work_tree::
checks if the repository is a bare repository, and dies
if so. Used by scripts that require working tree
(e.g. `checkout`).
checks if the current directory is within the working tree
of the repository, and otherwise dies.

require_work_tree_exists::
checks if the working tree associated with the repository
exists, and otherwise dies. Often done before calling
cd_to_toplevel, which is impossible to do if there is no
working tree.

get_author_ident_from_commit::
outputs code for use with eval to set the GIT_AUTHOR_NAME,
Expand Down
7 changes: 7 additions & 0 deletions git-sh-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ cd_to_toplevel () {
}
}
require_work_tree_exists () {
if test "z$(git rev-parse --is-bare-repository)" != zfalse
then
die "fatal: $0 cannot be used without a working tree."
fi
}
require_work_tree () {
test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ||
die "fatal: $0 cannot be used without a working tree."
Expand Down

0 comments on commit 0a2a5d8

Please sign in to comment.