<commit_before>#include <my_global.h>
#include <mysql.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#define GIT_PULL "git pull"
#define GIT_MASTER "git checkout master"
#define GIT_REPO "/var/lib/repo"

void finish_with_error(MYSQL *con)
{
  fprintf(stderr, "%s\n", mysql_error(con));
  mysql_close(con);
  exit(1);        
}
int repository(char *zz, char *qq);
int mdir(char *gitcmd, char *dir, char *clone);

int main(int argc, char **argv)
{      
  MYSQL *con = mysql_init(NULL);
  
  if (con == NULL)
  {
      fprintf(stderr, "mysql_init() failed\n");
      exit(1);
  }  
  
  if (mysql_real_connect(con, "localhost", "redmine", argv[1], 
          "redmine", 0, NULL, 0) == NULL) 
  {
      finish_with_error(con);
  }    
  
  if (mysql_query(con, "SELECT project_id, url FROM repositories where type='Repository::Git'")) 
  {
      finish_with_error(con);
  }
  
  MYSQL_RES *result = mysql_store_result(con);
  
  if (result == NULL) 
  {
      finish_with_error(con);
  }

  int num_fields = mysql_num_fields(result);

  MYSQL_ROW row;
  
  while ((row = mysql_fetch_row(result))) 
  { 
      //for(int i = 0; i < num_fields; i++) 
       repository(row[0], row[1]);<commit_msg>Use argv mysql password<commit_after>#include <my_global.h>
#include <mysql.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#define GIT_PULL "git pull"
#define GIT_MASTER "git checkout master"
#define GIT_REPO "/var/lib/repo"

void finish_with_error(MYSQL *con)
{
  fprintf(stderr, "%s\n", mysql_error(con));
  mysql_close(con);
  exit(1);        
}
int repository(char *zz, char *qq);
int mdir(char *gitcmd, char *dir, char *clone);

int main(int argc, char **argv)
{      
  MYSQL *con = mysql_init(NULL);
  
  if (con == NULL)
  {
      fprintf(stderr, "mysql_init() failed\n");
      exit(1);
  }  

//Use argv[1] for mysql password
  if (mysql_real_connect(con, "localhost", "redmine", argv[1], 
          "redmine", 0, NULL, 0) == NULL) 
  {
      finish_with_error(con);
  }    
  
  if (mysql_query(con, "SELECT project_id, url FROM repositories where type='Repository::Git'")) 
  {
      finish_with_error(con);
  }
  
  MYSQL_RES *result = mysql_store_result(con);
  
  if (result == NULL) 
  {
      finish_with_error(con);
  }

  int num_fields = mysql_num_fields(result);

  MYSQL_ROW row;
  
  while ((row = mysql_fetch_row(result))) 
  { 
      //for(int i = 0; i < num_fields; i++) 
       repository(row[0], row[1]);
{'fraction_non_alphanumeric': 0.15766653527788727, 'fraction_numerical': 0.006700827749310209, 'mean_word_length': 3.398613518197574, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3324738', 'n_tokens_mistral': 997, 'n_tokens_neox': 972, 'n_words': 217}