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 2005-11-24 00:12:11 -08:00
parent e8cc80d039
commit ae2b0f1518
26 changed files with 34 additions and 31 deletions

View File

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


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

View File

@ -18,7 +18,7 @@
## ##
## git-am is supposed to be the newer and better tool for this job. ## 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 () { usage () {
echo >&2 "applymbox [-u] [-k] [-q] [-m] (-c .dotest/<num> | mbox) [signoff]" echo >&2 "applymbox [-u] [-k] [-q] [-m] (-c .dotest/<num> | mbox) [signoff]"

View File

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


final=.dotest/final-commit final=.dotest/final-commit
## ##

View File

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


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

View File

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


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


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

View File

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


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

View File

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


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


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



View File

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


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


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

View File

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


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


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

View File

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

View File

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


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


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

View File

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


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


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

View File

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


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


LF=' LF='
' '

View File

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


usage () { usage () {
die "usage: git octopus" die "usage: git octopus"

View File

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


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


dryrun= dryrun=
echo= echo=

View File

@ -4,7 +4,7 @@
# #
# Fetch one or more remote refs and merge it/them into the current HEAD. # 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 () { usage () {
echo >&2 "usage: $0"' [-n] [--no-commit] [--no-summary] [--help] echo >&2 "usage: $0"' [-n] [--no-commit] [--no-summary] [--help]

View File

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


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

View File

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


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


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

View File

@ -3,7 +3,7 @@
# Copyright (c) 2005 Linus Torvalds # 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= no_update_info= all_into_one= remove_redundant= local=
while case "$#" in 0) break ;; esac while case "$#" in 0) break ;; esac

View File

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


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

View File

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


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

View File

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


case "$0" in case "$0" in
*-revert* ) *-revert* )

View File

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


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


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

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

View File

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


report () { report () {
header="# header="#

View File

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


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


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

View File

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


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