rugged 0.24.0b2 → 0.24.0b3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb4fe7da10d53dd706d2d8c31e63145f752483e1
4
- data.tar.gz: 8373c3e1414d5557cfec7f5970286278b97e1daa
3
+ metadata.gz: a31950be316b1d3480f1617cc75189bf90697dc2
4
+ data.tar.gz: a97a557386b6875652eb2859e88da305fbb65ae3
5
5
  SHA512:
6
- metadata.gz: 8779a103e14c2eeff09294d32b9d38b215903295502bf5d8619375f22fb714fa1263538b04ddc876fc3c6b5d0f23cfe6ce2cc8972caa791b859aaa3f7abe2d52
7
- data.tar.gz: 7fded5b859f54137656ebeab2b8cdd3b3b498f5e4a3bebd1bfe49da9eef0fdc20b224bf8429c88d9cf42e675decd8913feb0ff5f89f6c9e1072896af21ad2c59
6
+ metadata.gz: c6879754a8a09f93cff19b46a3faa180a091dbc5c80f0c00361da4d8661bcd837d362df6f519913501f3a878ec1f0a1fd192dcdb14d3b56d6384661769cc9144
7
+ data.tar.gz: c958d72e7dfd55e54cd5b6ee6d6e9e56013919eb084759ef67354e02d48f883b93f2f2c5e876c1c48359321d8bb4458f1c5cde6a201ca6a92f19a0accab3a53d
@@ -1,3 +1,3 @@
1
1
  module Rugged
2
- Version = VERSION = '0.24.0b2'
2
+ Version = VERSION = '0.24.0b3'
3
3
  end
@@ -154,13 +154,27 @@ typedef enum {
154
154
  GIT_INDEX_ADD_CHECK_PATHSPEC = (1u << 2),
155
155
  } git_index_add_option_t;
156
156
 
157
- /**
158
- * Match any index stage.
159
- *
160
- * Some index APIs take a stage to match; pass this value to match
161
- * any entry matching the path regardless of stage.
162
- */
163
- #define GIT_INDEX_STAGE_ANY -1
157
+ typedef enum {
158
+ /**
159
+ * Match any index stage.
160
+ *
161
+ * Some index APIs take a stage to match; pass this value to match
162
+ * any entry matching the path regardless of stage.
163
+ */
164
+ GIT_INDEX_STAGE_ANY = -1,
165
+
166
+ /** A normal staged file in the index. */
167
+ GIT_INDEX_STAGE_NORMAL = 0,
168
+
169
+ /** The ancestor side of a conflict. */
170
+ GIT_INDEX_STAGE_ANCESTOR = 1,
171
+
172
+ /** The "ours" side of a conflict. */
173
+ GIT_INDEX_STAGE_OURS = 2,
174
+
175
+ /** The "theirs" side of a conflict. */
176
+ GIT_INDEX_STAGE_THEIRS = 3,
177
+ } git_index_stage_t;
164
178
 
165
179
  /** @name Index File Functions
166
180
  *
@@ -110,7 +110,7 @@ static int commit_quick_parse(
110
110
  const uint8_t *buffer_end = buffer + buffer_len;
111
111
  const uint8_t *parents_start, *committer_start;
112
112
  int i, parents = 0;
113
- int commit_time;
113
+ int64_t commit_time;
114
114
 
115
115
  buffer += strlen("tree ") + GIT_OID_HEXSZ + 1;
116
116
 
@@ -166,10 +166,10 @@ static int commit_quick_parse(
166
166
  buffer--;
167
167
  }
168
168
 
169
- if ((buffer == committer_start) || (git__strtol32(&commit_time, (char *)(buffer + 1), NULL, 10) < 0))
169
+ if ((buffer == committer_start) || (git__strtol64(&commit_time, (char *)(buffer + 1), NULL, 10) < 0))
170
170
  return commit_error(commit, "cannot parse commit time");
171
171
 
172
- commit->time = (time_t)commit_time;
172
+ commit->time = commit_time;
173
173
  commit->parsed = 1;
174
174
  return 0;
175
175
  }
@@ -22,7 +22,7 @@
22
22
 
23
23
  typedef struct git_commit_list_node {
24
24
  git_oid oid;
25
- uint32_t time;
25
+ int64_t time;
26
26
  unsigned int seen:1,
27
27
  uninteresting:1,
28
28
  topo_delay:1,
@@ -1114,7 +1114,9 @@ static int check_file_directory_collision(git_index *index,
1114
1114
  }
1115
1115
 
1116
1116
  static int canonicalize_directory_path(
1117
- git_index *index, git_index_entry *entry)
1117
+ git_index *index,
1118
+ git_index_entry *entry,
1119
+ git_index_entry *existing)
1118
1120
  {
1119
1121
  const git_index_entry *match, *best = NULL;
1120
1122
  char *search, *sep;
@@ -1124,8 +1126,8 @@ static int canonicalize_directory_path(
1124
1126
  return 0;
1125
1127
 
1126
1128
  /* item already exists in the index, simply re-use the existing case */
1127
- if ((match = git_index_get_bypath(index, entry->path, 0)) != NULL) {
1128
- memcpy((char *)entry->path, match->path, strlen(entry->path));
1129
+ if (existing) {
1130
+ memcpy((char *)entry->path, existing->path, strlen(existing->path));
1129
1131
  return 0;
1130
1132
  }
1131
1133
 
@@ -1190,6 +1192,52 @@ static int index_no_dups(void **old, void *new)
1190
1192
  return GIT_EEXISTS;
1191
1193
  }
1192
1194
 
1195
+ static void index_existing_and_best(
1196
+ git_index_entry **existing,
1197
+ size_t *existing_position,
1198
+ git_index_entry **best,
1199
+ git_index *index,
1200
+ const git_index_entry *entry)
1201
+ {
1202
+ git_index_entry *e;
1203
+ size_t pos;
1204
+ int error;
1205
+
1206
+ error = index_find(&pos,
1207
+ index, entry->path, 0, GIT_IDXENTRY_STAGE(entry), false);
1208
+
1209
+ if (error == 0) {
1210
+ *existing = index->entries.contents[pos];
1211
+ *existing_position = pos;
1212
+ *best = index->entries.contents[pos];
1213
+ return;
1214
+ }
1215
+
1216
+ *existing = NULL;
1217
+ *existing_position = 0;
1218
+ *best = NULL;
1219
+
1220
+ if (GIT_IDXENTRY_STAGE(entry) == 0) {
1221
+ for (; pos < index->entries.length; pos++) {
1222
+ int (*strcomp)(const char *a, const char *b) =
1223
+ index->ignore_case ? git__strcasecmp : git__strcmp;
1224
+
1225
+ e = index->entries.contents[pos];
1226
+
1227
+ if (strcomp(entry->path, e->path) != 0)
1228
+ break;
1229
+
1230
+ if (GIT_IDXENTRY_STAGE(e) == GIT_INDEX_STAGE_ANCESTOR) {
1231
+ *best = e;
1232
+ continue;
1233
+ } else {
1234
+ *best = e;
1235
+ break;
1236
+ }
1237
+ }
1238
+ }
1239
+ }
1240
+
1193
1241
  /* index_insert takes ownership of the new entry - if it can't insert
1194
1242
  * it, then it will return an error **and also free the entry**. When
1195
1243
  * it replaces an existing entry, it will update the entry_ptr with the
@@ -1208,7 +1256,7 @@ static int index_insert(
1208
1256
  {
1209
1257
  int error = 0;
1210
1258
  size_t path_length, position;
1211
- git_index_entry *existing = NULL, *entry;
1259
+ git_index_entry *existing, *best, *entry;
1212
1260
 
1213
1261
  assert(index && entry_ptr);
1214
1262
 
@@ -1231,20 +1279,19 @@ static int index_insert(
1231
1279
 
1232
1280
  git_vector_sort(&index->entries);
1233
1281
 
1234
- /* look if an entry with this path already exists */
1235
- if (!index_find(
1236
- &position, index, entry->path, 0, GIT_IDXENTRY_STAGE(entry), false)) {
1237
- existing = index->entries.contents[position];
1238
- /* update filemode to existing values if stat is not trusted */
1239
- if (trust_mode)
1240
- entry->mode = git_index__create_mode(entry->mode);
1241
- else
1242
- entry->mode = index_merge_mode(index, existing, entry->mode);
1243
- }
1282
+ /* look if an entry with this path already exists, either staged, or (if
1283
+ * this entry is a regular staged item) as the "ours" side of a conflict.
1284
+ */
1285
+ index_existing_and_best(&existing, &position, &best, index, entry);
1286
+
1287
+ /* update the file mode */
1288
+ entry->mode = trust_mode ?
1289
+ git_index__create_mode(entry->mode) :
1290
+ index_merge_mode(index, best, entry->mode);
1244
1291
 
1245
1292
  /* canonicalize the directory name */
1246
1293
  if (!trust_path)
1247
- error = canonicalize_directory_path(index, entry);
1294
+ error = canonicalize_directory_path(index, entry, best);
1248
1295
 
1249
1296
  /* look for tree / blob name collisions, removing conflicts if requested */
1250
1297
  if (!error)
@@ -34,13 +34,27 @@ static bool contains_angle_brackets(const char *input)
34
34
  return strchr(input, '<') != NULL || strchr(input, '>') != NULL;
35
35
  }
36
36
 
37
+ static bool is_crud(unsigned char c)
38
+ {
39
+ return c <= 32 ||
40
+ c == '.' ||
41
+ c == ',' ||
42
+ c == ':' ||
43
+ c == ';' ||
44
+ c == '<' ||
45
+ c == '>' ||
46
+ c == '"' ||
47
+ c == '\\' ||
48
+ c == '\'';
49
+ }
50
+
37
51
  static char *extract_trimmed(const char *ptr, size_t len)
38
52
  {
39
- while (len && git__isspace(ptr[0])) {
53
+ while (len && is_crud((unsigned char)ptr[0])) {
40
54
  ptr++; len--;
41
55
  }
42
56
 
43
- while (len && git__isspace(ptr[len - 1])) {
57
+ while (len && is_crud((unsigned char)ptr[len - 1])) {
44
58
  len--;
45
59
  }
46
60
 
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.0b2
4
+ version: 0.24.0b3
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-15 00:00:00.000000000 Z
12
+ date: 2015-10-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
@@ -529,7 +529,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
529
529
  version: 1.3.1
530
530
  requirements: []
531
531
  rubyforge_project:
532
- rubygems_version: 2.2.5
532
+ rubygems_version: 2.2.2
533
533
  signing_key:
534
534
  specification_version: 4
535
535
  summary: Rugged is a Ruby binding to the libgit2 linkable library