git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[QGIT PATCH/RFC]

From
AYAbdelrazak Younes <younes@lyx.org>
Date
Nov 4, 2009, 14:56 UTC
Message-ID
<4AF19630.2070402@lyx.org>
Hello Marco,

While recompiling latest qgit4, I stumbled accross this. I am not quite sure you used a QLatin1String instead of a QByteArray but the attached seems to work fine...

Anyway, I'll let you decide what do to with it.

Thanks for QGit, Abdel.

diff --git a/src/cache.cpp b/src/cache.cpp 
 

index af18fbf..2d9f415 100644 
 

--- a/src/cache.cpp 
 

+++ b/src/cache.cpp 
 

@@ -70,11 +70,11 @@ bool Cache::save(const QString& gitDir, const 
RevFileMap& rf, 

                 const ShaString& sha = it.key(); 
 

                 if (   sha == ZERO_SHA_RAW 
 

                     || sha == CUSTOM_SHA_RAW 
 

-                   || sha.latin1()[0] == 'A') // ALL_MERGE_FILES + rev 
sha 

+                   || sha.at(0) == 'A') // ALL_MERGE_FILES + rev sha 
 

                         continue; 
 


                 v.append(it.value());
-               buf.append(sha.latin1()).append('\0');
+               buf.append(sha);
                 newSize += 41;
                 if (newSize > bufSize) {
                         dbs("ASSERT in Cache::save, out of allocated 
space");
diff --git a/src/common.h b/src/common.h
index ceb62fb..0d65980 100644
--- a/src/common.h
+++ b/src/common.h
@@ -7,6 +7,7 @@
  #ifndef COMMON_H
  #define COMMON_H

+#include <QByteArray>
  #include <QColor>
  #include <QEvent>
  #include <QFont>
@@ -49,7 +50,7 @@ class QDataStream;
  class QProcess;
  class QSplitter;
  class QWidget;
-class ShaString;
+typedef QByteArray ShaString;

  // type shortcuts
  typedef const QString&              SCRef;
@@ -274,18 +275,6 @@ namespace QGit {
         extern const QString SCRIPT_EXT;
  }

-class ShaString : public QLatin1String {
-public:
-       inline ShaString() : QLatin1String(NULL) {}
-       inline ShaString(const ShaString& sha) : 
QLatin1String(sha.latin1()) {}
-       inline explicit ShaString(const char* sha) : QLatin1String(sha) {}
-
-       inline bool operator!=(const ShaString& o) const { return 
!operator==(o); }
-       inline bool operator==(const ShaString& o) const {
-
-               return (latin1() == o.latin1()) || !qstrcmp(latin1(), 
o.latin1());
-       }
-};

  class Rev {
         // prevent implicit C++ compiler defaults
diff --git a/src/git.cpp b/src/git.cpp
index 177b24a..afa5234 100644
--- a/src/git.cpp
+++ b/src/git.cpp
@@ -725,7 +725,7 @@ const Rev* Git::revLookup(SCRef sha, const 
FileHistory* fh) const {
  const Rev* Git::revLookup(const ShaString& sha, const FileHistory* fh) 
const {

         const RevMap& r = (fh ? fh->revs : revData->revs);
-       return (sha.latin1() ? r.value(sha) : NULL);
+       return (sha.isEmpty() ? NULL : r.value(sha));
  }

  bool Git::run(SCRef runCmd, QString* runOutput, QObject* receiver, 
SCRef buf) {
diff --git a/src/namespace_def.cpp b/src/namespace_def.cpp
index 80c2551..2960c36 100644
--- a/src/namespace_def.cpp
+++ b/src/namespace_def.cpp
@@ -95,7 +95,7 @@ static inline uint hexVal(const uchar* ch) {

  uint qHash(const ShaString& s) { // fast path, called 6-7 times per 
revision

-       const uchar* ch = reinterpret_cast<const uchar*>(s.latin1());
+       const uchar* ch = reinterpret_cast<const uchar*>(s.data());
         return (hexVal(ch     ) << 24)
              + (hexVal(ch +  2) << 20)
              + (hexVal(ch +  4) << 16)
Next: Marco Costalba
Message 1 of 10 in “[QGIT PATCH/RFC]”
  1. Abdelrazak Younes, Nov 4, 2009
  2. Marco CostalbaNov 5, 2009
  3. Abdelrazak YounesNov 5, 2009
  4. Abdelrazak YounesNov 5, 2009
  5. Abdelrazak YounesNov 5, 2009
  6. Abdelrazak YounesNov 5, 2009
  7. Marco CostalbaNov 5, 2009
  8. Marco CostalbaNov 5, 2009
  9. Abdelrazak YounesNov 6, 2009
  10. Abdelrazak YounesNov 6, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.