浏览代码

Merge branch 'ctest-git-empty-commits'

Brad King 15 年之前
父节点
当前提交
566bb2d078
共有 4 个文件被更改,包括 32 次插入4 次删除
  1. 9 0
      Source/CTest/cmCTestGIT.cxx
  2. 4 2
      Source/cmProcessTools.cxx
  3. 1 0
      Source/cmProcessTools.h
  4. 18 2
      Tests/CTestUpdateGIT.cmake.in

+ 9 - 0
Source/CTest/cmCTestGIT.cxx

@@ -317,8 +317,12 @@ protected:
    \n
    \n
        Log message indented by (4) spaces\n
        Log message indented by (4) spaces\n
        (even blank lines have the spaces)\n
        (even blank lines have the spaces)\n
+ [[
    \n
    \n
    [Diff format]
    [Diff format]
+ OR
+   \0
+ ]]
 
 
    The header may have more fields.  See 'git help diff-tree'.
    The header may have more fields.  See 'git help diff-tree'.
 */
 */
@@ -372,6 +376,11 @@ private:
     {
     {
     if(this->Line.empty())
     if(this->Line.empty())
       {
       {
+      if(this->Section == SectionBody && this->LineEnd == '\0')
+        {
+        // Skip SectionDiff
+        this->NextSection();
+        }
       this->NextSection();
       this->NextSection();
       }
       }
     else
     else

+ 4 - 2
Source/cmProcessTools.cxx

@@ -44,7 +44,7 @@ void cmProcessTools::RunProcess(struct cmsysProcess_s* cp,
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
 cmProcessTools::LineParser::LineParser(char sep, bool ignoreCR):
 cmProcessTools::LineParser::LineParser(char sep, bool ignoreCR):
-  Separator(sep), IgnoreCR(ignoreCR), Log(0), Prefix(0)
+  Separator(sep), IgnoreCR(ignoreCR), Log(0), Prefix(0), LineEnd('\0')
 {
 {
 }
 }
 
 
@@ -61,8 +61,10 @@ bool cmProcessTools::LineParser::ProcessChunk(const char* first, int length)
   const char* last = first + length;
   const char* last = first + length;
   for(const char* c = first; c != last; ++c)
   for(const char* c = first; c != last; ++c)
     {
     {
-    if(*c == this->Separator)
+    if(*c == this->Separator || *c == '\0')
       {
       {
+      this->LineEnd = *c;
+
       // Log this line.
       // Log this line.
       if(this->Log && this->Prefix)
       if(this->Log && this->Prefix)
         {
         {

+ 1 - 0
Source/cmProcessTools.h

@@ -55,6 +55,7 @@ public:
     bool IgnoreCR;
     bool IgnoreCR;
     std::ostream* Log;
     std::ostream* Log;
     const char* Prefix;
     const char* Prefix;
+    char LineEnd;
     std::string Line;
     std::string Line;
     virtual bool ProcessChunk(const char* data, int length);
     virtual bool ProcessChunk(const char* data, int length);
 
 

+ 18 - 2
Tests/CTestUpdateGIT.cmake.in

@@ -131,6 +131,22 @@ run_child(
   COMMAND ${GIT} submodule update
   COMMAND ${GIT} submodule update
   )
   )
 
 
+# Save the first revision name.
+execute_process(
+  WORKING_DIRECTORY ${TOP}/user-source
+  COMMAND ${GIT} rev-parse HEAD
+  OUTPUT_VARIABLE revision1
+  OUTPUT_STRIP_TRAILING_WHITESPACE
+  )
+
+#-----------------------------------------------------------------------------
+# Create an empty commit.
+message("Creating empty commit...")
+run_child(
+  WORKING_DIRECTORY ${TOP}/user-source
+  COMMAND ${GIT} commit --allow-empty -m "Empty commit"
+  )
+
 #-----------------------------------------------------------------------------
 #-----------------------------------------------------------------------------
 # Make changes in the working tree.
 # Make changes in the working tree.
 message("Changing content...")
 message("Changing content...")
@@ -196,7 +212,7 @@ macro(rewind_source src_dir)
   message("Backing up to revision 1...")
   message("Backing up to revision 1...")
   run_child(
   run_child(
     WORKING_DIRECTORY ${TOP}/${src_dir}
     WORKING_DIRECTORY ${TOP}/${src_dir}
-    COMMAND ${GIT} reset --hard origin/master~2
+    COMMAND ${GIT} reset --hard ${revision1}
     )
     )
   run_child(
   run_child(
     WORKING_DIRECTORY ${TOP}/${src_dir}
     WORKING_DIRECTORY ${TOP}/${src_dir}
@@ -261,7 +277,7 @@ execute_process(
   )
   )
 execute_process(
 execute_process(
   WORKING_DIRECTORY \"${TOP}/dash-source\"
   WORKING_DIRECTORY \"${TOP}/dash-source\"
-  COMMAND \"${GIT}\" reset --hard master~2
+  COMMAND \"${GIT}\" reset --hard ${revision1}
   )
   )
 execute_process(
 execute_process(
   WORKING_DIRECTORY \"${TOP}/dash-source\"
   WORKING_DIRECTORY \"${TOP}/dash-source\"