rugged 0.24.0b6 → 0.24.0b7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57c683acff03189ef9196296e95aa485bc55529d
4
- data.tar.gz: 55277e7b32012102b7f3bff2983dbeb0a88b085f
3
+ metadata.gz: 34a82c36a2937fc0183d0c2a5cad5682c4d64055
4
+ data.tar.gz: 98ef84b8da23e17429430ebc0cc37b860e51bc28
5
5
  SHA512:
6
- metadata.gz: 0747d31d7351cf1831446d043bcf1c68cab7f9bb4080b2acb1eae02a5360aa4ad4e66cb637da1e65622d02eb056e2cfe54b6dff0935e42680d55a108bff3aa9d
7
- data.tar.gz: ae77e90ec575f52368f60d7e9ae3ecf353b32e1f1d57d35a08ec967d2695d892c56de11b687e5bc3768b8e63e7320baa7986af2fee1564a800ca57e8b8bec0b9
6
+ metadata.gz: 3d288fc1bb1799b49da9fbf7e525def0695dfcddd347cfcc08f6855dc6e9fba31913547bc21d8560d99a1dbadf3e06913ebd447f13ced8f0f9d3f1c24d8bf520
7
+ data.tar.gz: f624e44c09a2f0742b23e79b6151729f80381be2e3b91a4130debbd372ff4246e269d741887cab61a9459ecaa3484f437add2cb5cb5984e40377730fb851f56c
@@ -1,3 +1,3 @@
1
1
  module Rugged
2
- Version = VERSION = '0.24.0b6'
2
+ Version = VERSION = '0.24.0b7'
3
3
  end
@@ -13,6 +13,7 @@
13
13
  #define PARENT2 (1 << 1)
14
14
  #define RESULT (1 << 2)
15
15
  #define STALE (1 << 3)
16
+ #define ALL_FLAGS (PARENT1 | PARENT2 | STALE | RESULT)
16
17
 
17
18
  #define PARENTS_PER_COMMIT 2
18
19
  #define COMMIT_ALLOC \
@@ -2899,6 +2899,7 @@ int git_index_read_index(
2899
2899
  {
2900
2900
  git_vector new_entries = GIT_VECTOR_INIT,
2901
2901
  remove_entries = GIT_VECTOR_INIT;
2902
+ git_idxmap *new_entries_map = NULL;
2902
2903
  git_iterator *index_iterator = NULL;
2903
2904
  git_iterator *new_iterator = NULL;
2904
2905
  git_iterator_options opts = GIT_ITERATOR_OPTIONS_INIT;
@@ -2908,9 +2909,15 @@ int git_index_read_index(
2908
2909
  int error;
2909
2910
 
2910
2911
  if ((error = git_vector_init(&new_entries, new_index->entries.length, index->entries._cmp)) < 0 ||
2911
- (error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0)
2912
+ (error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0 ||
2913
+ (error = git_idxmap_alloc(&new_entries_map)) < 0)
2912
2914
  goto done;
2913
2915
 
2916
+ if (index->ignore_case)
2917
+ kh_resize(idxicase, (khash_t(idxicase) *) new_entries_map, new_index->entries.length);
2918
+ else
2919
+ kh_resize(idx, new_entries_map, new_index->entries.length);
2920
+
2914
2921
  opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;
2915
2922
 
2916
2923
  if ((error = git_iterator_for_index(&index_iterator, index, &opts)) < 0 ||
@@ -2924,6 +2931,7 @@ int git_index_read_index(
2924
2931
  goto done;
2925
2932
 
2926
2933
  while (true) {
2934
+ git_index_entry *add_entry = NULL, *remove_entry = NULL;
2927
2935
  int diff;
2928
2936
 
2929
2937
  if (old_entry && new_entry)
@@ -2936,27 +2944,37 @@ int git_index_read_index(
2936
2944
  break;
2937
2945
 
2938
2946
  if (diff < 0) {
2939
- git_vector_insert(&remove_entries, (git_index_entry *)old_entry);
2947
+ remove_entry = (git_index_entry *)old_entry;
2940
2948
  } else if (diff > 0) {
2941
- if ((error = index_entry_dup(&entry, index, new_entry)) < 0)
2949
+ if ((error = index_entry_dup(&add_entry, index, new_entry)) < 0)
2942
2950
  goto done;
2943
-
2944
- git_vector_insert(&new_entries, entry);
2945
2951
  } else {
2946
2952
  /* Path and stage are equal, if the OID is equal, keep it to
2947
2953
  * keep the stat cache data.
2948
2954
  */
2949
2955
  if (git_oid_equal(&old_entry->id, &new_entry->id)) {
2950
- git_vector_insert(&new_entries, (git_index_entry *)old_entry);
2956
+ add_entry = (git_index_entry *)old_entry;
2951
2957
  } else {
2952
- if ((error = index_entry_dup(&entry, index, new_entry)) < 0)
2958
+ if ((error = index_entry_dup(&add_entry, index, new_entry)) < 0)
2953
2959
  goto done;
2954
2960
 
2955
- git_vector_insert(&new_entries, entry);
2956
- git_vector_insert(&remove_entries, (git_index_entry *)old_entry);
2961
+ remove_entry = (git_index_entry *)old_entry;
2957
2962
  }
2958
2963
  }
2959
2964
 
2965
+ if (add_entry) {
2966
+ if ((error = git_vector_insert(&new_entries, add_entry)) == 0)
2967
+ INSERT_IN_MAP_EX(index, new_entries_map, add_entry, error);
2968
+ }
2969
+
2970
+ if (remove_entry && !error)
2971
+ error = git_vector_insert(&remove_entries, remove_entry);
2972
+
2973
+ if (error < 0) {
2974
+ giterr_set(GITERR_INDEX, "failed to insert entry");
2975
+ return error;
2976
+ }
2977
+
2960
2978
  if (diff <= 0) {
2961
2979
  if ((error = git_iterator_advance(&old_entry, index_iterator)) < 0 &&
2962
2980
  error != GIT_ITEROVER)
@@ -2974,6 +2992,7 @@ int git_index_read_index(
2974
2992
  git_index_reuc_clear(index);
2975
2993
 
2976
2994
  git_vector_swap(&new_entries, &index->entries);
2995
+ new_entries_map = git__swap(index->entries_map, new_entries_map);
2977
2996
 
2978
2997
  git_vector_foreach(&remove_entries, i, entry) {
2979
2998
  if (index->tree)
@@ -2985,6 +3004,7 @@ int git_index_read_index(
2985
3004
  error = 0;
2986
3005
 
2987
3006
  done:
3007
+ git_idxmap_free(new_entries_map);
2988
3008
  git_vector_free(&new_entries);
2989
3009
  git_vector_free(&remove_entries);
2990
3010
  git_iterator_free(index_iterator);
@@ -302,30 +302,59 @@ static int interesting(git_pqueue *list)
302
302
  return 0;
303
303
  }
304
304
 
305
- int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_list_node *one, git_vector *twos)
305
+ static void clear_commit_marks_1(git_commit_list **plist,
306
+ git_commit_list_node *commit, unsigned int mark)
306
307
  {
307
- int error;
308
- unsigned int i;
309
- git_commit_list_node *two;
310
- git_commit_list *result = NULL, *tmp = NULL;
311
- git_pqueue list;
308
+ while (commit) {
309
+ unsigned int i;
312
310
 
313
- /* If there's only the one commit, there can be no merge bases */
314
- if (twos->length == 0) {
315
- *out = NULL;
316
- return 0;
311
+ if (!(mark & commit->flags))
312
+ return;
313
+
314
+ commit->flags &= ~mark;
315
+
316
+ for (i = 1; i < commit->out_degree; i++) {
317
+ git_commit_list_node *p = commit->parents[i];
318
+ git_commit_list_insert(p, plist);
319
+ }
320
+
321
+ commit = commit->out_degree ? commit->parents[0] : NULL;
317
322
  }
323
+ }
318
324
 
319
- /* if the commit is repeated, we have a our merge base already */
320
- git_vector_foreach(twos, i, two) {
321
- if (one == two)
322
- return git_commit_list_insert(one, out) ? 0 : -1;
325
+ static void clear_commit_marks_many(git_vector *commits, unsigned int mark)
326
+ {
327
+ git_commit_list *list = NULL;
328
+ git_commit_list_node *c;
329
+ unsigned int i;
330
+
331
+ git_vector_foreach(commits, i, c) {
332
+ git_commit_list_insert(c, &list);
323
333
  }
324
334
 
325
- if (git_pqueue_init(&list, 0, twos->length * 2, git_commit_list_time_cmp) < 0)
326
- return -1;
335
+ while (list)
336
+ clear_commit_marks_1(&list, git_commit_list_pop(&list), mark);
337
+ }
327
338
 
328
- if (git_commit_list_parse(walk, one) < 0)
339
+ static void clear_commit_marks(git_commit_list_node *commit, unsigned int mark)
340
+ {
341
+ git_commit_list *list = NULL;
342
+ git_commit_list_insert(commit, &list);
343
+ while (list)
344
+ clear_commit_marks_1(&list, git_commit_list_pop(&list), mark);
345
+ }
346
+
347
+ static int paint_down_to_common(
348
+ git_commit_list **out, git_revwalk *walk, git_commit_list_node *one, git_vector *twos)
349
+ {
350
+ git_pqueue list;
351
+ git_commit_list *result = NULL;
352
+ git_commit_list_node *two;
353
+
354
+ int error;
355
+ unsigned int i;
356
+
357
+ if (git_pqueue_init(&list, 0, twos->length * 2, git_commit_list_time_cmp) < 0)
329
358
  return -1;
330
359
 
331
360
  one->flags |= PARENT1;
@@ -376,19 +405,138 @@ int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_l
376
405
  }
377
406
 
378
407
  git_pqueue_free(&list);
408
+ *out = result;
409
+ return 0;
410
+ }
411
+
412
+ static int remove_redundant(git_revwalk *walk, git_vector *commits)
413
+ {
414
+ git_vector work = GIT_VECTOR_INIT;
415
+ unsigned char *redundant;
416
+ unsigned int *filled_index;
417
+ unsigned int i, j;
418
+ int error = 0;
419
+
420
+ redundant = git__calloc(commits->length, 1);
421
+ GITERR_CHECK_ALLOC(redundant);
422
+ filled_index = git__calloc((commits->length - 1), sizeof(unsigned int));
423
+ GITERR_CHECK_ALLOC(filled_index);
424
+
425
+ for (i = 0; i < commits->length; ++i) {
426
+ if ((error = git_commit_list_parse(walk, commits->contents[i])) < 0)
427
+ goto done;
428
+ }
429
+
430
+ for (i = 0; i < commits->length; ++i) {
431
+ git_commit_list *common = NULL;
432
+ git_commit_list_node *commit = commits->contents[i];
433
+
434
+ if (redundant[i])
435
+ continue;
436
+
437
+ git_vector_clear(&work);
438
+
439
+ for (j = 0; j < commits->length; j++) {
440
+ if (i == j || redundant[j])
441
+ continue;
442
+
443
+ filled_index[work.length] = j;
444
+ if ((error = git_vector_insert(&work, commits->contents[j])) < 0)
445
+ goto done;
446
+ }
447
+
448
+ error = paint_down_to_common(&common, walk, commit, &work);
449
+ if (error < 0)
450
+ goto done;
451
+
452
+ if (commit->flags & PARENT2)
453
+ redundant[i] = 1;
454
+
455
+ for (j = 0; j < work.length; j++) {
456
+ git_commit_list_node *w = work.contents[j];
457
+ if (w->flags & PARENT1)
458
+ redundant[filled_index[j]] = 1;
459
+ }
460
+
461
+ clear_commit_marks(commit, ALL_FLAGS);
462
+ clear_commit_marks_many(&work, ALL_FLAGS);
463
+
464
+ git_commit_list_free(&common);
465
+ }
466
+
467
+ for (i = 0; i < commits->length; ++i) {
468
+ if (redundant[i])
469
+ commits->contents[i] = NULL;
470
+ }
471
+
472
+ done:
473
+ git__free(redundant);
474
+ git__free(filled_index);
475
+ git_vector_free(&work);
476
+ return error;
477
+ }
478
+
479
+ int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_list_node *one, git_vector *twos)
480
+ {
481
+ int error;
482
+ unsigned int i;
483
+ git_commit_list_node *two;
484
+ git_commit_list *result = NULL, *tmp = NULL;
485
+
486
+ /* If there's only the one commit, there can be no merge bases */
487
+ if (twos->length == 0) {
488
+ *out = NULL;
489
+ return 0;
490
+ }
491
+
492
+ /* if the commit is repeated, we have a our merge base already */
493
+ git_vector_foreach(twos, i, two) {
494
+ if (one == two)
495
+ return git_commit_list_insert(one, out) ? 0 : -1;
496
+ }
497
+
498
+ if (git_commit_list_parse(walk, one) < 0)
499
+ return -1;
500
+
501
+ error = paint_down_to_common(&result, walk, one, twos);
502
+ if (error < 0)
503
+ return error;
379
504
 
380
505
  /* filter out any stale commits in the results */
381
506
  tmp = result;
382
507
  result = NULL;
383
508
 
384
509
  while (tmp) {
385
- struct git_commit_list *next = tmp->next;
386
- if (!(tmp->item->flags & STALE))
387
- if (git_commit_list_insert_by_date(tmp->item, &result) == NULL)
510
+ git_commit_list_node *c = git_commit_list_pop(&tmp);
511
+ if (!(c->flags & STALE))
512
+ if (git_commit_list_insert_by_date(c, &result) == NULL)
388
513
  return -1;
514
+ }
515
+
516
+ /*
517
+ * more than one merge base -- see if there are redundant merge
518
+ * bases and remove them
519
+ */
520
+ if (result && result->next) {
521
+ git_vector redundant = GIT_VECTOR_INIT;
522
+
523
+ while (result)
524
+ git_vector_insert(&redundant, git_commit_list_pop(&result));
525
+
526
+ clear_commit_marks(one, ALL_FLAGS);
527
+ clear_commit_marks_many(twos, ALL_FLAGS);
528
+
529
+ if ((error = remove_redundant(walk, &redundant)) < 0) {
530
+ git_vector_free(&redundant);
531
+ return error;
532
+ }
533
+
534
+ git_vector_foreach(&redundant, i, two) {
535
+ if (two != NULL)
536
+ git_commit_list_insert_by_date(two, &result);
537
+ }
389
538
 
390
- git__free(tmp);
391
- tmp = next;
539
+ git_vector_free(&redundant);
392
540
  }
393
541
 
394
542
  *out = result;
@@ -38,12 +38,12 @@ typedef struct {
38
38
  *
39
39
  * To allocation strings, use like this:
40
40
  *
41
- * git_pool_init(&string_pool, 1, 0);
41
+ * git_pool_init(&string_pool, 1);
42
42
  * my_string = git_pool_strdup(&string_pool, your_string);
43
43
  *
44
44
  * To allocate items of fixed size, use like this:
45
45
  *
46
- * git_pool_init(&pool, sizeof(item), 0);
46
+ * git_pool_init(&pool, sizeof(item));
47
47
  * my_item = git_pool_malloc(&pool, 1);
48
48
  *
49
49
  * Of course, you can use this in other ways, but those are the
@@ -1464,7 +1464,7 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size)
1464
1464
  entry = git__calloc(1, sizeof(git_reflog_entry));
1465
1465
  GITERR_CHECK_ALLOC(entry);
1466
1466
 
1467
- entry->committer = git__malloc(sizeof(git_signature));
1467
+ entry->committer = git__calloc(1, sizeof(git_signature));
1468
1468
  GITERR_CHECK_ALLOC(entry->committer);
1469
1469
 
1470
1470
  if (git_oid_fromstrn(&entry->oid_old, buf, GIT_OID_HEXSZ) < 0)
@@ -130,11 +130,14 @@ static int git_proto_stream_write(
130
130
 
131
131
  static void git_proto_stream_free(git_smart_subtransport_stream *stream)
132
132
  {
133
- git_proto_stream *s = (git_proto_stream *)stream;
134
- git_subtransport *t = OWNING_SUBTRANSPORT(s);
135
- int ret;
133
+ git_proto_stream *s;
134
+ git_subtransport *t;
135
+
136
+ if (!stream)
137
+ return;
136
138
 
137
- GIT_UNUSED(ret);
139
+ s = (git_proto_stream *)stream;
140
+ t = OWNING_SUBTRANSPORT(s);
138
141
 
139
142
  t->current_stream = NULL;
140
143
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rugged
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0b6
4
+ version: 0.24.0b7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-28 00:00:00.000000000 Z
12
+ date: 2015-11-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler