Karl Rupp <[email protected]> writes:

> Hi Satish,
>
>  > In git - how do I list branches that started off maint - but are not
>> yet merged back?
>
> Hmm, I don't have a one-liner for this, but you'll get some idea of the 
> relevant branches using
>   git branch --contains maint
> as well as
>   git branch --no-merge maint

Note that 'maint' is usually part of 'master', so any branch started
From 'master' after 'maint' has been merged will also contain 'maint'.

My ad-hoc method has just been to check whether 'git log
maint..my/branch' contains patches that don't belong in the branch.  But
that's not robust or automatable.  Here's a script that I think does the
trick.  It works by checking whether the "merge base" of the branch with
'master' (before it was merged to 'master') is actually part of 'maint'.

candidate-branches () {
  merged=$1
  dest=$2
  git for-each-ref --shell --format 'branch=%(refname) date=%(committerdate)' 
refs/remotes/origin | while read entry
  do
    eval "$entry"
    git merge-base --is-ancestor $branch $merged || continue
    git merge-base --is-ancestor $branch $dest && continue
    merge_point=$(git rev-list --ancestry-path --reverse $branch..$merged | 
head -1)
    start=$(git merge-base $branch ${merge_point}~1)
    # echo Testing branch $branch merge_point $merge_point start $start
    git merge-base --is-ancestor $start $dest || continue
    echo Candidate for $dest: $branch $date
  done
}


Don't just blindly merge these things.  For example,
'jed/pcmg-residual-underscore' contains two commits, the first of which
went to 'maint' and the second of which removes the old function and
thus cannot go to 'maint'.  (The merge commit messages explain this.)

Attachment: pgp6i8lhkZHbH.pgp
Description: PGP signature

Reply via email to