forked from zhenyw/gvt-maintainer-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dim
executable file
·1557 lines (1313 loc) · 38.9 KB
/
dim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Copyright © 2012-2016 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
# Authors:
# Daniel Vetter <daniel.vetter@ffwll.ch>
# Jani Nikula <jani.nikula@intel.com>
# drm-intel-next maintainer script
# gvt maintainer script based on 'dim' tool
#
# Zhenyu Wang <zhenyuw@linux.intel.com>
# TODO
# - extract the integration tree logic and make it generally useful, maybe for a
# drm-integration tree ...
# - Improve staging-forget to forget a specific merge instead of just the first
# dinq/dif merge.
# - add option to check-patch to check stdin
# - integrate ninja-check? Or too much checkers considered harmful?
# https://lists.linuxfoundation.org/pipermail/ksummit-discuss/2014-May/000554.html
# - add patchwork Link: also after manually resolving conflicts in drm
# apply-resolved
# - pull in dim extract-tags tool from Ville
# - allow dim rebuild-staging to pull branches from local trees in dry-run mode.
# This is useful to confirm a backmerge is indeed correct, by comparing the
# resulting -staging with the old one. Current the branch must be pushed out
# first for rebuild-staging to pick it up, which means the merge can't be
# fixed any more.
# fail on any goof-up
set -e
#
# User configuration. Set in environment or configuration file. See
# dimrc.sample for an example.
#
# dim configuration file
DIM_CONFIG=${DIM_CONFIG:-$HOME/.dimrc}
if [ -r $DIM_CONFIG ]; then
. $DIM_CONFIG
fi
# warning if no config found?
# prefix for repo directories
DIM_PREFIX=${DIM_PREFIX:-$HOME/linux}
# main maintainer repo under $DIM_PREFIX
DIM_GVT_LINUX=${DIM_GVT_LINUX:-src}
# name of the $drm_intel_ssh remote within $DIM_GVT_LINUX
DIM_GVT_LINUX_REMOTE=${DIM_GVT_LINUX_REMOTE:-origin}
# name of the $drm_upstream_git remote within $DIM_GVT_LINUX
# match rerere/staging.conf
DIM_DRM_INTEL_UPSTREAM_REMOTE="drm-intel"
# name of $drm_tip_upstream_git remote
DIM_DRM_TIP_UPSTREAM_REMOTE="drm-tip"
# mail user agent. must support a subset of mutt(1) command line options:
# usage: $DIM_MUA [-s subject] [-i file] [-c cc-addr] to-addr [...]
DIM_MUA=${DIM_MUA:-mutt}
# command to run after dim apply
DIM_POST_APPLY_ACTION=${DIM_POST_APPLY_ACTION:-}
# greetings pull request template
DIM_TEMPLATE_HELLO=${DIM_TEMPLATE_HELLO:-$HOME/.dim.template.hello}
# signature pull request template
DIM_TEMPLATE_SIGNATURE=${DIM_TEMPLATE_SIGNATURE:-$HOME/.dim.template.signature}
#
# Internal configuration.
#
today=`date +%Y-%m-%d`
#drm_upstream_git=git://people.freedesktop.org/~airlied/linux
#sound_upstream_git=git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
#driver_core_upstream_git=git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
linux_upstream_git=git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
gvt_linux_git=https://github.com/intel/gvt-linux
drm_intel_upstream_git=git://anongit.freedesktop.org/drm-intel
drm_tip_upstream_git=git://anongit.freedesktop.org/drm/drm-tip
vfio_upstream_git=https://github.com/awilliam/linux-vfio.git
kvm_upstream_git=git://git.kernel.org/pub/scm/virt/kvm/kvm.git
intel_iommu_git=https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git
# email aliases
addr_drm_maintainer="Dave Airlie <airlied@gmail.com>"
addr_drm_intel_maintainer="Daniel Vetter <daniel.vetter@ffwll.ch>"
addr_intel_gfx_maintainer1="Daniel Vetter <daniel.vetter@ffwll.ch>"
addr_intel_gfx_maintainer2="Jani Nikula <jani.nikula@linux.intel.com>"
addr_intel_gfx="intel-gfx@lists.freedesktop.org"
addr_dri_devel="dri-devel@lists.freedesktop.org"
addr_intel_qa="\"Christophe Prigent\" <christophe.prigent@intel.com>"
# FIXME
addr_gvt_maintainer1="\"Zhenyu Wang\" <zhenyuw@linux.intel.com>"
addr_gvt_maintainer2="zhi.a.wang@intel.com"
addr_gvt_internal="intel-gvt@eclists.intel.com"
addr_gvt_intel="sse.gvt@intel.com"
addr_gvt_qa="sse.gvt.qa@intel.com"
#
# Command line options.
#
DRY_RUN=
INTERACTIVE=
DRY=
FORCE=
HELP=
function warn_or_fail
{
if [[ $FORCE ]] ; then
echo WARNING: $1, but continuing
else
echo ERROR: $1, aborting
exit 1
fi
}
while getopts hdfi opt; do
case "$opt" in
d)
DRY_RUN=--dry-run
DRY=echo
;;
f)
FORCE=1
;;
i)
INTERACTIVE='eval read -rsp "Press any key to continue..." -n1 key2; echo'
;;
h)
HELP=1
;;
*)
echo "See '$0 help' for more information." >&2
exit
esac
done
shift `expr $OPTIND - 1`
# first positional argument is the subcommand
if [ -n "$HELP" -o "$#" = "0" ]; then
subcommand="usage"
else
subcommand="$1"
shift
fi
#
# Sanity checks.
#
if [ "$subcommand" != "setup" -a "$subcommand" != "help" -a "$subcommand" != "usage" ]; then
#for d in $DIM_PREFIX $DIM_PREFIX/$DIM_GVT_LINUX $DIM_PREFIX/gvt-rerere $DIM_PREFIX/gvt-staging; do
for d in $DIM_PREFIX $DIM_PREFIX/$DIM_GVT_LINUX $DIM_PREFIX/gvt-staging; do
if [ ! -d $d ]; then
echo "$d is missing, please check your configuration and/or run dim setup"
exit 1
fi
done
#
# Internal configuration that depends on a sane setup.
#
dim_branches=`(source $DIM_PREFIX/staging.conf ; echo $staging_branches) | \
xargs -n 1 echo | grep '^origin' | sed -e 's/^origin\///'`
fi
# get message id from file
# $1 = file
message_get_id ()
{
python <<EOF
from email.parser import Parser
headers = Parser().parse(open('$1', 'r'))
message_id = headers['message-id']
if message_id is not None:
print(message_id.strip('<>'))
EOF
}
# append all arguments as tags at the end of the commit message of HEAD
function dim_commit_add_tag
{
for arg; do
# the first sed deletes all trailing blank lines at the end
git log -1 --pretty=%B | \
sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' | \
sed "\$a${arg}" | \
git commit --amend -F-
done
}
# XXX double check with process
# So we will have branches as below:
# 'gvt-next' : normal next target for dinq
# 'gvt-fixes' : normal fixes target for drm-intel-fixes
# 'gvt-next-fixes' : 'gvt-next' fixes
function update_linux_next
{
cd $DIM_PREFIX/gvt-staging
# XXX check, just push the specific branch?
# always update gvt-fixes
echo -n "Pushing gvt-fixes to for-drm-intel-fixes... "
git push $DRY_RUN origin +origin/gvt-fixes:for-drm-intel-fixes >& /dev/null && echo "Done." || echo "Fail"
if git merge-base --is-ancestor origin/gvt-next-fixes origin/gvt-fixes ; then
# -fixes has caught up to dinf, i.e. we're out of the merge
# window. Push the next queue.
echo -n "Out of merge window. Pushing gvt-next to for-drm-intel-next-queued... "
git push $DRY_RUN origin +origin/gvt-next:for-drm-intel-next-queued >& /dev/null && echo "Done." || echo "Fail"
else
# dinf is ahead of -fixes, i.e. drm-next has already closed for
# the next merge window and we've started to gather new fixes
# for the current -next cycle. Push dinf
echo -n "Pushing gvt-next-fixes to for-drm-intel-next-fixes... "
git push $DRY_RUN origin +origin/gvt-next-fixes:for-drm-intel-next-fixes >& /dev/null && echo "Done." || echo "Fail"
fi
}
function check_conflicts
{
if git diff | grep '\(<<<<<<<\|=======\|>>>>>>>\||||||||\)' ; then
if [ -n "$1" ]; then
echo $*
fi
exit 1
fi
true
}
function update_rerere_cache
{
cd $DIM_PREFIX/gvt-rerere/
git pull
cp rr-cache/* $DIM_PREFIX/gvt-staging/.git/rr-cache/ -r
cd -
}
function dim_rebase_xengt
{
local integration_branch=gvt-staging
local xengt_branch=topic/gvt-xengt
local time="`date +%Yy-%mm-%dd-%Hh-%Mm-%Ss`"
local force_local=$1
echo "./dim rebase-xengt <y> : <y> to force local branch usually after resolving conflict."
cd $DIM_PREFIX/$integration_branch
git fetch origin
if git branch | grep $xengt_branch >& /dev/null; then
if [[ "x$force_local" = "x" ]]; then
echo "Force to refresh current $xengt_branch from remote"
git branch -D $xengt_branch
git fetch origin +$xengt_branch:$xengt_branch
else
echo "Force to use local $xengt_branch"
fi
else
echo "Create new $xengt_branch"
git branch $xengt_branch origin/$xengt_branch
fi
git checkout $xengt_branch
if ! git rebase -i origin/$integration_branch ; then
echo "topic/gvt-xengt failed to rebase onto gvt-staging"
#ignore error now
cat >> /tmp/xengt-error <<-HERE
topic/gvt-xengt failed to rebase to latest gvt-staging branch.
conflicts:
HERE
git diff >> /tmp/xengt-error
echo "" | $DRY $DIM_MUA -s "[INFO] topic/gvt-xengt fail to rebase on gvt-staging" \
-i /tmp/xengt-error \
-c "$addr_gvt_maintainer1" \
-c "$addr_gvt_maintainer2" \
-c "xiong.y.zhang@intel.com" \
-c "$addr_gvt_qa" \
-c "$addr_gvt_intel" \
"$addr_gvt_internal"
git rebase --abort
git reset --hard
rm -f /tmp/xengt-error
else
echo "Tagging gvt-xengt-$time"
git tag gvt-xengt-$time
git push $DRY_RUN origin +HEAD >& /dev/null && echo "Done." || echo "Fail"
git push $DRY_RUN origin gvt-xengt-$time >& /dev/null && echo "Done." || echo "Fail"
$DRY $DIM_MUA -s "[INFO] New gvt-xengt-$time available" \
-c "$addr_gvt_maintainer1" \
-c "$addr_gvt_maintainer2" \
-c "xiong.y.zhang@intel.com" \
-c "$addr_gvt_qa" \
-c "$addr_gvt_intel" \
"$addr_gvt_internal"
fi
git checkout $integration_branch
echo "done"
}
function dim_rebuild_staging
{
local integration_branch=gvt-staging
local specfile=`mktemp`
local time="`date +%Yy-%mm-%dd-%Hh-%Mm-%Ss`"
local commit_time="$time CST"
local first=1
local force_push_and_tag=$1
#local rerere=$DIM_PREFIX/gvt-rerere
#cd $rerere
#if [[ `git status --porcelain | grep -v "^[ ?][ ?]" | wc -l` -gt 0 ]]; then
# warn_or_fail "-staging configuration file not commited"
#fi
#echo -n "Updating rerere cache and staging.conf... "
#update_rerere_cache >& /dev/null
#echo "Done."
# pull $staging_branches
#source $rerere/staging.conf
source $DIM_PREFIX/staging.conf
cd $DIM_PREFIX/$integration_branch
if ! git branch | grep $integration_branch | grep '\*' >& /dev/null ; then
echo "Branch setup for the integration repo is borked(not on $integration_branch?)"
exit 1
fi
if [ x"$force_push_and_tag" != x ]; then
echo "Warn: just tag and push for local change..."
echo -n "Adding integration manifest $integration_branch: $commit_time... "
mv $specfile integration-manifest
git add integration-manifest
git commit --quiet -m "$integration_branch: $commit_time integration manifest"
echo "Done."
echo "Pushing $integration_branch... "
$INTERACTIVE
git push origin +HEAD >& /dev/null && echo "Done." || echo "Fail"
echo "Tagging: $time... "
$INTERACTIVE
git tag gvt-staging-$time
git push origin gvt-staging-$time >& /dev/null && echo "Done." || echo "Fail"
$DIM_MUA -s "[INFO] New gvt-staging-$time available" \
-c "$addr_gvt_maintainer1" \
-c "$addr_gvt_maintainer2" \
-c "$addr_gvt_qa" \
-c "$addr_gvt_intel" \
"$addr_gvt_internal"
exit 0
fi
for remote in $(echo $staging_branches | tr " " "\n" | sed 's|/.*$||g' | sort -u); do
echo "Fetching $remote... "
# git fetch returns 128 if there's nothing to be fetched
#git fetch $remote >& /dev/null || true
git fetch $remote || true
echo "Done."
done
# merge -fixes
for tree in $staging_branches; do
local branch=${tree%:*}
local sha1=${tree#*:}
local name=${branch##*/}
# the : separator is optional
if [[ $sha1 == $tree ]] ; then
sha1=
fi
echo -n "Merging $branch... "
if [[ -n $sha1 ]] ; then
echo -n "Using override sha1: $sha1... "
else
sha1=$branch
fi
if [ $first == 1 ] ; then
echo "Reset $sha1. Done."
git reset --hard $sha1 >& /dev/null
first=0
elif git merge --rerere-autoupdate --ff-only $sha1 >& /dev/null ; then
# nothing to do if just fast-forward
echo "Fast-forward. Done."
true
else
local fixup_file=$integration_branch-$name-fixup.patch
echo "checking..$fixup_file"
echo $fixup_file > .fixup_file_path
git merge --rerere-autoupdate --no-commit $sha1 >& /dev/null || true
if [ -f $fixup_file ] ; then
echo -n "Applying manual fixup patch for $integration_branch merge... "
patch -p1 -i $fixup_file
fi
check_conflicts "Fail: conflict merging $tree"
git add -u
# because we filter out fast-forward merges there will
# always be something to commit
git commit --no-edit --quiet
echo "Done."
fi
echo -e "$branch `git rev-parse $sha1`\n\t`git log -1 $sha1 --pretty=format:%s`" >> $specfile
$INTERACTIVE
done
echo -n "Adding integration manifest $integration_branch: $commit_time... "
mv $specfile integration-manifest
git add integration-manifest
git commit --quiet -m "$integration_branch: $commit_time integration manifest"
echo "Done."
echo "Pushing $integration_branch... "
$INTERACTIVE
git push $DRY_RUN origin +HEAD >& /dev/null && echo "Done." || echo "Fail"
echo "Tagging: $time... "
git tag gvt-staging-$time
git push $DRY_RUN origin gvt-staging-$time >& /dev/null && echo "Done." || echo "Fail"
#echo -n "Updating rerere cache... "
#cd $rerere
#if git branch | grep gvt-rerere-cache | grep '\*' >& /dev/null ; then
# git pull >& /dev/null
# cp $DIM_PREFIX/$integration_branch/.git/rr-cache/* rr-cache -r
# git add *.patch >& /dev/null || true
# git add rr-cache/* > /dev/null
# if git commit -m "$time: $integration_branch rerere cache update" >& /dev/null; then
# echo -n "New commit. "
# else
# echo -n "Nothing changed. "
# fi
# echo -n "Pushing rerere cache... "
# git push $DRY_RUN origin HEAD >& /dev/null && echo "Done." || echo "Fail"
#else
# echo "Fail: Branch setup for the gvt-rerere-cache is borked."
# exit 1
#fi
#update_linux_next
$DRY $DIM_MUA -s "[INFO] New gvt-staging-$time available" \
-c "$addr_gvt_maintainer1" \
-c "$addr_gvt_maintainer2" \
-c "$addr_gvt_qa" \
-c "$addr_gvt_intel" \
"$addr_gvt_internal"
}
function dim_staging_forget
{
cd $DIM_PREFIX/gvt-staging
git fetch origin >& /dev/null
git reset --hard origin/gvt-next >& /dev/null
git merge origin/gvt-fixes
git rerere forget
}
# push branch $1, rebuild staging. the rest of the arguments are passed to git
# push.
function dim_push_branch
{
if [[ "x$1" = "x" ]]; then
echo "usage: $0 $subcommand branch"
exit 1
fi
branch=$1
shift
assert_branch $branch
git push $DRY_RUN $DIM_GVT_LINUX_REMOTE $branch "$@"
#dim_rebuild_staging
}
function dim_push_gvt_next
{
dim_push_branch gvt-next "$@"
}
function dim_push_gvt_gt_next
{
dim_push_branch gvt-gt-next "$@"
}
function dim_push_gvt_fixes
{
dim_push_branch gvt-fixes "$@"
}
function dim_push_gvt_next_fixes
{
dim_push_branch gvt-next-fixes "$@"
}
function apply_patch
{
patch="$1"
shift
local message_id=$(message_get_id $patch)
local commiter_email=$(git config --get user.email)
local patch_from=$(grep "From:" "$patch" | head -1)
local sob
if [[ "$patch_from" != *"$commiter_email"* ]] ; then
sob=-s
fi
if ! git am --scissors -3 $sob "$@" $patch ; then
echo "ERROR: git apply-mbox failed"
return 1
fi
if [ -n "$message_id" ]; then
dim_commit_add_tag "Link: http://patchwork.freedesktop.org/patch/msgid/$message_id"
else
echo "No message-id found in the patch file."
fi
#assume: git config alias.rb "interpret-trailers --trailer \
# \"Reviewed-by: $(git config user.name) <$(git config user.email)>\" --in-place"
GIT_EDITOR="git rb" git commit --amend
checkpatch_commit HEAD
eval $DRY $DIM_POST_APPLY_ACTION
return 0
}
# ensure we're on branch $1, and apply patches. the rest of the arguments are
# passed to git am.
dim_alias_ab=apply-branch
dim_alias_sob=apply-branch
function dim_apply_branch
{
local branch=$1
shift
local file=`mktemp`
local dir=`mktemp -d`
local rv
assert_branch $branch
assert_repo_clean
cat > $file
git mailsplit -b -o$dir $file > /dev/null
for patch in "$dir"/*; do
if ! apply_patch $patch "$@"; then
rv=1
fi
done
rm -rf $file $dir
return $rv
}
dim_alias_aq=apply-gvt-next
function dim_apply_gvt_next
{
dim_apply_branch gvt-next "$@"
}
dim_alias_aq=apply-gvt-gt-next
function dim_apply_gvt_gt_next
{
dim_apply_branch gvt-gt-next "$@"
}
dim_alias_af=apply-gvt-fixes
function dim_apply_gvt_fixes
{
dim_apply_branch gvt-fixes "$@"
}
# have this?
dim_alias_anf=apply-gvt-next-fixes
function dim_apply_gvt_next_fixes
{
dim_apply_branch gvt-next-fixes "$@"
}
function dim_cherry_pick
{
warn_or_fail "FIXME"
if [[ "x$1" = "x" ]]; then
echo "usage: $0 $subcommand commit-ish"
exit 1
fi
sha=`git rev-parse $1`
sha_short=${sha:0:8}
# need latest -staging
git fetch $DIM_GVT_LINUX_REMOTE
echo Possible fixup patches for your cherry-pick:
git log --grep=$sha_short --pretty=oneline $sha..$DIM_GVT_LINUX_REMOTE/gvt-staging
$DRY git cherry-pick -s -x -e $1
}
function dim_cherry_pick_branch
{
warn_or_fail "FIXME"
# Look for commits in dinq tagged as fixes.
for commit in $(git log --reverse --format=format:%h --grep="drm-intel-fixes@lists.freedesktop.org" --grep="stable@vger.kernel.org" origin/master..$DIM_GVT_LINUX_REMOTE/gvt-next -- drivers/gpu/drm/i915); do
echo "Considering $(git --no-pager log --oneline -1 $commit)"
log=$(mktemp)
# Look at history for already cherry-picked fixes.
# Note: use *local* branches to account for unpushed commits.
git log gvt-fixes --after=12months --oneline \
--grep="cherry picked .* $commit" > $log
if [ "$(cat $log)" = "" ]; then
git log gvt-next-fixes --after=12months --oneline \
--grep="cherry picked .* $commit" > $log
fi
if [ "$(cat $log)" = "" ]; then
# Try cherry-pick, offer options on fail.
if ! git cherry-pick -e -x -s $commit; then
select choice in "Diff" "Resolve" "Skip" "Abort"; do
case $choice in
Diff)
git diff
;;
Resolve)
exit
;;
Skip)
git cherry-pick --abort
break
;;
Abort)
git cherry-pick --abort
exit
;;
esac
done
fi
else
echo "Already backported as:"
sed 's/^/\t/' < $log
fi
rm -f $log
done
}
function dim_cherry_pick_fixes
{
assert_branch gvt-fixes
dim_cherry_pick_branch "$@"
}
function dim_cherry_pick_next_fixes
{
assert_branch gvt-next-fixes
dim_cherry_pick_branch "$@"
}
dim_alias_ar=apply-resolved
function dim_apply_resolved
{
make -j 20 && git add -u && git am --resolved
checkpatch_commit HEAD
git commit --amend &
}
dim_alias_mrr=magic-rebase-resolve
function dim_magic_rebase_resolve
{
git diff HEAD | patch -p1 -R
cat .git/rebase-merge/patch | dim mp
make -j 20
git add -u
git rebase --continue
}
#dim_alias_ai=apply-igt
#function dim_apply_igt
#{
# cd ~/xorg/intel-gpu-tools/
# git am --whitespace=fix -3 -s
#}
dim_alias_mp=magic-patch
function dim_magic_patch
{
warn_or_fail "FIXME"
if [[ "$1" = "-a" ]]; then
cd `cat ~/.dim-last-path`
fi
local conflict_files=`patch -p1 | grep "saving rejects" | sed -e "s/.*saving rejects to file \(.*\)/\1/"`
if [[ $conflict_files != "" ]] ; then
echo conflicts found!
fi
for file in $conflict_files ; do
echo wiggling in ${file%.rej}:
#cat $file
rm -f ${file%.rej}.porig
wiggle -r ${file%.rej} $file || true
done
}
function dim_create_branch
{
if [[ "x$1" = "x" ]]; then
echo "usage: $0 $subcommand branch [commit-ish]"
exit 1
fi
branch=$1
if [[ "x$2" = "x" ]]; then
start=HEAD
else
start=$2
fi
cd $DIM_PREFIX/$DIM_GVT_LINUX
$DRY git branch $branch $start
git push $DRY_RUN $DIM_GVT_LINUX_REMOTE +$branch --set-upstream
#cd $DIM_PREFIX/gvt-rerere
cd $DIM_PREFIX
$DRY echo "staging_branches=\"\$staging_branches origin/$branch\"" \
>> staging.conf
#$DRY git add staging.conf
#$DRY git commit --quiet -m "Adding $branch to -staging"
}
function dim_remove_branch
{
if [[ "x$1" = "x" ]]; then
echo "usage: $0 $subcommand branch"
exit 1
fi
branch=$1
cd $DIM_PREFIX/$DIM_GVT_LINUX
if ! $DRY git branch -d $branch ; then
warn_or_fail "Can't remove $branch in working repo"
fi
if [[ -d $DIM_PREFIX/$branch ]] ; then
rm -R $DIM_PREFIX/$branch
fi
cd $DIM_PREFIX/gvt-staging
git push $DRY_RUN origin --delete $branch
$DRY git fetch origin --prune
#cd $DIM_PREFIX/gvt-rerere
cd $DIM_PREFIX
full_branch="origin/$branch"
$DRY sed -e "/${full_branch//\//\\\/}/d" -i staging.conf
#$DRY git add staging.conf
#$DRY git commit --quiet -m "Deleted $branch and removed from -staging"
}
function dim_cd
{
local path
if [[ -d $DIM_PREFIX/$1 ]] ; then
path=$DIM_PREFIX/$1
else
path=$DIM_PREFIX/$DIM_GVT_LINUX
fi
echo $path > ~/.dim-last-path
cd $path
}
dim_alias_co=checkout
function dim_checkout
{
if [[ "x$1" = "x" ]]; then
echo "usage: $0 $subcommand branch"
exit 1
fi
dim_cd $1
if ! git branch | grep $1 > /dev/null ; then
git checkout -t $DIM_GVT_LINUX_REMOTE/$1
else
git checkout $1
fi
}
function dim_con
{
dim_checkout gvt-next "$@"
}
function dim_cogn
{
dim_checkout gvt-gt-next "$@"
}
function dim_cof
{
dim_checkout gvt-fixes "$@"
}
function dim_conf
{
dim_checkout gvt-next-fixes "$@"
}
# check sob for one commit id
function commit_check_sob
{
local ret=0
git show $1 --pretty=full > /tmp/$1.tmp
local target=/tmp/$1.tmp
local author=`grep -m 1 Author $target`
author=`echo $author | sed s/Author:// | xargs`
local committer=`grep -m 1 Commit $target`
committer=`echo $committer | sed s/Commit:// | xargs`
local author_sob="Signed-off-by: $author"
local committer_sob="Signed-off-by: $committer"
if ! grep "$author_sob" $target > /dev/null; then
#echo "sob missing for author $author, require $author_sob"
rm -f $target
return 1
fi
if ! grep -q "$committer_sob" $target > /dev/null ; then
#echo "sob missing for committer $committer, require $committer_sob"
rm -f $target
return 1
fi
return 0
}
function dim_check_next_sob
{
assert_branch gvt-next
local commits=`git log --format=%h "$@"`
for commit in $commits;
do
if ! commit_check_sob $commit; then
echo -n "Bad: "
else
echo -n "Good: "
fi
echo `git log -1 --oneline $commit`
done
}
function dim_check_fixes_sob
{
assert_branch gvt-fixes
local commits=`git log --format=%h "$@"`
for commit in $commits;
do
if ! commit_check_sob $commit; then
echo -n "Bad: "
else
echo -n "Good: "
fi
echo `git log -1 --oneline $commit`
done
}
function dim_check_next_fixes_sob
{
assert_branch gvt-next-fixes
local commits=`git log --format=%h "$@"`
for commit in $commits;
do
if ! commit_check_sob $commit; then
echo -n "Bad: "
else
echo -n "Good: "
fi
echo `git log -1 --oneline $commit`
done
}
# $1 is the git sha1 to check
function checkpatch_commit
{
local commit=$1
local cmd="git show --pretty=email $commit"
git --no-pager log --oneline -1 $commit
$cmd | scripts/checkpatch.pl -q --emacs --strict - || true
local bug_lines=$($cmd | grep -m 1 -B 1 '^\+.*\WBUG' | grep -c '^[+-].*\WBUG')
if test "$bug_lines" -eq 1; then
warn_or_fail "New BUG macro added"
fi
# change for gvt-next
if [ "$branch" = "gvt-next" ]; then
local non_i915_files=$(git diff-tree --no-commit-id --name-only -r $commit | \
grep -v "^\(drivers/gpu/drm/i915/\|include/drm/i915\|include/uapi/drm/i915\)")
if [ -n "$non_i915_files" ]; then
echo -e "The following files are outside of i915 maintenance scope:\n"
echo "$non_i915_files"
echo -e "\nConfirm you have appropriate Acked-by and Reviewed-by for above files."
fi
fi
}
# turn $1 in to a git commit range
function rangeish()
{
if [ -z "$1" ]; then
echo "HEAD^..HEAD"
elif [ -n "`echo $1 | grep '\.\.'`" ]; then
echo "$1"
else
echo "$1..HEAD"
fi
}
dim_alias_check_patch=checkpatch
dim_alias_cp=checkpatch
function dim_checkpatch
{
local range=$(rangeish "$1")
for commit in $(git rev-list --reverse $range); do
checkpatch_commit $commit || true
done
}
function dim_checker
{
rm drivers/gpu/drm/i915/*.o &> /dev/null || true
rm drivers/gpu/drm/i915/*.ko &> /dev/null || true