{"thread":{"id":"10636","subject":"[PATCH qgit] Add support for --early-output option of git log command","startedAt":"2007-11-04T10:25:41Z","lastAt":"2007-11-04T18:15:40Z","messageCount":3,"participants":["Marco Costalba","Michael J. Cohen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"58239","messageId":"e5bfff550711040225ne67c907r2023b1354c35f35@mail.gmail.com","threadId":"10636","inReplyTo":null,"subject":"[PATCH qgit] Add support for --early-output option of git log command","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2007-11-04T10:25:41Z","receivedAt":"2007-11-04T10:25:41Z","isPatch":true,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"With this option 'git log' outputs the first commits\nas soon as they are ready in order to be able to show at\nleast something quickly, even if the full output may take\nlonger to generate.\n\nAt the end of the reordering correct revisions are re-sent.\n\nThis avoid the user to wait in front a blank screen for\nseveral seconds in case of big repos and cold chaches.\n\nSTGit repositories are still not correctly handled, and\nfile history (annotation) does not uses, still, this new\n--early-output feature.\n\nSigned-off-by: Marco Costalba <mcostalba@gmail.com>\n---\n\nPatch to apply on top of current qgit-2.0 at\n\ngit://git.kernel.org/pub/scm/qgit/qgit4.git\n\n\n src/common.h        |    2 +-\n src/git.cpp         |   12 ++++++++----\n src/git.h           |    3 ++-\n src/git_startup.cpp |   39 +++++++++++++++----\n 4 files changed, 46 insertions(+), 10 deletions(-)\n\ndiff --git a/src/common.h b/src/common.h\nindex 198348e..de3cb7d 100644\n--- a/src/common.h\n+++ b/src/common.h\n@@ -289,7 +289,7 @@ namespace QGit {\n class Rev {\n \t// prevent implicit C++ compiler defaults\n \tRev();\n-\tRev(const Rev&);\n+// \tRev(const Rev&);\n \tRev& operator=(const Rev&);\n public:\n \tRev(const QByteArray& b, uint s, int idx, int* next, bool withDiff)\ndiff --git a/src/git.cpp b/src/git.cpp\nindex d273c60..ef9b627 100644\n--- a/src/git.cpp\n+++ b/src/git.cpp\n@@ -73,9 +73,11 @@ const QString FileHistory::sha(int row) const {\n \treturn (row < 0 || row >= _rowCnt ? \"\" : revOrder.at(row));\n }\n\n-void FileHistory::clear() {\n+void FileHistory::clear(bool earlyOutput) {\n+\n+\tif (!earlyOutput)\n+\t\tgit->cancelDataLoading(this);\n\n-\tgit->cancelDataLoading(this);\n \tqDeleteAll(revs);\n \trevs.clear();\n \trevOrder.clear();\n@@ -83,9 +85,11 @@ void FileHistory::clear() {\n \tlns->clear();\n \tfNames.clear();\n \tcurFNames.clear();\n-\tqDeleteAll(rowData);\n-\trowData.clear();\n\n+\tif (!earlyOutput) {\n+\t\tqDeleteAll(rowData);\n+\t\trowData.clear();\n+\t}\n \tif (testFlag(REL_DATE_F)) {\n \t\t_secs = QDateTime::currentDateTime().toTime_t();\n \t\t_headerInfo[4] = \"Last Change\";\ndiff --git a/src/git.h b/src/git.h\nindex de014e0..92879fb 100644\n--- a/src/git.h\n+++ b/src/git.h\n@@ -27,7 +27,7 @@ Q_OBJECT\n public:\n \tFileHistory(QObject* parent, Git* git);\n \t~FileHistory();\n-\tvoid clear();\n+\tvoid clear(bool earlyOutput = false);\n \tconst QString sha(int row) const;\n \tint row(SCRef sha) const;\n \tconst QStringList fileNames() const { return fNames; }\n@@ -251,6 +251,7 @@ private:\n \tbool startParseProc(SCList initCmd, FileHistory* fh, SCRef buf);\n \tbool tryFollowRenames(FileHistory* fh);\n \tbool populateRenamedPatches(SCRef sha, SCList nn, FileHistory* fh,\nQStringList* on, bool bt);\n+\tvoid doEarlyOutput(Rev* rev, int* start);\n \tint addChunk(FileHistory* fh, const QByteArray& ba, int ofs);\n \tvoid parseDiffFormat(RevFile& rf, SCRef buf);\n \tvoid parseDiffFormatLine(RevFile& rf, SCRef line, int parNum);\ndiff --git a/src/git_startup.cpp b/src/git_startup.cpp\nindex 3faa059..df272fc 100644\n--- a/src/git_startup.cpp\n+++ b/src/git_startup.cpp\n@@ -492,7 +492,9 @@ bool Git::startRevList(SCList args, FileHistory* fh) {\n \t   the file deletion revision.\n \t*/\n \t\tinitCmd << QString(\"-r -m -p --full-index\").split(' ');\n-\t}\n+\t} else\n+\t\tinitCmd << QString(\"--early-output\");\n+\n \treturn startParseProc(initCmd + args, fh, QString());\n }\n\n@@ -839,13 +841,38 @@ void Git::loadFileNames() {\n \tindexTree();\n }\n\n+void Git::doEarlyOutput(Rev* rev, int* start) {\n+\n+\tdelete rev;\n+\t*start += QString(\"Final output:\\n\").length();\n+\n+\tRev* cl = NULL;\n+\tconst Rev* r = revLookup(ZERO_SHA);\n+\tif (r)\n+\t\tcl = new Rev(*r); // copy working dir revision\n+\n+\trevData->clear(true); // keep row QByteArray data\n+\n+\tif (cl) { // re-add working dir revision\n+\t\trevData->revs.insert(ZERO_SHA, cl);\n+\t\trevData->revOrder.append(ZERO_SHA);\n+\t}\n+}\n+\n int Git::addChunk(FileHistory* fh, const QByteArray& ba, int start) {\n\n \tRevMap& r = fh->revs;\n \tint nextStart;\n+\tRev* rev;\n\n-\t// only here we create a new rev\n-\tRev* rev = new Rev(ba, start, fh->revOrder.count(), &nextStart,\n!isMainHistory(fh));\n+\tdo {\n+\t\t// only here we create a new rev\n+\t\trev = new Rev(ba, start, fh->revOrder.count(), &nextStart,\n!isMainHistory(fh));\n+\n+\t\tif (nextStart == -2)\n+\t\t\tdoEarlyOutput(rev, &start);\n+\n+\t} while (nextStart == -2);\n\n \tif (nextStart == -1) { // half chunk detected\n \t\tdelete rev;\n@@ -1331,6 +1358,7 @@ int Rev::indexData(bool quick, bool withDiff) const {\n /*\n   This is what 'git log' produces:\n\n+\t- a possible one line with \"Final output:\\n\" in case of --early-output option\n \t- one line with \"commit\" + sha + an arbitrary amount of parent's sha, in case\n \t  of a merge in file history the line terminates with \"(from <sha of parent>)\"\n \t- one line with \"log size\" + len of this record\n@@ -1346,9 +1374,12 @@ int Rev::indexData(bool quick, bool withDiff) const {\n \t- a terminating '\\0'\n */\n \tint last = ba.size() - 1;\n-\tif (start > last)\n+\tif (start > last) // offset 'start' points to the char after \"commit \"\n \t\treturn -1;\n\n+\tif (uint(ba.at(start) == 'u'))\n+\t\treturn -2; // \"Final output:\", let caller handle this\n+\n \t// take in account --boundary and --left-right options\n \tstartOfs = uint(ba.at(start) == '-' || ba.at(start) == '<' ||\nba.at(start) == '>');\n \tboundary = startOfs && ba.at(start) == '-';\n-- \n1.5.3.5.532.g5c38-dirty\n"},{"id":"58284","messageId":"34C93069-06F8-44DA-A18F-EE36BB457ABC@mac.com","threadId":"10636","inReplyTo":"e5bfff550711040225ne67c907r2023b1354c35f35@mail.gmail.com","subject":"Re: [PATCH qgit] Add support for --early-output option of git log command","fromName":"Michael J. Cohen","fromEmail":"michaeljosephcohen@mac.com","sentAt":"2007-11-04T17:12:23Z","receivedAt":"2007-11-04T17:12:23Z","isPatch":true,"sender":{"key":"michaeljosephcohen@mac.com","avatar":null},"body":"On Nov 4, 2007, at 5:25 AM, Marco Costalba wrote:\n\n> \tbool populateRenamedPatches(SCRef sha, SCList nn, FileHistory* fh,\n> QStringList* on, bool bt);\n\n**** malformed patch at line 137: QStringList* on, bool bt);\n\nlooks like it was wrapped...\n\n-mjc\n"},{"id":"58288","messageId":"e5bfff550711041015i739ff6efpcbd6b5ec704e8c10@mail.gmail.com","threadId":"10636","inReplyTo":"34C93069-06F8-44DA-A18F-EE36BB457ABC@mac.com","subject":"Re: [PATCH qgit] Add support for --early-output option of git log command","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2007-11-04T18:15:40Z","receivedAt":"2007-11-04T18:15:40Z","isPatch":true,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"On 11/4/07, Michael J. Cohen <michaeljosephcohen@mac.com> wrote:\n> On Nov 4, 2007, at 5:25 AM, Marco Costalba wrote:\n>\n> >       bool populateRenamedPatches(SCRef sha, SCList nn, FileHistory* fh,\n> > QStringList* on, bool bt);\n>\n> **** malformed patch at line 137: QStringList* on, bool bt);\n>\n> looks like it was wrapped...\n>\n\nSorry, it's a problem with gmail, please tell me if you want me to\nresend as attachment or you fix the patch yourself.\n\nMarco\n"}]}