Skip to content

Commit

Permalink
Specify a path when checking if a repo has a detached head
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrarimarco committed Nov 9, 2023
1 parent 808fd31 commit 49bd406
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .shells/.all/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ is_wsl() {
}

is_git_detached_head() {
if [ "$(git rev-parse --abbrev-ref --symbolic-full-name HEAD)" = "HEAD" ]; then
repository_dir="$1"
if [ "$(git -C ${repository_dir} rev-parse --abbrev-ref --symbolic-full-name HEAD)" = "HEAD" ]; then
return 0
else
return 1
Expand Down Expand Up @@ -333,7 +334,7 @@ update_git_repository() {
_git_dir="${destination_dir}/.git"
if [ -d "${_git_dir}" ]; then
echo "Updating $program_name in: $destination_dir"
if ! is_git_detached_head; then
if ! is_git_detached_head "${destination_dir}"; then
git -C "$destination_dir" pull
else
echo "$destination_dir is in detached head state. Fetching only."
Expand Down

0 comments on commit 49bd406

Please sign in to comment.