1
0
Fork 0

Make sure that the current directory is a Git repository

pull/298/head
Sorin Ionescu 12 years ago
parent 6c1a81b5cf
commit 102da8bea0

@ -8,6 +8,10 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
return 1
fi
local state expl remotes remote branches_or_tags branches tags files ret=1
_arguments -C -s -S \

@ -8,6 +8,10 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
return 1
fi
_arguments "1:toggle:((
on\:'enable in-prompt information for the current repository'
off\:'disable in-prompt information for the current repository'

@ -5,7 +5,13 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
if ! git rev-parse 2> /dev/null; then
print "$0: not a repository: $PWD" >&2
return 1
fi
local ref="$(git symbolic-ref HEAD 2> /dev/null)"
if [[ -n "$ref" ]]; then
print "${ref#refs/heads/}"
return 0

@ -5,6 +5,11 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2
return 1
fi
git fsck 2> /dev/null \
| grep "^dangling commit" \
| awk '{print $3}' \

@ -11,6 +11,7 @@ if [[ -n "$git_dir" ]]; then
print "$git_dir"
return 0
else
print "$0: not a repository: $PWD" >&2
return 1
fi

@ -5,6 +5,11 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2
return 1
fi
local remotes remote references reference file url
remote="${1:-origin}"

@ -11,6 +11,7 @@ if [[ -n "$root" ]]; then
print "$root"
return 0
else
print "$0: not a repository work tree: $PWD" >&2
return 1
fi

@ -5,6 +5,11 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2
return 1
fi
local stashed
if [[ -f "$(git-dir)/refs/stash" ]]; then

@ -5,6 +5,11 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2
return 1
fi
git fsck --unreachable 2> /dev/null \
| grep 'commit' \
| awk '{print $3}' \

@ -5,6 +5,11 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2
return 1
fi
local commit
for commit in "$@"; do

@ -5,15 +5,18 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2
return 1
elif [[ "$PWD" != "$(git-root)" ]]; then
print "$0: must be run from the root of the work tree" >&2
return 1
fi
local src="$1"
local dst="$2"
local url
if [[ "$PWD" != "$(git-root)" ]]; then
print "$0: must be run from the root of the working tree" >&2
return 1
fi
url="$(git config --file "$(git-root)/.gitmodules" --get "submodule.${src}.url")"
if [[ -z "$url" ]]; then

@ -5,12 +5,13 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
if [[ "$PWD" != "$(git-root)" ]]; then
print "$0: must be run from the root of the working tree" >&2
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2
return 1
fi
if ! git config --file .gitmodules --get "submodule.${1}.path" &>/dev/null; then
elif [[ "$PWD" != "$(git-root)" ]]; then
print "$0: must be run from the root of the work tree" >&2
return 1
elif ! git config --file .gitmodules --get "submodule.${1}.path" &>/dev/null; then
print "$0: submodule not found: $1" >&2
return 1
fi

Loading…
Cancel
Save