~ubuntu-branches/ubuntu/precise/cmake/precise

« back to all changes in this revision

Viewing changes to Source/CTest/cmCTestGIT.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Modestas Vainius
  • Date: 2011-06-19 17:33:45 UTC
  • mfrom: (3.1.23 sid)
  • Revision ID: james.westby@ubuntu.com-20110619173345-f3oofqo7rjwvds2f
Tags: 2.8.5~rc2-1
* New upstream release.
* No longer repack upstream tarball and drop dfsg suffix from the version
  number. The tarball is DFSG clean now.
* Drop fixup_manpages.diff patch, merged upstream.
* Drop backport_test_order_fix.diff patch, was backported from upstream.
* Drop multiarch_basic_support.diff patch, merged upstream.
* Refresh screen-256color-bce.diff patch.
* Add spelling_formatting_fixes.diff which fixes a couple of new
  spelling / formatting errors.
* Override incorrect menu-icon-missing lintian warning properly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <ctype.h>
25
25
 
26
26
//----------------------------------------------------------------------------
 
27
static unsigned int cmCTestGITVersion(unsigned int epic, unsigned int major,
 
28
                                      unsigned int minor, unsigned int fix)
 
29
{
 
30
  // 1.6.5.0 maps to 10605000
 
31
  return fix + minor*1000 + major*100000 + epic*10000000;
 
32
}
 
33
 
 
34
//----------------------------------------------------------------------------
27
35
cmCTestGIT::cmCTestGIT(cmCTest* ct, std::ostream& log):
28
36
  cmCTestGlobalVC(ct, log)
29
37
{
30
38
  this->PriorRev = this->Unknown;
 
39
  this->CurrentGitVersion = 0;
31
40
}
32
41
 
33
42
//----------------------------------------------------------------------------
263
272
 
264
273
  std::string top_dir = this->FindTopDir();
265
274
  const char* git = this->CommandLineTool.c_str();
266
 
  char const* git_submodule[] = {git, "submodule", "update", 0};
 
275
  const char* recursive = "--recursive";
 
276
 
 
277
  // Git < 1.6.5.0 did not support --recursive
 
278
  if(this->GetGitVersion() < cmCTestGITVersion(1,6,5,0))
 
279
    {
 
280
    recursive = 0;
 
281
    // No need to require >= 1.6.5.0 if there are no submodules.
 
282
    if(cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str()))
 
283
      {
 
284
      this->Log << "Git < 1.6.5.0 cannot update submodules recursively\n";
 
285
      }
 
286
    }
 
287
 
 
288
  char const* git_submodule[] = {git, "submodule", "update", recursive, 0};
267
289
  OutputLogger submodule_out(this->Log, "submodule-out> ");
268
290
  OutputLogger submodule_err(this->Log, "submodule-err> ");
269
291
  return this->RunChild(git_submodule, &submodule_out, &submodule_err,
271
293
}
272
294
 
273
295
//----------------------------------------------------------------------------
 
296
unsigned int cmCTestGIT::GetGitVersion()
 
297
{
 
298
  if(!this->CurrentGitVersion)
 
299
    {
 
300
    const char* git = this->CommandLineTool.c_str();
 
301
    char const* git_version[] = {git, "--version", 0};
 
302
    std::string version;
 
303
    OneLineParser version_out(this, "version-out> ", version);
 
304
    OutputLogger version_err(this->Log, "version-err> ");
 
305
    unsigned int v[4] = {0,0,0,0};
 
306
    if(this->RunChild(git_version, &version_out, &version_err) &&
 
307
       sscanf(version.c_str(), "git version %u.%u.%u.%u",
 
308
              &v[0], &v[1], &v[2], &v[3]) >= 3)
 
309
      {
 
310
      this->CurrentGitVersion = cmCTestGITVersion(v[0], v[1], v[2], v[3]);
 
311
      }
 
312
    }
 
313
  return this->CurrentGitVersion;
 
314
}
 
315
 
 
316
//----------------------------------------------------------------------------
274
317
/* Diff format:
275
318
 
276
319
   :src-mode dst-mode src-sha1 dst-sha1 status\0