On Tue, 29 Sep 2020, Rodrigo Vivi <[email protected]> wrote: > This is the minimal and more straight forward way to do it, > although I'm sure there are better ways.
Hardly minimal? I think there's probably a magic git spell to list multiple branches to look for when passing the parameters to git_list_fixes. Failing at that, at least the refactoring and adding branches should be separate steps. BR, Jani. > > Since I'm not confident yet with the overall approach, let's > at least use this for a proposal. > > Signed-off-by: Rodrigo Vivi <[email protected]> > --- > dim | 105 ++++++++++++++++++++++++++++++++++-------------------------- > 1 file changed, 59 insertions(+), 46 deletions(-) > > diff --git a/dim b/dim > index c3a048db8956..9c1891e79a81 100755 > --- a/dim > +++ b/dim > @@ -1373,64 +1373,77 @@ function git_list_fixes > "$@" > } > > -function cherry_pick_branch > +function cherry_pick_commit > { > - local branch log fail_log intel_remote needed have_fixes > + local commit have_fixes needed > + commit=${1:?$usage} > > - branch=${1:?$usage} > - log=$(mktemp) > - fail_log=$(mktemp) > + echo -n "Considering $(dim_cite $commit)... " > > - intel_remote=$(repo_to_remote drm-intel) > + # Look at history for already cherry-picked fixes. > + # Note: use *local* branches to account for unpushed commits. > + git log drm-intel-fixes --format=format:%h --after=6months \ > + --grep="cherry picked .* $commit" > $log > + if [ "$(cat $log)" = "" ]; then > + git log drm-intel-next-fixes --format=format:%h --after=6months > \ > + --grep="cherry picked .* $commit" > $log > + fi > > - # Look for commits in dinq tagged as fixes. > - for commit in $(git_list_fixes > $intel_remote/$branch..$intel_remote/drm-intel-next-queued -- > drivers/gpu/drm/i915); do > - echo -n "Considering $(dim_cite $commit)... " > + if [ "$(cat $log)" != "" ]; then > + echo "Already backported as $(tr "\n" " " < $log). OK." > + continue > + fi > > - # Look at history for already cherry-picked fixes. > - # Note: use *local* branches to account for unpushed commits. > - git log drm-intel-fixes --format=format:%h --after=6months \ > - --grep="cherry picked .* $commit" > $log > - if [ "$(cat $log)" = "" ]; then > - git log drm-intel-next-fixes --format=format:%h > --after=6months \ > - --grep="cherry picked .* $commit" > $log > + have_fixes= > + needed= > + for fixes in $(git show -s $commit | grep -i "^ Fixes: *[0-9a-fA-F]" > | sed 's/^ *[Ff]ixes: *\([0-9a-fA-F]\+\).*/\1/'); do > + have_fixes=1 > + fixes=$(git log -1 --format=format:%H $fixes 2>/dev/null || > true) > + if [[ -z "$fixes" ]]; then > + continue > fi > > - if [ "$(cat $log)" != "" ]; then > - echo "Already backported as $(tr "\n" " " < $log). OK." > - continue > + # FIXME: see if the commit to be fixed has been > + # backported! > + echo -n "Fixes: $(dim_cite $fixes). " > + if [[ "$(git merge-base $branch $fixes)" = "$fixes" ]]; then > + needed=1 > fi > + done > > - have_fixes= > - needed= > - for fixes in $(git show -s $commit | grep -i "^ Fixes: > *[0-9a-fA-F]" | sed 's/^ *[Ff]ixes: *\([0-9a-fA-F]\+\).*/\1/'); do > - have_fixes=1 > - fixes=$(git log -1 --format=format:%H $fixes > 2>/dev/null || true) > - if [[ -z "$fixes" ]]; then > - continue > - fi > + # Note: Cc: stable will overrule Fixes: > + if [[ -n "$have_fixes" && -z "$needed" ]]; then > + echo "Fixes a commit not in $branch. OK." > + continue > + fi > > - # FIXME: see if the commit to be fixed has been > - # backported! > - echo -n "Fixes: $(dim_cite $fixes). " > - if [[ "$(git merge-base $branch $fixes)" = "$fixes" ]]; > then > - needed=1 > - fi > - done > + echo "Try to cherry-pick." > + commit_list_references $commit > + if ! git cherry-pick -x -s $commit; then > + echo "FAILED: $(dim_cite $commit)" > + (dim_cite $commit) >> $fail_log > + git cherry-pick --abort > + fi > +} > > - # Note: Cc: stable will overrule Fixes: > - if [[ -n "$have_fixes" && -z "$needed" ]]; then > - echo "Fixes a commit not in $branch. OK." > - continue > - fi > +function cherry_pick_branch > +{ > + local branch log fail_log intel_remote > > - echo "Try to cherry-pick." > - commit_list_references $commit > - if ! git cherry-pick -x -s $commit; then > - echo "FAILED: $(dim_cite $commit)" > - (dim_cite $commit) >> $fail_log > - git cherry-pick --abort > - fi > + branch=${1:?$usage} > + log=$(mktemp) > + fail_log=$(mktemp) > + > + intel_remote=$(repo_to_remote drm-intel) > + > + # Look for commits in dinq tagged as fixes. > + for commit in $(git_list_fixes > $intel_remote/$branch..$intel_remote/drm-intel-next-queued -- > drivers/gpu/drm/i915); do > + cherry_pick_commit $commit > + done > + > + # Look for commits in dinq tagged as fixes. > + for commit in $(git_list_fixes > $intel_remote/$branch..$intel_remote/drm-intel-gt-next -- > drivers/gpu/drm/i915); do > + cherry_pick_commit $commit > done > > # FIXME: evolve this into an email report to commit authors etc. -- Jani Nikula, Intel Open Source Graphics Center _______________________________________________ dim-tools mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dim-tools
