{"thread":{"id":"19796","subject":"[PATCH QGit RFC] Fix \"Save patch...\" on a commit range","startedAt":"2009-06-12T23:29:17Z","lastAt":"2009-06-16T18:48:00Z","messageCount":15,"participants":["Markus Heidelberg","Marco Costalba"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"116203","messageId":"1244849357-31166-1-git-send-email-markus.heidelberg@web.de","threadId":"19796","inReplyTo":null,"subject":"[PATCH QGit RFC] Fix \"Save patch...\" on a commit range","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-06-12T23:29:17Z","receivedAt":"2009-06-12T23:29:17Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Creating a patch series didn't work, because the SHA1 list was\ninterpreted in the wrong order.\n\nSigned-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n---\n\nTo find out if this problem was caused by a regression, I tested\n2e63608 (Format patch: use selected patches as a range, 2008-01-13),\nwhich changed the behavior of generating multiple patches and introduced\nthe lines that are now changed in my patch.\n\nBut that commit didn't work for me either. Now I don't think that it\ndidn't work for you at that time. Can this be a Qt problem?\n\n src/git.cpp |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/src/git.cpp b/src/git.cpp\nindex a20bf0d..0f18f61 100644\n--- a/src/git.cpp\n+++ b/src/git.cpp\n@@ -1577,9 +1577,9 @@ bool Git::formatPatch(SCList shaList, SCRef dirPath, SCRef remoteDir) {\n \tif (remote)\n \t\tworkDir = remoteDir; // run() uses workDir value\n \n-\t// shaList is ordered by newest to oldest\n-\trunCmd.append(\" \" + shaList.last());\n-\trunCmd.append(QString::fromLatin1(\"^..\") + shaList.first());\n+\t// shaList is ordered by oldest to newest\n+\trunCmd.append(\" \" + shaList.first());\n+\trunCmd.append(QString::fromLatin1(\"^..\") + shaList.last());\n \tbool ret = run(runCmd);\n \tworkDir = tmp;\n \treturn ret;\n-- \n1.6.3.2.248.g8cb59\n"},{"id":"116214","messageId":"e5bfff550906130013j3a9802cen48ac5828a2357bf1@mail.gmail.com","threadId":"19796","inReplyTo":"1244849357-31166-1-git-send-email-markus.heidelberg@web.de","subject":"Re: [PATCH QGit RFC] Fix \"Save patch...\" on a commit range","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2009-06-13T07:13:55Z","receivedAt":"2009-06-13T07:13:55Z","isPatch":true,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"On Sat, Jun 13, 2009 at 00:29, Markus\nHeidelberg<markus.heidelberg@web.de> wrote:\n> Creating a patch series didn't work, because the SHA1 list was\n> interpreted in the wrong order.\n>\n> Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n> ---\n\nI think they are generated in apply order as should be.\n\nAs example, from git repo we have the following revisions:\n\nGIT 1.6.3\nt4029: use sh instead of bash\nt4200: convert sed expression which operates on non-text file to perl\nt4200: remove two unnecessary lines\n\nNow if I select the 4 revisions and use \"Save patch...\" I have\n\n0001-t4200-remove-two-unnecessary-lines.patch\n0002-t4200-convert-sed-expression-which-operates-on-non.patch\n0003-t4029-use-sh-instead-of-bash.patch\n0004-GIT-1.6.3.patch\n\nThat is correct because if I go to apply the patches I have to apply\nin the reverse cronological order, from the oldest to the newest.\n"},{"id":"116221","messageId":"200906131211.39361.markus.heidelberg@web.de","threadId":"19796","inReplyTo":"e5bfff550906130013j3a9802cen48ac5828a2357bf1@mail.gmail.com","subject":"Re: [PATCH QGit RFC] Fix \"Save patch...\" on a commit range","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-06-13T10:11:38Z","receivedAt":"2009-06-13T10:11:38Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Marco Costalba, 13.06.2009:\n> On Sat, Jun 13, 2009 at 00:29, Markus\n> Heidelberg<markus.heidelberg@web.de> wrote:\n> > Creating a patch series didn't work, because the SHA1 list was\n> > interpreted in the wrong order.\n> >\n> > Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n> > ---\n> \n> I think they are generated in apply order as should be.\n> \n> As example, from git repo we have the following revisions:\n> \n> GIT 1.6.3\n> t4029: use sh instead of bash\n> t4200: convert sed expression which operates on non-text file to perl\n> t4200: remove two unnecessary lines\n> \n> Now if I select the 4 revisions and use \"Save patch...\" I have\n> \n> 0001-t4200-remove-two-unnecessary-lines.patch\n> 0002-t4200-convert-sed-expression-which-operates-on-non.patch\n> 0003-t4029-use-sh-instead-of-bash.patch\n> 0004-GIT-1.6.3.patch\n> \n> That is correct because if I go to apply the patches I have to apply\n> in the reverse cronological order, from the oldest to the newest.\n\nSorry, I didn't describe the problem proper. The problem was not about\nthe order of the created patches - it's that I can't create multiple\npatches at all.\n\nIf I only select 1 revision and use \"Save patch...\" I get\n0001-xyz.patch, which is correct.\n\nBut if I select 2 or more revisions, I don't get any patch file.\n\nFor example, with the following DAG:\n\n    A---B---C---D---E\n\nIf I select B to D and use \"Save patch...\", Qgit creates the following\ncommand:\n\n    git format-patch -o /home/markus D^..B\n\nbut D^..B obviously is empty.\n\nMy patch now changes it, so that this command is produced:\n\n    git format-patch -o /home/markus B^..D\n\nwhich generates 3 patches.\n\n\nOK, that was the state from yesterday. While testing a bit more, I can\nnotice some really strange behavior:\n\nI managed to get the following shaList in Git::formatPatch(): D, B, C\nwhich led to this revision range in the command: C^..D\nwhich produced 2 patches.\n\nAfter several tests it seems as if the revisions C and D are always the\nfirst and last of the shaList variable, if they are included in the\nselection. Selecting only the first and last revision with\nCtrl+LeftMouse instead of all including the ones in between with\nShift+LeftMouse works.\n\nHmm, I will look some more into it...\n\nMarkus\n"},{"id":"116222","messageId":"200906131302.43091.markus.heidelberg@web.de","threadId":"19796","inReplyTo":"e5bfff550906130013j3a9802cen48ac5828a2357bf1@mail.gmail.com","subject":"Re: [PATCH QGit RFC] Fix \"Save patch...\" on a commit range","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-06-13T11:02:42Z","receivedAt":"2009-06-13T11:02:42Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Marco Costalba, 13.06.2009:\n> On Sat, Jun 13, 2009 at 00:29, Markus\n> Heidelberg<markus.heidelberg@web.de> wrote:\n> > Creating a patch series didn't work, because the SHA1 list was\n> > interpreted in the wrong order.\n> >\n> > Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n> > ---\n> \n> I think they are generated in apply order as should be.\n> \n> As example, from git repo we have the following revisions:\n> \n> GIT 1.6.3\n> t4029: use sh instead of bash\n> t4200: convert sed expression which operates on non-text file to perl\n> t4200: remove two unnecessary lines\n> \n> Now if I select the 4 revisions and use \"Save patch...\" I have\n> \n> 0001-t4200-remove-two-unnecessary-lines.patch\n> 0002-t4200-convert-sed-expression-which-operates-on-non.patch\n> 0003-t4029-use-sh-instead-of-bash.patch\n> 0004-GIT-1.6.3.patch\n\nIn my git repository with some local branches I get this:\n\n0001-t4200-convert-sed-expression-which-operates-on-non-t.patch\n0002-t4029-use-sh-instead-of-bash.patch\n\nIn a plain newly created git repo with this command:\n\ngit clone --reference git git://git.kernel.org/pub/scm/git/git.git git-orig\n\nI don't get any patches. I haven't tried it explicitely now, but I guess\nmy patch would solve this for me.\n\nOK, if I now disable \"All branches\" in \"View->Select range...\", I get\nthe 2 patches from above again.\nBut in my git repo with local branches, it's the other way round...\n\nMarkus\n"},{"id":"116226","messageId":"e5bfff550906130412v6e223511tf0e20c685b21c490@mail.gmail.com","threadId":"19796","inReplyTo":"200906131302.43091.markus.heidelberg@web.de","subject":"Re: [PATCH QGit RFC] Fix \"Save patch...\" on a commit range","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2009-06-13T11:12:58Z","receivedAt":"2009-06-13T11:12:58Z","isPatch":true,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"On Sat, Jun 13, 2009 at 12:02, Markus\nHeidelberg<markus.heidelberg@web.de> wrote:\n>\n> OK, if I now disable \"All branches\" in \"View->Select range...\", I get\n> the 2 patches from above again.\n> But in my git repo with local branches, it's the other way round...\n>\n> Markus\n>\n\nOk. The point is that if I select 4 _consecutive_ revisions from any\nrepo and do \"Save as...\" then I see the 4 patches created in reverse\ncronoligical order as it should be.\n\nIf I select only two patches _non_ consecutives and I do \"Save as...\"\nI get the two patches + all the pacthes in between still in reverse\ncronological order.\n\nThis is with stock QGit 2.3, Windows version.\n\nHave you some problem to reproduce this behavior (that is intended to\nbe the correct one BTW) ?\n\nThanks\nMarco\n"},{"id":"116229","messageId":"200906131333.57725.markus.heidelberg@web.de","threadId":"19796","inReplyTo":"e5bfff550906130412v6e223511tf0e20c685b21c490@mail.gmail.com","subject":"Re: [PATCH QGit RFC] Fix \"Save patch...\" on a commit range","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-06-13T11:33:57Z","receivedAt":"2009-06-13T11:33:57Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Marco Costalba, 13.06.2009:\n> On Sat, Jun 13, 2009 at 12:02, Markus\n> Heidelberg<markus.heidelberg@web.de> wrote:\n> >\n> > OK, if I now disable \"All branches\" in \"View->Select range...\", I get\n> > the 2 patches from above again.\n> > But in my git repo with local branches, it's the other way round...\n> >\n> > Markus\n> >\n> \n> Ok. The point is that if I select 4 _consecutive_ revisions from any\n> repo and do \"Save as...\" then I see the 4 patches created in reverse\n> cronoligical order as it should be.\n\nI did the same as you: selected the 4 consecutive revisions. But I\ndidn't get 4 patches. Dependent on the state of the \"All branches\"\ncheckbox of the \"Range select\", I get 2 or 0 patches. The QStringList\nshaList is set wrong for me.\n\n> If I select only two patches _non_ consecutives and I do \"Save as...\"\n> I get the two patches + all the pacthes in between still in reverse\n> cronological order.\n\nYes, I'm aware of that. It shouldn't make a difference if I only select\nstart end end revision or if I select all revisions including the\nrevisions between start and end.\nAnd as I said earlier: the order of the patches is not my problem.\n\n> This is with stock QGit 2.3, Windows version.\n\nI tested with the latest qgit.git and with QGit 2.2 from my\ndistribution. All on Gentoo Linux.\n\nI just built QGit 2.3, this has the same problems.\n\n> Have you some problem to reproduce this behavior (that is intended to\n> be the correct one BTW) ?\n\nYes, I have :)\n\nCan you please try, if enabling/disabling the \"All branches\" checkbox\nmakes a difference for you?\n\nI have few time this weekend to respond. Have to play a concert with my\nband today and clean my bike for a triathlon tomorrow. I will try to\nreproduce on Windows, probably after this weekend.\n\nThanks, Markus\n"},{"id":"116231","messageId":"e5bfff550906130523w20087211l9e85378203dc6877@mail.gmail.com","threadId":"19796","inReplyTo":"200906131333.57725.markus.heidelberg@web.de","subject":"Re: [PATCH QGit RFC] Fix \"Save patch...\" on a commit range","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2009-06-13T12:23:09Z","receivedAt":"2009-06-13T12:23:09Z","isPatch":true,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"On Sat, Jun 13, 2009 at 12:33, Markus\nHeidelberg<markus.heidelberg@web.de> wrote:\n>\n> I have few time this weekend to respond. Have to play a concert with my\n> band today and clean my bike for a triathlon tomorrow. I will try to\n> reproduce on Windows, probably after this weekend.\n>\n\nAll your patches but the format-patch one have been applied and pushed.\n\nI will investigate further on the format-patch one....\n\nThanks\nMarco\n"},{"id":"116353","messageId":"200906152313.20002.markus.heidelberg@web.de","threadId":"19796","inReplyTo":"200906131333.57725.markus.heidelberg@web.de","subject":"Re: [PATCH QGit RFC] Fix \"Save patch...\" on a commit range","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-06-15T21:13:19Z","receivedAt":"2009-06-15T21:13:19Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Markus Heidelberg, 13.06.2009:\n> \n> I tested with the latest qgit.git and with QGit 2.2 from my\n> distribution. All on Gentoo Linux.\n> \n> I just built QGit 2.3, this has the same problems.\n> \n> [...]\n> \n> I will try to reproduce on Windows, probably after this weekend.\n\nSome news, tested with the 4 commits in git.git around v1.6.3 as before:\n\nIt works correctly with QGit-2.3 installed from the Windows installer\n(http://sourceforge.net/projects/qgit).\n\nIt works reversed when using a self-compiled qgit.\ngcc: mingw-gcc 3.4.5\nQt: 4.4.1\n\nReversed means, git-format-patch is invoked like this:\n    git format-patch v1.6.3..v1.6.3~3^\nand doesn't produce patch files, instead of:\n    git format-patch v1.6.3~3^..v1.6.3\n\nThe strange behaviour of getting only 2 patches on Linux, I couldn't\nreproduce on Windows.\n\nYou use MSVC, don't you? Can you please try with mingw? It would be\nreally helpful, if you could reproduce it.\n\nMarkus\n"},{"id":"116356","messageId":"e5bfff550906151425p2dacdcdasbae09af4ce34813d@mail.gmail.com","threadId":"19796","inReplyTo":"200906152313.20002.markus.heidelberg@web.de","subject":"Re: [PATCH QGit RFC] Fix \"Save patch...\" on a commit range","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2009-06-15T21:25:02Z","receivedAt":"2009-06-15T21:25:02Z","isPatch":true,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"On Mon, Jun 15, 2009 at 22:13, Markus\nHeidelberg<markus.heidelberg@web.de> wrote:\n> Markus Heidelberg, 13.06.2009:\n>>\n>> I tested with the latest qgit.git and with QGit 2.2 from my\n>> distribution. All on Gentoo Linux.\n>>\n>> I just built QGit 2.3, this has the same problems.\n>>\n>> [...]\n>>\n>> I will try to reproduce on Windows, probably after this weekend.\n>\n> Some news, tested with the 4 commits in git.git around v1.6.3 as before:\n>\n> It works correctly with QGit-2.3 installed from the Windows installer\n> (http://sourceforge.net/projects/qgit).\n>\n> It works reversed when using a self-compiled qgit.\n> gcc: mingw-gcc 3.4.5\n> Qt: 4.4.1\n>\n> Reversed means, git-format-patch is invoked like this:\n>    git format-patch v1.6.3..v1.6.3~3^\n> and doesn't produce patch files, instead of:\n>    git format-patch v1.6.3~3^..v1.6.3\n>\n> The strange behaviour of getting only 2 patches on Linux, I couldn't\n> reproduce on Windows.\n>\n> You use MSVC, don't you? Can you please try with mingw? It would be\n> really helpful, if you could reproduce it.\n>\n> Markus\n>\n>\n\nThis is really strange !\n\nYes I use MSVC, I cannot try mingw-gcc because I should recompile all\nQt with gcc.\n\nBut I can test on Linux tomorrow evening and see what's happens\nthere...but there is _nothing_ in the code that is platform dependent,\nsee Git::formatPatch() in git.cpp\n"},{"id":"116363","messageId":"e5bfff550906151445m2f38c3fw964e01251d9568b9@mail.gmail.com","threadId":"19796","inReplyTo":"e5bfff550906151425p2dacdcdasbae09af4ce34813d@mail.gmail.com","subject":"Re: [PATCH QGit RFC] Fix \"Save patch...\" on a commit range","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2009-06-15T21:45:45Z","receivedAt":"2009-06-15T21:45:45Z","isPatch":true,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"On Mon, Jun 15, 2009 at 22:25, Marco Costalba<mcostalba@gmail.com> wrote:\n>\n> This is really strange !\n>\n\nOk. This is a quick test that perhaps you could do.\n\nGit::formatPatch() get the list of selected revisions already ordered\nby its caller, MainImpl::ActMailFormatPatch_activated() in\nmainimpl.cpp, in this function the selected items are retrieved\ncalling ListView::getSelectedItems() in listview.cpp\n\nThere, finally, there is the call to the native Qt function that\ncollects the selected rows, QItemSelectionModel::selectedRows()\n\nThe returned list is takes as is by QGit and nevere reordered or\ntouched, so the order of the revisions belong directly on how\nQItemSelectionModel::selectedRows() returns the rows.\n\nNow the published windows version (and also teh Linux one) is compiled\nagainst Qt4.3.3, while you are using Qt4.4.1\n\n\nI have checked in the Qt documentation and I didn't found any point\nwhere the order of the returned rows is specified, I know in Qt4.3.3\nis from the top toward the bottom of the list, but perhaps in Qt4.4.1\nit has been changed.\n\nSo you could check, in ListView::getSelectedItems() how the rows are returned.\n"},{"id":"116365","messageId":"e5bfff550906151507t3f6ccf39j177f7c39d8495f5a@mail.gmail.com","threadId":"19796","inReplyTo":"e5bfff550906151445m2f38c3fw964e01251d9568b9@mail.gmail.com","subject":"Re: [PATCH QGit RFC] Fix \"Save patch...\" on a commit range","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2009-06-15T22:07:07Z","receivedAt":"2009-06-15T22:07:07Z","isPatch":true,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"On Mon, Jun 15, 2009 at 22:45, Marco Costalba<mcostalba@gmail.com> wrote:\n> On Mon, Jun 15, 2009 at 22:25, Marco Costalba<mcostalba@gmail.com> wrote:\n>>\n>> This is really strange !\n>>\n>\n\nI have prepared a possible patch, could you please test if fixes the\nproblem for you.\n\nPatch is in attachment.\n\nThanks\nMarco\n\n\nFrom 8e4ac4bf9b6c04b09e16a2a49b96f6bf4c75d2e7 Mon Sep 17 00:00:00 2001\nFrom: Marco Costalba <mcostalba@gmail.com>\nDate: Mon, 15 Jun 2009 23:01:42 +0100\nSubject: [PATCH] Fix format patch bad selected revision order\n\nWe cannot trust the order of selected items returned\nby QItemSelectionModel::selectedRows() that is used\nto call git format-patch.\n\nIt is not documented and could change with a new version\nof Qt libraries.\n\nSo manually reorder the selected revisions before to feed\ngit format-patch.\n\nSigned-off-by: Marco Costalba <mcostalba@gmail.com>\n---\n src/git.cpp |   15 ++++++++++++---\n 1 files changed, 12 insertions(+), 3 deletions(-)\n\ndiff --git a/src/git.cpp b/src/git.cpp\nindex 8546f6f..d55d1c2 100644\n--- a/src/git.cpp\n+++ b/src/git.cpp\n@@ -1577,9 +1577,18 @@ bool Git::formatPatch(SCList shaList, SCRef dirPath, SCRef remoteDir) {\n \tif (remote)\n \t\tworkDir = remoteDir; // run() uses workDir value\n \n-\t// shaList is ordered by newest to oldest\n-\trunCmd.append(\" \" + shaList.last());\n-\trunCmd.append(QString::fromLatin1(\"^..\") + shaList.first());\n+\t// Don't trust shaList order but reorder from newest to oldest\n+\tQStringList orderedShaList;\n+\tFOREACH_SL (it, shaList)\n+\t\tappendNamesWithId(orderedShaList, *it, QStringList(*it), true);\n+\n+\torderedShaList.sort();\n+\tQStringList::iterator itN(orderedShaList.begin());\n+\tfor ( ; itN != orderedShaList.end(); ++itN) // strip 'idx'\n+\t\t(*itN) = (*itN).section(' ', -1, -1);\n+\n+\trunCmd.append(\" \" + orderedShaList.last());\n+\trunCmd.append(QString::fromLatin1(\"^..\") + orderedShaList.first());\n \tbool ret = run(runCmd);\n \tworkDir = tmp;\n \treturn ret;\n-- \n1.6.1.9.g97c34\n\n"},{"id":"116369","messageId":"200906160144.02320.markus.heidelberg@web.de","threadId":"19796","inReplyTo":"e5bfff550906151445m2f38c3fw964e01251d9568b9@mail.gmail.com","subject":"Re: [PATCH QGit RFC] Fix \"Save patch...\" on a commit range","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-06-15T23:44:01Z","receivedAt":"2009-06-15T23:44:01Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Marco Costalba, 15.06.2009:\n> So you could check, in ListView::getSelectedItems() how the rows are returned.\n\nI added this snippet:\n\n-->8--\n\ndiff --git a/src/listview.cpp b/src/listview.cpp\nindex b2f4915..5bd1ee6 100644\n--- a/src/listview.cpp\n+++ b/src/listview.cpp\n@@ -171,10 +171,12 @@ void ListView::showIdValues() {\n \tviewport()->update();\n }\n \n+#include <QtDebug>\n void ListView::getSelectedItems(QStringList& selectedItems) {\n \n \tselectedItems.clear();\n \tQModelIndexList ml = selectionModel()->selectedRows();\n+\tqDebug() << ml;\n \tFOREACH (QModelIndexList, it, ml)\n \t\tselectedItems.append(sha((*it).row()));\n }\n\n--8<--\n\nand got the following for the 4 commits around v1.6.3 in git.git when\nenabled \"All branches\" (output prettified, was one line):\n\n(QModelIndex(2554,0,0x0,FileHistory(0xa06bfe8) )  ,\n QModelIndex(2553,0,0x0,FileHistory(0xa06bfe8) )  ,\n QModelIndex(2552,0,0x0,FileHistory(0xa06bfe8) )  ,\n QModelIndex(2551,0,0x0,FileHistory(0xa06bfe8) )  )\n\nHere it is ordered from oldest to newest. The newest commit (HEAD or\nworking tree) has '0'.\n\nThe same with \"All branches\" unchecked, just a bit smaller values:\n\n(QModelIndex(404,0,0x0,FileHistory(0xa06bfe8) )  ,\n QModelIndex(403,0,0x0,FileHistory(0xa06bfe8) )  ,\n QModelIndex(402,0,0x0,FileHistory(0xa06bfe8) )  ,\n QModelIndex(401,0,0x0,FileHistory(0xa06bfe8) )  )\n\nBut try with selecting many commits, for example v1.6.3..origin/master\n(fewer are sufficient). The order has a pattern, but it's not sorted at\nall.\n\nOr selecting only two commits v1.6.3 and origin/master prints this for\nme, ordered from newest to oldest this time:\n\n(QModelIndex(16,0,0x0,FileHistory(0xa06bfe8) )  ,\n QModelIndex(401,0,0x0,FileHistory(0xa06bfe8) )  )\n"},{"id":"116370","messageId":"200906160153.28018.markus.heidelberg@web.de","threadId":"19796","inReplyTo":"e5bfff550906151507t3f6ccf39j177f7c39d8495f5a@mail.gmail.com","subject":"Re: [PATCH QGit RFC] Fix \"Save patch...\" on a commit range","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-06-15T23:53:27Z","receivedAt":"2009-06-15T23:53:27Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Marco Costalba, 16.06.2009:\n> On Mon, Jun 15, 2009 at 22:45, Marco Costalba<mcostalba@gmail.com> wrote:\n> > On Mon, Jun 15, 2009 at 22:25, Marco Costalba<mcostalba@gmail.com> wrote:\n> >>\n> >> This is really strange !\n> >>\n> >\n> \n> I have prepared a possible patch, could you please test if fixes the\n> problem for you.\n\nYes, it works. Thanks. Would it make sense and be possible to fix it\ndirectly in ListView::getSelectedItems()?\n\nBTW, a nice way to see the created git-format-patch command without\nmodifying the sources is to use a directory with spaces, which is not\nhandled correctly by qgit.\n\nMarkus\n"},{"id":"116387","messageId":"e5bfff550906152310m1dc92bf7vf73fdb8f925e2fb7@mail.gmail.com","threadId":"19796","inReplyTo":"200906160153.28018.markus.heidelberg@web.de","subject":"Re: [PATCH QGit RFC] Fix \"Save patch...\" on a commit range","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2009-06-16T06:10:36Z","receivedAt":"2009-06-16T06:10:36Z","isPatch":true,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"On Tue, Jun 16, 2009 at 00:53, Markus\nHeidelberg<markus.heidelberg@web.de> wrote:\n>\n> Yes, it works. Thanks. Would it make sense and be possible to fix it\n> directly in ListView::getSelectedItems()?\n>\n\nI am not sure it is a problem of the selected items set. Unfortunatly\nit is not ordered, but actually this was not documented, so it was my\nbad to assume rows are always ordered because it happens they are\nsorted with Qt4.3.3\n\nAnd also ordering in Git::formatPatch() is easier because the \"tools\"\nlike appendNamesWithId() are already there and only there.\n\nAnother reason is that is Git::formatPatch() that needs the rows to be\nordered, so has a sense to do it there where is needed. Of corse if\nother places of QGit requires that the rows returned by\nListView::getSelectedItems() should be ordered then we can move the\nordering in ListView::getSelectedItems() as you suggest, or, even\nbetter, move the ordering in ListView::getSelectedItems() but from\nthere call a new helper function Git::sortShaByIndex() that does the\nwork and is defined in git.cpp because should use internal information\nlike the index and call directly the sha database.\n\nYes, a possible cleanup / reformat job could be to:\n\n- Add a new public helper function Git::sortShaByIndex() defined in git.cpp\n\n- Call from ListView::getSelectedItems() when we get the list of sha\nuser as select\n\n- Document ListView::getSelectedItems() always returns a list of ordered sha's\n\n\n> BTW, a nice way to see the created git-format-patch command without\n> modifying the sources is to use a directory with spaces, which is not\n> handled correctly by qgit.\n>\n\n\n????\n\nI cannot test now, but this seems a bug.\n"},{"id":"116431","messageId":"200906162048.00849.markus.heidelberg@web.de","threadId":"19796","inReplyTo":"e5bfff550906152310m1dc92bf7vf73fdb8f925e2fb7@mail.gmail.com","subject":"Re: [PATCH QGit RFC] Fix \"Save patch...\" on a commit range","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-06-16T18:48:00Z","receivedAt":"2009-06-16T18:48:00Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Marco Costalba, 16.06.2009:\n> On Tue, Jun 16, 2009 at 00:53, Markus\n> Heidelberg<markus.heidelberg@web.de> wrote:\n> >\n> > Yes, it works. Thanks. Would it make sense and be possible to fix it\n> > directly in ListView::getSelectedItems()?\n> \n> Another reason is that is Git::formatPatch() that needs the rows to be\n> ordered, so has a sense to do it there where is needed.\n\nListView::mouseMoveEvent() needs it as well, I just tested\ncherry-picking revisions per drag-and-drop and it was applied in the\nwrong order.\n\nI have never used stgit, but isn't MainImpl::ActPush_activated() and\nMainImpl::ActPop_activated() affected in the same way?\n\n> Of corse if\n> other places of QGit requires that the rows returned by\n> ListView::getSelectedItems() should be ordered then we can move the\n> ordering in ListView::getSelectedItems() as you suggest, or, even\n> better, move the ordering in ListView::getSelectedItems() but from\n> there call a new helper function Git::sortShaByIndex() that does the\n> work and is defined in git.cpp because should use internal information\n> like the index and call directly the sha database.\n> \n> Yes, a possible cleanup / reformat job could be to:\n> \n> - Add a new public helper function Git::sortShaByIndex() defined in git.cpp\n> \n> - Call from ListView::getSelectedItems() when we get the list of sha\n> user as select\n> \n> - Document ListView::getSelectedItems() always returns a list of ordered sha's\n\nI guess this is the right solution.\n\n> > BTW, a nice way to see the created git-format-patch command without\n> > modifying the sources is to use a directory with spaces, which is not\n> > handled correctly by qgit.\n> >\n> \n> \n> ????\n> \n> I cannot test now, but this seems a bug.\n\nI was not clear enough, but yes, it's a bug - with a usable side effect :)\n\nMarkus\n"}]}