rugged 0.21.3 → 0.21.4

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: 2276d0e49569313a6d31cf68b90615f8d1a2c4a8
4
- data.tar.gz: 30ebcb87a56c02eee6742a86b0eff38ef91b2a9c
3
+ metadata.gz: 4f476d2b5aaa786237a1a2e6c02ad6817395753a
4
+ data.tar.gz: bf560fd348d673a1ecf2082347cdcab68bc85141
5
5
  SHA512:
6
- metadata.gz: 84a1ce59332b2d6494c3e1f3be71fde89bbb27a12839b0ac35ab673e02977c9fefbc8443815e4dff34574b65e588dec22aaded418660c3323b04c03a137bb79b
7
- data.tar.gz: b3d6bc7c00b28e4a9255f1826bb35e7b7b66d5cf3a325f3f51f355cf50016f544dc9bc30c3c7e2eb5a6cb501f977e3e8a8c4b76862a82881f6b09eb6674f9264
6
+ metadata.gz: a47343b080593b0e668fdb259baafb7cd6f0a26dd7813476bafa83e60ded6e9218c417f4591b266825369ad8b600e3bd0e4016f2efa1c536501f39c64160256f
7
+ data.tar.gz: eec3ac2c4f8d77755e44c8f6d5e4358dbfa650905b6d6dfa8ecc2b404ffc466b4f1d34cfa8ea6879f9081a13d4a21cbf49c87ebb1826c2377c7a5094a3758d85
@@ -1,3 +1,3 @@
1
1
  module Rugged
2
- Version = VERSION = '0.21.3'
2
+ Version = VERSION = '0.21.4'
3
3
  end
@@ -11,6 +11,15 @@
11
11
  #include "git2/types.h"
12
12
  #include "git2/oid.h"
13
13
 
14
+ /**
15
+ * @file git2/sys/refs.h
16
+ * @brief Low-level Git ref creation
17
+ * @defgroup git_backend Git custom backend APIs
18
+ * @ingroup Git
19
+ * @{
20
+ */
21
+ GIT_BEGIN_DECL
22
+
14
23
  /**
15
24
  * Create a new direct reference from an OID.
16
25
  *
@@ -35,4 +44,6 @@ GIT_EXTERN(git_reference *) git_reference__alloc_symbolic(
35
44
  const char *name,
36
45
  const char *target);
37
46
 
47
+ /** @} */
48
+ GIT_END_DECL
38
49
  #endif
@@ -7,10 +7,10 @@
7
7
  #ifndef INCLUDE_git_version_h__
8
8
  #define INCLUDE_git_version_h__
9
9
 
10
- #define LIBGIT2_VERSION "0.21.3"
10
+ #define LIBGIT2_VERSION "0.21.4"
11
11
  #define LIBGIT2_VER_MAJOR 0
12
12
  #define LIBGIT2_VER_MINOR 21
13
- #define LIBGIT2_VER_REVISION 3
13
+ #define LIBGIT2_VER_REVISION 4
14
14
 
15
15
  #define LIBGIT2_SOVERSION 21
16
16
 
@@ -347,6 +347,21 @@ bool git_attr_fnmatch__match(
347
347
  const char *filename;
348
348
  int flags = 0;
349
349
 
350
+ /*
351
+ * If the rule was generated in a subdirectory, we must only
352
+ * use it for paths inside that directory. We can thus return
353
+ * a non-match if the prefixes don't match.
354
+ */
355
+ if (match->containing_dir) {
356
+ if (match->flags & GIT_ATTR_FNMATCH_ICASE) {
357
+ if (git__strncasecmp(path->path, match->containing_dir, match->containing_dir_length))
358
+ return 0;
359
+ } else {
360
+ if (git__prefixcmp(path->path, match->containing_dir))
361
+ return 0;
362
+ }
363
+ }
364
+
350
365
  if (match->flags & GIT_ATTR_FNMATCH_ICASE)
351
366
  flags |= FNM_CASEFOLD;
352
367
  if (match->flags & GIT_ATTR_FNMATCH_LEADINGDIR)
@@ -566,6 +581,17 @@ int git_attr_fnmatch__parse(
566
581
  /* leave FULLPATH match on, however */
567
582
  }
568
583
 
584
+ if (context) {
585
+ char *slash = strchr(context, '/');
586
+ size_t len;
587
+ if (slash) {
588
+ /* include the slash for easier matching */
589
+ len = slash - context + 1;
590
+ spec->containing_dir = git_pool_strndup(pool, context, len);
591
+ spec->containing_dir_length = len;
592
+ }
593
+ }
594
+
569
595
  if ((spec->flags & GIT_ATTR_FNMATCH_FULLPATH) != 0 &&
570
596
  context != NULL && git_path_root(pattern) < 0)
571
597
  {
@@ -52,6 +52,8 @@ extern const char *git_attr__unset;
52
52
  typedef struct {
53
53
  char *pattern;
54
54
  size_t length;
55
+ char *containing_dir;
56
+ size_t containing_dir_length;
55
57
  unsigned int flags;
56
58
  } git_attr_fnmatch;
57
59
 
@@ -64,6 +64,13 @@ void openssl_locking_function(int mode, int n, const char *file, int line)
64
64
 
65
65
  static void shutdown_ssl(void)
66
66
  {
67
+ int num_locks, i;
68
+
69
+ num_locks = CRYPTO_num_locks();
70
+ CRYPTO_set_locking_callback(NULL);
71
+
72
+ for (i = 0; i < num_locks; ++i)
73
+ git_mutex_free(openssl_locks);
67
74
  git__free(openssl_locks);
68
75
  }
69
76
  #endif
@@ -4,11 +4,87 @@
4
4
  #include "attrcache.h"
5
5
  #include "path.h"
6
6
  #include "config.h"
7
+ #include "fnmatch.h"
7
8
 
8
9
  #define GIT_IGNORE_INTERNAL "[internal]exclude"
9
10
 
10
11
  #define GIT_IGNORE_DEFAULT_RULES ".\n..\n.git\n"
11
12
 
13
+ /**
14
+ * A negative ignore can only unignore a file which is given explicitly before, thus
15
+ *
16
+ * foo
17
+ * !foo/bar
18
+ *
19
+ * does not unignore 'foo/bar' as it's not in the list. However
20
+ *
21
+ * foo/<star>
22
+ * !foo/bar
23
+ *
24
+ * does unignore 'foo/bar', as it is contained within the 'foo/<star>' rule.
25
+ */
26
+ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match)
27
+ {
28
+ int error = 0;
29
+ size_t i;
30
+ git_attr_fnmatch *rule;
31
+ char *path;
32
+ git_buf buf = GIT_BUF_INIT;
33
+
34
+ /* path of the file relative to the workdir, so we match the rules in subdirs */
35
+ if (match->containing_dir) {
36
+ git_buf_puts(&buf, match->containing_dir);
37
+ }
38
+ if (git_buf_puts(&buf, match->pattern) < 0)
39
+ return -1;
40
+
41
+ path = git_buf_detach(&buf);
42
+
43
+ git_vector_foreach(rules, i, rule) {
44
+ /* no chance of matching w/o a wilcard */
45
+ if (!(rule->flags & GIT_ATTR_FNMATCH_HASWILD))
46
+ continue;
47
+
48
+ /*
49
+ * If we're dealing with a directory (which we know via the
50
+ * strchr() check) we want to use 'dirname/<star>' as the
51
+ * pattern so p_fnmatch() honours FNM_PATHNAME
52
+ */
53
+ git_buf_clear(&buf);
54
+ if (rule->containing_dir) {
55
+ git_buf_puts(&buf, rule->containing_dir);
56
+ }
57
+ if (!strchr(rule->pattern, '*'))
58
+ error = git_buf_printf(&buf, "%s/*", rule->pattern);
59
+ else
60
+ error = git_buf_puts(&buf, rule->pattern);
61
+
62
+ if (error < 0)
63
+ goto out;
64
+
65
+
66
+ if ((error = p_fnmatch(git_buf_cstr(&buf), path, FNM_PATHNAME)) < 0) {
67
+ giterr_set(GITERR_INVALID, "error matching pattern");
68
+ goto out;
69
+ }
70
+
71
+ /* if we found a match, we want to keep this rule */
72
+ if (error != FNM_NOMATCH) {
73
+ *out = 1;
74
+ error = 0;
75
+ goto out;
76
+ }
77
+ }
78
+
79
+ *out = 0;
80
+ error = 0;
81
+
82
+ out:
83
+ git__free(path);
84
+ git_buf_free(&buf);
85
+ return error;
86
+ }
87
+
12
88
  static int parse_ignore_file(
13
89
  git_repository *repo, git_attr_file *attrs, const char *data)
14
90
  {
@@ -32,6 +108,8 @@ static int parse_ignore_file(
32
108
  }
33
109
 
34
110
  while (!error && *scan) {
111
+ int valid_rule = 1;
112
+
35
113
  if (!match && !(match = git__calloc(1, sizeof(*match)))) {
36
114
  error = -1;
37
115
  break;
@@ -48,11 +126,16 @@ static int parse_ignore_file(
48
126
  match->flags |= GIT_ATTR_FNMATCH_ICASE;
49
127
 
50
128
  scan = git__next_line(scan);
51
- error = git_vector_insert(&attrs->rules, match);
129
+
130
+ /* if a negative match doesn't actually do anything, throw it away */
131
+ if (match->flags & GIT_ATTR_FNMATCH_NEGATIVE)
132
+ error = does_negate_rule(&valid_rule, &attrs->rules, match);
133
+
134
+ if (!error && valid_rule)
135
+ error = git_vector_insert(&attrs->rules, match);
52
136
  }
53
137
 
54
- if (error != 0) {
55
- git__free(match->pattern);
138
+ if (error != 0 || !valid_rule) {
56
139
  match->pattern = NULL;
57
140
 
58
141
  if (error == GIT_ENOTFOUND)
@@ -433,6 +433,8 @@ static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t
433
433
  git_map map;
434
434
  int error;
435
435
 
436
+ assert(data && size);
437
+
436
438
  /* the offset needs to be at the beginning of the a page boundary */
437
439
  page_start = (offset / page_size) * page_size;
438
440
  page_offset = offset - page_start;
@@ -451,6 +453,9 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
451
453
  {
452
454
  git_off_t current_size = idx->pack->mwf.size;
453
455
 
456
+ if (!size)
457
+ return 0;
458
+
454
459
  /* add the extra space we need at the end */
455
460
  if (p_ftruncate(idx->pack->mwf.fd, current_size + size) < 0) {
456
461
  giterr_set(GITERR_OS, "Failed to increase size of pack file '%s'", idx->pack->pack_name);
@@ -8,6 +8,7 @@
8
8
  #define INCLUDE_path_h__
9
9
 
10
10
  #include "common.h"
11
+ #include "posix.h"
11
12
  #include "buffer.h"
12
13
  #include "vector.h"
13
14
 
@@ -592,7 +592,9 @@ int git_smart__download_pack(
592
592
  }
593
593
  } else if (pkt->type == GIT_PKT_DATA) {
594
594
  git_pkt_data *p = (git_pkt_data *) pkt;
595
- error = writepack->append(writepack, p->data, p->len, stats);
595
+
596
+ if (p->len)
597
+ error = writepack->append(writepack, p->data, p->len, stats);
596
598
  } else if (pkt->type == GIT_PKT_FLUSH) {
597
599
  /* A flush indicates the end of the packfile */
598
600
  git__free(pkt);
@@ -20,7 +20,7 @@ long git__page_size(void)
20
20
 
21
21
  int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset)
22
22
  {
23
- int mprot = 0;
23
+ int mprot = PROT_READ;
24
24
  int mflag = 0;
25
25
 
26
26
  GIT_MMAP_VALIDATE(out, len, prot, flags);
@@ -29,9 +29,7 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
29
29
  out->len = 0;
30
30
 
31
31
  if (prot & GIT_PROT_WRITE)
32
- mprot = PROT_WRITE;
33
- else if (prot & GIT_PROT_READ)
34
- mprot = PROT_READ;
32
+ mprot |= PROT_WRITE;
35
33
 
36
34
  if ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED)
37
35
  mflag = MAP_SHARED;
@@ -7,6 +7,8 @@
7
7
  #ifndef INCLUDE_git_path_w32_h__
8
8
  #define INCLUDE_git_path_w32_h__
9
9
 
10
+ #include "common.h"
11
+
10
12
  /*
11
13
  * Provides a large enough buffer to support Windows paths: MAX_PATH is
12
14
  * 260, corresponding to a maximum path length of 259 characters plus a
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.21.3
4
+ version: 0.21.4
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: 2014-12-18 00:00:00.000000000 Z
12
+ date: 2015-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler