mirror of
https://github.com/dgibson/dtc.git
synced 2025-12-09 05:05:20 -05:00
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>
This commit is contained in:
parent
9059912187
commit
c8afc5ecbc
1 changed files with 50 additions and 25 deletions
|
|
@ -42,6 +42,7 @@ def_range="HEAD^!"
|
||||||
def_color='y'
|
def_color='y'
|
||||||
def_pause='y'
|
def_pause='y'
|
||||||
def_sensitivity=0
|
def_sensitivity=0
|
||||||
|
def_summary='n'
|
||||||
|
|
||||||
upstream=`git config backport-diff.upstream || true`
|
upstream=`git config backport-diff.upstream || true`
|
||||||
diffprog=`git config backport-diff.diffprog || 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`
|
color=`git config backport-diff.color || true`
|
||||||
pause=`git config backport-diff.pause || true`
|
pause=`git config backport-diff.pause || true`
|
||||||
sensitivity=`git config backport-diff.sensitivity || true`
|
sensitivity=`git config backport-diff.sensitivity || true`
|
||||||
|
summary=`git config backport-diff.summary || true`
|
||||||
|
|
||||||
if [[ -z "$upstream" ]]
|
if [[ -z "$upstream" ]]
|
||||||
then
|
then
|
||||||
|
|
@ -80,6 +82,11 @@ then
|
||||||
sensitivity=$def_sensitivity
|
sensitivity=$def_sensitivity
|
||||||
git config backport-diff.sensitivity $sensitivity || true
|
git config backport-diff.sensitivity $sensitivity || true
|
||||||
fi
|
fi
|
||||||
|
if [[ -z "$summary" ]]
|
||||||
|
then
|
||||||
|
summary=$def_summary
|
||||||
|
git config backport-diff.summary $summary || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
|
|
@ -106,6 +113,8 @@ usage() {
|
||||||
1: show (0) + contextual differences
|
1: show (0) + contextual differences
|
||||||
2+: offer to compare all patches, regardless of any differences
|
2+: offer to compare all patches, regardless of any differences
|
||||||
"
|
"
|
||||||
|
echo " -S summary only (no diff viewing)
|
||||||
|
"
|
||||||
echo " -h help"
|
echo " -h help"
|
||||||
echo ""
|
echo ""
|
||||||
echo "You can set each of the default options using git-config:"
|
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.range"
|
||||||
echo " git config backport-diff.color"
|
echo " git config backport-diff.color"
|
||||||
echo " git config backport-diff.pause"
|
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
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
r) range=$OPTARG
|
r) range=$OPTARG
|
||||||
|
|
@ -137,6 +147,8 @@ do
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
S) summary='y'
|
||||||
|
;;
|
||||||
h) usage
|
h) usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
@ -219,7 +231,7 @@ compare_git()
|
||||||
# subject lines, and using the last one. Not all backports contain
|
# subject lines, and using the last one. Not all backports contain
|
||||||
# the phrase "cherry-pick", so we can't really try and find the
|
# the phrase "cherry-pick", so we can't really try and find the
|
||||||
# upstream hash from that...
|
# 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" ]]
|
if [[ -n "$uphash" ]]
|
||||||
then
|
then
|
||||||
numdiff=`diff -u <(git diff $uphash^! |egrep ^[-+])\
|
numdiff=`diff -u <(git diff $uphash^! |egrep ^[-+])\
|
||||||
|
|
@ -249,26 +261,47 @@ compare_git()
|
||||||
then
|
then
|
||||||
f=${bold}F${reset}
|
f=${bold}F${reset}
|
||||||
showdiff=1
|
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
|
else
|
||||||
printf "%03d/$total:[----] [${f}${c}] '$subj'\n" $cnt
|
printf "%03d/$total:[----] [${f}${c}] '%s'\n" $cnt "$subj"
|
||||||
fi
|
fi
|
||||||
if [[ $showdiff -eq 1 ]]
|
if [[ $showdiff -eq 1 ]]
|
||||||
then
|
then
|
||||||
if [[ diffprog == "meld" ]]
|
if [[ $diffprog == "meld" ]]
|
||||||
then
|
then
|
||||||
label="--label=\"#$cnt: $subj ( <-upstream, downstream-> )\""
|
label="--label=\"Patch #$cnt: $subj\" --label=\" \""
|
||||||
fi
|
fi
|
||||||
subjlist[$cnt]=$subj
|
subjlist[$cnt]=$subj
|
||||||
exe[$cnt]="${label} <(git show $uphash^!) <(git show $downhash^!) 2>/dev/null"
|
exe[$cnt]="${label} <(git show $uphash^!) <(git show $downhash^!) 2>/dev/null"
|
||||||
shortexe[$cnt]="<(git show ${uphash:0:7}^\!) <(git show ${downhash:0:7}^\!)"
|
shortexe[$cnt]="<(git show ${uphash:0:7}^\!) <(git show ${downhash:0:7}^\!)"
|
||||||
fi
|
fi
|
||||||
else
|
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
|
fi
|
||||||
done < <(git log --pretty=tformat:"%H%s" --reverse $range)
|
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' ]]
|
if [[ $upstream_valid != 'y' ]]
|
||||||
then
|
then
|
||||||
echo "Upstream $upstream is not valid (does not exist)!"
|
echo "Upstream $upstream is not valid (does not exist)!"
|
||||||
|
|
@ -277,26 +310,18 @@ then
|
||||||
fi >&2
|
fi >&2
|
||||||
|
|
||||||
compare_git
|
compare_git
|
||||||
echo "Do you want to view the diffs using ${bold}${diffprog}${reset}? y/[n]: "
|
|
||||||
read -n 1 view
|
|
||||||
|
|
||||||
echo ""
|
if [[ $summary != 'y' ]]
|
||||||
if [[ "$view" == "y" ]]
|
|
||||||
then
|
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
|
do
|
||||||
if [[ $pause == 'y' ]]
|
printf "%03d/$total: '${diffprog} ${shortexe[$idx]}'\n" $idx
|
||||||
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
|
done
|
||||||
fi
|
fi
|
||||||
echo "To view diffs later, you may run:"
|
|
||||||
for idx in ${!shortexe[*]}
|
|
||||||
do
|
|
||||||
printf "%03d/$total: '${diffprog} ${shortexe[$idx]}'\n" $idx
|
|
||||||
done
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue