diff options
-rwxr-xr-x | git-am.sh | 2 | ||||
-rwxr-xr-x | git-applymbox.sh | 2 | ||||
-rwxr-xr-x | git-applypatch.sh | 2 | ||||
-rwxr-xr-x | git-bisect.sh | 2 | ||||
-rwxr-xr-x | git-branch.sh | 2 | ||||
-rwxr-xr-x | git-checkout.sh | 2 | ||||
-rwxr-xr-x | git-cherry.sh | 2 | ||||
-rwxr-xr-x | git-commit.sh | 2 | ||||
-rwxr-xr-x | git-count-objects.sh | 2 | ||||
-rwxr-xr-x | git-fetch.sh | 2 | ||||
-rwxr-xr-x | git-format-patch.sh | 2 | ||||
-rwxr-xr-x | git-lost-found.sh | 2 | ||||
-rwxr-xr-x | git-merge.sh | 2 | ||||
-rwxr-xr-x | git-octopus.sh | 2 | ||||
-rwxr-xr-x | git-prune.sh | 2 | ||||
-rwxr-xr-x | git-pull.sh | 2 | ||||
-rwxr-xr-x | git-push.sh | 2 | ||||
-rwxr-xr-x | git-rebase.sh | 2 | ||||
-rwxr-xr-x | git-repack.sh | 2 | ||||
-rwxr-xr-x | git-reset.sh | 2 | ||||
-rwxr-xr-x | git-resolve.sh | 2 | ||||
-rwxr-xr-x | git-revert.sh | 2 | ||||
-rwxr-xr-x | git-sh-setup.sh | 15 | ||||
-rwxr-xr-x | git-status.sh | 2 | ||||
-rwxr-xr-x | git-tag.sh | 2 | ||||
-rwxr-xr-x | git-verify-tag.sh | 2 |
26 files changed, 34 insertions, 31 deletions
@@ -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>" diff --git a/git-applymbox.sh b/git-applymbox.sh index 6de6932879..24d4a8cb4e 100755 --- a/git-applymbox.sh +++ b/git-applymbox.sh @@ -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]" diff --git a/git-applypatch.sh b/git-applypatch.sh index 66fd19ae2d..f0549960fb 100755 --- a/git-applypatch.sh +++ b/git-applypatch.sh @@ -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 ## diff --git a/git-bisect.sh b/git-bisect.sh index 1ab2f187dc..d92993b94e 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -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] diff --git a/git-branch.sh b/git-branch.sh index 2594518e9f..4cd5da16f7 100755 --- a/git-branch.sh +++ b/git-branch.sh @@ -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]] diff --git a/git-checkout.sh b/git-checkout.sh index 9509ab4b9a..4cf30e2c05 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -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>...]" diff --git a/git-cherry.sh b/git-cherry.sh index aad2e6171f..867522b37f 100755 --- a/git-cherry.sh +++ b/git-cherry.sh @@ -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>] diff --git a/git-commit.sh b/git-commit.sh index 27aea80a43..3d250ec853 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -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>...]' diff --git a/git-count-objects.sh b/git-count-objects.sh index fc61a1a987..d6e9a3221f 100755 --- a/git-count-objects.sh +++ b/git-count-objects.sh @@ -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 diff --git a/git-fetch.sh b/git-fetch.sh index 6586e773e6..14ea295113 100755 --- a/git-fetch.sh +++ b/git-fetch.sh @@ -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" diff --git a/git-format-patch.sh b/git-format-patch.sh index 351790c449..bc56876531 100755 --- a/git-format-patch.sh +++ b/git-format-patch.sh @@ -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] diff --git a/git-lost-found.sh b/git-lost-found.sh index 3892f52005..9dd7430018 100755 --- a/git-lost-found.sh +++ b/git-lost-found.sh @@ -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 diff --git a/git-merge.sh b/git-merge.sh index 255476e2de..d352a3cf65 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -3,7 +3,7 @@ # 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 d2471af3c8..2edbf52c42 100755 --- a/git-octopus.sh +++ b/git-octopus.sh @@ -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" diff --git a/git-prune.sh b/git-prune.sh index c4de7f5f25..1fd8c731cd 100755 --- a/git-prune.sh +++ b/git-prune.sh @@ -1,6 +1,6 @@ #!/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 3b875ad438..3a139849fb 100755 --- a/git-pull.sh +++ b/git-pull.sh @@ -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] diff --git a/git-push.sh b/git-push.sh index edc0b8317a..140c8f85d5 100755 --- a/git-push.sh +++ b/git-push.sh @@ -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>]" diff --git a/git-rebase.sh b/git-rebase.sh index 5289762883..2bc3a12995 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -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 diff --git a/git-repack.sh b/git-repack.sh index c0f271d101..430ddc5a70 100755 --- a/git-repack.sh +++ b/git-repack.sh @@ -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 diff --git a/git-reset.sh b/git-reset.sh index 2086d26d34..72ef303aed 100755 --- a/git-reset.sh +++ b/git-reset.sh @@ -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>]' diff --git a/git-resolve.sh b/git-resolve.sh index 7d8fb54f95..fcc5ad7349 100755 --- a/git-resolve.sh +++ b/git-resolve.sh @@ -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>" diff --git a/git-revert.sh b/git-revert.sh index 4ba6912f0d..c1aebb159c 100755 --- a/git-revert.sh +++ b/git-revert.sh @@ -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* ) diff --git a/git-sh-setup.sh b/git-sh-setup.sh index dbb98842bf..e343349c00 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -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 @@ # exporting it. unset CDPATH +: ${GIT_DIR=.git} +: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"} + die() { echo >&2 "$@" exit 1 @@ -22,4 +24,5 @@ refs/*) : ;; *) 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 837f334d87..b90ffc198d 100755 --- a/git-status.sh +++ b/git-status.sh @@ -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="# diff --git a/git-tag.sh b/git-tag.sh index 1375945307..16efc5b70a 100755 --- a/git-tag.sh +++ b/git-tag.sh @@ -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>]" diff --git a/git-verify-tag.sh b/git-verify-tag.sh index ed4c893968..3c65f4a6b5 100755 --- a/git-verify-tag.sh +++ b/git-verify-tag.sh @@ -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." |