summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e8cc80d)
raw | patch | inline | side by side (parent: e8cc80d)
author | Junio C Hamano <junkio@cox.net> | |
Thu, 24 Nov 2005 08:12:11 +0000 (00:12 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 25 Nov 2005 21:49:17 +0000 (13:49 -0800) |
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>
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>
26 files changed:
git-am.sh | patch | blob | history | |
git-applymbox.sh | patch | blob | history | |
git-applypatch.sh | patch | blob | history | |
git-bisect.sh | patch | blob | history | |
git-branch.sh | patch | blob | history | |
git-checkout.sh | patch | blob | history | |
git-cherry.sh | patch | blob | history | |
git-commit.sh | patch | blob | history | |
git-count-objects.sh | patch | blob | history | |
git-fetch.sh | patch | blob | history | |
git-format-patch.sh | patch | blob | history | |
git-lost-found.sh | patch | blob | history | |
git-merge.sh | patch | blob | history | |
git-octopus.sh | patch | blob | history | |
git-prune.sh | patch | blob | history | |
git-pull.sh | patch | blob | history | |
git-push.sh | patch | blob | history | |
git-rebase.sh | patch | blob | history | |
git-repack.sh | patch | blob | history | |
git-reset.sh | patch | blob | history | |
git-resolve.sh | patch | blob | history | |
git-revert.sh | patch | blob | history | |
git-sh-setup.sh | patch | blob | history | |
git-status.sh | patch | blob | history | |
git-tag.sh | patch | blob | history | |
git-verify-tag.sh | patch | blob | history |
diff --git a/git-am.sh b/git-am.sh
index 8f073c90f6dce20e6e4f3a0b3046cc25dfd503e0..660b3a4b6113f58ff33fd2db2cdeac25ce32f95d 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
#!/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>"
diff --git a/git-applymbox.sh b/git-applymbox.sh
index 6de6932879e9f1298f69e2826f13e1ee231ecea0..24d4a8cb4eb95a5201c205be879d3ac6a62a8a15 100755 (executable)
--- a/git-applymbox.sh
+++ b/git-applymbox.sh
##
## 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]"
diff --git a/git-applypatch.sh b/git-applypatch.sh
index 66fd19ae2df2e1f44b709a20802342c88d9d2cf2..f0549960fbd706f06fff5b2c602450917505a1ad 100755 (executable)
--- a/git-applypatch.sh
+++ b/git-applypatch.sh
## $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
##
diff --git a/git-bisect.sh b/git-bisect.sh
index 1ab2f187dcfd1ab9b81bbc3ebb3605601b4d29f0..d92993b94e4264d9c13547f8bc3a1d9c6c77017a 100755 (executable)
--- a/git-bisect.sh
+++ b/git-bisect.sh
#!/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]
diff --git a/git-branch.sh b/git-branch.sh
index 2594518e9f7a812a77aaba5b10f3194a7eced423..4cd5da16f74cee6e277d33bce74242496eca94fe 100755 (executable)
--- a/git-branch.sh
+++ b/git-branch.sh
#!/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]]
diff --git a/git-checkout.sh b/git-checkout.sh
index 9509ab4b9a53fd132ae74de241c3f60744b6162c..4cf30e2c0529e90886e6edfd485cec67a278e224 100755 (executable)
--- a/git-checkout.sh
+++ b/git-checkout.sh
#!/bin/sh
-. git-sh-setup || die "Not a git archive"
+. git-sh-setup
usage () {
die "usage: git checkout [-f] [-b <new_branch>] [<branch>] [<paths>...]"
diff --git a/git-cherry.sh b/git-cherry.sh
index aad2e6171f920c4ad6e83a521837f32d2402da68..867522b37ff4fd85f963019a025ba07789ffef37 100755 (executable)
--- a/git-cherry.sh
+++ b/git-cherry.sh
# Copyright (c) 2005 Junio C Hamano.
#
-. git-sh-setup || die "Not a git archive."
+. git-sh-setup
usage="usage: $0 "'[-v] <upstream> [<head>]
diff --git a/git-commit.sh b/git-commit.sh
index 27aea80a43acf7ee7994b53ef05828edd84f3f73..3d250ec853dad3ff7e714025026ca90f2c77e7bb 100755 (executable)
--- a/git-commit.sh
+++ b/git-commit.sh
# 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>...]'
diff --git a/git-count-objects.sh b/git-count-objects.sh
index fc61a1a987d45bc73bcee805e9010c5ac96ea66a..d6e9a3221f1f63142d9490e9abdfc5c8ac8d6348 100755 (executable)
--- a/git-count-objects.sh
+++ b/git-count-objects.sh
# 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
diff --git a/git-fetch.sh b/git-fetch.sh
index 6586e773e6b3979463d5cc6537e6ddc5700de25a..14ea295113be9381ce9d4af52f022ce99c75506f 100755 (executable)
--- a/git-fetch.sh
+++ b/git-fetch.sh
#!/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"
diff --git a/git-format-patch.sh b/git-format-patch.sh
index 351790c4494ec88c01063a4c97c487f9e015c339..bc5687653150ff1e27720173b137d759d60c74c6 100755 (executable)
--- a/git-format-patch.sh
+++ b/git-format-patch.sh
# 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]
diff --git a/git-lost-found.sh b/git-lost-found.sh
index 3892f52005d1e36676681806a87ef35dc0689f22..9dd7430018f4bfb76c29e77e7fb9365acaa3bd9b 100755 (executable)
--- a/git-lost-found.sh
+++ b/git-lost-found.sh
#!/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
diff --git a/git-merge.sh b/git-merge.sh
index 255476e2deda1e5c7f9654fd92ba9d1950b1a3b7..d352a3cf65e45e0da0a8ee1989e9acb522e132b5 100755 (executable)
--- a/git-merge.sh
+++ b/git-merge.sh
# Copyright (c) 2005 Junio C Hamano
#
-. git-sh-setup || die "Not a git archive"
+. git-sh-setup
LF='
'
diff --git a/git-octopus.sh b/git-octopus.sh
index d2471af3c8a002c175bf9b1370039b9e7d4ab946..2edbf52c42d329bc1cd091f0ec07f6ccf032478e 100755 (executable)
--- a/git-octopus.sh
+++ b/git-octopus.sh
#
# 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"
diff --git a/git-prune.sh b/git-prune.sh
index c4de7f5f250b647065c97dabbb234216f5c8c718..1fd8c731cdd3651e3cd3c527915db7a4c4324be0 100755 (executable)
--- a/git-prune.sh
+++ b/git-prune.sh
#!/bin/sh
-. git-sh-setup || die "Not a git archive"
+. git-sh-setup
dryrun=
echo=
diff --git a/git-pull.sh b/git-pull.sh
index 3b875ad438c21df50c0b1f26bc8fac5ab1bc9740..3a139849fbfc545b7c479dd2889a0285fab646d5 100755 (executable)
--- a/git-pull.sh
+++ b/git-pull.sh
#
# 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]
diff --git a/git-push.sh b/git-push.sh
index edc0b8317a6d566895c4a2df6a3f7d86773ca138..140c8f85d55c5654cfc9077fecfd03ad067a6862 100755 (executable)
--- a/git-push.sh
+++ b/git-push.sh
#!/bin/sh
-. git-sh-setup || die "Not a git archive"
+. git-sh-setup
usage () {
die "Usage: git push [--all] [--force] <repository> [<refspec>]"
diff --git a/git-rebase.sh b/git-rebase.sh
index 5289762883f07e2737e1dbf3acfa106d101687f3..2bc3a12995ec5f18cf666289a6691fa2e4d3fb47 100755 (executable)
--- a/git-rebase.sh
+++ b/git-rebase.sh
# 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
diff --git a/git-repack.sh b/git-repack.sh
index c0f271d1015d4d6abfa332a3baa427f125be3581..430ddc5a706945035149464d0bea8f25acc21d3c 100755 (executable)
--- a/git-repack.sh
+++ b/git-repack.sh
# 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
diff --git a/git-reset.sh b/git-reset.sh
index 2086d26d343c59d36df79d874d65f58d6d7d8b10..72ef303aedc69a1d9cdd946a91059638cb2e550a 100755 (executable)
--- a/git-reset.sh
+++ b/git-reset.sh
#!/bin/sh
-. git-sh-setup || die "Not a git archive"
+. git-sh-setup
usage () {
die 'Usage: git reset [--mixed | --soft | --hard] [<commit-ish>]'
diff --git a/git-resolve.sh b/git-resolve.sh
index 7d8fb54f952e3f85c8c77b8fd9c67afbe76f0316..fcc5ad7349e3f77a6817e499b331b262c4a07b57 100755 (executable)
--- a/git-resolve.sh
+++ b/git-resolve.sh
#
# Resolve two trees.
#
-. git-sh-setup || die "Not a git archive"
+. git-sh-setup
usage () {
die "git-resolve <head> <remote> <merge-message>"
diff --git a/git-revert.sh b/git-revert.sh
index 4ba6912f0de972a95ec040aa9fb09af78ab2765b..c1aebb159cab86f419ff2aaab2a8f1d9d79a9a72 100755 (executable)
--- a/git-revert.sh
+++ b/git-revert.sh
# 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* )
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index dbb98842bf6327210c604ae65a128cdfc785b32c..e343349c0087aefbb42d17ace9102a72d2fb437a 100755 (executable)
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
#!/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
# exporting it.
unset CDPATH
+: ${GIT_DIR=.git}
+: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
+
die() {
echo >&2 "$@"
exit 1
*) false ;;
esac &&
[ -d "$GIT_DIR/refs" ] &&
-[ -d "$GIT_OBJECT_DIRECTORY/" ]
+[ -d "$GIT_OBJECT_DIRECTORY/" ] ||
+ die "Not a git repository."
diff --git a/git-status.sh b/git-status.sh
index 837f334d8760c9ff4af4de5d057e97d7af3cfc61..b90ffc198d97bccfc7f484e8555b01ba9bf5217b 100755 (executable)
--- a/git-status.sh
+++ b/git-status.sh
#
# Copyright (c) 2005 Linus Torvalds
#
-. git-sh-setup || die "Not a git archive"
+GIT_DIR=$(git-rev-parse --git-dir) || exit
report () {
header="#
diff --git a/git-tag.sh b/git-tag.sh
index 13759453077b025d7815354c61269c2a9847e68f..16efc5b70ac7ea4f0770530845e35091e71feab6 100755 (executable)
--- a/git-tag.sh
+++ b/git-tag.sh
#!/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>]"
diff --git a/git-verify-tag.sh b/git-verify-tag.sh
index ed4c89396841d8292185b0504ef62ef36007f354..3c65f4a6b51707601bc8f66657e6e79cc33094fd 100755 (executable)
--- a/git-verify-tag.sh
+++ b/git-verify-tag.sh
#!/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."