summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Xu <peterx@redhat.com>2017-03-24 07:44:47 +0100
committerMiroslav Rezanina <mrezanin@redhat.com>2017-04-05 09:15:32 +0200
commitc8afc5ecbc8d05c2c4fd0f1678d2fa0a4075174d (patch)
treeb88df649a12254ad46379da27d2a011364c2b7a3
parent9059912187fb5b9472a220b31e577fcdc303dd89 (diff)
downloaddevice-tree-compiler-c8afc5ecbc8d05c2c4fd0f1678d2fa0a4075174d.tar.gz
script: update git-backport-diff to latest
RH-Author: Peter Xu <peterx@redhat.com> Message-id: <1490341487-21581-1-git-send-email-peterx@redhat.com> Patchwork-id: 74520 O-Subject: [RHEV-7.4 qemu-kvm-rhev PATCH] script: update git-backport-diff to latest Bugzilla: BZ: None Brew: None Upstream: Downstream only Upstream git-backport-diff (https://github.com/codyprime/git-scripts) has several enhancements. Let's sync up with that one. This patch will upgrade the script to the following commit on Apr 22th, 2016 (which is current latest): a7ccff88e (More fixes for printing literal strings) Signed-off-by: Peter Xu <peterx@redhat.com> --- redhat/scripts/git-backport-diff | 75 ++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 25 deletions(-) Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
-rwxr-xr-xredhat/scripts/git-backport-diff75
1 files changed, 50 insertions, 25 deletions
diff --git a/redhat/scripts/git-backport-diff b/redhat/scripts/git-backport-diff
index 0e75341..a91db3d 100755
--- a/redhat/scripts/git-backport-diff
+++ b/redhat/scripts/git-backport-diff
@@ -42,6 +42,7 @@ def_range="HEAD^!"
def_color='y'
def_pause='y'
def_sensitivity=0
+def_summary='n'
upstream=`git config backport-diff.upstream || true`
diffprog=`git config backport-diff.diffprog || true`
@@ -49,6 +50,7 @@ range=`git config backport-diff.range || true`
color=`git config backport-diff.color || true`
pause=`git config backport-diff.pause || true`
sensitivity=`git config backport-diff.sensitivity || true`
+summary=`git config backport-diff.summary || true`
if [[ -z "$upstream" ]]
then
@@ -80,6 +82,11 @@ then
sensitivity=$def_sensitivity
git config backport-diff.sensitivity $sensitivity || true
fi
+if [[ -z "$summary" ]]
+then
+ summary=$def_summary
+ git config backport-diff.summary $summary || true
+fi
usage() {
@@ -106,6 +113,8 @@ usage() {
1: show (0) + contextual differences
2+: offer to compare all patches, regardless of any differences
"
+ echo " -S summary only (no diff viewing)
+ "
echo " -h help"
echo ""
echo "You can set each of the default options using git-config:"
@@ -114,9 +123,10 @@ usage() {
echo " git config backport-diff.range"
echo " git config backport-diff.color"
echo " git config backport-diff.pause"
+ echo " git config backport-diff.summary"
}
-while getopts ":r:u:nd:phs:" opt
+while getopts ":r:u:nd:phs:S" opt
do
case $opt in
r) range=$OPTARG
@@ -137,6 +147,8 @@ do
exit 1
fi
;;
+ S) summary='y'
+ ;;
h) usage
exit
;;
@@ -219,7 +231,7 @@ compare_git()
# subject lines, and using the last one. Not all backports contain
# the phrase "cherry-pick", so we can't really try and find the
# upstream hash from that...
- uphash=`git log $upstream --pretty=format:"%H" --perl-regexp --grep="^\\Q${subj}\\E$"|tail -n 1`
+ uphash=`git log $upstream --pretty=format:"%H" --fixed-strings --grep="${subj}" |tail -n 1`
if [[ -n "$uphash" ]]
then
numdiff=`diff -u <(git diff $uphash^! |egrep ^[-+])\
@@ -249,26 +261,47 @@ compare_git()
then
f=${bold}F${reset}
showdiff=1
- printf "%03d/${total}:[${bold}%04d${reset}] [${f}${c}] ${bold}${color4}'${subj}'${reset}\n" $cnt $numdiff
+ printf "%03d/${total}:[${bold}%04d${reset}] [${f}${c}] ${bold}${color4}'%s'${reset}\n" $cnt $numdiff "$subj"
else
- printf "%03d/$total:[----] [${f}${c}] '$subj'\n" $cnt
+ printf "%03d/$total:[----] [${f}${c}] '%s'\n" $cnt "$subj"
fi
if [[ $showdiff -eq 1 ]]
then
- if [[ diffprog == "meld" ]]
+ if [[ $diffprog == "meld" ]]
then
- label="--label=\"#$cnt: $subj ( <-upstream, downstream-> )\""
+ label="--label=\"Patch #$cnt: $subj\" --label=\" \""
fi
subjlist[$cnt]=$subj
exe[$cnt]="${label} <(git show $uphash^!) <(git show $downhash^!) 2>/dev/null"
shortexe[$cnt]="<(git show ${uphash:0:7}^\!) <(git show ${downhash:0:7}^\!)"
fi
else
- printf "%03d/$total:[${bold}${color1}down${reset}] ${bold}${color4}'$subj'${reset}\n" $cnt
+ printf "%03d/$total:[${bold}${color1}down${reset}] ${bold}${color4}'%s'${reset}\n" $cnt "$subj"
fi
done < <(git log --pretty=tformat:"%H%s" --reverse $range)
}
+show_diff()
+{
+ echo "Do you want to view the diffs using ${bold}${diffprog}${reset}? y/[n]: "
+ read -n 1 view
+ echo ""
+ if [[ "$view" == "y" ]]
+ then
+ for idx in ${!exe[*]}
+ do
+ if [[ $pause == 'y' ]]
+ then
+ echo "Press [Enter] to view diff(diff) of ${idx}/${total}: ${bold}${color4}${subjlist[$idx]}${reset}"
+ read
+ else
+ echo "Viewing diff(diff) of ${idx}/${total}: ${bold}${color4}${subjlist[$idx]}${reset}"
+ fi
+ eval ${diffprog} ${exe[$idx]} || true
+ done
+ fi
+}
+
if [[ $upstream_valid != 'y' ]]
then
echo "Upstream $upstream is not valid (does not exist)!"
@@ -277,26 +310,18 @@ then
fi >&2
compare_git
-echo "Do you want to view the diffs using ${bold}${diffprog}${reset}? y/[n]: "
-read -n 1 view
-echo ""
-if [[ "$view" == "y" ]]
+if [[ $summary != 'y' ]]
then
- for idx in ${!exe[*]}
+ show_diff
+fi
+
+if [[ ${!shortexe[*]} != '' ]]
+then
+ echo ""
+ echo "To view diffs later, you may run:"
+ for idx in ${!shortexe[*]}
do
- if [[ $pause == 'y' ]]
- then
- echo "Press [Enter] to view diff(diff) of ${idx}/${total}: ${bold}${color4}${subjlist[$idx]}${reset}"
- read
- else
- echo "Viewing diff(diff) of ${idx}/${total}: ${bold}${color4}${subjlist[$idx]}${reset}"
- fi
- eval ${diffprog} ${exe[$idx]} || true
+ printf "%03d/$total: '${diffprog} ${shortexe[$idx]}'\n" $idx
done
fi
-echo "To view diffs later, you may run:"
-for idx in ${!shortexe[*]}
-do
- printf "%03d/$total: '${diffprog} ${shortexe[$idx]}'\n" $idx
-done