rugged 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/CMakeLists.txt +1 -1
  4. data/vendor/libgit2/cmake/FindLibSSH2.cmake +13 -0
  5. data/vendor/libgit2/include/git2/attr.h +7 -1
  6. data/vendor/libgit2/include/git2/blob.h +7 -1
  7. data/vendor/libgit2/include/git2/clone.h +1 -1
  8. data/vendor/libgit2/include/git2/common.h +19 -1
  9. data/vendor/libgit2/include/git2/deprecated.h +120 -0
  10. data/vendor/libgit2/include/git2/diff.h +3 -97
  11. data/vendor/libgit2/include/git2/email.h +127 -0
  12. data/vendor/libgit2/include/git2/filter.h +7 -1
  13. data/vendor/libgit2/include/git2/notes.h +2 -2
  14. data/vendor/libgit2/include/git2/oidarray.h +5 -8
  15. data/vendor/libgit2/include/git2/remote.h +4 -4
  16. data/vendor/libgit2/include/git2/repository.h +12 -10
  17. data/vendor/libgit2/include/git2/stash.h +1 -1
  18. data/vendor/libgit2/include/git2/stdint.h +3 -3
  19. data/vendor/libgit2/include/git2/sys/email.h +45 -0
  20. data/vendor/libgit2/include/git2/version.h +3 -3
  21. data/vendor/libgit2/include/git2.h +1 -0
  22. data/vendor/libgit2/src/CMakeLists.txt +7 -0
  23. data/vendor/libgit2/src/attr.c +24 -9
  24. data/vendor/libgit2/src/attr_file.c +23 -15
  25. data/vendor/libgit2/src/attr_file.h +3 -3
  26. data/vendor/libgit2/src/blame.c +4 -4
  27. data/vendor/libgit2/src/blame_git.c +1 -1
  28. data/vendor/libgit2/src/blob.c +15 -9
  29. data/vendor/libgit2/src/buffer.c +16 -8
  30. data/vendor/libgit2/src/buffer.h +2 -1
  31. data/vendor/libgit2/src/cc-compat.h +1 -7
  32. data/vendor/libgit2/src/checkout.c +6 -7
  33. data/vendor/libgit2/src/clone.c +1 -1
  34. data/vendor/libgit2/src/commit_graph.c +1 -1
  35. data/vendor/libgit2/src/config.c +1 -1
  36. data/vendor/libgit2/src/config_file.c +2 -2
  37. data/vendor/libgit2/src/config_parse.c +1 -1
  38. data/vendor/libgit2/src/describe.c +1 -1
  39. data/vendor/libgit2/src/diff.c +41 -173
  40. data/vendor/libgit2/src/email.c +299 -0
  41. data/vendor/libgit2/src/email.h +25 -0
  42. data/vendor/libgit2/src/filter.c +7 -1
  43. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +8 -8
  44. data/vendor/libgit2/src/ignore.c +2 -2
  45. data/vendor/libgit2/src/indexer.c +37 -3
  46. data/vendor/libgit2/src/libgit2.c +23 -0
  47. data/vendor/libgit2/src/merge.c +7 -4
  48. data/vendor/libgit2/src/notes.c +31 -31
  49. data/vendor/libgit2/src/oidarray.c +10 -1
  50. data/vendor/libgit2/src/path.c +1 -1
  51. data/vendor/libgit2/src/path.h +1 -1
  52. data/vendor/libgit2/src/pathspec.c +1 -1
  53. data/vendor/libgit2/src/refdb_fs.c +1 -1
  54. data/vendor/libgit2/src/refs.c +2 -2
  55. data/vendor/libgit2/src/refspec.c +1 -1
  56. data/vendor/libgit2/src/remote.c +12 -5
  57. data/vendor/libgit2/src/repository.c +130 -19
  58. data/vendor/libgit2/src/repository.h +4 -0
  59. data/vendor/libgit2/src/reset.c +1 -1
  60. data/vendor/libgit2/src/revparse.c +4 -4
  61. data/vendor/libgit2/src/stash.c +1 -1
  62. data/vendor/libgit2/src/streams/openssl_legacy.c +1 -1
  63. data/vendor/libgit2/src/streams/openssl_legacy.h +1 -1
  64. data/vendor/libgit2/src/threadstate.c +2 -1
  65. data/vendor/libgit2/src/trailer.c +1 -1
  66. data/vendor/libgit2/src/transports/ssh.c +4 -4
  67. data/vendor/libgit2/src/transports/winhttp.c +1 -1
  68. data/vendor/libgit2/src/util.c +1 -1
  69. data/vendor/libgit2/src/util.h +1 -1
  70. data/vendor/libgit2/src/win32/findfile.c +1 -1
  71. data/vendor/libgit2/src/win32/posix.h +6 -6
  72. data/vendor/libgit2/src/win32/posix_w32.c +9 -6
  73. metadata +11 -6
@@ -0,0 +1,45 @@
1
+ /*
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
3
+ *
4
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
5
+ * a Linking Exception. For full terms see the included COPYING file.
6
+ */
7
+ #ifndef INCLUDE_sys_git_email_h__
8
+ #define INCLUDE_sys_git_email_h__
9
+
10
+ /**
11
+ * @file git2/sys/email.h
12
+ * @brief Advanced git email creation routines
13
+ * @defgroup git_email Advanced git email creation routines
14
+ * @ingroup Git
15
+ * @{
16
+ */
17
+ GIT_BEGIN_DECL
18
+
19
+ /**
20
+ * Create a diff for a commit in mbox format for sending via email.
21
+ *
22
+ * @param out buffer to store the e-mail patch in
23
+ * @param diff the changes to include in the email
24
+ * @param patch_idx the patch index
25
+ * @param patch_count the total number of patches that will be included
26
+ * @param commit_id the commit id for this change
27
+ * @param summary the commit message for this change
28
+ * @param body optional text to include above the diffstat
29
+ * @param author the person who authored this commit
30
+ * @param opts email creation options
31
+ */
32
+ GIT_EXTERN(int) git_email_create_from_diff(
33
+ git_buf *out,
34
+ git_diff *diff,
35
+ size_t patch_idx,
36
+ size_t patch_count,
37
+ const git_oid *commit_id,
38
+ const char *summary,
39
+ const char *body,
40
+ const git_signature *author,
41
+ const git_email_create_options *opts);
42
+
43
+ /** @} */
44
+ GIT_END_DECL
45
+ #endif
@@ -7,12 +7,12 @@
7
7
  #ifndef INCLUDE_git_version_h__
8
8
  #define INCLUDE_git_version_h__
9
9
 
10
- #define LIBGIT2_VERSION "1.2.0"
10
+ #define LIBGIT2_VERSION "1.3.0"
11
11
  #define LIBGIT2_VER_MAJOR 1
12
- #define LIBGIT2_VER_MINOR 2
12
+ #define LIBGIT2_VER_MINOR 3
13
13
  #define LIBGIT2_VER_REVISION 0
14
14
  #define LIBGIT2_VER_PATCH 0
15
15
 
16
- #define LIBGIT2_SOVERSION "1.2"
16
+ #define LIBGIT2_SOVERSION "1.3"
17
17
 
18
18
  #endif
@@ -26,6 +26,7 @@
26
26
  #include "git2/deprecated.h"
27
27
  #include "git2/describe.h"
28
28
  #include "git2/diff.h"
29
+ #include "git2/email.h"
29
30
  #include "git2/errors.h"
30
31
  #include "git2/filter.h"
31
32
  #include "git2/global.h"
@@ -232,6 +232,13 @@ ENDIF()
232
232
  # Optional external dependency: libssh2
233
233
  IF (USE_SSH)
234
234
  FIND_PKGLIBRARIES(LIBSSH2 libssh2)
235
+ IF (NOT LIBSSH2_FOUND)
236
+ FIND_PACKAGE(LibSSH2)
237
+ SET(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
238
+ GET_FILENAME_COMPONENT(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY)
239
+ SET(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY})
240
+ SET(LIBSSH2_LDFLAGS "-lssh2")
241
+ ENDIF()
235
242
  ENDIF()
236
243
  IF (LIBSSH2_FOUND)
237
244
  SET(GIT_SSH 1)
@@ -68,7 +68,7 @@ int git_attr_get_ext(
68
68
  if (git_repository_is_bare(repo))
69
69
  dir_flag = GIT_DIR_FLAG_FALSE;
70
70
 
71
- if (git_attr_path__init(&path, repo, pathname, git_repository_workdir(repo), dir_flag) < 0)
71
+ if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
72
72
  return -1;
73
73
 
74
74
  if ((error = collect_attr_files(repo, NULL, opts, pathname, &files)) < 0)
@@ -149,7 +149,7 @@ int git_attr_get_many_with_session(
149
149
  if (git_repository_is_bare(repo))
150
150
  dir_flag = GIT_DIR_FLAG_FALSE;
151
151
 
152
- if (git_attr_path__init(&path, repo, pathname, git_repository_workdir(repo), dir_flag) < 0)
152
+ if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
153
153
  return -1;
154
154
 
155
155
  if ((error = collect_attr_files(repo, attr_session, opts, pathname, &files)) < 0)
@@ -264,7 +264,7 @@ int git_attr_foreach_ext(
264
264
  if (git_repository_is_bare(repo))
265
265
  dir_flag = GIT_DIR_FLAG_FALSE;
266
266
 
267
- if (git_attr_path__init(&path, repo, pathname, git_repository_workdir(repo), dir_flag) < 0)
267
+ if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
268
268
  return -1;
269
269
 
270
270
  if ((error = collect_attr_files(repo, NULL, opts, pathname, &files)) < 0 ||
@@ -382,7 +382,7 @@ static int attr_setup(
382
382
  {
383
383
  git_buf system = GIT_BUF_INIT, info = GIT_BUF_INIT;
384
384
  git_attr_file_source index_source = { GIT_ATTR_FILE_SOURCE_INDEX, NULL, GIT_ATTR_FILE, NULL };
385
- git_attr_file_source head_source = { GIT_ATTR_FILE_SOURCE_COMMIT, NULL, GIT_ATTR_FILE, NULL };
385
+ git_attr_file_source head_source = { GIT_ATTR_FILE_SOURCE_HEAD, NULL, GIT_ATTR_FILE, NULL };
386
386
  git_attr_file_source commit_source = { GIT_ATTR_FILE_SOURCE_COMMIT, NULL, GIT_ATTR_FILE, NULL };
387
387
  git_index *idx = NULL;
388
388
  const char *workdir;
@@ -432,7 +432,12 @@ static int attr_setup(
432
432
  goto out;
433
433
 
434
434
  if ((opts && (opts->flags & GIT_ATTR_CHECK_INCLUDE_COMMIT) != 0)) {
435
- commit_source.commit_id = opts->commit_id;
435
+ #ifndef GIT_DEPRECATE_HARD
436
+ if (opts->commit_id)
437
+ commit_source.commit_id = opts->commit_id;
438
+ else
439
+ #endif
440
+ commit_source.commit_id = &opts->attr_commit_id;
436
441
 
437
442
  if ((error = preload_attr_source(repo, attr_session, &commit_source)) < 0)
438
443
  goto out;
@@ -521,8 +526,10 @@ static int attr_decide_sources(
521
526
  break;
522
527
  }
523
528
 
524
- if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0 ||
525
- (flags & GIT_ATTR_CHECK_INCLUDE_COMMIT) != 0)
529
+ if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0)
530
+ srcs[count++] = GIT_ATTR_FILE_SOURCE_HEAD;
531
+
532
+ if ((flags & GIT_ATTR_CHECK_INCLUDE_COMMIT) != 0)
526
533
  srcs[count++] = GIT_ATTR_FILE_SOURCE_COMMIT;
527
534
 
528
535
  return count;
@@ -582,8 +589,14 @@ static int push_one_attr(void *ref, const char *path)
582
589
  for (i = 0; !error && i < n_src; ++i) {
583
590
  git_attr_file_source source = { src[i], path, GIT_ATTR_FILE };
584
591
 
585
- if (src[i] == GIT_ATTR_FILE_SOURCE_COMMIT && info->opts)
586
- source.commit_id = info->opts->commit_id;
592
+ if (src[i] == GIT_ATTR_FILE_SOURCE_COMMIT && info->opts) {
593
+ #ifndef GIT_DEPRECATE_HARD
594
+ if (info->opts->commit_id)
595
+ source.commit_id = info->opts->commit_id;
596
+ else
597
+ #endif
598
+ source.commit_id = &info->opts->attr_commit_id;
599
+ }
587
600
 
588
601
  error = push_attr_source(info->repo, info->attr_session, info->files,
589
602
  &source, allow_macros);
@@ -616,6 +629,8 @@ static int collect_attr_files(
616
629
  const char *workdir = git_repository_workdir(repo);
617
630
  attr_walk_up_info info = { NULL };
618
631
 
632
+ GIT_ASSERT(!git_path_is_absolute(path));
633
+
619
634
  if ((error = attr_setup(repo, attr_session, opts)) < 0)
620
635
  return error;
621
636
 
@@ -163,8 +163,9 @@ int git_attr_file__load(
163
163
 
164
164
  break;
165
165
  }
166
+ case GIT_ATTR_FILE_SOURCE_HEAD:
166
167
  case GIT_ATTR_FILE_SOURCE_COMMIT: {
167
- if (source->commit_id) {
168
+ if (source->type == GIT_ATTR_FILE_SOURCE_COMMIT) {
168
169
  if ((error = git_commit_lookup(&commit, repo, source->commit_id)) < 0 ||
169
170
  (error = git_commit_tree(&tree, commit)) < 0)
170
171
  goto cleanup;
@@ -234,6 +235,8 @@ int git_attr_file__load(
234
235
  file->nonexistent = 1;
235
236
  else if (source->type == GIT_ATTR_FILE_SOURCE_INDEX)
236
237
  git_oid_cpy(&file->cache_data.oid, git_blob_id(blob));
238
+ else if (source->type == GIT_ATTR_FILE_SOURCE_HEAD)
239
+ git_oid_cpy(&file->cache_data.oid, git_tree_id(tree));
237
240
  else if (source->type == GIT_ATTR_FILE_SOURCE_COMMIT)
238
241
  git_oid_cpy(&file->cache_data.oid, git_tree_id(tree));
239
242
  else if (source->type == GIT_ATTR_FILE_SOURCE_FILE)
@@ -288,22 +291,29 @@ int git_attr_file__out_of_date(
288
291
  return (git_oid__cmp(&file->cache_data.oid, &id) != 0);
289
292
  }
290
293
 
291
- case GIT_ATTR_FILE_SOURCE_COMMIT: {
294
+ case GIT_ATTR_FILE_SOURCE_HEAD: {
292
295
  git_tree *tree = NULL;
293
- int error;
296
+ int error = git_repository_head_tree(&tree, repo);
294
297
 
295
- if (source->commit_id) {
296
- git_commit *commit = NULL;
298
+ if (error < 0)
299
+ return error;
300
+
301
+ error = (git_oid__cmp(&file->cache_data.oid, git_tree_id(tree)) != 0);
302
+
303
+ git_tree_free(tree);
304
+ return error;
305
+ }
297
306
 
298
- if ((error = git_commit_lookup(&commit, repo, source->commit_id)) < 0)
299
- return error;
307
+ case GIT_ATTR_FILE_SOURCE_COMMIT: {
308
+ git_commit *commit = NULL;
309
+ git_tree *tree = NULL;
310
+ int error;
300
311
 
301
- error = git_commit_tree(&tree, commit);
312
+ if ((error = git_commit_lookup(&commit, repo, source->commit_id)) < 0)
313
+ return error;
302
314
 
303
- git_commit_free(commit);
304
- } else {
305
- error = git_repository_head_tree(&tree, repo);
306
- }
315
+ error = git_commit_tree(&tree, commit);
316
+ git_commit_free(commit);
307
317
 
308
318
  if (error < 0)
309
319
  return error;
@@ -541,7 +551,6 @@ git_attr_assignment *git_attr_rule__lookup_assignment(
541
551
 
542
552
  int git_attr_path__init(
543
553
  git_attr_path *info,
544
- git_repository *repo,
545
554
  const char *path,
546
555
  const char *base,
547
556
  git_dir_flag dir_flag)
@@ -551,8 +560,7 @@ int git_attr_path__init(
551
560
  /* build full path as best we can */
552
561
  git_buf_init(&info->full, 0);
553
562
 
554
- if (git_path_join_unrooted(&info->full, path, base, &root) < 0 ||
555
- git_path_validate_workdir_buf(repo, &info->full) < 0)
563
+ if (git_path_join_unrooted(&info->full, path, base, &root) < 0)
556
564
  return -1;
557
565
 
558
566
  info->path = info->full.ptr + root;
@@ -40,9 +40,10 @@ typedef enum {
40
40
  GIT_ATTR_FILE_SOURCE_MEMORY = 0,
41
41
  GIT_ATTR_FILE_SOURCE_FILE = 1,
42
42
  GIT_ATTR_FILE_SOURCE_INDEX = 2,
43
- GIT_ATTR_FILE_SOURCE_COMMIT = 3,
43
+ GIT_ATTR_FILE_SOURCE_HEAD = 3,
44
+ GIT_ATTR_FILE_SOURCE_COMMIT = 4,
44
45
 
45
- GIT_ATTR_FILE_NUM_SOURCES = 4
46
+ GIT_ATTR_FILE_NUM_SOURCES = 5
46
47
  } git_attr_file_source_t;
47
48
 
48
49
  typedef struct {
@@ -226,7 +227,6 @@ typedef enum { GIT_DIR_FLAG_TRUE = 1, GIT_DIR_FLAG_FALSE = 0, GIT_DIR_FLAG_UNKNO
226
227
 
227
228
  extern int git_attr_path__init(
228
229
  git_attr_path *out,
229
- git_repository *repo,
230
230
  const char *path,
231
231
  const char *base,
232
232
  git_dir_flag is_dir);
@@ -59,7 +59,7 @@ static bool hunk_starts_at_or_after_line(git_blame_hunk *hunk, size_t line)
59
59
  return line <= hunk->final_start_line_number;
60
60
  }
61
61
 
62
- static git_blame_hunk* new_hunk(
62
+ static git_blame_hunk *new_hunk(
63
63
  size_t start,
64
64
  size_t lines,
65
65
  size_t orig_start,
@@ -84,7 +84,7 @@ static void free_hunk(git_blame_hunk *hunk)
84
84
  git__free(hunk);
85
85
  }
86
86
 
87
- static git_blame_hunk* dup_hunk(git_blame_hunk *hunk)
87
+ static git_blame_hunk *dup_hunk(git_blame_hunk *hunk)
88
88
  {
89
89
  git_blame_hunk *newhunk = new_hunk(
90
90
  hunk->final_start_line_number,
@@ -122,7 +122,7 @@ static void shift_hunks_by(git_vector *v, size_t start_line, int shift_by)
122
122
  }
123
123
  }
124
124
 
125
- git_blame* git_blame__alloc(
125
+ git_blame *git_blame__alloc(
126
126
  git_repository *repo,
127
127
  git_blame_options opts,
128
128
  const char *path)
@@ -299,7 +299,7 @@ static int index_blob_lines(git_blame *blame)
299
299
  return blame->num_lines;
300
300
  }
301
301
 
302
- static git_blame_hunk* hunk_from_entry(git_blame__entry *e, git_blame *blame)
302
+ static git_blame_hunk *hunk_from_entry(git_blame__entry *e, git_blame *blame)
303
303
  {
304
304
  git_blame_hunk *h = new_hunk(
305
305
  e->lno+1, e->num_lines, e->s_lno+1, e->suspect->path);
@@ -429,7 +429,7 @@ static int paths_on_dup(void **old, void *new)
429
429
  return -1;
430
430
  }
431
431
 
432
- static git_blame__origin* find_origin(
432
+ static git_blame__origin *find_origin(
433
433
  git_blame *blame,
434
434
  git_commit *parent,
435
435
  git_blame__origin *origin)
@@ -138,12 +138,13 @@ static int write_file_filtered(
138
138
  git_object_size_t *size,
139
139
  git_odb *odb,
140
140
  const char *full_path,
141
- git_filter_list *fl)
141
+ git_filter_list *fl,
142
+ git_repository* repo)
142
143
  {
143
144
  int error;
144
145
  git_buf tgt = GIT_BUF_INIT;
145
146
 
146
- error = git_filter_list_apply_to_file(&tgt, fl, NULL, full_path);
147
+ error = git_filter_list_apply_to_file(&tgt, fl, repo, full_path);
147
148
 
148
149
  /* Write the file to disk if it was properly filtered */
149
150
  if (!error) {
@@ -238,7 +239,7 @@ int git_blob__create_from_paths(
238
239
  error = write_file_stream(id, odb, content_path, size);
239
240
  else {
240
241
  /* We need to apply one or more filters */
241
- error = write_file_filtered(id, &size, odb, content_path, fl);
242
+ error = write_file_filtered(id, &size, odb, content_path, fl, repo);
242
243
 
243
244
  git_filter_list_free(fl);
244
245
  }
@@ -276,21 +277,20 @@ int git_blob_create_from_disk(
276
277
  {
277
278
  int error;
278
279
  git_buf full_path = GIT_BUF_INIT;
279
- const char *workdir, *hintpath;
280
+ const char *workdir, *hintpath = NULL;
280
281
 
281
282
  if ((error = git_path_prettify(&full_path, path, NULL)) < 0) {
282
283
  git_buf_dispose(&full_path);
283
284
  return error;
284
285
  }
285
286
 
286
- hintpath = git_buf_cstr(&full_path);
287
287
  workdir = git_repository_workdir(repo);
288
288
 
289
- if (workdir && !git__prefixcmp(hintpath, workdir))
290
- hintpath += strlen(workdir);
289
+ if (workdir && !git__prefixcmp(full_path.ptr, workdir))
290
+ hintpath = full_path.ptr + strlen(workdir);
291
291
 
292
292
  error = git_blob__create_from_paths(
293
- id, NULL, repo, git_buf_cstr(&full_path), hintpath, 0, true);
293
+ id, NULL, repo, git_buf_cstr(&full_path), hintpath, 0, !!hintpath);
294
294
 
295
295
  git_buf_dispose(&full_path);
296
296
  return error;
@@ -448,7 +448,13 @@ int git_blob_filter(
448
448
 
449
449
  if ((opts.flags & GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT) != 0) {
450
450
  filter_opts.flags |= GIT_FILTER_ATTRIBUTES_FROM_COMMIT;
451
- filter_opts.commit_id = opts.commit_id;
451
+
452
+ #ifndef GIT_DEPRECATE_HARD
453
+ if (opts.commit_id)
454
+ git_oid_cpy(&filter_opts.attr_commit_id, opts.commit_id);
455
+ else
456
+ #endif
457
+ git_oid_cpy(&filter_opts.attr_commit_id, &opts.attr_commit_id);
452
458
  }
453
459
 
454
460
  if (!(error = git_filter_list_load_ext(
@@ -600,6 +600,13 @@ void git_buf_shorten(git_buf *buf, size_t amount)
600
600
  git_buf_clear(buf);
601
601
  }
602
602
 
603
+ void git_buf_truncate_at_char(git_buf *buf, char separator)
604
+ {
605
+ ssize_t idx = git_buf_find(buf, separator);
606
+ if (idx >= 0)
607
+ git_buf_truncate(buf, (size_t)idx);
608
+ }
609
+
603
610
  void git_buf_rtruncate_at_char(git_buf *buf, char separator)
604
611
  {
605
612
  ssize_t idx = git_buf_rfind_next(buf, separator);
@@ -670,7 +677,7 @@ int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...)
670
677
 
671
678
  va_start(ap, nbuf);
672
679
  for (i = 0; i < nbuf; ++i) {
673
- const char* segment;
680
+ const char *segment;
674
681
  size_t segment_len;
675
682
 
676
683
  segment = va_arg(ap, const char *);
@@ -702,7 +709,7 @@ int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...)
702
709
 
703
710
  va_start(ap, nbuf);
704
711
  for (i = 0; i < nbuf; ++i) {
705
- const char* segment;
712
+ const char *segment;
706
713
  size_t segment_len;
707
714
 
708
715
  segment = va_arg(ap, const char *);
@@ -1194,25 +1201,26 @@ int git_buf_lf_to_crlf(git_buf *tgt, const git_buf *src)
1194
1201
  return git_buf_put(tgt, scan, end - scan);
1195
1202
  }
1196
1203
 
1197
- int git_buf_common_prefix(git_buf *buf, const git_strarray *strings)
1204
+ int git_buf_common_prefix(git_buf *buf, char *const *const strings, size_t count)
1198
1205
  {
1199
1206
  size_t i;
1200
1207
  const char *str, *pfx;
1201
1208
 
1202
1209
  git_buf_clear(buf);
1203
1210
 
1204
- if (!strings || !strings->count)
1211
+ if (!strings || !count)
1205
1212
  return 0;
1206
1213
 
1207
1214
  /* initialize common prefix to first string */
1208
- if (git_buf_sets(buf, strings->strings[0]) < 0)
1215
+ if (git_buf_sets(buf, strings[0]) < 0)
1209
1216
  return -1;
1210
1217
 
1211
1218
  /* go through the rest of the strings, truncating to shared prefix */
1212
- for (i = 1; i < strings->count; ++i) {
1219
+ for (i = 1; i < count; ++i) {
1213
1220
 
1214
- for (str = strings->strings[i], pfx = buf->ptr;
1215
- *str && *str == *pfx; str++, pfx++)
1221
+ for (str = strings[i], pfx = buf->ptr;
1222
+ *str && *str == *pfx;
1223
+ str++, pfx++)
1216
1224
  /* scanning */;
1217
1225
 
1218
1226
  git_buf_truncate(buf, pfx - buf->ptr);
@@ -171,6 +171,7 @@ void git_buf_consume_bytes(git_buf *buf, size_t len);
171
171
  void git_buf_consume(git_buf *buf, const char *end);
172
172
  void git_buf_truncate(git_buf *buf, size_t len);
173
173
  void git_buf_shorten(git_buf *buf, size_t amount);
174
+ void git_buf_truncate_at_char(git_buf *buf, char separator);
174
175
  void git_buf_rtruncate_at_char(git_buf *path, char separator);
175
176
 
176
177
  /** General join with separator */
@@ -323,7 +324,7 @@ extern int git_buf_lf_to_crlf(git_buf *tgt, const git_buf *src);
323
324
  *
324
325
  * Buffer will be set to empty if there is no common prefix
325
326
  */
326
- extern int git_buf_common_prefix(git_buf *buf, const git_strarray *strs);
327
+ extern int git_buf_common_prefix(git_buf *buf, char *const *const strings, size_t count);
327
328
 
328
329
  /**
329
330
  * Check if a buffer begins with a UTF BOM
@@ -29,12 +29,6 @@
29
29
  # endif
30
30
  #endif
31
31
 
32
- #ifdef __GNUC__
33
- # define GIT_TYPEOF(x) (__typeof__(x))
34
- #else
35
- # define GIT_TYPEOF(x)
36
- #endif
37
-
38
32
  #if defined(__GNUC__)
39
33
  # define GIT_ALIGN(x,size) x __attribute__ ((aligned(size)))
40
34
  #elif defined(_MSC_VER)
@@ -46,7 +40,7 @@
46
40
  #if defined(__GNUC__)
47
41
  # define GIT_UNUSED(x) \
48
42
  do { \
49
- typeof(x) _unused __attribute__((unused)); \
43
+ __typeof__(x) _unused __attribute__((unused)); \
50
44
  _unused = (x); \
51
45
  } while (0)
52
46
  #else
@@ -1520,8 +1520,7 @@ static int blob_content_to_file(
1520
1520
  int fd;
1521
1521
  int error = 0;
1522
1522
 
1523
- if (hint_path == NULL)
1524
- hint_path = path;
1523
+ GIT_ASSERT(hint_path != NULL);
1525
1524
 
1526
1525
  if ((error = mkpath2file(data, path, data->opts.dir_mode)) < 0)
1527
1526
  return error;
@@ -1789,7 +1788,7 @@ static int checkout_blob(
1789
1788
  }
1790
1789
 
1791
1790
  error = checkout_write_content(
1792
- data, &file->id, fullpath->ptr, NULL, file->mode, &st);
1791
+ data, &file->id, fullpath->ptr, file->path, file->mode, &st);
1793
1792
 
1794
1793
  /* update the index unless prevented */
1795
1794
  if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
@@ -1975,7 +1974,7 @@ static int checkout_write_entry(
1975
1974
  checkout_conflictdata *conflict,
1976
1975
  const git_index_entry *side)
1977
1976
  {
1978
- const char *hint_path = NULL, *suffix;
1977
+ const char *hint_path, *suffix;
1979
1978
  git_buf *fullpath;
1980
1979
  struct stat st;
1981
1980
  int error;
@@ -1998,10 +1997,10 @@ static int checkout_write_entry(
1998
1997
 
1999
1998
  if (checkout_path_suffixed(fullpath, suffix) < 0)
2000
1999
  return -1;
2001
-
2002
- hint_path = side->path;
2003
2000
  }
2004
2001
 
2002
+ hint_path = side->path;
2003
+
2005
2004
  if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 &&
2006
2005
  (error = checkout_safe_for_update_only(data, fullpath->ptr, side->mode)) <= 0)
2007
2006
  return error;
@@ -2118,7 +2117,7 @@ static int checkout_write_merge(
2118
2117
  filter_session.temp_buf = &data->tmp;
2119
2118
 
2120
2119
  if ((error = git_filter_list__load(
2121
- &fl, data->repo, NULL, git_buf_cstr(&path_workdir),
2120
+ &fl, data->repo, NULL, result.path,
2122
2121
  GIT_FILTER_TO_WORKTREE, &filter_session)) < 0 ||
2123
2122
  (error = git_filter_list__convert_buf(&out_data, fl, &in_data)) < 0)
2124
2123
  goto done;
@@ -265,7 +265,7 @@ static int update_head_to_branch(
265
265
  {
266
266
  int retcode;
267
267
  git_buf remote_branch_name = GIT_BUF_INIT;
268
- git_reference* remote_ref = NULL;
268
+ git_reference *remote_ref = NULL;
269
269
  git_buf default_branch = GIT_BUF_INIT;
270
270
 
271
271
  GIT_ASSERT_ARG(remote);
@@ -728,7 +728,7 @@ int git_commit_graph_writer_add_revwalk(git_commit_graph_writer *w, git_revwalk
728
728
  git_oid id;
729
729
  git_repository *repo = git_revwalk_repository(walk);
730
730
  git_commit *commit;
731
- struct packed_commit* packed_commit;
731
+ struct packed_commit *packed_commit;
732
732
 
733
733
  while ((git_revwalk_next(&id, walk)) == 0) {
734
734
  error = git_commit_lookup(&commit, repo, &id);
@@ -511,7 +511,7 @@ int git_config_backend_foreach_match(
511
511
  void *payload)
512
512
  {
513
513
  git_config_entry *entry;
514
- git_config_iterator* iter;
514
+ git_config_iterator *iter;
515
515
  git_regexp regex;
516
516
  int error = 0;
517
517
 
@@ -164,7 +164,7 @@ out:
164
164
  return error;
165
165
  }
166
166
 
167
- static void config_file_clear_includes(config_file_backend* cfg)
167
+ static void config_file_clear_includes(config_file_backend *cfg)
168
168
  {
169
169
  config_file *include;
170
170
  uint32_t i;
@@ -1104,7 +1104,7 @@ static int write_on_eof(
1104
1104
  /*
1105
1105
  * This is pretty much the parsing, except we write out anything we don't have
1106
1106
  */
1107
- static int config_file_write(config_file_backend *cfg, const char *orig_key, const char *key, const git_regexp *preg, const char* value)
1107
+ static int config_file_write(config_file_backend *cfg, const char *orig_key, const char *key, const git_regexp *preg, const char *value)
1108
1108
 
1109
1109
  {
1110
1110
  char *orig_section = NULL, *section = NULL, *orig_name, *name, *ldot;
@@ -349,7 +349,7 @@ static int parse_multiline_variable(git_config_parser *reader, git_buf *value, i
349
349
  }
350
350
 
351
351
  /* If it was just a comment, pretend it didn't exist */
352
- quote_count = strip_comments(line, !!in_quotes);
352
+ quote_count = strip_comments(line, in_quotes);
353
353
  if (line[0] == '\0')
354
354
  goto next;
355
355
 
@@ -391,7 +391,7 @@ static int show_suffix(
391
391
  git_buf *buf,
392
392
  int depth,
393
393
  git_repository *repo,
394
- const git_oid* id,
394
+ const git_oid *id,
395
395
  unsigned int abbrev_size)
396
396
  {
397
397
  int error, size = 0;