Skip to content

Commit e8bc855

Browse files
committed
Merge remote-tracking branch 'origin/master' into charliesome/trailer-info
2 parents 72fbf05 + 7610638 commit e8bc855

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1397
-427
lines changed

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ OPTION( ENABLE_TRACE "Enables tracing support" OFF )
4343
OPTION( LIBGIT2_FILENAME "Name of the produced binary" OFF )
4444

4545
OPTION( USE_SHA1DC "Use SHA-1 with collision detection" OFF )
46-
OPTION( USE_ICONV "Link with and use iconv library" OFF )
4746
OPTION( USE_SSH "Link with libssh to enable SSH support" ON )
4847
OPTION( USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON )
4948
OPTION( USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF )
@@ -52,10 +51,15 @@ OPTION( CURL "Use curl for HTTP if available" ON)
5251
OPTION( USE_EXT_HTTP_PARSER "Use system HTTP_Parser if available" ON)
5352
OPTION( DEBUG_POOL "Enable debug pool allocator" OFF )
5453
OPTION( ENABLE_WERROR "Enable compilation with -Werror" OFF )
54+
OPTION( USE_BUNDLED_ZLIB "Use the bundled version of zlib" OFF )
55+
5556
IF (UNIX AND NOT APPLE)
5657
OPTION( ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF )
5758
ENDIF()
58-
OPTION( USE_BUNDLED_ZLIB "Use the bundled version of zlib" OFF )
59+
60+
IF (APPLE)
61+
OPTION( USE_ICONV "Link with and use iconv library" ON )
62+
ENDIF()
5963

6064
IF(MSVC)
6165
# This option is only available when building with MSVC. By default, libgit2

git.git-authors

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ ok Jeff King <peff@peff.net>
5353
ok Johannes Schindelin <Johannes.Schindelin@gmx.de>
5454
ok Johannes Sixt <j6t@kdbg.org>
5555
ask Jonathan Nieder <jrnieder@gmail.com>
56+
ok Jonathan Tan <jonathantanmy@google.com>
5657
ok Junio C Hamano <gitster@pobox.com>
5758
ok Kristian Høgsberg <krh@redhat.com>
5859
ok Linus Torvalds <torvalds@linux-foundation.org>

include/git2/notes.h

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ GIT_EXTERN(int) git_note_iterator_new(
5151
git_repository *repo,
5252
const char *notes_ref);
5353

54+
/**
55+
* Creates a new iterator for notes from a commit
56+
*
57+
* The iterator must be freed manually by the user.
58+
*
59+
* @param out pointer to the iterator
60+
* @param notes_commit a pointer to the notes commit object
61+
*
62+
* @return 0 or an error code
63+
*/
64+
GIT_EXTERN(int) git_note_commit_iterator_new(
65+
git_note_iterator **out,
66+
git_commit *notes_commit);
67+
5468
/**
5569
* Frees an git_note_iterator
5670
*
@@ -94,6 +108,25 @@ GIT_EXTERN(int) git_note_read(
94108
const char *notes_ref,
95109
const git_oid *oid);
96110

111+
112+
/**
113+
* Read the note for an object from a note commit
114+
*
115+
* The note must be freed manually by the user.
116+
*
117+
* @param out pointer to the read note; NULL in case of error
118+
* @param repo repository where to look up the note
119+
* @param notes_commit a pointer to the notes commit object
120+
* @param oid OID of the git object to read the note from
121+
*
122+
* @return 0 or an error code
123+
*/
124+
GIT_EXTERN(int) git_note_commit_read(
125+
git_note **out,
126+
git_repository *repo,
127+
git_commit *notes_commit,
128+
const git_oid *oid);
129+
97130
/**
98131
* Get the note author
99132
*
@@ -153,6 +186,36 @@ GIT_EXTERN(int) git_note_create(
153186
const char *note,
154187
int force);
155188

189+
/**
190+
* Add a note for an object from a commit
191+
*
192+
* This function will create a notes commit for a given object,
193+
* the commit is a dangling commit, no reference is created.
194+
*
195+
* @param notes_commit_out pointer to store the commit (optional);
196+
* NULL in case of error
197+
* @param notes_blob_out a point to the id of a note blob (optional)
198+
* @param repo repository where the note will live
199+
* @param parent Pointer to parent note
200+
* or NULL if this shall start a new notes tree
201+
* @param author signature of the notes commit author
202+
* @param committer signature of the notes commit committer
203+
* @param oid OID of the git object to decorate
204+
* @param note Content of the note to add for object oid
205+
* @param allow_note_overwrite Overwrite existing note
206+
*
207+
* @return 0 or an error code
208+
*/
209+
GIT_EXTERN(int) git_note_commit_create(
210+
git_oid *notes_commit_out,
211+
git_oid *notes_blob_out,
212+
git_repository *repo,
213+
git_commit *parent,
214+
const git_signature *author,
215+
const git_signature *committer,
216+
const git_oid *oid,
217+
const char *note,
218+
int allow_note_overwrite);
156219

157220
/**
158221
* Remove the note for an object
@@ -173,6 +236,32 @@ GIT_EXTERN(int) git_note_remove(
173236
const git_signature *committer,
174237
const git_oid *oid);
175238

239+
/**
240+
* Remove the note for an object
241+
*
242+
* @param notes_commit_out pointer to store the new notes commit (optional);
243+
* NULL in case of error.
244+
* When removing a note a new tree containing all notes
245+
* sans the note to be removed is created and a new commit
246+
* pointing to that tree is also created.
247+
* In the case where the resulting tree is an empty tree
248+
* a new commit pointing to this empty tree will be returned.
249+
* @param repo repository where the note lives
250+
* @param notes_commit a pointer to the notes commit object
251+
* @param author signature of the notes commit author
252+
* @param committer signature of the notes commit committer
253+
* @param oid OID of the git object to remove the note from
254+
*
255+
* @return 0 or an error code
256+
*/
257+
GIT_EXTERN(int) git_note_commit_remove(
258+
git_oid *notes_commit_out,
259+
git_repository *repo,
260+
git_commit *notes_commit,
261+
const git_signature *author,
262+
const git_signature *committer,
263+
const git_oid *oid);
264+
176265
/**
177266
* Free a git_note object
178267
*

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ ENDIF()
310310
ADD_FEATURE_INFO(SPNEGO GIT_GSSAPI "SPNEGO authentication support")
311311

312312
# Optional external dependency: iconv
313-
IF (USE_ICONV OR CMAKE_SYSTEM_NAME MATCHES "Darwin")
313+
IF (USE_ICONV)
314314
FIND_PACKAGE(Iconv)
315315
ENDIF()
316316
IF (ICONV_FOUND)

src/checkout.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,8 +2022,11 @@ static int checkout_write_entry(
20222022
(error = checkout_safe_for_update_only(data, fullpath->ptr, side->mode)) <= 0)
20232023
return error;
20242024

2025-
return checkout_write_content(data,
2026-
&side->id, fullpath->ptr, hint_path, side->mode, &st);
2025+
if (!S_ISGITLINK(side->mode))
2026+
return checkout_write_content(data,
2027+
&side->id, fullpath->ptr, hint_path, side->mode, &st);
2028+
2029+
return 0;
20272030
}
20282031

20292032
static int checkout_write_entries(

src/diff_file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ int git_diff_file_content__init_from_src(
139139
memset(fc, 0, sizeof(*fc));
140140
fc->repo = repo;
141141
fc->file = as_file;
142-
fc->blob = src->blob;
143142

144143
if (!src->blob && !src->buf) {
145144
fc->flags |= GIT_DIFF_FLAG__NO_DATA;
@@ -149,12 +148,15 @@ int git_diff_file_content__init_from_src(
149148
fc->file->mode = GIT_FILEMODE_BLOB;
150149

151150
if (src->blob) {
151+
git_blob_dup((git_blob **)&fc->blob, (git_blob *) src->blob);
152152
fc->file->size = git_blob_rawsize(src->blob);
153153
git_oid_cpy(&fc->file->id, git_blob_id(src->blob));
154154
fc->file->id_abbrev = GIT_OID_HEXSZ;
155155

156156
fc->map.len = (size_t)fc->file->size;
157157
fc->map.data = (char *)git_blob_rawcontent(src->blob);
158+
159+
fc->flags |= GIT_DIFF_FLAG__FREE_BLOB;
158160
} else {
159161
fc->file->size = src->buflen;
160162
git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJ_BLOB);

src/fetchhead.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ int git_fetchhead_write(git_repository *repo, git_vector *fetchhead_refs)
118118
if (git_buf_joinpath(&path, repo->gitdir, GIT_FETCH_HEAD_FILE) < 0)
119119
return -1;
120120

121-
if (git_filebuf_open(&file, path.ptr, GIT_FILEBUF_FORCE, GIT_REFS_FILE_MODE) < 0) {
121+
if (git_filebuf_open(&file, path.ptr, GIT_FILEBUF_APPEND, GIT_REFS_FILE_MODE) < 0) {
122122
git_buf_free(&path);
123123
return -1;
124124
}

src/fileops.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ int git_futils_open_ro(const char *path)
102102
return fd;
103103
}
104104

105+
int git_futils_truncate(const char *path, int mode)
106+
{
107+
int fd = p_open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, mode);
108+
if (fd < 0)
109+
return git_path_set_error(errno, path, "open");
110+
111+
close(fd);
112+
return 0;
113+
}
114+
105115
git_off_t git_futils_filesize(git_file fd)
106116
{
107117
struct stat sb;

src/fileops.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ extern int git_futils_cp_r(
247247
*/
248248
extern int git_futils_open_ro(const char *path);
249249

250+
/**
251+
* Truncate a file, creating it if it doesn't exist.
252+
*/
253+
extern int git_futils_truncate(const char *path, int mode);
254+
250255
/**
251256
* Get the filesize in bytes of a file
252257
*/

src/hash/hash_common_crypto.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ struct git_hash_ctx {
1616
CC_SHA1_CTX c;
1717
};
1818

19+
#define CC_LONG_MAX ((CC_LONG)-1)
20+
1921
#define git_hash_global_init() 0
2022
#define git_hash_ctx_init(ctx) git_hash_init(ctx)
2123
#define git_hash_ctx_cleanup(ctx)
@@ -27,10 +29,21 @@ GIT_INLINE(int) git_hash_init(git_hash_ctx *ctx)
2729
return 0;
2830
}
2931

30-
GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *data, size_t len)
32+
GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *_data, size_t len)
3133
{
34+
const unsigned char *data = _data;
35+
3236
assert(ctx);
33-
CC_SHA1_Update(&ctx->c, data, len);
37+
38+
while (len > 0) {
39+
CC_LONG chunk = (len > CC_LONG_MAX) ? CC_LONG_MAX : (CC_LONG)len;
40+
41+
CC_SHA1_Update(&ctx->c, data, chunk);
42+
43+
data += chunk;
44+
len -= chunk;
45+
}
46+
3447
return 0;
3548
}
3649

0 commit comments

Comments
 (0)