Browse Source

git-sh-setup: die if outside git repository.

Now all the users of this script detect its exit status and die,
complaining that it is outside git repository.  So move the code
that dies from all callers to git-sh-setup script.

Signed-off-by: Junio C Hamano <junkio@cox.net>
maint
Junio C Hamano 19 years ago
parent
commit
ae2b0f1518
  1. 2
      git-am.sh
  2. 2
      git-applymbox.sh
  3. 2
      git-applypatch.sh
  4. 2
      git-bisect.sh
  5. 2
      git-branch.sh
  6. 2
      git-checkout.sh
  7. 2
      git-cherry.sh
  8. 2
      git-commit.sh
  9. 2
      git-count-objects.sh
  10. 2
      git-fetch.sh
  11. 2
      git-format-patch.sh
  12. 2
      git-lost-found.sh
  13. 2
      git-merge.sh
  14. 2
      git-octopus.sh
  15. 2
      git-prune.sh
  16. 2
      git-pull.sh
  17. 2
      git-push.sh
  18. 2
      git-rebase.sh
  19. 2
      git-repack.sh
  20. 2
      git-reset.sh
  21. 2
      git-resolve.sh
  22. 2
      git-revert.sh
  23. 15
      git-sh-setup.sh
  24. 2
      git-status.sh
  25. 2
      git-tag.sh
  26. 2
      git-verify-tag.sh

2
git-am.sh

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/bin/sh
#
#
. git-sh-setup || die "Not a git archive"
. git-sh-setup

usage () {
echo >&2 "usage: $0 [--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] <mbox>"

2
git-applymbox.sh

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
##
## git-am is supposed to be the newer and better tool for this job.

. git-sh-setup || die "Not a git archive"
. git-sh-setup

usage () {
echo >&2 "applymbox [-u] [-k] [-q] [-m] (-c .dotest/<num> | mbox) [signoff]"

2
git-applypatch.sh

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
## $3 - "info" file with Author, email and subject
## $4 - optional file containing signoff to add
##
. git-sh-setup || die "Not a git archive."
. git-sh-setup

final=.dotest/final-commit
##

2
git-bisect.sh

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/bin/sh
. git-sh-setup || dir "Not a git archive"
. git-sh-setup

usage() {
echo >&2 'usage: git bisect [start|bad|good|next|reset|visualize]

2
git-branch.sh

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
#!/bin/sh

. git-sh-setup || die "Not a git archive"
. git-sh-setup

usage () {
echo >&2 "usage: $(basename $0)"' [-d <branch>] | [[-f] <branch> [start-point]]

2
git-checkout.sh

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/bin/sh
. git-sh-setup || die "Not a git archive"
. git-sh-setup

usage () {
die "usage: git checkout [-f] [-b <new_branch>] [<branch>] [<paths>...]"

2
git-cherry.sh

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano.
#

. git-sh-setup || die "Not a git archive."
. git-sh-setup

usage="usage: $0 "'[-v] <upstream> [<head>]


2
git-commit.sh

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
# Copyright (c) 2005 Linus Torvalds
#

. git-sh-setup || die "Not a git archive"
. git-sh-setup

usage () {
die 'git commit [-a] [-s] [-v | --no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit>] [-e] [<path>...]'

2
git-count-objects.sh

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano
#

. git-sh-setup || die "Not a git repository"
. git-sh-setup

dc </dev/null 2>/dev/null || {
# This is not a real DC at all -- it just knows how

2
git-fetch.sh

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
#!/bin/sh
#
. git-sh-setup || die "Not a git archive"
. git-sh-setup
. git-parse-remote
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"

2
git-format-patch.sh

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano
#

. git-sh-setup || die "Not a git archive."
. git-sh-setup

usage () {
echo >&2 "usage: $0"' [-n] [-o dir | --stdout] [--keep-subject] [--mbox]

2
git-lost-found.sh

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
#!/bin/sh

. git-sh-setup || die "Not a git archive."
. git-sh-setup

laf="$GIT_DIR/lost-found"
rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit

2
git-merge.sh

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano
#

. git-sh-setup || die "Not a git archive"
. git-sh-setup

LF='
'

2
git-octopus.sh

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
#
# Resolve two or more trees recorded in $GIT_DIR/FETCH_HEAD.
#
. git-sh-setup || die "Not a git archive"
. git-sh-setup

usage () {
die "usage: git octopus"

2
git-prune.sh

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
#!/bin/sh

. git-sh-setup || die "Not a git archive"
. git-sh-setup

dryrun=
echo=

2
git-pull.sh

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
#
# Fetch one or more remote refs and merge it/them into the current HEAD.

. git-sh-setup || die "Not a git archive"
. git-sh-setup

usage () {
echo >&2 "usage: $0"' [-n] [--no-commit] [--no-summary] [--help]

2
git-push.sh

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/bin/sh
. git-sh-setup || die "Not a git archive"
. git-sh-setup

usage () {
die "Usage: git push [--all] [--force] <repository> [<refspec>]"

2
git-rebase.sh

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano.
#

. git-sh-setup || die "Not a git archive."
. git-sh-setup

# The other head is given
other=$(git-rev-parse --verify "$1^0") || exit

2
git-repack.sh

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
# Copyright (c) 2005 Linus Torvalds
#

. git-sh-setup || die "Not a git archive"
. git-sh-setup
no_update_info= all_into_one= remove_redundant= local=
while case "$#" in 0) break ;; esac

2
git-reset.sh

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/bin/sh
. git-sh-setup || die "Not a git archive"
. git-sh-setup

usage () {
die 'Usage: git reset [--mixed | --soft | --hard] [<commit-ish>]'

2
git-resolve.sh

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
#
# Resolve two trees.
#
. git-sh-setup || die "Not a git archive"
. git-sh-setup

usage () {
die "git-resolve <head> <remote> <merge-message>"

2
git-revert.sh

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
# Copyright (c) 2005 Linus Torvalds
# Copyright (c) 2005 Junio C Hamano
#
. git-sh-setup || die "Not a git archive"
. git-sh-setup

case "$0" in
*-revert* )

15
git-sh-setup.sh

@ -1,10 +1,9 @@ @@ -1,10 +1,9 @@
#!/bin/sh
#
# Set up GIT_DIR and GIT_OBJECT_DIRECTORY
# and return true if everything looks ok
#
: ${GIT_DIR=.git}
: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
# This is included in commands that either have to be run from the toplevel
# of the repository, or with GIT_DIR environment variable properly.
# If the GIT_DIR does not look like the right correct git-repository,
# it dies.

# Having this variable in your environment would break scripts because
# you would cause "cd" to be be taken to unexpected places. If you
@ -12,6 +11,9 @@ @@ -12,6 +11,9 @@
# exporting it.
unset CDPATH

: ${GIT_DIR=.git}
: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}

die() {
echo >&2 "$@"
exit 1
@ -22,4 +24,5 @@ refs/*) : ;; @@ -22,4 +24,5 @@ refs/*) : ;;
*) false ;;
esac &&
[ -d "$GIT_DIR/refs" ] &&
[ -d "$GIT_OBJECT_DIRECTORY/" ]
[ -d "$GIT_OBJECT_DIRECTORY/" ] ||
die "Not a git repository."

2
git-status.sh

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
#
# Copyright (c) 2005 Linus Torvalds
#
. git-sh-setup || die "Not a git archive"
GIT_DIR=$(git-rev-parse --git-dir) || exit

report () {
header="#

2
git-tag.sh

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/bin/sh
# Copyright (c) 2005 Linus Torvalds

. git-sh-setup || die "Not a git archive"
. git-sh-setup

usage () {
echo >&2 "Usage: git-tag [-a | -s | -u <key-id>] [-f | -d] [-m <msg>] <tagname> [<head>]"

2
git-verify-tag.sh

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/bin/sh
. git-sh-setup || die "Not a git archive"
. git-sh-setup

type="$(git-cat-file -t "$1" 2>/dev/null)" ||
die "$1: no such object."

Loading…
Cancel
Save