{"thread":{"id":"288","subject":"Adding quilt functionality to git?","startedAt":"2005-04-24T15:23:04Z","lastAt":"2005-04-24T15:23:04Z","messageCount":1,"participants":["Roman Zippel"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"1524","messageId":"Pine.LNX.4.61.0504241319330.4073@scrub.home","threadId":"288","inReplyTo":null,"subject":"Adding quilt functionality to git?","fromName":"Roman Zippel","fromEmail":"zippel@linux-m68k.org","sentAt":"2005-04-24T15:23:04Z","receivedAt":"2005-04-24T15:23:04Z","isPatch":false,"sender":{"key":"zippel@linux-m68k.org","avatar":null},"body":"Hi,\n\nCurrently git reproduces the old bk work flow and with this it also has \nthe same problems and makes quilt still a very useful tool, so how about \nadding quilt functionality to git?\n\nWhat basically would be needed is adding a new file type 'series' which \nbasically has a contents like this:\n\ntop\t<sha1>\nfoo.patch\t<sha1>\nbar.patch\t<sha1>\n\nThe sha1 points to commit objects. Next we need a new merge operator, \nwhich basically does \"merge differences between tree1 and tree2 into \nanother tree\" (without renames this is quite simple, basically just \ncalling diff3).\nWith these two things one can implement quilt on top of git. A push of \nfoo.patch would merge its changes into the current working tree. A refresh \nwould generate a diff between top and current working tree and stores it \nas the new foo.patch.\nThis would also allow cherry picking by simply editing the series file. \nE.g. Andrew could merge other patches simply by adding a few lines to his \nseries file and run a few updates with an url where to get the missing \nchanges from. When he wants to send patches to Linus, he just needs to \nextract a new series file and send it off.\n\ngit is currently a bit too much moving target to do this myself right now, \nbut maybe someone else wants to do this. As inspiration I appended below \na simple script to implement something similiar with quilt. It basically \ndoes a 3-way-merge when updating the patches to a new source tree, so one \nbasically uses it like this:\n\ncp -al <src> <dest>\n<update dest>\nqm <src> <dest>\n\nIf there are any conflicts, it just calls kdiff3 or diff3+vi.\nWith git now one could skip the copy step and simply change the top sha1 \nand pull the old files out of the cache.\n\nPersonally I think this merging style is more suited for the kernel \ndevelopment style then the bk merging method. There might be of course \nother problems, but due the simple design of git it would be a lot easier\nto try out new things compared to other traditional SCM.\n\nbye, Roman\n\n---\n\n#!/bin/bash\n\nif [ $# -ne 2 ]; then\n\techo \"Usage: $0 <src> <dst>\"\n\texit\nfi\n\nDIR1=$1\ntest ${DIR1:0:1} = / || DIR1=$PWD/$DIR1\nDIR2=$2\ntest ${DIR2:0:1} = / || DIR2=$PWD/$DIR2\n\nif [ ! -d $DIR1/patches -o ! -d $DIR2 ]; then\n\techo \"Invalid arguments\"\n\texit\nfi\n\ntype kdiff3 >& /dev/null && test -n \"$DISPLAY\" && use_kdiff=1\n\nif [ -e $DIR2/patches ]; then\n\ttime=`date +.%y%m%d.%H%M%S`\n\techo \"Backing up old patches as patches$time\"\n\tmv $DIR2/patches $DIR2/patches$time\nfi\n\ncd $DIR1\ncp -a patches $DIR2\nquilt top > /dev/null && quilt pop -qa\ncd $DIR2\nwhile [ -n \"`quilt next`\" ]; do\n\tp=`quilt next`\n\techo \"Merging patch $p\"\n\trej=`quilt push | sed -n 's/.* -- rejects in file \\(.*\\)$/\\1/p'`\n\tif [ -n \"$rej\" ]; then\n\t\techo \"need to resolve conflicts in $rej\"\n\t\tcd $DIR1\n\t\tquilt push -q $p\n\t\tcd $DIR2\n\t\tfor m in $rej; do\n\t\t\tcp $m $m.rq.cur\n\t\tdone\n\t\tquilt push -f\n\t\tfor m in $rej; do\n\t\t\tif [ \"$use_kdiff\" -eq 1 ]; then\n\t\t\t\tkdiff3 -m -o $m \\\n\t\t\t\t\t-L \"$m (`quilt prev`)\" \\\n\t\t\t\t\t-L \"$m ($p)\" \\\n\t\t\t\t\t-L \"$m (current)\" \\\n\t\t\t\t\t$DIR1/.pc/$p/$m $DIR1/$m $m.rq.cur\n\t\t\telse\n\t\t\t\tdiff3 -mE > $m \\\n\t\t\t\t\t-L \"$m (current)\" \\\n\t\t\t\t\t-L \"$m (`quilt prev`)\" \\\n\t\t\t\t\t-L \"$m ($p)\" \\\n\t\t\t\t\t$m.rq.cur $DIR1/.pc/$p/$m $DIR1/$m\n\t\t\t\t${EDITOR:-vi} $m\n\t\t\tfi\n\t\t\tif cmp -s $m.rq.cur $m; then\n\t\t\t\techo \"No changes\"\n\t\t\t\tquilt remove $m\n\t\t\tfi\n\t\t\trm $m.rq.cur\n\t\tdone\n\t\tif [ -z \"`quilt files`\" ]; then\n\t\t\techo \"Empty patch\"\n\t\t\tquilt pop -qf\n\t\t\tquilt delete $p\n\t\telse\n\t\t\tquilt ref\n\t\tfi\n\tfi\ndone\n\n"}]}