CVSTrac Legacy Code

Check-in [0b1a22dfae]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Need to prefix filenames with the module for browse to work correctly. Fortunately, we can strip it.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0b1a22dfae5fe6857c2acf78c975fb768d7c6615
User & Date: cpb 2015-06-04 18:55:01
Context
2015-06-17
13:04
We need to use the "full" commit id for the base too. check-in: 6de5916d35 user: root tags: trunk
2015-06-04
18:55
Need to prefix filenames with the module for browse to work correctly. Fortunately, we can strip it. check-in: 0b1a22dfae user: cpb tags: trunk
2015-05-25
16:12
Initial support for multiple GIT modules in a single GitTrac instance (i.e. conceptually similar to multiple CVS modules in a single CvsTrac). check-in: 8c72a44f1e user: cpb tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to git.c.

256
257
258
259
260
261
262









263
264
265
266
267
268
269
...
298
299
300
301
302
303
304










305
306
307
308
309
310
311
...
817
818
819
820
821
822
823




824
825
826
827
828
829
830
...
861
862
863
864
865
866
867





868
869
870
871
872
873
874
             zMode, zType, zObject, zPath);

      if( !strcmp(zType,"blob") ){
        int nIns = 0;
        int nDel = 0;

        nFiles ++;









        db_execute(
          "INSERT INTO filechng(cn,filename,vers,prevvers,chngtype,nins,ndel) "
          "VALUES(%d,'%q','%s','',1,%d,%d)",
          cn, zPath, zCommit, nIns, nDel);
        if( !skipInsertFile ) insert_file(zPath, cn);
      }
    }
................................................................................
      char cStatus, zPath[PATH_MAX];

      if( 0==fgets(zLine,sizeof(zLine),in) ) break;
      remove_newline(zLine);

      sscanf(zLine, "%*c%8s %8s %50[0-9a-fA-F] %50[0-9a-fA-F] %c %[^\t]",
             zSrcMode, zDstMode, zSrcObject, zDstObject, &cStatus, zPath);











      if( zSrcMode[1]=='0' || zDstMode[1]=='0' ){
        int nIns = 0;
        int nDel = 0;

        if( cStatus=='N' || cStatus=='A' ){
          if( !skipInsertFile ) insert_file(zPath, cn);
................................................................................
     zOldVers, sizeof(zOldVers) );
  parse_git_object( newCommit, zModule, sizeof(zModule),
     zNewVers, sizeof(zNewVers) );

  /* Find the command used to compute the file difference.*/
  azSubst[0] = "F";
  azSubst[1] = zFile;




  azSubst[2] = "V1";
  azSubst[3] = zOldVers;
  azSubst[4] = "V2";
  azSubst[5] = zNewVers;
  azSubst[6] = "RP";
  azSubst[7] = zModule[0]
    ? mprintf("%s/%s", db_config("cvsroot", ""), zModule)
................................................................................
  const char* zPath
){
  FILE *in;
  char zLine[PATH_MAX*2];
  char *zCmd;

  if( zCommit==0 || zCommit[0]==0 || zPath==0 || zPath[0]==0 ) return 0;





    
  zCmd = mprintf("GIT_DIR='%s/%s' git ls-tree -r '%s' '%s'",
                 zGitDir, zModule ? quotable_string(zModule) : "",
                 quotable_string(zCommit), quotable_string(zPath));
  in = popen(zCmd,"r");
  if( in==0 ){
    err_pipe("Reading tree",zCmd);







>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>







 







>
>
>
>







 







>
>
>
>
>







256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
...
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
...
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
...
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
             zMode, zType, zObject, zPath);

      if( !strcmp(zType,"blob") ){
        int nIns = 0;
        int nDel = 0;

        nFiles ++;
        if( zModule[0] ) {
          /* We need the module prepended to any filenames that end up
           * in the db or the browse stuff chokes. We'll handle it when
           * we deal with filenames.
           */
          char zTPath[PATH_MAX];
          snprintf(zTPath,sizeof(zTPath),"%s/%s",zModule,zPath);
          strcpy(zPath,zTPath);
        }
        db_execute(
          "INSERT INTO filechng(cn,filename,vers,prevvers,chngtype,nins,ndel) "
          "VALUES(%d,'%q','%s','',1,%d,%d)",
          cn, zPath, zCommit, nIns, nDel);
        if( !skipInsertFile ) insert_file(zPath, cn);
      }
    }
................................................................................
      char cStatus, zPath[PATH_MAX];

      if( 0==fgets(zLine,sizeof(zLine),in) ) break;
      remove_newline(zLine);

      sscanf(zLine, "%*c%8s %8s %50[0-9a-fA-F] %50[0-9a-fA-F] %c %[^\t]",
             zSrcMode, zDstMode, zSrcObject, zDstObject, &cStatus, zPath);

      if( zModule[0] ) {
        /* We need the module prepended to any filenames that end up
         * in the db or the browse stuff chokes. We'll handle it when
         * we deal with filenames.
         */
        char zTPath[PATH_MAX];
        snprintf(zTPath,sizeof(zTPath),"%s/%s",zModule,zPath);
        strcpy(zPath,zTPath);
      }

      if( zSrcMode[1]=='0' || zDstMode[1]=='0' ){
        int nIns = 0;
        int nDel = 0;

        if( cStatus=='N' || cStatus=='A' ){
          if( !skipInsertFile ) insert_file(zPath, cn);
................................................................................
     zOldVers, sizeof(zOldVers) );
  parse_git_object( newCommit, zModule, sizeof(zModule),
     zNewVers, sizeof(zNewVers) );

  /* Find the command used to compute the file difference.*/
  azSubst[0] = "F";
  azSubst[1] = zFile;
  if( zModule[0] && !strncmp(zFile,zModule,strlen(zModule)) ) {
    /* skip module prepended to filename */
    azSubst[1] = zFile + strlen(zModule)+1;
  }
  azSubst[2] = "V1";
  azSubst[3] = zOldVers;
  azSubst[4] = "V2";
  azSubst[5] = zNewVers;
  azSubst[6] = "RP";
  azSubst[7] = zModule[0]
    ? mprintf("%s/%s", db_config("cvsroot", ""), zModule)
................................................................................
  const char* zPath
){
  FILE *in;
  char zLine[PATH_MAX*2];
  char *zCmd;

  if( zCommit==0 || zCommit[0]==0 || zPath==0 || zPath[0]==0 ) return 0;

  if( zModule && !strncmp(zPath,zModule,strlen(zModule)) ) {
    /* skip module prepended to filename */
    zPath = zPath + strlen(zModule)+1;
  }
    
  zCmd = mprintf("GIT_DIR='%s/%s' git ls-tree -r '%s' '%s'",
                 zGitDir, zModule ? quotable_string(zModule) : "",
                 quotable_string(zCommit), quotable_string(zPath));
  in = popen(zCmd,"r");
  if( in==0 ){
    err_pipe("Reading tree",zCmd);