Skip to content

Commit

Permalink
Default second argument to the current branch
Browse files Browse the repository at this point in the history
If not included.

Means that you can write:

  ./compare master

To compare the current branch to master and not have to list out and
copy and paste the current branch.
  • Loading branch information
michaeljones committed Aug 21, 2021
1 parent fc3103f commit 9931d32
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions documentation/compare
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@
first=$1
second=$2

if [ -z "$second" ]; then
echo "Usage: compare <branch name A> <branch name B>"
if [ -z "$first" ]; then
echo "Usage: compare <branch name A> [<branch name B>]"
echo ""
echo "The second argument defaults to the current branch if not specified"
exit 1
fi

firstdir=comparison/first
seconddir=comparison/second

# Remember the branch we're on
currentbranch=`git symbolic-ref --short HEAD`

if [ -z "$second" ]; then
second=$currentbranch
fi

firstdir=comparison/first
seconddir=comparison/second

# Make sure the output directory exists
mkdir -p comparison

Expand Down

0 comments on commit 9931d32

Please sign in to comment.