diff options
Diffstat (limited to 'csvncgi/ui-shared.c')
-rw-r--r-- | csvncgi/ui-shared.c | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/csvncgi/ui-shared.c b/csvncgi/ui-shared.c index e34141e..1079486 100644 --- a/csvncgi/ui-shared.c +++ b/csvncgi/ui-shared.c @@ -406,23 +406,32 @@ static void xml_csvn_info( struct strbuf *sb, struct csvn_info *info ) void csvn_repo_info( struct csvn_info *info, 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( co_prefix ) { - char cmd[1024]; + char repo_path[PATH_MAX] = { 0 }; + char cmd[PATH_MAX]; struct strbuf buf = STRBUF_INIT; 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 ); + if( revision ) snprintf( (char *)&cmd[0], 1024, "svn info --revision %d --xml %s/%s/ 2>/dev/null", - revision, co_prefix, repo_path ); + revision, co_prefix, (char *)&repo_path[0] ); else snprintf( (char *)&cmd[0], 1024, "svn info --xml %s/%s/ 2>/dev/null", - co_prefix, repo_path ); + co_prefix, (char *)&repo_path[0] ); p = sys_exec_command( &buf, cmd ); rc = sys_wait_command( p, NULL ); if( rc != 0 ) @@ -650,25 +659,34 @@ static const char *mime_info( struct csvn_info *info, const char *buffer, size_t void csvn_rpath_mime_info( struct csvn_info *info, 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( !info || !relative_path ) return; if( co_prefix ) { - char cmd[1024]; + char repo_path[PATH_MAX] = { 0 }; + char cmd[PATH_MAX]; struct strbuf buf = STRBUF_INIT; 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 ); + if( revision ) snprintf( (char *)&cmd[0], 1024, "svn cat --revision %d %s/%s/%s 2>/dev/null | tr -d '\\0' | head -c 1024", - revision, co_prefix, repo_path, relative_path ); + revision, co_prefix, (char *)&repo_path[0], relative_path ); else snprintf( (char *)&cmd[0], 1024, "svn cat %s/%s/%s 2>/dev/null | tr -d '\\0' | head -c 1024", - co_prefix, repo_path, relative_path ); + co_prefix, (char *)&repo_path[0], relative_path ); p = sys_exec_command( &buf, cmd ); rc = sys_wait_command( p, NULL ); if( rc != 0 ) @@ -689,25 +707,34 @@ void csvn_rpath_mime_info( struct csvn_info *info, const char *relative_path, in void csvn_rpath_info( struct csvn_info *info, 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( !info || !relative_path ) return; if( co_prefix ) { - char cmd[1024]; + char repo_path[PATH_MAX] = { 0 }; + char cmd[PATH_MAX]; struct strbuf buf = STRBUF_INIT; 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 ); + if( revision ) snprintf( (char *)&cmd[0], 1024, "svn info --revision %d --xml %s/%s/%s 2>/dev/null", - revision, co_prefix, repo_path, relative_path ); + revision, co_prefix, (char *)&repo_path[0], relative_path ); else snprintf( (char *)&cmd[0], 1024, "svn info --xml %s/%s/%s 2>/dev/null", - co_prefix, repo_path, relative_path ); + co_prefix, (char *)&repo_path[0], relative_path ); p = sys_exec_command( &buf, cmd ); rc = sys_wait_command( p, NULL ); if( rc != 0 ) |