cSvn-UI for SVN Repositories

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

6 Commits   0 Branches   2 Tags
author: kx <kx@radix.pro> 2023-04-12 19:21:06 +0300 committer: kx <kx@radix.pro> 2023-04-12 19:21:06 +0300 commit: c7693c71799633467d154afe65f9b4810cec42f5 parent: c8b2593c941778dcfa307badf981160e19d2932b
Commit Summary:
Added repo-root variable for repositories which placed in subdirectory relative svnserve root
Diffstat:
1 file changed, 12 insertions, 3 deletions
diff --git a/csvncgi/ui-diff.c b/csvncgi/ui-diff.c
index 7851f00..e74de6c 100644
--- a/csvncgi/ui-diff.c
+++ b/csvncgi/ui-diff.c
@@ -53,7 +53,8 @@
 static void csvn_print_diff( struct strbuf *sb, const char *relative_path, int revision )
 {
   const char *co_prefix = ctx.repo.checkout_ro_prefix;
-  const char *repo_path = ctx.repo.name;
+  const char *name      = ctx.repo.name;
+  const char *repo_root = ctx.repo.repo_root;
 
   if( !sb || !relative_path || !revision ) return;
 
@@ -61,15 +62,23 @@ static void csvn_print_diff( struct strbuf *sb, const char *relative_path, int r
 
   if( co_prefix )
   {
-    char cmd[1024];
+    char repo_path[PATH_MAX] = { 0 };
+    char cmd[PATH_MAX];
     struct strbuf buf = STRBUF_INIT;
     char  *raw = NULL;
     pid_t  p = (pid_t) -1;
     int    rc;
 
+    if( repo_root && *repo_root )
+    {
+      strcat( (char *)&repo_path[0], repo_root );
+      strcat( (char *)&repo_path[0], "/" );
+    }
+    strcat( (char *)&repo_path[0], name );
+
     snprintf( (char *)&cmd[0], 1024,
               "svn diff --revision %d:%d %s/%s/%s 2>/dev/null",
-              revision-1, revision, co_prefix, repo_path, relative_path );
+              revision-1, revision, co_prefix, (char *)&repo_path[0], relative_path );
     p = sys_exec_command( &buf, cmd );
     rc = sys_wait_command( p, NULL );
     if( rc != 0 )