[petsc-dev] git : list branches started off maint - but not yet merged back

Satish Balay balay at mcs.anl.gov
Thu Aug 29 20:06:39 CDT 2013


On Thu, 29 Aug 2013, Jed Brown wrote:

> Karl Rupp <rupp at mcs.anl.gov> 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

balay at asterix /home/balay/petsc.clone (maint)
$ git branch -r --contains maint
  origin/maint
  origin/next
  origin/prbrune/snes-jacobiancolormgfix

hm - looks like this is not that useful as it just shows the branches
started from current maint.HEAD

> > as well as
> >   git branch --no-merge maint

balay at asterix /home/balay/petsc.clone (maint)
$ git branch -r --no-merge maint | wc -l
164

So this shows all branches [most of them started off master] - that are not merged into maint.


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

Is this in referene to 'git branch -r --contains maint'? I don't
understand this.

> 
> 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.

Sure - I use this sometimes I'm checking on a known branch.


>  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

what are the arguments here?. Looks a bit complex - so will leave this to you.. :)


>   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.)

yeah - the thought was - if I could easily find the list of branches -
then I can look at them - and then ping the relavent folks about it.

Satish



More information about the petsc-dev mailing list