Commit 376d0b93 authored by Brad King's avatar Brad King

Teach "git gerrit-push" new --dry-run option

This tells the script to do everything except actually make the final
changes to the local and remote repositories.  It uses the --dry-run
option of "git push".

While at it, initialize the "refspec" variable and comment handling of
the return code from the push.

Change-Id: I0466be76f5c28122dbf9b7f23a7a679703ca6bb8
parent 7c4c44dd
#!/usr/bin/env bash
USAGE="[<remote>] [--no-topic] [--]"
USAGE="[<remote>] [--no-topic] [--dry-run] [--]"
. "$(git --exec-path)/git-sh-setup"
# Parse the command line options.
while test $# != 0; do
case "$1" in
--no-topic) no_topic=1 ;;
--dry-run) dry_run=--dry-run ;;
--) shift; break ;;
-*) usage ;;
*) test -z "$remote" || usage ; remote="$1" ;;
......@@ -44,8 +49,10 @@ fi
echo "Fetching $remote master"
fetch_out=$(git fetch "$remote" master 2>&1) || die "$fetch_out"
# Now push the topic branch
# Push. Save output and exit code.
echo "Pushing to $remote"
push_stdout=$(git push --porcelain "$remote" $refspecs); push_exit=$?
push_stdout=$(git push --porcelain $dry_run "$remote" $refspecs); push_exit=$?
echo "$push_stdout"
# Reproduce the push exit code.
exit $push_exit
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