rugged 0.25.0b10 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/extconf.rb +5 -0
  3. data/ext/rugged/rugged.c +3 -20
  4. data/ext/rugged/rugged.h +3 -20
  5. data/ext/rugged/rugged_backend.c +3 -20
  6. data/ext/rugged/rugged_blame.c +7 -24
  7. data/ext/rugged/rugged_blob.c +5 -22
  8. data/ext/rugged/rugged_branch.c +3 -20
  9. data/ext/rugged/rugged_branch_collection.c +3 -20
  10. data/ext/rugged/rugged_commit.c +37 -24
  11. data/ext/rugged/rugged_config.c +3 -20
  12. data/ext/rugged/rugged_cred.c +3 -20
  13. data/ext/rugged/rugged_diff.c +3 -20
  14. data/ext/rugged/rugged_diff_delta.c +3 -20
  15. data/ext/rugged/rugged_diff_hunk.c +3 -20
  16. data/ext/rugged/rugged_diff_line.c +3 -20
  17. data/ext/rugged/rugged_index.c +38 -149
  18. data/ext/rugged/rugged_note.c +3 -20
  19. data/ext/rugged/rugged_object.c +3 -20
  20. data/ext/rugged/rugged_patch.c +4 -22
  21. data/ext/rugged/rugged_rebase.c +3 -20
  22. data/ext/rugged/rugged_reference.c +4 -21
  23. data/ext/rugged/rugged_reference_collection.c +3 -20
  24. data/ext/rugged/rugged_remote.c +4 -21
  25. data/ext/rugged/rugged_remote_collection.c +3 -20
  26. data/ext/rugged/rugged_repo.c +5 -22
  27. data/ext/rugged/rugged_revwalk.c +4 -21
  28. data/ext/rugged/rugged_settings.c +3 -20
  29. data/ext/rugged/rugged_signature.c +3 -20
  30. data/ext/rugged/rugged_submodule.c +4 -21
  31. data/ext/rugged/rugged_submodule_collection.c +3 -20
  32. data/ext/rugged/rugged_tag.c +3 -20
  33. data/ext/rugged/rugged_tag_collection.c +3 -20
  34. data/ext/rugged/rugged_tree.c +56 -183
  35. data/lib/rugged.rb +5 -0
  36. data/lib/rugged/attributes.rb +5 -0
  37. data/lib/rugged/blob.rb +5 -0
  38. data/lib/rugged/branch.rb +6 -1
  39. data/lib/rugged/commit.rb +5 -0
  40. data/lib/rugged/console.rb +5 -0
  41. data/lib/rugged/credentials.rb +5 -0
  42. data/lib/rugged/diff.rb +5 -0
  43. data/lib/rugged/diff/delta.rb +5 -0
  44. data/lib/rugged/diff/hunk.rb +5 -0
  45. data/lib/rugged/diff/line.rb +5 -0
  46. data/lib/rugged/index.rb +120 -0
  47. data/lib/rugged/object.rb +5 -0
  48. data/lib/rugged/patch.rb +5 -0
  49. data/lib/rugged/reference.rb +5 -0
  50. data/lib/rugged/remote.rb +5 -0
  51. data/lib/rugged/repository.rb +6 -1
  52. data/lib/rugged/submodule_collection.rb +5 -0
  53. data/lib/rugged/tag.rb +5 -0
  54. data/lib/rugged/tree.rb +156 -1
  55. data/lib/rugged/version.rb +6 -1
  56. data/lib/rugged/walker.rb +5 -0
  57. data/vendor/libgit2/include/git2/common.h +20 -1
  58. data/vendor/libgit2/include/git2/describe.h +5 -2
  59. data/vendor/libgit2/include/git2/patch.h +1 -1
  60. data/vendor/libgit2/include/git2/proxy.h +1 -1
  61. data/vendor/libgit2/include/git2/remote.h +4 -4
  62. data/vendor/libgit2/include/git2/transaction.h +9 -0
  63. data/vendor/libgit2/include/git2/version.h +3 -3
  64. data/vendor/libgit2/src/apply.c +1 -1
  65. data/vendor/libgit2/src/branch.c +5 -4
  66. data/vendor/libgit2/src/checkout.c +2 -2
  67. data/vendor/libgit2/src/commit.c +4 -3
  68. data/vendor/libgit2/src/common.h +2 -1
  69. data/vendor/libgit2/src/curl_stream.c +19 -2
  70. data/vendor/libgit2/src/diff_stats.c +18 -10
  71. data/vendor/libgit2/src/fetchhead.c +8 -8
  72. data/vendor/libgit2/src/fileops.c +9 -1
  73. data/vendor/libgit2/src/fileops.h +2 -2
  74. data/vendor/libgit2/src/global.c +19 -4
  75. data/vendor/libgit2/src/global.h +6 -0
  76. data/vendor/libgit2/src/graph.c +1 -1
  77. data/vendor/libgit2/src/index.c +1 -1
  78. data/vendor/libgit2/src/iterator.c +1 -1
  79. data/vendor/libgit2/src/merge.c +1 -1
  80. data/vendor/libgit2/src/odb.c +1 -1
  81. data/vendor/libgit2/src/odb_mempack.c +1 -1
  82. data/vendor/libgit2/src/openssl_stream.c +45 -26
  83. data/vendor/libgit2/src/openssl_stream.h +106 -0
  84. data/vendor/libgit2/src/pack.c +12 -7
  85. data/vendor/libgit2/src/patch_generate.c +1 -1
  86. data/vendor/libgit2/src/patch_parse.c +28 -26
  87. data/vendor/libgit2/src/path.c +5 -2
  88. data/vendor/libgit2/src/pqueue.c +3 -2
  89. data/vendor/libgit2/src/rebase.c +1 -1
  90. data/vendor/libgit2/src/refdb.c +4 -2
  91. data/vendor/libgit2/src/refdb_fs.c +82 -54
  92. data/vendor/libgit2/src/repository.c +9 -6
  93. data/vendor/libgit2/src/revwalk.c +1 -1
  94. data/vendor/libgit2/src/settings.c +2 -0
  95. data/vendor/libgit2/src/signature.c +1 -1
  96. data/vendor/libgit2/src/sortedcache.c +14 -5
  97. data/vendor/libgit2/src/sysdir.c +1 -1
  98. data/vendor/libgit2/src/transports/http.c +1 -1
  99. data/vendor/libgit2/src/transports/smart_protocol.c +11 -7
  100. data/vendor/libgit2/src/tree.c +13 -5
  101. data/vendor/libgit2/src/unix/pthread.h +2 -0
  102. data/vendor/libgit2/src/win32/thread.c +18 -0
  103. data/vendor/libgit2/src/win32/thread.h +2 -0
  104. data/vendor/libgit2/src/win32/w32_util.h +1 -1
  105. data/vendor/libgit2/src/zstream.c +1 -1
  106. metadata +76 -76
@@ -247,6 +247,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
247
247
  #elif defined(GIT_THREADS) && defined(_POSIX_THREADS)
248
248
 
249
249
  static pthread_key_t _tls_key;
250
+ static pthread_mutex_t _init_mutex = PTHREAD_MUTEX_INITIALIZER;
250
251
  static pthread_once_t _once_init = PTHREAD_ONCE_INIT;
251
252
  int init_error = 0;
252
253
 
@@ -268,12 +269,19 @@ static void init_once(void)
268
269
 
269
270
  int git_libgit2_init(void)
270
271
  {
271
- int ret;
272
+ int ret, err;
272
273
 
273
274
  ret = git_atomic_inc(&git__n_inits);
274
- pthread_once(&_once_init, init_once);
275
275
 
276
- return init_error ? init_error : ret;
276
+ if ((err = pthread_mutex_lock(&_init_mutex)) != 0)
277
+ return err;
278
+ err = pthread_once(&_once_init, init_once);
279
+ err |= pthread_mutex_unlock(&_init_mutex);
280
+
281
+ if (err || init_error)
282
+ return err | init_error;
283
+
284
+ return ret;
277
285
  }
278
286
 
279
287
  int git_libgit2_shutdown(void)
@@ -285,6 +293,9 @@ int git_libgit2_shutdown(void)
285
293
  if ((ret = git_atomic_dec(&git__n_inits)) != 0)
286
294
  return ret;
287
295
 
296
+ if ((ret = pthread_mutex_lock(&_init_mutex)) != 0)
297
+ return ret;
298
+
288
299
  /* Shut down any subsystems that have global state */
289
300
  shutdown_common();
290
301
 
@@ -298,6 +309,9 @@ int git_libgit2_shutdown(void)
298
309
  git_mutex_free(&git__mwindow_mutex);
299
310
  _once_init = new_once;
300
311
 
312
+ if ((ret = pthread_mutex_unlock(&_init_mutex)) != 0)
313
+ return ret;
314
+
301
315
  return 0;
302
316
  }
303
317
 
@@ -327,7 +341,7 @@ int git_libgit2_init(void)
327
341
  {
328
342
  int ret;
329
343
 
330
- /* Only init SSL the first time */
344
+ /* Only init subsystems the first time */
331
345
  if ((ret = git_atomic_inc(&git__n_inits)) != 1)
332
346
  return ret;
333
347
 
@@ -345,6 +359,7 @@ int git_libgit2_shutdown(void)
345
359
  if ((ret = git_atomic_dec(&git__n_inits)) == 0) {
346
360
  shutdown_common();
347
361
  git__global_state_cleanup(&__state);
362
+ memset(&__state, 0, sizeof(__state));
348
363
  }
349
364
 
350
365
  return ret;
@@ -16,6 +16,12 @@ typedef struct {
16
16
  git_error error_t;
17
17
  git_buf error_buf;
18
18
  char oid_fmt[GIT_OID_HEXSZ+1];
19
+
20
+ /* On Windows, this is the current child thread that was started by
21
+ * `git_thread_create`. This is used to set the thread's exit code
22
+ * when terminated by `git_thread_exit`. It is unused on POSIX.
23
+ */
24
+ git_thread *current_thread;
19
25
  } git_global_st;
20
26
 
21
27
  #ifdef GIT_OPENSSL
@@ -59,7 +59,7 @@ static int mark_parents(git_revwalk *walk, git_commit_list_node *one,
59
59
  /* as long as there are non-STALE commits */
60
60
  while (interesting(&list, roots)) {
61
61
  git_commit_list_node *commit = git_pqueue_pop(&list);
62
- int flags;
62
+ unsigned int flags;
63
63
 
64
64
  if (commit == NULL)
65
65
  break;
@@ -552,7 +552,7 @@ int git_index_clear(git_index *index)
552
552
 
553
553
  static int create_index_error(int error, const char *msg)
554
554
  {
555
- giterr_set(GITERR_INDEX, msg);
555
+ giterr_set_str(GITERR_INDEX, msg);
556
556
  return error;
557
557
  }
558
558
 
@@ -1311,7 +1311,7 @@ static int filesystem_iterator_frame_push(
1311
1311
 
1312
1312
  if (iter->frames.size == FILESYSTEM_MAX_DEPTH) {
1313
1313
  giterr_set(GITERR_REPOSITORY,
1314
- "directory nesting too deep (%d)", iter->frames.size);
1314
+ "directory nesting too deep (%"PRIuZ")", iter->frames.size);
1315
1315
  return -1;
1316
1316
  }
1317
1317
 
@@ -591,7 +591,7 @@ int git_repository_mergehead_foreach(
591
591
  }
592
592
 
593
593
  if (*buffer) {
594
- giterr_set(GITERR_MERGE, "No EOL at line %d", line_num);
594
+ giterr_set(GITERR_MERGE, "No EOL at line %"PRIuZ, line_num);
595
595
  error = -1;
596
596
  goto cleanup;
597
597
  }
@@ -1400,7 +1400,7 @@ int git_odb__error_notfound(
1400
1400
  char oid_str[GIT_OID_HEXSZ + 1];
1401
1401
  git_oid_tostr(oid_str, oid_len+1, oid);
1402
1402
  giterr_set(GITERR_ODB, "Object not found - %s (%.*s)",
1403
- message, oid_len, oid_str);
1403
+ message, (int) oid_len, oid_str);
1404
1404
  } else
1405
1405
  giterr_set(GITERR_ODB, "Object not found - %s", message);
1406
1406
 
@@ -24,7 +24,7 @@ struct memobject {
24
24
  git_oid oid;
25
25
  size_t len;
26
26
  git_otype type;
27
- char data[];
27
+ char data[GIT_FLEX_ARRAY];
28
28
  };
29
29
 
30
30
  struct memory_packer_db {
@@ -13,6 +13,7 @@
13
13
  #include "posix.h"
14
14
  #include "stream.h"
15
15
  #include "socket_stream.h"
16
+ #include "openssl_stream.h"
16
17
  #include "netops.h"
17
18
  #include "git2/transport.h"
18
19
  #include "git2/sys/openssl.h"
@@ -71,12 +72,20 @@ static void shutdown_ssl_locking(void)
71
72
 
72
73
  #endif /* GIT_THREADS */
73
74
 
75
+ static BIO_METHOD *git_stream_bio_method;
76
+ static int init_bio_method(void);
77
+
74
78
  /**
75
79
  * This function aims to clean-up the SSL context which
76
80
  * we allocated.
77
81
  */
78
82
  static void shutdown_ssl(void)
79
83
  {
84
+ if (git_stream_bio_method) {
85
+ BIO_meth_free(git_stream_bio_method);
86
+ git_stream_bio_method = NULL;
87
+ }
88
+
80
89
  if (git__ssl_ctx) {
81
90
  SSL_CTX_free(git__ssl_ctx);
82
91
  git__ssl_ctx = NULL;
@@ -121,6 +130,13 @@ int git_openssl_stream_global_init(void)
121
130
  git__ssl_ctx = NULL;
122
131
  return -1;
123
132
  }
133
+
134
+ if (init_bio_method() < 0) {
135
+ SSL_CTX_free(git__ssl_ctx);
136
+ git__ssl_ctx = NULL;
137
+ return -1;
138
+ }
139
+
124
140
  #endif
125
141
 
126
142
  git__on_shutdown(shutdown_ssl);
@@ -148,7 +164,7 @@ int git_openssl_set_locking(void)
148
164
  git__on_shutdown(shutdown_ssl_locking);
149
165
  return 0;
150
166
  #else
151
- giterr_set(GITERR_THREAD, "libgit2 as not built with threads");
167
+ giterr_set(GITERR_THREAD, "libgit2 was not built with threads");
152
168
  return -1;
153
169
  #endif
154
170
  }
@@ -156,10 +172,8 @@ int git_openssl_set_locking(void)
156
172
 
157
173
  static int bio_create(BIO *b)
158
174
  {
159
- b->init = 1;
160
- b->num = 0;
161
- b->ptr = NULL;
162
- b->flags = 0;
175
+ BIO_set_init(b, 1);
176
+ BIO_set_data(b, NULL);
163
177
 
164
178
  return 1;
165
179
  }
@@ -169,23 +183,22 @@ static int bio_destroy(BIO *b)
169
183
  if (!b)
170
184
  return 0;
171
185
 
172
- b->init = 0;
173
- b->num = 0;
174
- b->ptr = NULL;
175
- b->flags = 0;
186
+ BIO_set_data(b, NULL);
176
187
 
177
188
  return 1;
178
189
  }
179
190
 
180
191
  static int bio_read(BIO *b, char *buf, int len)
181
192
  {
182
- git_stream *io = (git_stream *) b->ptr;
193
+ git_stream *io = (git_stream *) BIO_get_data(b);
194
+
183
195
  return (int) git_stream_read(io, buf, len);
184
196
  }
185
197
 
186
198
  static int bio_write(BIO *b, const char *buf, int len)
187
199
  {
188
- git_stream *io = (git_stream *) b->ptr;
200
+ git_stream *io = (git_stream *) BIO_get_data(b);
201
+
189
202
  return (int) git_stream_write(io, buf, len, 0);
190
203
  }
191
204
 
@@ -214,17 +227,22 @@ static int bio_puts(BIO *b, const char *str)
214
227
  return bio_write(b, str, strlen(str));
215
228
  }
216
229
 
217
- static BIO_METHOD git_stream_bio_method = {
218
- BIO_TYPE_SOURCE_SINK,
219
- "git_stream",
220
- bio_write,
221
- bio_read,
222
- bio_puts,
223
- bio_gets,
224
- bio_ctrl,
225
- bio_create,
226
- bio_destroy
227
- };
230
+ static int init_bio_method(void)
231
+ {
232
+ /* Set up the BIO_METHOD we use for wrapping our own stream implementations */
233
+ git_stream_bio_method = BIO_meth_new(BIO_TYPE_SOURCE_SINK | BIO_get_new_index(), "git_stream");
234
+ GITERR_CHECK_ALLOC(git_stream_bio_method);
235
+
236
+ BIO_meth_set_write(git_stream_bio_method, bio_write);
237
+ BIO_meth_set_read(git_stream_bio_method, bio_read);
238
+ BIO_meth_set_puts(git_stream_bio_method, bio_puts);
239
+ BIO_meth_set_gets(git_stream_bio_method, bio_gets);
240
+ BIO_meth_set_ctrl(git_stream_bio_method, bio_ctrl);
241
+ BIO_meth_set_create(git_stream_bio_method, bio_create);
242
+ BIO_meth_set_destroy(git_stream_bio_method, bio_destroy);
243
+
244
+ return 0;
245
+ }
228
246
 
229
247
  static int ssl_set_error(SSL *ssl, int error)
230
248
  {
@@ -339,7 +357,7 @@ static int verify_server_cert(SSL *ssl, const char *host)
339
357
  num = sk_GENERAL_NAME_num(alts);
340
358
  for (i = 0; i < num && matched != 1; i++) {
341
359
  const GENERAL_NAME *gn = sk_GENERAL_NAME_value(alts, i);
342
- const char *name = (char *) ASN1_STRING_data(gn->d.ia5);
360
+ const char *name = (char *) ASN1_STRING_get0_data(gn->d.ia5);
343
361
  size_t namelen = (size_t) ASN1_STRING_length(gn->d.ia5);
344
362
 
345
363
  /* Skip any names of a type we're not looking for */
@@ -394,7 +412,7 @@ static int verify_server_cert(SSL *ssl, const char *host)
394
412
  if (size > 0) {
395
413
  peer_cn = OPENSSL_malloc(size + 1);
396
414
  GITERR_CHECK_ALLOC(peer_cn);
397
- memcpy(peer_cn, ASN1_STRING_data(str), size);
415
+ memcpy(peer_cn, ASN1_STRING_get0_data(str), size);
398
416
  peer_cn[size] = '\0';
399
417
  } else {
400
418
  goto cert_fail_name;
@@ -445,11 +463,12 @@ int openssl_connect(git_stream *stream)
445
463
 
446
464
  st->connected = true;
447
465
 
448
- bio = BIO_new(&git_stream_bio_method);
466
+ bio = BIO_new(git_stream_bio_method);
449
467
  GITERR_CHECK_ALLOC(bio);
450
- bio->ptr = st->io;
451
468
 
469
+ BIO_set_data(bio, st->io);
452
470
  SSL_set_bio(st->ssl, bio, bio);
471
+
453
472
  /* specify the host in case SNI is needed */
454
473
  #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
455
474
  SSL_set_tlsext_host_name(st->ssl, st->host);
@@ -13,4 +13,110 @@ extern int git_openssl_stream_global_init(void);
13
13
 
14
14
  extern int git_openssl_stream_new(git_stream **out, const char *host, const char *port);
15
15
 
16
+ /*
17
+ * OpenSSL 1.1 made BIO opaque so we have to use functions to interact with it
18
+ * which do not exist in previous versions. We define these inline functions so
19
+ * we can program against the interface instead of littering the implementation
20
+ * with ifdefs.
21
+ */
22
+ #ifdef GIT_OPENSSL
23
+ # include <openssl/ssl.h>
24
+ # include <openssl/err.h>
25
+ # include <openssl/x509v3.h>
26
+ # include <openssl/bio.h>
27
+
28
+
29
+
30
+ # if OPENSSL_VERSION_NUMBER < 0x10100000L
31
+
32
+ GIT_INLINE(BIO_METHOD*) BIO_meth_new(int type, const char *name)
33
+ {
34
+ BIO_METHOD *meth = git__calloc(1, sizeof(BIO_METHOD));
35
+ if (!meth) {
36
+ return NULL;
37
+ }
38
+
39
+ meth->type = type;
40
+ meth->name = name;
41
+
42
+ return meth;
43
+ }
44
+
45
+ GIT_INLINE(void) BIO_meth_free(BIO_METHOD *biom)
46
+ {
47
+ git__free(biom);
48
+ }
49
+
50
+ GIT_INLINE(int) BIO_meth_set_write(BIO_METHOD *biom, int (*write) (BIO *, const char *, int))
51
+ {
52
+ biom->bwrite = write;
53
+ return 1;
54
+ }
55
+
56
+ GIT_INLINE(int) BIO_meth_set_read(BIO_METHOD *biom, int (*read) (BIO *, char *, int))
57
+ {
58
+ biom->bread = read;
59
+ return 1;
60
+ }
61
+
62
+ GIT_INLINE(int) BIO_meth_set_puts(BIO_METHOD *biom, int (*puts) (BIO *, const char *))
63
+ {
64
+ biom->bputs = puts;
65
+ return 1;
66
+ }
67
+
68
+ GIT_INLINE(int) BIO_meth_set_gets(BIO_METHOD *biom, int (*gets) (BIO *, char *, int))
69
+
70
+ {
71
+ biom->bgets = gets;
72
+ return 1;
73
+ }
74
+
75
+ GIT_INLINE(int) BIO_meth_set_ctrl(BIO_METHOD *biom, long (*ctrl) (BIO *, int, long, void *))
76
+ {
77
+ biom->ctrl = ctrl;
78
+ return 1;
79
+ }
80
+
81
+ GIT_INLINE(int) BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *))
82
+ {
83
+ biom->create = create;
84
+ return 1;
85
+ }
86
+
87
+ GIT_INLINE(int) BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *))
88
+ {
89
+ biom->destroy = destroy;
90
+ return 1;
91
+ }
92
+
93
+ GIT_INLINE(int) BIO_get_new_index(void)
94
+ {
95
+ /* This exists as of 1.1 so before we'd just have 0 */
96
+ return 0;
97
+ }
98
+
99
+ GIT_INLINE(void) BIO_set_init(BIO *b, int init)
100
+ {
101
+ b->init = init;
102
+ }
103
+
104
+ GIT_INLINE(void) BIO_set_data(BIO *a, void *ptr)
105
+ {
106
+ a->ptr = ptr;
107
+ }
108
+
109
+ GIT_INLINE(void*) BIO_get_data(BIO *a)
110
+ {
111
+ return a->ptr;
112
+ }
113
+
114
+ GIT_INLINE(const unsigned char *) ASN1_STRING_get0_data(const ASN1_STRING *x)
115
+ {
116
+ return ASN1_STRING_data((ASN1_STRING *)x);
117
+ }
118
+
119
+ # endif // OpenSSL < 1.1
120
+ #endif // GIT_OPENSSL
121
+
16
122
  #endif
@@ -509,8 +509,10 @@ int git_packfile_resolve_header(
509
509
  git_packfile_stream_free(&stream);
510
510
  if (error < 0)
511
511
  return error;
512
- } else
512
+ } else {
513
513
  *size_p = size;
514
+ base_offset = 0;
515
+ }
514
516
 
515
517
  while (type == GIT_OBJ_OFS_DELTA || type == GIT_OBJ_REF_DELTA) {
516
518
  curpos = base_offset;
@@ -757,8 +759,11 @@ int git_packfile_unpack(
757
759
  }
758
760
 
759
761
  cleanup:
760
- if (error < 0)
762
+ if (error < 0) {
761
763
  git__free(obj->data);
764
+ if (cached)
765
+ git_atomic_dec(&cached->refcount);
766
+ }
762
767
 
763
768
  if (elem)
764
769
  *obj_offset = curpos;
@@ -1268,8 +1273,8 @@ static int pack_entry_find_offset(
1268
1273
  const git_oid *short_oid,
1269
1274
  size_t len)
1270
1275
  {
1271
- const uint32_t *level1_ofs = p->index_map.data;
1272
- const unsigned char *index = p->index_map.data;
1276
+ const uint32_t *level1_ofs;
1277
+ const unsigned char *index;
1273
1278
  unsigned hi, lo, stride;
1274
1279
  int pos, found = 0;
1275
1280
  git_off_t offset;
@@ -1283,11 +1288,11 @@ static int pack_entry_find_offset(
1283
1288
  if ((error = pack_index_open(p)) < 0)
1284
1289
  return error;
1285
1290
  assert(p->index_map.data);
1286
-
1287
- index = p->index_map.data;
1288
- level1_ofs = p->index_map.data;
1289
1291
  }
1290
1292
 
1293
+ index = p->index_map.data;
1294
+ level1_ofs = p->index_map.data;
1295
+
1291
1296
  if (p->index_version > 1) {
1292
1297
  level1_ofs += 2;
1293
1298
  index += 8;