git-barepo

Tools for sharing git bare repositories
git clone git://git.meso-star.com/git-repo.git
Log | Files | Refs | README | LICENSE

commit 1209651978e2b11399a18bf1d74d414595683ed5
parent caf3604198b708f3629ec4bb550870f015b88947
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 20 Oct 2026 11:21:26 +0200

git-publich: improve error detection

If the directory where the repository is published is the directory in
which the repository is located, an error was reported as the
impossibility of deleting the repository, but without any explanation on
why git-publish was trying to delete it. A deletion that, if it
happened, is frightening for the user since the repository would then
have disappeared.

Now this situation is  explicitly treated and a specific error message
is displayed. An error is finally returned before any attempt to publish
the repository.

Diffstat:
Mgit-publish | 15+++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/git-publish b/git-publish @@ -293,10 +293,21 @@ publish_repo() # shellcheck disable=SC2310 check_repo "${_repo_git}" || return 1 - # If the path to the published repository already exists, - # verify that it matches the repository to publish... _dir0="$(cd "${_repo_git}" && pwd -P)" _dir1="$(cd "${_repo}" && pwd -P)" + + # Check that the directory where to publish the repository is not + # the directory where the repository is located. + if [ "${_dir0}" = "${_dir1}" ]; then + >&2 printf \ +'the directory "%s" where to publish the repository "%s" '\ +'is the directory in which the repository is located\n.' \ + "${dir_git}" "${_repo}" + return 1 + fi + + # If the path to the published repository already exists, + # verify that it matches the repository to publish... if [ "${_dir0}" != "${_dir1}" ]; then >&2 printf \ '"%s" already exists and is not the public version of "%s"\n' \