{"thread":{"id":"43572","subject":"git-merge-subordinate","startedAt":"2006-10-25T15:50:10Z","lastAt":"2006-10-25T16:27:58Z","messageCount":4,"participants":["Matthew Wilcox","Jakub Narebski","Shawn Pearce","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"295610","messageId":"20061025155009.GD5591@parisc-linux.org","threadId":"43572","inReplyTo":null,"subject":"git-merge-subordinate","fromName":"Matthew Wilcox","fromEmail":"matthew@wil.cx","sentAt":"2006-10-25T15:50:10Z","receivedAt":"2006-10-25T15:50:10Z","isPatch":false,"sender":{"key":"matthew@wil.cx","avatar":null},"body":"\nLinus doesn't like seeing unnecessary merges in his tree.  I'm not a huge\nfan of them either.  Wouldn't it be nice if we had a merge method that\ndid a merge without creating a merge?  I call it git-merge-subordinate\n(since my tree is subordinate to the tree I'm pulling from).  I suppose\nyou could call it 'slave' if you want to be more pithy.  Anyway, this\nis a first attempt, and it's totally cargo-cult programming; I make no\nclaim that I understand what I'm doing.  But it does seem to work.\n\nWhile working on it, I found a small bug in git-merge.  When\nno_trivial_merge_strategies has more than one component, setting\nindex_merge to f doesn't work.  So first, here's the patch to git-merge\nadding support for 'subordinate':\n\n--- /usr/bin/git-merge\t2006-07-29 15:47:09.000000000 -0600\n+++ /home/willy/bin/git-merge\t2006-10-25 09:21:00.000000000 -0600\n@@ -9,15 +9,15 @@\n LF='\n '\n \n-all_strategies='recursive octopus resolve stupid ours'\n+all_strategies='recursive octopus resolve stupid subordinate ours'\n default_twohead_strategies='recursive'\n default_octopus_strategies='octopus'\n-no_trivial_merge_strategies='ours'\n+no_trivial_merge_strategies='subordinate ours'\n use_strategies=\n \n index_merge=t\n if test \"\"; then\n-\tall_strategies='resolve octopus stupid ours'\n+\tall_strategies='resolve octopus stupid subordinate ours'\n \tdefault_twohead_strategies='resolve'\n fi\n \n@@ -154,12 +154,15 @@\n \n for s in $use_strategies\n do\n-\tcase \" $s \" in\n-\t*\" $no_trivial_merge_strategies \"*)\n-\t\tindex_merge=f\n-\t\tbreak\n-\t\t;;\n-\tesac\n+\tfor t in $no_trivial_merge_strategies\n+\tdo\n+\t\tcase \"$s\" in\n+\t\t\"$t\")\n+\t\t\tindex_merge=f\n+\t\t\tbreak\n+\t\t\t;;\n+\t\tesac\n+\tdone\n done\n \n case \"$#\" in\n\n\nAnd now, here's the extremely lame git-merge-subordinate script.\n\n#!/bin/sh\n#\n# Copyright (c) 2005 Linus Torvalds\n# Copyright (c) 2005 Junio C Hamano\n#\n# Resolve two trees, using enhancd multi-base read-tree.\n\n# The first parameters up to -- are merge bases; the rest are heads.\nbases= head= remotes= sep_seen=\nfor arg\ndo\n\tcase \",$sep_seen,$head,$arg,\" in\n\t*,--,)\n\t\tsep_seen=yes\n\t\t;;\n\t,yes,,*)\n\t\thead=$arg\n\t\t;;\n\t,yes,*)\n\t\tremotes=\"$remotes$arg \"\n\t\t;;\n\t*)\n\t\tbases=\"$bases$arg \"\n\t\t;;\n\tesac\ndone\n\n# Give up if we are given more than two remotes -- not handling octopus.\ncase \"$remotes\" in\n?*' '?*)\n\texit 2 ;;\nesac\n\n# Give up if this is a baseless merge.\nif test '' = \"$bases\"\nthen\n\texit 2\nfi\n\ngit-rebase $remotes || exit 2\nif result_tree=$(git-write-tree  2>/dev/null)\nthen\n\texit 0\nelse\n\techo \"Simple merge failed, trying Automatic merge.\"\n\tif git-merge-index -o git-merge-one-file -a\n\tthen\n\t\texit 0\n\telse\n\t\texit 1\n\tfi\nfi\n"},{"id":"296176","messageId":"eho29l$1td$1@sea.gmane.org","threadId":"43572","inReplyTo":"20061025155009.GD5591@parisc-linux.org","subject":"Re: git-merge-subordinate","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-25T16:11:05Z","receivedAt":"2006-10-25T16:11:05Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Matthew Wilcox wrote:\n\n> Linus doesn't like seeing unnecessary merges in his tree.  I'm not a huge\n> fan of them either.  Wouldn't it be nice if we had a merge method that\n> did a merge without creating a merge?  I call it git-merge-subordinate\n> (since my tree is subordinate to the tree I'm pulling from).  I suppose\n> you could call it 'slave' if you want to be more pithy.  Anyway, this\n> is a first attempt, and it's totally cargo-cult programming; I make no\n> claim that I understand what I'm doing.  But it does seem to work.\n\nHmmm... the --squash option to git-merge/git-pull isn't enough?\n\n--squash::\n        Produce the working tree and index state as if a real\n        merge happened, but do not actually make a commit or\n        move the `HEAD`, nor record `$GIT_DIR/MERGE_HEAD` to\n        cause the next `git commit` command to create a merge\n        commit.  This allows you to create a single commit on\n        top of the current branch whose effect is the same as\n        merging another branch (or more in case of an octopus).\n\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"},{"id":"298552","messageId":"Pine.LNX.4.63.0610251819080.3286@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"43572","inReplyTo":"eho29l$1td$1@sea.gmane.org","subject":"Re: git-merge-subordinate","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-10-25T16:19:54Z","receivedAt":"2006-10-25T16:19:54Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 25 Oct 2006, Jakub Narebski wrote:\n\n> Matthew Wilcox wrote:\n> \n> > Linus doesn't like seeing unnecessary merges in his tree.  I'm not a huge\n> > fan of them either.  Wouldn't it be nice if we had a merge method that\n> > did a merge without creating a merge?  I call it git-merge-subordinate\n> > (since my tree is subordinate to the tree I'm pulling from).  I suppose\n> > you could call it 'slave' if you want to be more pithy.  Anyway, this\n> > is a first attempt, and it's totally cargo-cult programming; I make no\n> > claim that I understand what I'm doing.  But it does seem to work.\n> \n> Hmmm... the --squash option to git-merge/git-pull isn't enough?\n\nWhat subordinate does is not _merge_, but _rebase_ on top of the fetched \ncommit. So yes, --squash isn't enough ;-)\n\nCiao,\nDscho\n"},{"id":"297262","messageId":"20061025162758.GC9312@spearce.org","threadId":"43572","inReplyTo":"Pine.LNX.4.63.0610251819080.3286@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: git-merge-subordinate","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-10-25T16:27:58Z","receivedAt":"2006-10-25T16:27:58Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n> \n> On Wed, 25 Oct 2006, Jakub Narebski wrote:\n> \n> > Matthew Wilcox wrote:\n> > \n> > > Linus doesn't like seeing unnecessary merges in his tree.  I'm not a huge\n> > > fan of them either.  Wouldn't it be nice if we had a merge method that\n> > > did a merge without creating a merge?  I call it git-merge-subordinate\n> > > (since my tree is subordinate to the tree I'm pulling from).  I suppose\n> > > you could call it 'slave' if you want to be more pithy.  Anyway, this\n> > > is a first attempt, and it's totally cargo-cult programming; I make no\n> > > claim that I understand what I'm doing.  But it does seem to work.\n> > \n> > Hmmm... the --squash option to git-merge/git-pull isn't enough?\n> \n> What subordinate does is not _merge_, but _rebase_ on top of the fetched \n> commit. So yes, --squash isn't enough ;-)\n\n\nAnd I would suggest calling it 'git-merge-rebase', as the strategy\nreally is rebase...  :-)\n\n-- \n"}]}