Browse Source

Make sure that the current directory is a Git repository

master
Sorin Ionescu 12 years ago
parent
commit
102da8bea0
  1. 4
      modules/git/functions/_git-hub-browse
  2. 4
      modules/git/functions/_git-info
  3. 6
      modules/git/functions/git-branch-current
  4. 5
      modules/git/functions/git-commit-lost
  5. 1
      modules/git/functions/git-dir
  6. 5
      modules/git/functions/git-hub-browse
  7. 1
      modules/git/functions/git-root
  8. 5
      modules/git/functions/git-stash-clear-interactive
  9. 5
      modules/git/functions/git-stash-dropped
  10. 5
      modules/git/functions/git-stash-recover
  11. 13
      modules/git/functions/git-submodule-move
  12. 11
      modules/git/functions/git-submodule-remove

4
modules/git/functions/_git-hub-browse

@ -8,6 +8,10 @@ @@ -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 \

4
modules/git/functions/_git-info

@ -8,6 +8,10 @@ @@ -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'

6
modules/git/functions/git-branch-current

@ -5,7 +5,13 @@ @@ -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
modules/git/functions/git-commit-lost

@ -5,6 +5,11 @@ @@ -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}' \

1
modules/git/functions/git-dir

@ -11,6 +11,7 @@ if [[ -n "$git_dir" ]]; then @@ -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
modules/git/functions/git-hub-browse

@ -5,6 +5,11 @@ @@ -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}"

1
modules/git/functions/git-root

@ -11,6 +11,7 @@ if [[ -n "$root" ]]; then @@ -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
modules/git/functions/git-stash-clear-interactive

@ -5,6 +5,11 @@ @@ -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
modules/git/functions/git-stash-dropped

@ -5,6 +5,11 @@ @@ -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
modules/git/functions/git-stash-recover

@ -5,6 +5,11 @@ @@ -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

13
modules/git/functions/git-submodule-move

@ -5,15 +5,18 @@ @@ -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

11
modules/git/functions/git-submodule-remove

@ -5,12 +5,13 @@ @@ -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