Commit c93fc348 authored by Kitware Robot's avatar Kitware Robot Committed by Kenneth Moreland

GitSetup 2017-10-23 (34f17af6)

Code extracted from:

    https://gitlab.kitware.com/utils/gitsetup.git

at commit 34f17af62ee67b907eee9504fc743637d2936507 (setup).
parent cc537c70
......@@ -30,12 +30,15 @@ OPTIONS
--no-topic
Do not push the topic HEAD.
--no-upstream
Do not set an upstream branch (i.e. tracking) for the topic
'
OPTIONS_SPEC=
SUBDIRECTORY_OK=Yes
. "$(git --exec-path)/git-sh-setup"
egrep-q() {
egrep_q() {
egrep "$@" >/dev/null 2>/dev/null
}
......@@ -65,14 +68,16 @@ lease_flag=''
no_topic=''
no_default=''
dry_run=''
set_upstream=true
# Parse the command line options.
while test $# != 0; do
case "$1" in
-f|--force) force='+'; lease=true ;;
--no-topic) no_topic=1 ;;
--dry-run) dry_run=--dry-run ;;
--no-default) no_default=1 ;;
-f|--force) force='+'; lease=true ;;
--no-topic) no_topic=1; set_upstream=false ;;
--dry-run) dry_run=--dry-run ;;
--no-default) no_default=1 ;;
--no-upstream) set_upstream=false ;;
--) shift; break ;;
-*) usage ;;
*) test -z "$remote" || usage ; remote="$1" ;;
......@@ -95,7 +100,7 @@ if test -z "$no_topic"; then
if $lease; then
have_ref=false
remoteref="refs/remotes/$remote/$topic"
if git rev-parse --verify -q "$remoteref"; then
if git rev-parse --verify -q "$remoteref" > /dev/null; then
have_ref=true
else
die "It seems that a local ref for the branch is
......@@ -105,7 +110,11 @@ push without '-f' or '--force'."
fi
have_lease_flag=false
if git push -h | egrep-q -e '--force-with-lease'; then
# Note: on Windows 'git push --help' will open a browser, and
# the check will fail, so use the flag by default.
if git --version | egrep_q -e 'windows'; then
have_lease_flag=true
elif git push --help | egrep_q -e '--force-with-lease'; then
have_lease_flag=true
fi
......@@ -159,7 +168,7 @@ echo "$push_stdout"
if test "$push_exit" -ne 0 && test -z "$force"; then
# Advise the user to fetch if needed.
if echo "$push_stdout" | egrep-q 'stale info'; then
if echo "$push_stdout" | egrep_q 'stale info'; then
echo "
You have pushed to your branch from another machine; you may be overwriting
commits unintentionally. Fetch from the $remote remote and check that you are
......@@ -167,10 +176,12 @@ not pushing an outdated branch."
fi
# Advise the user to force-push if needed.
if echo "$push_stdout" | egrep-q 'non-fast-forward'; then
if echo "$push_stdout" | egrep_q 'non-fast-forward'; then
echo '
Add "-f" or "--force" to push a rewritten topic.'
fi
elif $set_upstream && test -n "$topic"; then
git branch -u "$remote/$topic"
fi
# Reproduce the push exit code.
......
......@@ -26,7 +26,7 @@
# hooks.url = Repository URL publishing "hooks" branch
# hooks.branch = Repository branch instead of "hooks"
egrep-q() {
egrep_q() {
egrep "$@" >/dev/null 2>/dev/null
}
......@@ -42,7 +42,7 @@ if url=$(git config --get hooks.url); then
# Fetch hooks from locally configured repository.
branch=$(git config hooks.branch || echo hooks)
elif git for-each-ref refs/remotes/origin/hooks 2>/dev/null |
egrep-q 'refs/remotes/origin/hooks$'; then
egrep_q 'refs/remotes/origin/hooks$'; then
# Use hooks cloned from origin.
url=.. && branch=remotes/origin/hooks
elif url=$(git config -f config --get hooks.url); then
......
......@@ -25,7 +25,7 @@
# ssh.key = Local ssh key name
# ssh.request-url = Web page URL to request ssh access
egrep-q() {
egrep_q() {
egrep "$@" >/dev/null 2>/dev/null
}
......@@ -45,7 +45,7 @@ die 'This project is not configured for ssh push access.'
# Check for existing configuration.
if test -r ~/.ssh/config &&
egrep-q 'Host[= ]'"${host//\./\\.}" ~/.ssh/config; then
egrep_q 'Host[= ]'"${host//\./\\.}" ~/.ssh/config; then
echo 'Host "'"$host"'" is already in ~/.ssh/config' &&
setup= &&
question='Test'
......
......@@ -19,7 +19,7 @@
# Project configuration instructions: NONE
egrep-q() {
egrep_q() {
egrep "$@" >/dev/null 2>/dev/null
}
......@@ -33,7 +33,7 @@ One may enable color output from Git commands with
fi
# Suggest bash completion.
if ! bash -i -c 'echo $PS1' | egrep-q '__git_ps1'; then
if ! bash -i -c 'echo $PS1' | egrep_q '__git_ps1'; then
echo '
A dynamic, informative Git shell prompt can be obtained by sourcing
the git bash-completion script in your "~/.bashrc". Set the PS1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment