Fossil

Check-in [cb8f7eb88a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix array indexing issue in db_all_column_text_and_int64() and refactor all_cmd() in an attempt to avoid bug [b6eea9446d].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | tkt-b6eea9446d
Files: files | file ages | folders
SHA1: cb8f7eb88a0ce933ea87df359ecd8568935537a1
User & Date: mistachkin 2013-10-07 21:36:09.738
Context
2015-04-03
02:36
Merge updates from trunk. check-in: 06ffd8009f user: mistachkin tags: tkt-b6eea9446d
2013-10-07
21:36
Fix array indexing issue in db_all_column_text_and_int64() and refactor all_cmd() in an attempt to avoid bug [b6eea9446d]. check-in: cb8f7eb88a user: mistachkin tags: tkt-b6eea9446d
20:26
Comment fixes. check-in: 19d2a8db7c user: mistachkin tags: tkt-b6eea9446d
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/allrepo.c.
112
113
114
115
116
117
118



119
120
121
122
123
124
125
  char *zQFilename;
  Blob extra;
  int useCheckouts = 0;
  int quiet = 0;
  int dryRunFlag = 0;
  int stopOnError = find_option("dontstop",0,0)==0;
  int rc;



  Bag outOfDate;
  
  dryRunFlag = find_option("dry-run","n",0)!=0;
  if( !dryRunFlag ){
    dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
  }








>
>
>







112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
  char *zQFilename;
  Blob extra;
  int useCheckouts = 0;
  int quiet = 0;
  int dryRunFlag = 0;
  int stopOnError = find_option("dontstop",0,0)==0;
  int rc;
  int rowCount, i = 0;
  char **azFilename = 0;
  i64 *aiRowid = 0;
  Bag outOfDate;
  
  dryRunFlag = find_option("dry-run","n",0)!=0;
  if( !dryRunFlag ){
    dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
  }

202
203
204
205
206
207
208


209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237

238

239

240
241
242
243
244
245
246
    db_prepare(&q,
       "SELECT substr(name, 6) COLLATE nocase, max(rowid)"
       "  FROM global_config"
       " WHERE substr(name, 1, 5)=='repo:'"
       " GROUP BY 1 ORDER BY 1"
    );
  }


  bag_init(&outOfDate);
  while( db_step(&q)==SQLITE_ROW ){
    const char *zFilename = db_column_text(&q, 0);
    int rowid = db_column_int(&q, 1);
    if( file_access(zFilename, 0) || !file_is_canonical(zFilename) ){
      bag_insert(&outOfDate, rowid);
      continue;
    }
    if( useCheckouts && file_isdir(zFilename)!=1 ){
      bag_insert(&outOfDate, rowid);
      continue;
    }
    if( zCmd[0]=='l' ){
      fossil_print("%s\n", zFilename);
      continue;
    }
    zQFilename = quoteFilename(zFilename);
    zSyscmd = mprintf("%s %s %s%s",
                      zFossil, zCmd, zQFilename, blob_str(&extra));
    if( !quiet || dryRunFlag ){
      fossil_print("%s\n", zSyscmd);
      fflush(stdout);
    }
    rc = dryRunFlag ? 0 : fossil_system(zSyscmd);
    free(zSyscmd);
    free(zQFilename);
    if( stopOnError && rc ){
      break;
    }

  }

  db_finalize(&q);

  
  /* If any repositories whose names appear in the ~/.fossil file could not
  ** be found, remove those names from the ~/.fossil file.
  */
  if( bag_count(&outOfDate)>0 ){
    Blob sql;
    char *zSep = "(";







>
>

|
|
|


|



|



|














>

>
|
>







205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
    db_prepare(&q,
       "SELECT substr(name, 6) COLLATE nocase, max(rowid)"
       "  FROM global_config"
       " WHERE substr(name, 1, 5)=='repo:'"
       " GROUP BY 1 ORDER BY 1"
    );
  }
  rowCount = db_all_column_text_and_int64(&q, 0, &azFilename, 1, &aiRowid);
  db_finalize(&q);
  bag_init(&outOfDate);
  while( i<rowCount ){
    const char *zFilename = azFilename[i];
    int rowid = (int)aiRowid[i];
    if( file_access(zFilename, 0) || !file_is_canonical(zFilename) ){
      bag_insert(&outOfDate, rowid);
      i++; continue;
    }
    if( useCheckouts && file_isdir(zFilename)!=1 ){
      bag_insert(&outOfDate, rowid);
      i++; continue;
    }
    if( zCmd[0]=='l' ){
      fossil_print("%s\n", zFilename);
      i++; continue;
    }
    zQFilename = quoteFilename(zFilename);
    zSyscmd = mprintf("%s %s %s%s",
                      zFossil, zCmd, zQFilename, blob_str(&extra));
    if( !quiet || dryRunFlag ){
      fossil_print("%s\n", zSyscmd);
      fflush(stdout);
    }
    rc = dryRunFlag ? 0 : fossil_system(zSyscmd);
    free(zSyscmd);
    free(zQFilename);
    if( stopOnError && rc ){
      break;
    }
    i++;
  }
  db_all_column_free(rowCount, &azFilename, &aiRowid);
  assert( !azFilename );
  assert( !aiRowid );
  
  /* If any repositories whose names appear in the ~/.fossil file could not
  ** be found, remove those names from the ~/.fossil file.
  */
  if( bag_count(&outOfDate)>0 ){
    Blob sql;
    char *zSep = "(";
Changes to src/db.c.
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
  int count = 0;
  char **azValue = 0;
  i64 *aiValue = 0;
  while( db_step(pStmt)==SQLITE_ROW ){
    count++;
    if( pazValue1 ){
      azValue = fossil_realloc(azValue, count * sizeof(char*));
      azValue[count] = fossil_strdup(db_column_text(pStmt, iCol1));
    }
    if( paiValue2 ){
      aiValue = fossil_realloc(aiValue, count * sizeof(i64));
      aiValue[count] = db_column_int64(pStmt, iCol2);
    }
  }
  if( pazValue1 ){
    *pazValue1 = azValue;
  }
  if( paiValue2 ){
    *paiValue2 = aiValue;







|



|







368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
  int count = 0;
  char **azValue = 0;
  i64 *aiValue = 0;
  while( db_step(pStmt)==SQLITE_ROW ){
    count++;
    if( pazValue1 ){
      azValue = fossil_realloc(azValue, count * sizeof(char*));
      azValue[count - 1] = fossil_strdup(db_column_text(pStmt, iCol1));
    }
    if( paiValue2 ){
      aiValue = fossil_realloc(aiValue, count * sizeof(i64));
      aiValue[count - 1] = db_column_int64(pStmt, iCol2);
    }
  }
  if( pazValue1 ){
    *pazValue1 = azValue;
  }
  if( paiValue2 ){
    *paiValue2 = aiValue;