@ -10,7 +10,7 @@
static int cgit_prepare_cache ( struct cacheitem * item )
static int cgit_prepare_cache ( struct cacheitem * item )
{
{
if ( ! c git_ repo & & ctx . qry . repo ) {
if ( ! c tx. repo & & ctx . qry . repo ) {
char * title = fmt ( " %s - %s " , ctx . cfg . root_title , " Bad request " ) ;
char * title = fmt ( " %s - %s " , ctx . cfg . root_title , " Bad request " ) ;
cgit_print_docstart ( title , item ) ;
cgit_print_docstart ( title , item ) ;
cgit_print_pageheader ( title , 0 ) ;
cgit_print_pageheader ( title , 0 ) ;
@ -19,7 +19,7 @@ static int cgit_prepare_cache(struct cacheitem *item)
return 0 ;
return 0 ;
}
}
if ( ! c git_ repo) {
if ( ! c tx. repo) {
item - > name = xstrdup ( fmt ( " %s/index.html " , ctx . cfg . cache_root ) ) ;
item - > name = xstrdup ( fmt ( " %s/index.html " , ctx . cfg . cache_root ) ) ;
item - > ttl = ctx . cfg . cache_root_ttl ;
item - > ttl = ctx . cfg . cache_root_ttl ;
return 1 ;
return 1 ;
@ -27,12 +27,12 @@ static int cgit_prepare_cache(struct cacheitem *item)
if ( ! cgit_cmd ) {
if ( ! cgit_cmd ) {
item - > name = xstrdup ( fmt ( " %s/%s/index.%s.html " , ctx . cfg . cache_root ,
item - > name = xstrdup ( fmt ( " %s/%s/index.%s.html " , ctx . cfg . cache_root ,
cache_safe_filename ( c git_ repo- > url ) ,
cache_safe_filename ( c tx. repo- > url ) ,
cache_safe_filename ( ctx . qry . raw ) ) ) ;
cache_safe_filename ( ctx . qry . raw ) ) ) ;
item - > ttl = ctx . cfg . cache_repo_ttl ;
item - > ttl = ctx . cfg . cache_repo_ttl ;
} else {
} else {
item - > name = xstrdup ( fmt ( " %s/%s/%s/%s.html " , ctx . cfg . cache_root ,
item - > name = xstrdup ( fmt ( " %s/%s/%s/%s.html " , ctx . cfg . cache_root ,
cache_safe_filename ( c git_ repo- > url ) ,
cache_safe_filename ( c tx. repo- > url ) ,
ctx . qry . page ,
ctx . qry . page ,
cache_safe_filename ( ctx . qry . raw ) ) ) ;
cache_safe_filename ( ctx . qry . raw ) ) ) ;
if ( ctx . qry . has_symref )
if ( ctx . qry . has_symref )
@ -64,7 +64,7 @@ int find_current_ref(const char *refname, const unsigned char *sha1,
return info - > match ;
return info - > match ;
}
}
char * find_default_branch ( struct repoinf o * repo )
char * find_default_branch ( struct cgit_ repo * repo )
{
{
struct refmatch info ;
struct refmatch info ;
@ -84,7 +84,7 @@ static void cgit_print_repo_page(struct cacheitem *item)
int show_search ;
int show_search ;
unsigned char sha1 [ 20 ] ;
unsigned char sha1 [ 20 ] ;
if ( chdir ( c git_ repo- > path ) ) {
if ( chdir ( c tx. repo- > path ) ) {
title = fmt ( " %s - %s " , ctx . cfg . root_title , " Bad request " ) ;
title = fmt ( " %s - %s " , ctx . cfg . root_title , " Bad request " ) ;
cgit_print_docstart ( title , item ) ;
cgit_print_docstart ( title , item ) ;
cgit_print_pageheader ( title , 0 ) ;
cgit_print_pageheader ( title , 0 ) ;
@ -94,13 +94,13 @@ static void cgit_print_repo_page(struct cacheitem *item)
return ;
return ;
}
}
title = fmt ( " %s - %s " , c git_repo- > name , cgit_ repo- > desc ) ;
title = fmt ( " %s - %s " , c tx. repo - > name , ctx . repo- > desc ) ;
show_search = 0 ;
show_search = 0 ;
setenv ( " GIT_DIR " , c git_ repo- > path , 1 ) ;
setenv ( " GIT_DIR " , c tx. repo- > path , 1 ) ;
if ( ! ctx . qry . head ) {
if ( ! ctx . qry . head ) {
ctx . qry . head = xstrdup ( find_default_branch ( c git_ repo) ) ;
ctx . qry . head = xstrdup ( find_default_branch ( c tx. repo) ) ;
c git_ repo- > defbranch = ctx . qry . head ;
c tx. repo- > defbranch = ctx . qry . head ;
}
}
if ( ! ctx . qry . head ) {
if ( ! ctx . qry . head ) {
@ -113,7 +113,7 @@ static void cgit_print_repo_page(struct cacheitem *item)
if ( get_sha1 ( ctx . qry . head , sha1 ) ) {
if ( get_sha1 ( ctx . qry . head , sha1 ) ) {
tmp = xstrdup ( ctx . qry . head ) ;
tmp = xstrdup ( ctx . qry . head ) ;
ctx . qry . head = c git_ repo- > defbranch ;
ctx . qry . head = c tx. repo- > defbranch ;
cgit_print_docstart ( title , item ) ;
cgit_print_docstart ( title , item ) ;
cgit_print_pageheader ( title , 0 ) ;
cgit_print_pageheader ( title , 0 ) ;
cgit_print_error ( fmt ( " Invalid branch: %s " , tmp ) ) ;
cgit_print_error ( fmt ( " Invalid branch: %s " , tmp ) ) ;
@ -121,11 +121,11 @@ static void cgit_print_repo_page(struct cacheitem *item)
return ;
return ;
}
}
if ( ( cgit_cmd = = CMD_SNAPSHOT ) & & c git_ repo- > snapshots ) {
if ( ( cgit_cmd = = CMD_SNAPSHOT ) & & c tx. repo- > snapshots ) {
cgit_print_snapshot ( item , ctx . qry . head , ctx . qry . sha1 ,
cgit_print_snapshot ( item , ctx . qry . head , ctx . qry . sha1 ,
cgit_repobasename ( c git_ repo- > url ) ,
cgit_repobasename ( c tx. repo- > url ) ,
ctx . qry . path ,
ctx . qry . path ,
c git_ repo- > snapshots ) ;
c tx. repo- > snapshots ) ;
return ;
return ;
}
}
@ -192,7 +192,7 @@ static void cgit_fill_cache(struct cacheitem *item, int use_cache)
chk_positive ( dup2 ( item - > fd , STDOUT_FILENO ) , " Dup2(cachefile) " ) ;
chk_positive ( dup2 ( item - > fd , STDOUT_FILENO ) , " Dup2(cachefile) " ) ;
}
}
if ( c git_ repo)
if ( c tx. repo)
cgit_print_repo_page ( item ) ;
cgit_print_repo_page ( item ) ;
else
else
cgit_print_repolist ( item ) ;
cgit_print_repolist ( item ) ;
@ -300,7 +300,6 @@ int main(int argc, const char **argv)
cgit_read_config ( cgit_config_env ? cgit_config_env : CGIT_CONFIG ,
cgit_read_config ( cgit_config_env ? cgit_config_env : CGIT_CONFIG ,
cgit_global_config_cb ) ;
cgit_global_config_cb ) ;
cgit_repo = NULL ;
if ( getenv ( " SCRIPT_NAME " ) )
if ( getenv ( " SCRIPT_NAME " ) )
ctx . cfg . script_name = xstrdup ( getenv ( " SCRIPT_NAME " ) ) ;
ctx . cfg . script_name = xstrdup ( getenv ( " SCRIPT_NAME " ) ) ;
if ( getenv ( " QUERY_STRING " ) )
if ( getenv ( " QUERY_STRING " ) )