{"thread":{"id":"1039","subject":"Stacked GIT 0.3 (now more Quilt-like)","startedAt":"2005-06-28T21:26:43Z","lastAt":"2005-07-08T09:32:24Z","messageCount":16,"participants":["Catalin Marinas","Peter Osterlund","Martin Langhoff","randy_dunlap","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"5371","messageId":"1119994003.9631.6.camel@localhost.localdomain","threadId":"1039","inReplyTo":null,"subject":"Stacked GIT 0.3 (now more Quilt-like)","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2005-06-28T21:26:43Z","receivedAt":"2005-06-28T21:26:43Z","isPatch":false,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"A new StGIT release is available from http://procode.org/stgit/\n\nWhat's new in version 0.3:\n      * closer to the Quilt functionality\n      * there is only one commit object per patch which can be\n        indefinitely modified using the 'refresh' command. The commit\n        objects are stacked on top of the base and can also be accessed\n        via standard GIT commands\n      * no 'commit' command. Use 'refresh' instead\n\nStGIT is a Python application providing similar functionality to Quilt\n(i.e. pushing/popping patches to/from a stack) on top of GIT. These\noperations are performed using GIT commands and the patches are stored\nas GIT commit objects, allowing easy merging of the StGIT patches into\nother repositories using standard GIT functionality.\n\nNote that StGIT is not an SCM interface on top of GIT and it expects a\npreviously initialised GIT repository. For standard SCM operations,\neither use plain GIT commands or the Cogito tool.\n\nFor more information, see the README file in the archive.\n\n--\nCatalin\n"},{"id":"5593","messageId":"m3ekagp9mk.fsf@telia.com","threadId":"1039","inReplyTo":"1119994003.9631.6.camel@localhost.localdomain","subject":"Re: Stacked GIT 0.3 (now more Quilt-like)","fromName":"Peter Osterlund","fromEmail":"petero2@telia.com","sentAt":"2005-07-03T08:38:27Z","receivedAt":"2005-07-03T08:38:27Z","isPatch":false,"sender":{"key":"petero2@telia.com","avatar":null},"body":"Catalin Marinas <catalin.marinas@gmail.com> writes:\n\n> A new StGIT release is available from http://procode.org/stgit/\n> \n> What's new in version 0.3:\n>       * closer to the Quilt functionality\n>       * there is only one commit object per patch which can be\n>         indefinitely modified using the 'refresh' command. The commit\n>         objects are stacked on top of the base and can also be accessed\n>         via standard GIT commands\n>       * no 'commit' command. Use 'refresh' instead\n> \n> StGIT is a Python application providing similar functionality to Quilt\n> (i.e. pushing/popping patches to/from a stack) on top of GIT. These\n> operations are performed using GIT commands and the patches are stored\n> as GIT commit objects, allowing easy merging of the StGIT patches into\n> other repositories using standard GIT functionality.\n\nThis is good stuff and the 3-way merge really simplifies things.\nHowever, if there is a merge conflict, you will basically be stuck\nwith a 2-way merge when resolving manually. It's usually much easier\nif you can see all three version, so I think it's better to use -A\ninstead of -E in the diff3 command.\n\n--- stgit-0.3/gitmergeonefile.py~\t2005-06-28 14:15:22.000000000 +0200\n+++ stgit-0.3/gitmergeonefile.py\t2005-07-03 02:33:13.000000000 +0200\n@@ -108,7 +108,7 @@\n         # 3-way merge\n         else:\n             merge_ok = os.system('diff3 -L local -L older -L remote '\n-                                 '-m -E %s %s %s > %s'\n+                                 '-m -A %s %s %s > %s'\n                                   % (src1, orig, src2, path)) == 0\n \n             if merge_ok:\n\n-- \nPeter Osterlund - petero2@telia.com\nhttp://web.telia.com/~u89404340\n"},{"id":"5594","messageId":"1120385280.6845.12.camel@localhost.localdomain","threadId":"1039","inReplyTo":"m3ekagp9mk.fsf@telia.com","subject":"Re: Stacked GIT 0.3 (now more Quilt-like)","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2005-07-03T10:08:00Z","receivedAt":"2005-07-03T10:08:00Z","isPatch":false,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"Hi Peter,\n\nThanks for trying this tool.\n\nOn Sun, 2005-07-03 at 10:38 +0200, Peter Osterlund wrote:\n> This is good stuff and the 3-way merge really simplifies things.\n> However, if there is a merge conflict, you will basically be stuck\n> with a 2-way merge when resolving manually. It's usually much easier\n> if you can see all three version, so I think it's better to use -A\n> instead of -E in the diff3 command.\n\nI know that using -A gives a more detailed output in case of a conflict.\nThe problem is that you will get a conflict even if the changes are\nidentical, making it impossible to detect when a patch was merged\nupstream.\n\nFor example:\n\nancestor:\taaa\nbranch1:\taaa\n\t\tbbb\nbranch2:\taaa\n\t\tbbb\n\ndiff3 -E:\taaa\n\t\tbbb\ndiff3 -A:\taaa\n\t\t<<<<<<< ancestor\n\t\t=======\n\t\tbbb\n\t\t>>>>>>> branch2\n\nIn version 0.3, in case of a conflict, StGIT leaves 3 files in the tree:\nfile.older, file.local and file.remote so that one can use a graphical\ntool to do the merge. I think these names are a bit misleading, .remote\nextension means the file in the patch and .local is the one in the tree\nbefore pushing the patch. Anyway, it might be invoking a graphical tool\ndirectly from gitmergeonefile.py.\n\nSpeaking of detecting upstream merges, the latest StGIT snapshot shows a\n'0' in front of a patch if it is empty, when 'stg series' is invoked.\nWhen pushing, if all the changes are the same, it notifies you that the\npatch is empty so that it can be safely removed.\n\n--\nCatalin\n"},{"id":"5603","messageId":"m3oe9k6p40.fsf@telia.com","threadId":"1039","inReplyTo":"1120385280.6845.12.camel@localhost.localdomain","subject":"Re: Stacked GIT 0.3 (now more Quilt-like)","fromName":"Peter Osterlund","fromEmail":"petero2@telia.com","sentAt":"2005-07-03T12:38:55Z","receivedAt":"2005-07-03T12:38:55Z","isPatch":false,"sender":{"key":"petero2@telia.com","avatar":null},"body":"Catalin Marinas <catalin.marinas@gmail.com> writes:\n\n> Hi Peter,\n> \n> Thanks for trying this tool.\n> \n> On Sun, 2005-07-03 at 10:38 +0200, Peter Osterlund wrote:\n> > This is good stuff and the 3-way merge really simplifies things.\n> > However, if there is a merge conflict, you will basically be stuck\n> > with a 2-way merge when resolving manually. It's usually much easier\n> > if you can see all three version, so I think it's better to use -A\n> > instead of -E in the diff3 command.\n> \n> I know that using -A gives a more detailed output in case of a conflict.\n> The problem is that you will get a conflict even if the changes are\n> identical, making it impossible to detect when a patch was merged\n> upstream.\n\nOK, I see. How about using wiggle instead?\n\n        http://cgi.cse.unsw.edu.au/~neilb/source/wiggle/\n\nThat's what patch-utils uses if you run \"pushpatch -m\". wiggle is also\na lot smarter than diff3, so there will be fewer cases that result in\na conflict. Maybe a parameter to \"stg push\" could enable wiggle mode.\n\nAnother nice thing from patch-utils is that if applying the patch\nwould have failed, nothing will be done by \"pushpatch\". You then have\nthe option to rerun it with -m (merge) or -f (force, create .rej\nfiles), or decide that you don't want to push the patch at all. The\nlast part is quite useful if you try to reorder a patch series, find\nout that you would get a thousand conflicts, and want to reconsider.\n\nIs there a way in StGIT to undo a push that results in a large mess of\nconflicts?\n\n> Speaking of detecting upstream merges, the latest StGIT snapshot shows a\n> '0' in front of a patch if it is empty, when 'stg series' is invoked.\n> When pushing, if all the changes are the same, it notifies you that the\n> patch is empty so that it can be safely removed.\n\nThat's a useful feature. With patch-utils, I used to drop patches\nmanually, but that could lose information if the patch applied\nupstream is not exactly the same as the one I had locally.\n\n-- \nPeter Osterlund - petero2@telia.com\nhttp://web.telia.com/~u89404340\n"},{"id":"5608","messageId":"1120425269.6845.28.camel@localhost.localdomain","threadId":"1039","inReplyTo":"m3oe9k6p40.fsf@telia.com","subject":"Re: Stacked GIT 0.3 (now more Quilt-like)","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2005-07-03T21:14:29Z","receivedAt":"2005-07-03T21:14:29Z","isPatch":false,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"On Sun, 2005-07-03 at 14:38 +0200, Peter Osterlund wrote:\n> Catalin Marinas <catalin.marinas@gmail.com> writes:\n> > I know that using -A gives a more detailed output in case of a conflict.\n> > The problem is that you will get a conflict even if the changes are\n> > identical, making it impossible to detect when a patch was merged\n> > upstream.\n> \n> OK, I see. How about using wiggle instead?\n> \n>         http://cgi.cse.unsw.edu.au/~neilb/source/wiggle/\n> \n> That's what patch-utils uses if you run \"pushpatch -m\". wiggle is also\n> a lot smarter than diff3, so there will be fewer cases that result in\n> a conflict. Maybe a parameter to \"stg push\" could enable wiggle mode.\n\nI haven't used wiggle before but I will give it a try (though I prefer\nsuch a tool not to be too smart since it might make mistakes). Anyway, I\nwill make this configurable, i.e. you could put something like below in\nthe .stgitrc file:\n\nmerger = 'diff3 -m -E %(branch1)s %(ancestor)s %(branch2)s'\n\nor\n\nmerger = 'wiggle -m %(branch1)s %(ancestor)s %(branch2)s'\n\n> Is there a way in StGIT to undo a push that results in a large mess of\n> conflicts?\n\nGood point. No, there isn't yet. I will think about an undo command. At\nthe moment, the old top and bottom ids of a patch are saved so that the\npatch before the merge can be retrieved but there isn't any command to\nmake use of them.\n\n--\nCatalin\n"},{"id":"5622","messageId":"46a038f9050703232719a05c9e@mail.gmail.com","threadId":"1039","inReplyTo":"1120425269.6845.28.camel@localhost.localdomain","subject":"Re: Stacked GIT 0.3 (now more Quilt-like)","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2005-07-04T06:27:40Z","receivedAt":"2005-07-04T06:27:40Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"> > OK, I see. How about using wiggle instead?\n> >\n> >         http://cgi.cse.unsw.edu.au/~neilb/source/wiggle/\n> >\n> > That's what patch-utils uses if you run \"pushpatch -m\". wiggle is also\n> > a lot smarter than diff3, so there will be fewer cases that result in\n> > a conflict. Maybe a parameter to \"stg push\" could enable wiggle mode.\n> \n> I haven't used wiggle before but I will give it a try (though I prefer\n> such a tool not to be too smart since it might make mistakes). Anyway, I\n> will make this configurable, i.e. you could put something like below in\n> the .stgitrc file:\n\nwiggle is good but it's not safe. You should definitely review the\nresults of a wiggle merge with extra care. It sometimes does magic and\nmerges the unmergeable, and sometimes it does bad, bad things.\n\ncheers,\n\n\nmartin\n"},{"id":"5626","messageId":"m3y88m21ln.fsf@telia.com","threadId":"1039","inReplyTo":"1120425269.6845.28.camel@localhost.localdomain","subject":"Re: Stacked GIT 0.3 (now more Quilt-like)","fromName":"Peter Osterlund","fromEmail":"petero2@telia.com","sentAt":"2005-07-04T12:32:36Z","receivedAt":"2005-07-04T12:32:36Z","isPatch":false,"sender":{"key":"petero2@telia.com","avatar":null},"body":"Catalin Marinas <catalin.marinas@gmail.com> writes:\n\n> On Sun, 2005-07-03 at 14:38 +0200, Peter Osterlund wrote:\n> > Catalin Marinas <catalin.marinas@gmail.com> writes:\n> > > I know that using -A gives a more detailed output in case of a conflict.\n> > > The problem is that you will get a conflict even if the changes are\n> > > identical, making it impossible to detect when a patch was merged\n> > > upstream.\n> > \n> > OK, I see. How about using wiggle instead?\n> > \n> >         http://cgi.cse.unsw.edu.au/~neilb/source/wiggle/\n> > \n> > That's what patch-utils uses if you run \"pushpatch -m\". wiggle is also\n> > a lot smarter than diff3, so there will be fewer cases that result in\n> > a conflict. Maybe a parameter to \"stg push\" could enable wiggle mode.\n> \n> I haven't used wiggle before but I will give it a try (though I prefer\n> such a tool not to be too smart since it might make mistakes). Anyway, I\n> will make this configurable, i.e. you could put something like below in\n> the .stgitrc file:\n> \n> merger = 'diff3 -m -E %(branch1)s %(ancestor)s %(branch2)s'\n> \n> or\n> \n> merger = 'wiggle -m %(branch1)s %(ancestor)s %(branch2)s'\n> \n> > Is there a way in StGIT to undo a push that results in a large mess of\n> > conflicts?\n> \n> Good point. No, there isn't yet. I will think about an undo command. At\n> the moment, the old top and bottom ids of a patch are saved so that the\n> patch before the merge can be retrieved but there isn't any command to\n> make use of them.\n\nI agree with the other comments, it's probably not wise to rely on\nwiggle, and wiggle sometimes makes a mess. However, it often does the\nright thing, and with a configurable merge program and an undo\nfunction, this should not be a problem. Just undo and try again if you\ndon't like the result.\n\n-- \nPeter Osterlund - petero2@telia.com\nhttp://web.telia.com/~u89404340\n"},{"id":"5635","messageId":"20050704100950.393630e8.rdunlap@xenotime.net","threadId":"1039","inReplyTo":"m3y88m21ln.fsf@telia.com","subject":"Re: Stacked GIT 0.3 (now more Quilt-like)","fromName":"randy_dunlap","fromEmail":"rdunlap@xenotime.net","sentAt":"2005-07-04T17:09:50Z","receivedAt":"2005-07-04T17:09:50Z","isPatch":false,"sender":{"key":"rdunlap@xenotime.net","avatar":null},"body":"On 04 Jul 2005 14:32:36 +0200 Peter Osterlund wrote:\n\n| Catalin Marinas <catalin.marinas@gmail.com> writes:\n| \n| > On Sun, 2005-07-03 at 14:38 +0200, Peter Osterlund wrote:\n| > > Catalin Marinas <catalin.marinas@gmail.com> writes:\n| > > > I know that using -A gives a more detailed output in case of a conflict.\n| > > > The problem is that you will get a conflict even if the changes are\n| > > > identical, making it impossible to detect when a patch was merged\n| > > > upstream.\n| > > \n| > > OK, I see. How about using wiggle instead?\n| > > \n| > >         http://cgi.cse.unsw.edu.au/~neilb/source/wiggle/\n| > > \n| > > That's what patch-utils uses if you run \"pushpatch -m\". wiggle is also\n| > > a lot smarter than diff3, so there will be fewer cases that result in\n| > > a conflict. Maybe a parameter to \"stg push\" could enable wiggle mode.\n| > \n| > I haven't used wiggle before but I will give it a try (though I prefer\n| > such a tool not to be too smart since it might make mistakes). Anyway, I\n| > will make this configurable, i.e. you could put something like below in\n| > the .stgitrc file:\n| > \n| > merger = 'diff3 -m -E %(branch1)s %(ancestor)s %(branch2)s'\n| > \n| > or\n| > \n| > merger = 'wiggle -m %(branch1)s %(ancestor)s %(branch2)s'\n| > \n| > > Is there a way in StGIT to undo a push that results in a large mess of\n| > > conflicts?\n| > \n| > Good point. No, there isn't yet. I will think about an undo command. At\n| > the moment, the old top and bottom ids of a patch are saved so that the\n| > patch before the merge can be retrieved but there isn't any command to\n| > make use of them.\n| \n| I agree with the other comments, it's probably not wise to rely on\n| wiggle, and wiggle sometimes makes a mess. However, it often does the\n| right thing, and with a configurable merge program and an undo\n| function, this should not be a problem. Just undo and try again if you\n| don't like the result.\n\nYou could try Chris Mason's 'rej' as well.\nftp://ftp.oregonstate.edu/pub/suse/people/mason/rej/rej-0.15.tar.gz\n(from one mirror site)\n\n---\n~Randy\n"},{"id":"5644","messageId":"1120509766.6879.5.camel@localhost.localdomain","threadId":"1039","inReplyTo":"m3y88m21ln.fsf@telia.com","subject":"Re: Stacked GIT 0.3 (now more Quilt-like)","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2005-07-04T20:42:46Z","receivedAt":"2005-07-04T20:42:46Z","isPatch":false,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"On Mon, 2005-07-04 at 14:32 +0200, Peter Osterlund wrote:\n> I agree with the other comments, it's probably not wise to rely on\n> wiggle, and wiggle sometimes makes a mess. However, it often does the\n> right thing, and with a configurable merge program and an undo\n> function, this should not be a problem. Just undo and try again if you\n> don't like the result.\n\nI uploaded a new snapshot (stgit-20050704.tar.gz) which has support for\nmerge tool configuration. It installs a default /etc/stgitrc file but\nyou can define your own options in ~/.stgitrc or .git/stgitrc (the\nlatter overrides the options in the earlier files). You can even define\nsomething like - 'diff3 ... || xxdiff ...' so that if one tool fails it\nwill try the next one (the whole command is executed with 'sh -c').\n\nI will try to write an 'undo' command in the next days.\n\n--\nCatalin\n"},{"id":"5736","messageId":"1120683255.6881.8.camel@localhost.localdomain","threadId":"1039","inReplyTo":"m3y88m21ln.fsf@telia.com","subject":"Re: Stacked GIT 0.3 (now more Quilt-like)","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2005-07-06T20:54:15Z","receivedAt":"2005-07-06T20:54:15Z","isPatch":false,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"On Mon, 2005-07-04 at 14:32 +0200, Peter Osterlund wrote:\n> I agree with the other comments, it's probably not wise to rely on\n> wiggle, and wiggle sometimes makes a mess. However, it often does the\n> right thing, and with a configurable merge program and an undo\n> function, this should not be a problem. Just undo and try again if you\n> don't like the result.\n\nIn the today's snapshot you can get the 'stg push --undo' command which\nreverts the result of a push operation (either failed or not). The patch\nis reverted to its previous state. It works even if you ran 'refresh'.\n\nThe current implementation does not remove the .older/.local/.remote\nfiles from the tree when undoing a push. I think I will first implement\na 'resolve' command which takes care of these files.\n\nAnyway, once I fully test the current state of stgit, I will make the\n0.4 release (probably this weekend).\n\n--\nCatalin\n"},{"id":"5770","messageId":"m38y0ictno.fsf@telia.com","threadId":"1039","inReplyTo":"1120683255.6881.8.camel@localhost.localdomain","subject":"Re: Stacked GIT 0.3 (now more Quilt-like)","fromName":"Peter Osterlund","fromEmail":"petero2@telia.com","sentAt":"2005-07-07T19:17:47Z","receivedAt":"2005-07-07T19:17:47Z","isPatch":false,"sender":{"key":"petero2@telia.com","avatar":null},"body":"Catalin Marinas <catalin.marinas@gmail.com> writes:\n\n> On Mon, 2005-07-04 at 14:32 +0200, Peter Osterlund wrote:\n> > I agree with the other comments, it's probably not wise to rely on\n> > wiggle, and wiggle sometimes makes a mess. However, it often does the\n> > right thing, and with a configurable merge program and an undo\n> > function, this should not be a problem. Just undo and try again if you\n> > don't like the result.\n> \n> In the today's snapshot you can get the 'stg push --undo' command which\n> reverts the result of a push operation (either failed or not). The patch\n> is reverted to its previous state. It works even if you ran 'refresh'.\n\nThanks, this seems to work as expected.\n\n> The current implementation does not remove the .older/.local/.remote\n> files from the tree when undoing a push. I think I will first implement\n> a 'resolve' command which takes care of these files.\n> \n> Anyway, once I fully test the current state of stgit, I will make the\n> 0.4 release (probably this weekend).\n\nI've found an unrelated problem. If I export patches with \"stg export\ndirname\", there are no diffs included in the patches. The patch\ndescription is all that is generated. If I omit the dirname parameter,\nthe export works correctly though.\n\n-- \nPeter Osterlund - petero2@telia.com\nhttp://web.telia.com/~u89404340\n"},{"id":"5776","messageId":"1120771342.7032.5.camel@localhost.localdomain","threadId":"1039","inReplyTo":"m38y0ictno.fsf@telia.com","subject":"Re: Stacked GIT 0.3 (now more Quilt-like)","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2005-07-07T21:22:22Z","receivedAt":"2005-07-07T21:22:22Z","isPatch":false,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"On Thu, 2005-07-07 at 21:17 +0200, Peter Osterlund wrote:\n> I've found an unrelated problem. If I export patches with \"stg export\n> dirname\", there are no diffs included in the patches. The patch\n> description is all that is generated. If I omit the dirname parameter,\n> the export works correctly though.\n\nOK, thanks. Fixed in the today's snapshot. I also added a 'resolved'\ncommand to mark a solved conflict. 'stg status' also shows the conflicts\nand 'refresh', 'push', 'pop' fail if there are unresolved conflicts. You\ncan override this by setting 'autoresolved: yes' in the stgitrc file and\na 'refresh' command marks all the conflicts as solved automatically (I\nstill need to find some time to write a tutorial for StGIT).\n\nCatalin\n"},{"id":"5798","messageId":"m31x6acdcl.fsf@telia.com","threadId":"1039","inReplyTo":"1119994003.9631.6.camel@localhost.localdomain","subject":"Re: Stacked GIT 0.3 (now more Quilt-like)","fromName":"Peter Osterlund","fromEmail":"petero2@telia.com","sentAt":"2005-07-08T01:10:02Z","receivedAt":"2005-07-08T01:10:02Z","isPatch":false,"sender":{"key":"petero2@telia.com","avatar":null},"body":"Catalin Marinas <catalin.marinas@gmail.com> writes:\n\n> A new StGIT release is available from http://procode.org/stgit/\n\nI think it would be good if it was possible to include diffstat output\nin exported patches, something like this:\n\n\nAdded possibility to include diffstat output in exported patches.\n\nSigned-off-by: Peter Osterlund <petero2@telia.com>\n---\n\n b/stgit/git.py  |   22 ++++++++++++++++++++++\n b/stgit/main.py |    2 ++\n 2 files changed, 24 insertions(+)\n\ndiff --git a/stgit/git.py b/stgit/git.py\n--- a/stgit/git.py\n+++ b/stgit/git.py\n@@ -345,6 +345,28 @@ def diff(files = [], rev1 = 'HEAD', rev2\n                      % (rev1, files_str, extra_args)) != 0:\n             raise GitException, 'git-diff-cache failed'\n \n+def diffstat(files = [], rev1 = 'HEAD', rev2 = None):\n+    \"\"\"Return the diffstat between rev1 and rev2\n+    \"\"\"\n+    files_str = reduce(lambda x, y: x + ' ' + y, files, '')\n+\n+    os.system('git-update-cache --refresh > /dev/null')\n+\n+    if rev2:\n+        f = os.popen('git-diff-tree -p %s %s %s | diffstat -p0'\n+                     % (rev1, rev2, files_str), 'r')\n+        str = f.read()\n+        if f.close():\n+            raise GitException, 'git-diff-tree failed'\n+        return str\n+    else:\n+        f = os.popen('git-diff-cache -p %s %s | diffstat -p0'\n+                     % (rev1, files_str), 'r')\n+        str = f.read()\n+        if f.close():\n+            raise GitException, 'git-diff-cache failed'\n+        return str\n+\n def checkout(files = [], force = False):\n     \"\"\"Check out the given or all files\n     \"\"\"\ndiff --git a/stgit/main.py b/stgit/main.py\n--- a/stgit/main.py\n+++ b/stgit/main.py\n@@ -659,6 +659,8 @@ def export(parser, options, args):\n         patch = crt_series.get_patch(p)\n \n         tmpl_dict = {'description': patch.get_description().rstrip(),\n+                     'diffstat': git.diffstat(rev1 = __git_id('%s/bottom' % p),\n+                                              rev2 = __git_id('%s/top' % p)),\n                      'authname': patch.get_authname(),\n                      'authemail': patch.get_authemail(),\n                      'authdate': patch.get_authdate(),\n\n-- \nPeter Osterlund - petero2@telia.com\nhttp://web.telia.com/~u89404340\n"},{"id":"5799","messageId":"7vk6k2dr8i.fsf@assigned-by-dhcp.cox.net","threadId":"1039","inReplyTo":"m31x6acdcl.fsf@telia.com","subject":"Re: Stacked GIT 0.3 (now more Quilt-like)","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-07-08T01:24:45Z","receivedAt":"2005-07-08T01:24:45Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":">>>>> \"PO\" == Peter Osterlund <petero2@telia.com> writes:\n\nPO> I think it would be good if it was possible to include diffstat output\nPO> in exported patches, something like this:\n\nPO> Added possibility to include diffstat output in exported patches.\n\nAnd you wuold want to do things similarly to what others have\nalready done.  git-resolve-script uses \"git-apply --stat\" there,\ninstead of \"diffstat\", so people without diffstat installed can\nstill get the same information.\n\nEven if you want to stick to \"diffstat\", at least I would\nsuggest giving -p1, not -p0, to it; otherwise you would see b/\nlike what you have there.\n\nPO>  b/stgit/git.py  |   22 ++++++++++++++++++++++\nPO>  b/stgit/main.py |    2 ++\nPO>  2 files changed, 24 insertions(+)\n\nFurther, using \"git-apply --stat --summary\" would be nicer; this\nis something you cannot do with plain \"diffstat\".\n"},{"id":"5812","messageId":"m3d5ptlnoi.fsf@telia.com","threadId":"1039","inReplyTo":"7vk6k2dr8i.fsf@assigned-by-dhcp.cox.net","subject":"Re: Stacked GIT 0.3 (now more Quilt-like)","fromName":"Peter Osterlund","fromEmail":"petero2@telia.com","sentAt":"2005-07-08T08:14:21Z","receivedAt":"2005-07-08T08:14:21Z","isPatch":false,"sender":{"key":"petero2@telia.com","avatar":null},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> >>>>> \"PO\" == Peter Osterlund <petero2@telia.com> writes:\n> \n> PO> I think it would be good if it was possible to include diffstat output\n> PO> in exported patches, something like this:\n> \n> PO> Added possibility to include diffstat output in exported patches.\n> \n> And you wuold want to do things similarly to what others have\n> already done.  git-resolve-script uses \"git-apply --stat\" there,\n> instead of \"diffstat\", so people without diffstat installed can\n> still get the same information.\n\nThanks for the hint. Here is a replacement patch that uses git-apply\ninstead.\n\n\nAdded possibility to include diffstat output in exported patches.\n\nSigned-off-by: Peter Osterlund <petero2@telia.com>\n---\n\n stgit/git.py  |   23 +++++++++++++++++++++++\n stgit/main.py |    2 ++\n 2 files changed, 25 insertions(+), 0 deletions(-)\n\ndiff --git a/stgit/git.py b/stgit/git.py\n--- a/stgit/git.py\n+++ b/stgit/git.py\n@@ -345,6 +345,29 @@ def diff(files = [], rev1 = 'HEAD', rev2\n                      % (rev1, files_str, extra_args)) != 0:\n             raise GitException, 'git-diff-cache failed'\n \n+def diffstat(files = [], rev1 = 'HEAD', rev2 = None):\n+    \"\"\"Return the diffstat between rev1 and rev2\n+    \"\"\"\n+    files_str = reduce(lambda x, y: x + ' ' + y, files, '')\n+\n+    os.system('git-update-cache --refresh > /dev/null')\n+    ds_cmd = '| git-apply --stat --summary'\n+\n+    if rev2:\n+        f = os.popen('git-diff-tree -p %s %s %s %s'\n+                     % (rev1, rev2, files_str, ds_cmd), 'r')\n+        str = f.read()\n+        if f.close():\n+            raise GitException, 'git-diff-tree failed'\n+        return str\n+    else:\n+        f = os.popen('git-diff-cache -p %s %s %s'\n+                     % (rev1, files_str, ds_cmd), 'r')\n+        str = f.read()\n+        if f.close():\n+            raise GitException, 'git-diff-cache failed'\n+        return str\n+\n def checkout(files = [], force = False):\n     \"\"\"Check out the given or all files\n     \"\"\"\ndiff --git a/stgit/main.py b/stgit/main.py\n--- a/stgit/main.py\n+++ b/stgit/main.py\n@@ -659,6 +659,8 @@ def export(parser, options, args):\n         patch = crt_series.get_patch(p)\n \n         tmpl_dict = {'description': patch.get_description().rstrip(),\n+                     'diffstat': git.diffstat(rev1 = __git_id('%s/bottom' % p),\n+                                              rev2 = __git_id('%s/top' % p)),\n                      'authname': patch.get_authname(),\n                      'authemail': patch.get_authemail(),\n                      'authdate': patch.get_authdate(),\n\n-- \nPeter Osterlund - petero2@telia.com\nhttp://web.telia.com/~u89404340\n"},{"id":"5814","messageId":"tnxhdf5bq3b.fsf@arm.com","threadId":"1039","inReplyTo":"m3d5ptlnoi.fsf@telia.com","subject":"Re: Stacked GIT 0.3 (now more Quilt-like)","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2005-07-08T09:32:24Z","receivedAt":"2005-07-08T09:32:24Z","isPatch":false,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"Peter Osterlund <petero2@telia.com> wrote:\n> Added possibility to include diffstat output in exported patches.\n\nGreat. I had a plan to do this but I was busy with the push and\nresolved commands. I will apply this patch.\n\nThanks.\n\n-- \nCatalin\n"}]}