Skip to Content.
Sympa Menu

sm-discuss - Re: [SM-Discuss] git feedback

sm-discuss AT lists.ibiblio.org

Subject: Public SourceMage Discussion List

List archive

Chronological Thread  
  • From: Jeremy Blosser <jblosser-smgl AT firinn.org>
  • To: sm-discuss AT lists.ibiblio.org
  • Subject: Re: [SM-Discuss] git feedback
  • Date: Fri, 28 Jul 2006 17:47:38 -0500

On Jul 28, seth AT swoolley.homeip.net [seth AT swoolley.homeip.net] wrote:
> On Sat, Jul 29, 2006 at 12:12:24AM +0200, Arwed von Merkatz wrote:
> > On Fri, Jul 28, 2006 at 04:32:43PM -0500, Jeremy Blosser wrote:
> > > On Jul 28, Arwed von Merkatz [v.merkatz AT gmx.net] wrote:
> > > > > It shows up more often on the history files because of the specific
> > > > > way in
> > > > > which RCS' /usr/bin/merge makes bad assumptions, but yes, it shows
> > > > > up
> > > > > elsewhere as well. The fix for this would be general in nature.
> > > >
> > > > Merging in perforce was far from perfect too, but it was fitting our
> > > > work model a little bit better. There definitely is the possibility to
> > > > make the merging work better for us due to git just using external
> > > > tools, but all I did in that area was a proof-of-concept so far.
> > >
> > > Can you provide the code you had for that if you still have it?
> >
> > I will if I find it again, but it was really simple. /usr/bin/merge is a
> > 3-way merge tool, you basically start with 3 files:
> > - original from branch you cherry-pick to
> > - previous version from branch you cherry-pick from
> > - current version from branch you cherry-pick from
> >
> > merge tries to be smart and does a real 3-way comparison between those
> > files, which doesn't work too well for ChangeLog/HISTORY type files.
> > What I did was basically replicate the way p4 does merges:
> > - do a plain diff (i.e. not context or unified) between previous and
> > current version on the branch to cherry-pick from
> > - apply that as a patch to original on branch to cherry-pick to
> >
> > This leads to less conflicts because it doesn't use context/unified
> > diffs, instead it just records removed/added lines without context.
> > I wouldn't want an algorithm like that in general as it's too fault
> > tolerant, but for HISTORY/ChangeLog type merging, it works pretty well.
>
> So we just need to have this script act as a wrapper for both, trying
> the first one and if that doesn't succeed, try the second, and if that
> doesn't succeed, return failure.

If this is what we really want it to do. But what are examples where we
wouldn't just want it to use a regular diff/patch approach for a
cherry-pick?

> Or does git allow you to have mutliple merge algorithms inherently?

It does, though git-cherry-pick doesn't use the full git-merge set since
by definition a cherry-pick is at most a 3-way merge (it's not going to be
an octopus or anything). Regardless, cherry-pick already tries a few
simple merge strategies trying to find one that works, adding another would
be trivial and probably not too hard to get integrated upstream.

Start with less `which git-cherry-pick` and read man pages and commands
from there for more information on what it does now:

...
# This three way merge is an interesting one. We are at
# $head, and would want to apply the change between $commit
# and $prev on top of us (when reverting), or the change between
# $prev and $commit on top of us (when cherry-picking or replaying).

echo >&2 "First trying simple merge strategy to $me."
git-read-tree -m -u --aggressive $base $head $next &&
result=$(git-write-tree 2>/dev/null) || {
echo >&2 "Simple $me fails; trying Automatic $me."
git-merge-index -o git-merge-one-file -a || {
echo >&2 "Automatic $me failed. After resolving the conflicts,"
echo >&2 "mark the corrected paths with 'git-update-index
<paths>'"
echo >&2 "and commit with 'git commit -F .msg'"
case "$me" in
cherry-pick)
echo >&2 "You may choose to use the following when making"
echo >&2 "the commit:"
echo >&2 "$set_author_env"
esac
exit 1
}
result=$(git-write-tree) || exit
}
echo >&2 "Finished one $me."
...

Attachment: pgp0BHi_apjzY.pgp
Description: PGP signature




Archive powered by MHonArc 2.6.24.

Top of Page