@@ -359,7 +359,7 @@ QJSValue Utils::Git::getNoteVersions(QJSEngine &engine, const Note ¬e) {
359359    git_revwalk_push_head (walker);
360360
361361    git_oid oid;
362-     QString previousContent;
362+     const   QString previousContent = note. getNoteText () ;
363363    bool  isFirst = true ;
364364    int  versionIndex = 0 ;
365365
@@ -375,6 +375,14 @@ QJSValue Utils::Git::getNoteVersions(QJSEngine &engine, const Note ¬e) {
375375                        const  char  *content = (const  char  *)git_blob_rawcontent (blob);
376376                        QString currentContent = QString::fromUtf8 (content);
377377
378+                         if  (isFirst && currentContent == previousContent) {
379+                             //  Skip the first version if it matches the current content
380+                             git_blob_free (blob);
381+                             git_tree_entry_free (entry);
382+                             isFirst = false ;
383+                             continue ;
384+                         }
385+ 
378386                        QJSValue version = engine.newObject ();
379387
380388                        //  Get commit timestamp
@@ -390,18 +398,12 @@ QJSValue Utils::Git::getNoteVersions(QJSEngine &engine, const Note ¬e) {
390398                        //  Store the content
391399                        version.setProperty (" data" 
392400
393-                         //  Generate diff HTML if not the first version
394-                         if  (!isFirst) {
395-                             QList<Diff> diffs = differ.diff_main (currentContent, previousContent);
396-                             differ.diff_cleanupSemantic (diffs);
397-                             QString diffHtml = differ.diff_prettyHtml (diffs);
398-                             version.setProperty (" diffHtml" 
399-                         } else  {
400-                             version.setProperty (" diffHtml" " " 
401-                             isFirst = false ;
402-                         }
401+                         //  Generate diff HTML
402+                         QList<Diff> diffs = differ.diff_main (previousContent, currentContent);
403+                         differ.diff_cleanupSemantic (diffs);
404+                         QString diffHtml = differ.diff_prettyHtml (diffs);
405+                         version.setProperty (" diffHtml" 
403406
404-                         previousContent = currentContent;
405407                        versions.setProperty (versionIndex++, version);
406408                        //                         versionsArray.setProperty(versionsArray.property("length").toInt(),
407409                        //                         version);
0 commit comments