* git-merge-subordinate
@ 2006-10-25 15:50 Matthew Wilcox
2006-10-25 16:11 ` git-merge-subordinate Jakub Narebski
0 siblings, 1 reply; 4+ messages in thread
From: Matthew Wilcox @ 2006-10-25 15:50 UTC (permalink / raw)
To: git
Linus doesn't like seeing unnecessary merges in his tree. I'm not a huge
fan of them either. Wouldn't it be nice if we had a merge method that
did a merge without creating a merge? I call it git-merge-subordinate
(since my tree is subordinate to the tree I'm pulling from). I suppose
you could call it 'slave' if you want to be more pithy. Anyway, this
is a first attempt, and it's totally cargo-cult programming; I make no
claim that I understand what I'm doing. But it does seem to work.
While working on it, I found a small bug in git-merge. When
no_trivial_merge_strategies has more than one component, setting
index_merge to f doesn't work. So first, here's the patch to git-merge
adding support for 'subordinate':
--- /usr/bin/git-merge 2006-07-29 15:47:09.000000000 -0600
+++ /home/willy/bin/git-merge 2006-10-25 09:21:00.000000000 -0600
@@ -9,15 +9,15 @@
LF='
'
-all_strategies='recursive octopus resolve stupid ours'
+all_strategies='recursive octopus resolve stupid subordinate ours'
default_twohead_strategies='recursive'
default_octopus_strategies='octopus'
-no_trivial_merge_strategies='ours'
+no_trivial_merge_strategies='subordinate ours'
use_strategies=
index_merge=t
if test ""; then
- all_strategies='resolve octopus stupid ours'
+ all_strategies='resolve octopus stupid subordinate ours'
default_twohead_strategies='resolve'
fi
@@ -154,12 +154,15 @@
for s in $use_strategies
do
- case " $s " in
- *" $no_trivial_merge_strategies "*)
- index_merge=f
- break
- ;;
- esac
+ for t in $no_trivial_merge_strategies
+ do
+ case "$s" in
+ "$t")
+ index_merge=f
+ break
+ ;;
+ esac
+ done
done
case "$#" in
And now, here's the extremely lame git-merge-subordinate script.
#!/bin/sh
#
# Copyright (c) 2005 Linus Torvalds
# Copyright (c) 2005 Junio C Hamano
#
# Resolve two trees, using enhancd multi-base read-tree.
# The first parameters up to -- are merge bases; the rest are heads.
bases= head= remotes= sep_seen=
for arg
do
case ",$sep_seen,$head,$arg," in
*,--,)
sep_seen=yes
;;
,yes,,*)
head=$arg
;;
,yes,*)
remotes="$remotes$arg "
;;
*)
bases="$bases$arg "
;;
esac
done
# Give up if we are given more than two remotes -- not handling octopus.
case "$remotes" in
?*' '?*)
exit 2 ;;
esac
# Give up if this is a baseless merge.
if test '' = "$bases"
then
exit 2
fi
git-rebase $remotes || exit 2
if result_tree=$(git-write-tree 2>/dev/null)
then
exit 0
else
echo "Simple merge failed, trying Automatic merge."
if git-merge-index -o git-merge-one-file -a
then
exit 0
else
exit 1
fi
fi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: git-merge-subordinate
2006-10-25 15:50 git-merge-subordinate Matthew Wilcox
@ 2006-10-25 16:11 ` Jakub Narebski
2006-10-25 16:19 ` git-merge-subordinate Johannes Schindelin
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Narebski @ 2006-10-25 16:11 UTC (permalink / raw)
To: git
Matthew Wilcox wrote:
> Linus doesn't like seeing unnecessary merges in his tree. I'm not a huge
> fan of them either. Wouldn't it be nice if we had a merge method that
> did a merge without creating a merge? I call it git-merge-subordinate
> (since my tree is subordinate to the tree I'm pulling from). I suppose
> you could call it 'slave' if you want to be more pithy. Anyway, this
> is a first attempt, and it's totally cargo-cult programming; I make no
> claim that I understand what I'm doing. But it does seem to work.
Hmmm... the --squash option to git-merge/git-pull isn't enough?
--squash::
Produce the working tree and index state as if a real
merge happened, but do not actually make a commit or
move the `HEAD`, nor record `$GIT_DIR/MERGE_HEAD` to
cause the next `git commit` command to create a merge
commit. This allows you to create a single commit on
top of the current branch whose effect is the same as
merging another branch (or more in case of an octopus).
--
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: git-merge-subordinate
2006-10-25 16:11 ` git-merge-subordinate Jakub Narebski
@ 2006-10-25 16:19 ` Johannes Schindelin
2006-10-25 16:27 ` git-merge-subordinate Shawn Pearce
0 siblings, 1 reply; 4+ messages in thread
From: Johannes Schindelin @ 2006-10-25 16:19 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
[-- Attachment #1: Type: TEXT/PLAIN, Size: 799 bytes --]
Hi,
On Wed, 25 Oct 2006, Jakub Narebski wrote:
> Matthew Wilcox wrote:
>
> > Linus doesn't like seeing unnecessary merges in his tree. I'm not a huge
> > fan of them either. Wouldn't it be nice if we had a merge method that
> > did a merge without creating a merge? I call it git-merge-subordinate
> > (since my tree is subordinate to the tree I'm pulling from). I suppose
> > you could call it 'slave' if you want to be more pithy. Anyway, this
> > is a first attempt, and it's totally cargo-cult programming; I make no
> > claim that I understand what I'm doing. But it does seem to work.
>
> Hmmm... the --squash option to git-merge/git-pull isn't enough?
What subordinate does is not _merge_, but _rebase_ on top of the fetched
commit. So yes, --squash isn't enough ;-)
Ciao,
Dscho
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: git-merge-subordinate
2006-10-25 16:19 ` git-merge-subordinate Johannes Schindelin
@ 2006-10-25 16:27 ` Shawn Pearce
0 siblings, 0 replies; 4+ messages in thread
From: Shawn Pearce @ 2006-10-25 16:27 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Jakub Narebski, git
Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Wed, 25 Oct 2006, Jakub Narebski wrote:
>
> > Matthew Wilcox wrote:
> >
> > > Linus doesn't like seeing unnecessary merges in his tree. I'm not a huge
> > > fan of them either. Wouldn't it be nice if we had a merge method that
> > > did a merge without creating a merge? I call it git-merge-subordinate
> > > (since my tree is subordinate to the tree I'm pulling from). I suppose
> > > you could call it 'slave' if you want to be more pithy. Anyway, this
> > > is a first attempt, and it's totally cargo-cult programming; I make no
> > > claim that I understand what I'm doing. But it does seem to work.
> >
> > Hmmm... the --squash option to git-merge/git-pull isn't enough?
>
> What subordinate does is not _merge_, but _rebase_ on top of the fetched
> commit. So yes, --squash isn't enough ;-)
And I would suggest calling it 'git-merge-rebase', as the strategy
really is rebase... :-)
--
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-10-25 16:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-25 15:50 git-merge-subordinate Matthew Wilcox
2006-10-25 16:11 ` git-merge-subordinate Jakub Narebski
2006-10-25 16:19 ` git-merge-subordinate Johannes Schindelin
2006-10-25 16:27 ` git-merge-subordinate Shawn Pearce
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).