cGit-UI for Git Repositories

cGit-UI – is a web interface for Git (git-scm) Repositories. cGit CGI script is writen in C and therefore it's fast enough.

24 Commits   0 Branches   5 Tags   |
Index: cgitcgi/.cgit/css/cgit.css
===================================================================
--- cgitcgi/.cgit/css/cgit.css	(revision 6)
+++ cgitcgi/.cgit/css/cgit.css	(revision 7)
@@ -783,10 +783,6 @@
 .repo-rev:not(.trunc) {
   color: #5a0510;
 }
-@media screen and (max-width: 992px) {
-  .repo-owner { margin-right: 0.5rem; }
-}
-
 .repo-idle {
   margin-right: 1rem;
 }
Index: cgitcgi/git-shared.c
===================================================================
--- cgitcgi/git-shared.c	(revision 6)
+++ cgitcgi/git-shared.c	(revision 7)
@@ -1310,7 +1310,8 @@
   }
 }
 
-void cgit_fill_blob_diff_with_parent( struct strbuf *sb, char *parent_hex, size_t parent_len, int *files, int *insertions, int *deletions, const char *hex, const char *relative_path )
+
+void cgit_diff_with_parent( struct strbuf *sb, char *parent_hex, size_t parent_len, int *files, int *insertions, int *deletions, const char *hex, const char *relative_path )
 {
   const char *name = NULL, *git_root = NULL, *repo_root = NULL;
 
@@ -1389,16 +1390,17 @@
 
       while( *p )
       {
-        if( *p == '\n' )
+        if( *p == '\n' && p[1] && p[2] && p[3] )
         {
-          if( p[1] == '+' ) *insertions += 1;
-          if( p[1] == '-' ) *deletions  += 1;
+          if( (p[1] == '+' && p[2] == '+' && p[3] == '+') ||
+              (p[1] == '-' && p[2] == '-' && p[3] == '-')   )
+            *files += 1;
+          if( p[1] == '+' && p[2] != '+' && p[3] != '+' ) { ++p; *insertions += 1; }
+          if( p[1] == '-' && p[2] != '-' && p[3] != '-' ) { ++p; *deletions  += 1; }
         }
         ++p;
       }
-      *insertions -= 1;
-      *deletions  -= 1;
-      *files = 1;
+      *files /= 2;
 
       strbuf_addbuf( sb, (const struct strbuf *)&buf );
     }
@@ -1406,4 +1408,3 @@
     strbuf_release( &buf );
   }
 }
-
Index: cgitcgi/git-shared.h
===================================================================
--- cgitcgi/git-shared.h	(revision 6)
+++ cgitcgi/git-shared.h	(revision 7)
@@ -63,7 +63,7 @@
 extern git_commit *lookup_commit_by_hex( const char *hex );
 
 extern void cgit_fill_diff_with_parent( struct strbuf *sb, char *parent_hex, size_t parent_len, int *files, int *insertions, int *deletions, const char *hex );
-extern void cgit_fill_blob_diff_with_parent( struct strbuf *sb, char *parent_hex, size_t parent_len, int *files, int *insertions, int *deletions, const char *hex, const char *relative_path );
+extern void cgit_diff_with_parent( struct strbuf *sb, char *parent_hex, size_t parent_len, int *files, int *insertions, int *deletions, const char *hex, const char *relative_path );
 
 
 #ifdef __cplusplus
Index: cgitcgi/ui-diff.c
===================================================================
--- cgitcgi/ui-diff.c	(revision 6)
+++ cgitcgi/ui-diff.c	(revision 7)
@@ -146,12 +146,7 @@
 
   commit = lookup_commit_by_hex( revision );
 
-  if( relative_path && *relative_path && ctx.repo.relative_info.kind == GIT_OBJECT_BLOB )
-  {
-    cgit_fill_blob_diff_with_parent( &buf, (char *)&parent_hex[0], GIT_OID_HEXSZ+1, &files, &insertions, &deletions, revision, relative_path );
-  }
-  else
-    cgit_fill_diff_with_parent( &buf, (char *)&parent_hex[0], GIT_OID_HEXSZ+1, &files, &insertions, &deletions, revision );
+  cgit_diff_with_parent( &buf, (char *)&parent_hex[0], GIT_OID_HEXSZ+1, &files, &insertions, &deletions, revision, ( relative_path && *relative_path ) ? relative_path : "/" );
 
   print_commit( sb, commit, revision, (const char *)&parent_hex[0], files, insertions, deletions );
   git_commit_free( commit );