@matheusbsbs / matheus-bagliano / commits / ae2b0f1518
Fork 0

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>

Junio C Hamano committed Nov 24, 2005 at 00:12 UTC ae2b0f15180d4b044828c836bcab6a990efa5c8e
26 files changed +34 -31
git-am.sh
+1 -1
@@ -1,7 +1,7 @@
1 #!/bin/sh
2 #
3 #
4 -. git-sh-setup || die "Not a git archive"
4 +. git-sh-setup
5
6 usage () {
7 echo >&2 "usage: $0 [--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] <mbox>"
git-applymbox.sh
+1 -1
@@ -18,7 +18,7 @@
18 ##
19 ## git-am is supposed to be the newer and better tool for this job.
20
21 -. git-sh-setup || die "Not a git archive"
21 +. git-sh-setup
22
23 usage () {
24 echo >&2 "applymbox [-u] [-k] [-q] [-m] (-c .dotest/<num> | mbox) [signoff]"
git-applypatch.sh
+1 -1
@@ -10,7 +10,7 @@
10 ## $3 - "info" file with Author, email and subject
11 ## $4 - optional file containing signoff to add
12 ##
13 -. git-sh-setup || die "Not a git archive."
13 +. git-sh-setup
14
15 final=.dotest/final-commit
16 ##
git-bisect.sh
+1 -1
@@ -1,5 +1,5 @@
1 #!/bin/sh
2 -. git-sh-setup || dir "Not a git archive"
2 +. git-sh-setup
3
4 usage() {
5 echo >&2 'usage: git bisect [start|bad|good|next|reset|visualize]
git-branch.sh
+1 -1
@@ -1,6 +1,6 @@
1 #!/bin/sh
2
3 -. git-sh-setup || die "Not a git archive"
3 +. git-sh-setup
4
5 usage () {
6 echo >&2 "usage: $(basename $0)"' [-d <branch>] | [[-f] <branch> [start-point]]
git-checkout.sh
+1 -1
@@ -1,5 +1,5 @@
1 #!/bin/sh
2 -. git-sh-setup || die "Not a git archive"
2 +. git-sh-setup
3
4 usage () {
5 die "usage: git checkout [-f] [-b <new_branch>] [<branch>] [<paths>...]"
git-cherry.sh
+1 -1
@@ -3,7 +3,7 @@
3 # Copyright (c) 2005 Junio C Hamano.
4 #
5
6 -. git-sh-setup || die "Not a git archive."
6 +. git-sh-setup
7
8 usage="usage: $0 "'[-v] <upstream> [<head>]
9
git-commit.sh
+1 -1
@@ -3,7 +3,7 @@
3 # Copyright (c) 2005 Linus Torvalds
4 #
5
6 -. git-sh-setup || die "Not a git archive"
6 +. git-sh-setup
7
8 usage () {
9 die 'git commit [-a] [-s] [-v | --no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit>] [-e] [<path>...]'
git-count-objects.sh
+1 -1
@@ -3,7 +3,7 @@
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 -. git-sh-setup || die "Not a git repository"
6 +. git-sh-setup
7
8 dc </dev/null 2>/dev/null || {
9 # This is not a real DC at all -- it just knows how
git-fetch.sh
+1 -1
@@ -1,6 +1,6 @@
1 #!/bin/sh
2 #
3 -. git-sh-setup || die "Not a git archive"
3 +. git-sh-setup
4 . git-parse-remote
5 _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
6 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
git-format-patch.sh
+1 -1
@@ -3,7 +3,7 @@
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 -. git-sh-setup || die "Not a git archive."
6 +. git-sh-setup
7
8 usage () {
9 echo >&2 "usage: $0"' [-n] [-o dir | --stdout] [--keep-subject] [--mbox]
git-lost-found.sh
+1 -1
@@ -1,6 +1,6 @@
1 #!/bin/sh
2
3 -. git-sh-setup || die "Not a git archive."
3 +. git-sh-setup
4
5 laf="$GIT_DIR/lost-found"
6 rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit
git-merge.sh
+1 -1
@@ -3,7 +3,7 @@
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 -. git-sh-setup || die "Not a git archive"
6 +. git-sh-setup
7
8 LF='
9 '
git-octopus.sh
+1 -1
@@ -4,7 +4,7 @@
4 #
5 # Resolve two or more trees recorded in $GIT_DIR/FETCH_HEAD.
6 #
7 -. git-sh-setup || die "Not a git archive"
7 +. git-sh-setup
8
9 usage () {
10 die "usage: git octopus"
git-prune.sh
+1 -1
@@ -1,6 +1,6 @@
1 #!/bin/sh
2
3 -. git-sh-setup || die "Not a git archive"
3 +. git-sh-setup
4
5 dryrun=
6 echo=
git-pull.sh
+1 -1
@@ -4,7 +4,7 @@
4 #
5 # Fetch one or more remote refs and merge it/them into the current HEAD.
6
7 -. git-sh-setup || die "Not a git archive"
7 +. git-sh-setup
8
9 usage () {
10 echo >&2 "usage: $0"' [-n] [--no-commit] [--no-summary] [--help]
git-push.sh
+1 -1
@@ -1,5 +1,5 @@
1 #!/bin/sh
2 -. git-sh-setup || die "Not a git archive"
2 +. git-sh-setup
3
4 usage () {
5 die "Usage: git push [--all] [--force] <repository> [<refspec>]"
git-rebase.sh
+1 -1
@@ -3,7 +3,7 @@
3 # Copyright (c) 2005 Junio C Hamano.
4 #
5
6 -. git-sh-setup || die "Not a git archive."
6 +. git-sh-setup
7
8 # The other head is given
9 other=$(git-rev-parse --verify "$1^0") || exit
git-repack.sh
+1 -1
@@ -3,7 +3,7 @@
3 # Copyright (c) 2005 Linus Torvalds
4 #
5
6 -. git-sh-setup || die "Not a git archive"
6 +. git-sh-setup
7
8 no_update_info= all_into_one= remove_redundant= local=
9 while case "$#" in 0) break ;; esac
git-reset.sh
+1 -1
@@ -1,5 +1,5 @@
1 #!/bin/sh
2 -. git-sh-setup || die "Not a git archive"
2 +. git-sh-setup
3
4 usage () {
5 die 'Usage: git reset [--mixed | --soft | --hard] [<commit-ish>]'
git-resolve.sh
+1 -1
@@ -4,7 +4,7 @@
4 #
5 # Resolve two trees.
6 #
7 -. git-sh-setup || die "Not a git archive"
7 +. git-sh-setup
8
9 usage () {
10 die "git-resolve <head> <remote> <merge-message>"
git-revert.sh
+1 -1
@@ -3,7 +3,7 @@
3 # Copyright (c) 2005 Linus Torvalds
4 # Copyright (c) 2005 Junio C Hamano
5 #
6 -. git-sh-setup || die "Not a git archive"
6 +. git-sh-setup
7
8 case "$0" in
9 *-revert* )
git-sh-setup.sh
+9 -6
@@ -1,10 +1,9 @@
1 #!/bin/sh
2 #
3 -# Set up GIT_DIR and GIT_OBJECT_DIRECTORY
4 -# and return true if everything looks ok
5 -#
6 -: ${GIT_DIR=.git}
7 -: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
3 +# This is included in commands that either have to be run from the toplevel
4 +# of the repository, or with GIT_DIR environment variable properly.
5 +# If the GIT_DIR does not look like the right correct git-repository,
6 +# it dies.
7
8 # Having this variable in your environment would break scripts because
9 # you would cause "cd" to be be taken to unexpected places. If you
@@ -12,6 +11,9 @@
11 # exporting it.
12 unset CDPATH
13
14 +: ${GIT_DIR=.git}
15 +: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
16 +
17 die() {
18 echo >&2 "$@"
19 exit 1
@@ -22,4 +24,5 @@ refs/*) : ;;
24 *) false ;;
25 esac &&
26 [ -d "$GIT_DIR/refs" ] &&
25 -[ -d "$GIT_OBJECT_DIRECTORY/" ]
27 +[ -d "$GIT_OBJECT_DIRECTORY/" ] ||
28 + die "Not a git repository."
git-status.sh
+1 -1
@@ -2,7 +2,7 @@
2 #
3 # Copyright (c) 2005 Linus Torvalds
4 #
5 -. git-sh-setup || die "Not a git archive"
5 +GIT_DIR=$(git-rev-parse --git-dir) || exit
6
7 report () {
8 header="#
git-tag.sh
+1 -1
@@ -1,7 +1,7 @@
1 #!/bin/sh
2 # Copyright (c) 2005 Linus Torvalds
3
4 -. git-sh-setup || die "Not a git archive"
4 +. git-sh-setup
5
6 usage () {
7 echo >&2 "Usage: git-tag [-a | -s | -u <key-id>] [-f | -d] [-m <msg>] <tagname> [<head>]"
git-verify-tag.sh
+1 -1
@@ -1,5 +1,5 @@
1 #!/bin/sh
2 -. git-sh-setup || die "Not a git archive"
2 +. git-sh-setup
3
4 type="$(git-cat-file -t "$1" 2>/dev/null)" ||
5 die "$1: no such object."