From c7e5672d4d3d6a44ac01c0a56e122a58994846de Mon Sep 17 00:00:00 2001 From: Elliott Clark Date: Thu, 12 May 2016 11:15:57 -0700 Subject: [PATCH] HBASE-15725 make_patch.sh should add the branch name when -b is passed. --- dev-support/make_patch.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/dev-support/make_patch.sh b/dev-support/make_patch.sh index 446c0a54e88..0aedf885928 100755 --- a/dev-support/make_patch.sh +++ b/dev-support/make_patch.sh @@ -24,7 +24,7 @@ while getopts "ahd:b:" opt; do case "$opt" in a) addendum='-addendum' ;; - d) + d) patch_dir=$OPTARG ;; b) @@ -52,7 +52,7 @@ fi # Exit if git status is dirty git_dirty=$(git diff --shortstat 2> /dev/null | wc -l|awk {'print $1'}) echo "git_dirty is $git_dirty" -if [ "$git_dirty" -ne 0 ]; then +if [ "$git_dirty" -ne 0 ]; then echo "Git status is dirty. Commit locally first.">&2 exit 1 fi @@ -117,8 +117,15 @@ elif [ "$status" -ge 1 ]; then fi done fi +# If this is against a tracking branch other than master +# include it in the patch name +tracking_suffix="" +if [[ $tracking_branch != "origin/master" \ + && $tracking_branch != "master" ]]; then + tracking_suffix="-${tracking_branch#origin/}" +fi -patch_name="$branch$prefix$addendum.patch" +patch_name="$branch$prefix$addendum$tracking_suffix.patch" # Do we need to make a diff? git diff --quiet $tracking_branch @@ -134,10 +141,10 @@ local_commits=$(git log $tracking_branch..$branch|grep 'Author:'|wc -l|awk {'pri if [ "$local_commits" -gt 1 ]; then read -p "$local_commits commits exist only in your local branch. Interactive rebase?" yn case $yn in - [Yy]* ) + [Yy]* ) git rebase -i $tracking_branch ;; - [Nn]* ) + [Nn]* ) echo "Creating $patch_dir/$patch_name using git diff." git diff $tracking_branch > $patch_dir/$patch_name exit 0 @@ -147,5 +154,3 @@ fi echo "Creating patch $patch_dir/$patch_name using git format-patch" git format-patch --stdout $tracking_branch > $patch_dir/$patch_name - -