CVSTrac Legacy Code

Check-in [ec1de0af03]
Login

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

Overview
Comment:the dashed-forms of the git commands are now not reliably avaiable.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ec1de0af03c06c834b09c45fdbbca174442eb71e
User & Date: cpb 2009-03-10 01:19:03
Context
2009-03-10
03:06
(#791) first stab at a generic report RSS feed. Item titles need some fine tuning and there's no way to determine dates, but otherwise it seems sane. check-in: afb2fee9b7 user: cpb tags: trunk
01:19
the dashed-forms of the git commands are now not reliably avaiable. check-in: ec1de0af03 user: cpb tags: trunk
2009-03-08
00:14
(#791) allow individual pages to have their own RSS feeds

This means we need to allow generic RSS substitutions in the header. To that end, we add %R for the URL and %F for the title (a distinct feed needs a distinct title).

Figuring out whether a page has its own RSS feed is done by looking for an "RSS" entry in the action bar. The title is built from the project name and the current page title.

Then, to override the default (timeline) RSS feed on any given page, it's just a matter of doing something like:

common_add_action_item(mprintf("tkthistory.rss?tn=%d",tn), "RSS");

and the header output logic will just pick it up. check-in: c72535f17c user: cpb tags: trunk

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to git.c.

81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
...
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
...
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
...
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
...
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
...
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
...
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
...
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
  char zComment[10000];

  assert(nDate);

  *pzAuthor = 0;
  *pzComment = 0;

  zCmd = mprintf("GIT_DIR='%s' git-cat-file commit '%s' 2>&1",
                 zGitDir, zObject);
  if( zCmd==0 ) return 0;

  in = popen(zCmd, "r");
  if( in==0 ){
    err_pipe("Reading commit",zCmd);
    free(zCmd);
................................................................................
  int nFiles = 0;

  if( zPrevVers==0 || zPrevVers[0]==0 ){
    /* Initial commit, hence no parent(s) to compare against. That means just a
    ** straight tree list
    */

    char *zCmd = mprintf("GIT_DIR='%s' git-ls-tree -r '%s'", zGitDir, zCommit);
    in = popen(zCmd,"r");
    if( in==0 ){
      err_pipe("Reading tree",zCmd);
      return;
    }
    free(zCmd);

................................................................................
    ** and FILECHNG records.  git-diff-tree is disgustingly PERFECT for
    ** this. Compared to the hassles one has to go through with CVS or
    ** Subversion to find out what's in a change tree, it's just mind
    ** blowing how ideal this is.  FIXME: we're not handling renames or
    ** copies right now. When/if we do, add in the "-C -M" flags.
    */

    char *zCmd = mprintf("GIT_DIR='%s' git-diff-tree -r -t '%s' '%s'",
                         zGitDir, zPrevVers, zCommit);
    in = popen(zCmd,"r");
    if( in==0 ){
      err_pipe("Reading tree",zCmd);
      return;
    }
    free(zCmd);
................................................................................
static char *add_merge_to_comment( const char *zGitDir,
  char* zComment, const char *zHead, const char *zRemote
) {
  int rc;
  int nMerged = 0;
  char zBase[100];
  FILE *in;
  char *zCmd = mprintf("GIT_DIR='%s' git-merge-base '%s' '%s'",
                       zGitDir, zHead, zRemote );
  in = popen(zCmd,"r");
  if( in==0 ){
    err_pipe("Reading tree",zCmd);
    return zComment;
  }
  free(zCmd);
................................................................................
  char zLine[PATH_MAX+200];
  char zObject[100];
  char zName[PATH_MAX];
  char *zCmd;
  char *zOldObject;
  const char* zFormat = "%(objecttype) %(objectname) %(*objectname) %(refname)";

  zCmd = mprintf("GIT_DIR='%s' git-for-each-ref --format='%s' 2>&1",
                 zGitDir, zFormat);
  if( zCmd==0 ) return 0;

  in = popen(zCmd, "r");
  if( in==0 ){
    err_pipe("Reading refs",zCmd);
    free(zCmd);
................................................................................
  azSubst[7] = db_config("cvsroot", "");
  azSubst[8] = "V";
  azSubst[9] = newVersion;
  azSubst[10] = 0;
			  
  zTemplate = db_config(
    "filediff", 
    OS_VAL( "GIT_DIR='%RP' git-diff --full-index "
              "-t -p -r '%V1' '%V2' -- '%F' 2>/dev/null",
	          "GIT_DIR=\"%RP\" git-diff --full-index "
              "-t -p -r \"%V1\" \"%V2\" -- \"%F\" 2>NUL" )
          );
  zCmd = subst(zTemplate, azSubst);
  
  in = popen(zCmd, "r");
  free(zCmd);
  if( in==0 ) return -1;
................................................................................
){
  FILE *in;
  char zLine[PATH_MAX*2];
  char *zCmd;

  if( zTreeish==0 || zTreeish[0]==0 || zPath==0 || zPath[0]==0 ) return 0;
    
  zCmd = mprintf("GIT_DIR='%s' git-ls-tree -r '%s' '%s'", zGitDir,
                 quotable_string(zTreeish), quotable_string(zPath));
  in = popen(zCmd,"r");
  if( in==0 ){
    err_pipe("Reading tree",zCmd);
    return 0;
  }
  free(zCmd);
................................................................................
static int git_dump_version(const char *zVersion, const char *zFile,int bRaw){
  int rc = -1;
  char *zCmd;
  const char *zRoot = db_config("cvsroot","");
  const char *zBlob = git_get_blob(zRoot, zVersion, zFile);
  if( zBlob==0 ) return -1;

  zCmd = mprintf("GIT_DIR='%s' git-cat-file blob '%s' 2>/dev/null",
                zRoot, zBlob);
  rc = common_dumpfile( zCmd, zVersion, zFile, bRaw );
  free(zCmd);

  return rc;
}

................................................................................
  azSubst[6] = "RP";
  azSubst[7] = db_config("cvsroot", "");
  azSubst[8] = "V";
  azSubst[9] = azRev[0];
  azSubst[10] = 0;
			  
  zTemplate = 
    OS_VAL( "GIT_DIR='%RP' git-diff --full-index -t "
              "-p -r '%V1' '%V2' -- '%F' 2>/dev/null",
            "GIT_DIR=\"%RP\" git-diff --full-index -t "
              "-p -r \"%V1\" \"%V2\" -- \"%F\" 2>NUL" );
  if( !bRaw ){
    /* Only use external diff filter if bRaw is false */
    zTemplate = db_config( "filediff", zTemplate );
  }
  zCmd = subst(zTemplate, azSubst);
  







|







 







|







 







|







 







|







 







|







 







|

|







 







|







 







|







 







|

|







81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
...
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
...
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
...
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
...
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
...
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
...
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
...
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
  char zComment[10000];

  assert(nDate);

  *pzAuthor = 0;
  *pzComment = 0;

  zCmd = mprintf("GIT_DIR='%s' git cat-file commit '%s' 2>&1",
                 zGitDir, zObject);
  if( zCmd==0 ) return 0;

  in = popen(zCmd, "r");
  if( in==0 ){
    err_pipe("Reading commit",zCmd);
    free(zCmd);
................................................................................
  int nFiles = 0;

  if( zPrevVers==0 || zPrevVers[0]==0 ){
    /* Initial commit, hence no parent(s) to compare against. That means just a
    ** straight tree list
    */

    char *zCmd = mprintf("GIT_DIR='%s' git ls-tree -r '%s'", zGitDir, zCommit);
    in = popen(zCmd,"r");
    if( in==0 ){
      err_pipe("Reading tree",zCmd);
      return;
    }
    free(zCmd);

................................................................................
    ** and FILECHNG records.  git-diff-tree is disgustingly PERFECT for
    ** this. Compared to the hassles one has to go through with CVS or
    ** Subversion to find out what's in a change tree, it's just mind
    ** blowing how ideal this is.  FIXME: we're not handling renames or
    ** copies right now. When/if we do, add in the "-C -M" flags.
    */

    char *zCmd = mprintf("GIT_DIR='%s' git diff-tree -r -t '%s' '%s'",
                         zGitDir, zPrevVers, zCommit);
    in = popen(zCmd,"r");
    if( in==0 ){
      err_pipe("Reading tree",zCmd);
      return;
    }
    free(zCmd);
................................................................................
static char *add_merge_to_comment( const char *zGitDir,
  char* zComment, const char *zHead, const char *zRemote
) {
  int rc;
  int nMerged = 0;
  char zBase[100];
  FILE *in;
  char *zCmd = mprintf("GIT_DIR='%s' git merge-base '%s' '%s'",
                       zGitDir, zHead, zRemote );
  in = popen(zCmd,"r");
  if( in==0 ){
    err_pipe("Reading tree",zCmd);
    return zComment;
  }
  free(zCmd);
................................................................................
  char zLine[PATH_MAX+200];
  char zObject[100];
  char zName[PATH_MAX];
  char *zCmd;
  char *zOldObject;
  const char* zFormat = "%(objecttype) %(objectname) %(*objectname) %(refname)";

  zCmd = mprintf("GIT_DIR='%s' git for-each-ref --format='%s' 2>&1",
                 zGitDir, zFormat);
  if( zCmd==0 ) return 0;

  in = popen(zCmd, "r");
  if( in==0 ){
    err_pipe("Reading refs",zCmd);
    free(zCmd);
................................................................................
  azSubst[7] = db_config("cvsroot", "");
  azSubst[8] = "V";
  azSubst[9] = newVersion;
  azSubst[10] = 0;
			  
  zTemplate = db_config(
    "filediff", 
    OS_VAL( "GIT_DIR='%RP' git diff --full-index "
              "-t -p -r '%V1' '%V2' -- '%F' 2>/dev/null",
	          "GIT_DIR=\"%RP\" git diff --full-index "
              "-t -p -r \"%V1\" \"%V2\" -- \"%F\" 2>NUL" )
          );
  zCmd = subst(zTemplate, azSubst);
  
  in = popen(zCmd, "r");
  free(zCmd);
  if( in==0 ) return -1;
................................................................................
){
  FILE *in;
  char zLine[PATH_MAX*2];
  char *zCmd;

  if( zTreeish==0 || zTreeish[0]==0 || zPath==0 || zPath[0]==0 ) return 0;
    
  zCmd = mprintf("GIT_DIR='%s' git ls-tree -r '%s' '%s'", zGitDir,
                 quotable_string(zTreeish), quotable_string(zPath));
  in = popen(zCmd,"r");
  if( in==0 ){
    err_pipe("Reading tree",zCmd);
    return 0;
  }
  free(zCmd);
................................................................................
static int git_dump_version(const char *zVersion, const char *zFile,int bRaw){
  int rc = -1;
  char *zCmd;
  const char *zRoot = db_config("cvsroot","");
  const char *zBlob = git_get_blob(zRoot, zVersion, zFile);
  if( zBlob==0 ) return -1;

  zCmd = mprintf("GIT_DIR='%s' git cat-file blob '%s' 2>/dev/null",
                zRoot, zBlob);
  rc = common_dumpfile( zCmd, zVersion, zFile, bRaw );
  free(zCmd);

  return rc;
}

................................................................................
  azSubst[6] = "RP";
  azSubst[7] = db_config("cvsroot", "");
  azSubst[8] = "V";
  azSubst[9] = azRev[0];
  azSubst[10] = 0;
			  
  zTemplate = 
    OS_VAL( "GIT_DIR='%RP' git diff --full-index -t "
              "-p -r '%V1' '%V2' -- '%F' 2>/dev/null",
            "GIT_DIR=\"%RP\" git diff --full-index -t "
              "-p -r \"%V1\" \"%V2\" -- \"%F\" 2>NUL" );
  if( !bRaw ){
    /* Only use external diff filter if bRaw is false */
    zTemplate = db_config( "filediff", zTemplate );
  }
  zCmd = subst(zTemplate, azSubst);