From 1fed6b07f0722c8b4349ff3709a49df3d3c9ae61 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Mon, 13 May 2013 21:57:37 +0200 Subject: [PATCH] Fix trailing whitespaces --- examples/rev-list.c | 1 - include/git2/merge.h | 8 +- include/git2/pack.h | 6 +- include/git2/sys/index.h | 1 - include/git2/trace.h | 3 +- src/checkout.c | 2 +- src/clone.c | 2 +- src/diff_tform.c | 6 +- src/hashsig.c | 1 - src/index.c | 38 +-- src/merge.c | 327 +++++++++++++------------- src/merge.h | 36 +-- src/merge_file.c | 47 ++-- src/merge_file.h | 6 +- src/pathspec.c | 2 +- src/refdb_fs.c | 6 +- src/reset.c | 2 +- src/revparse.c | 1 - src/signature.c | 2 +- src/trace.c | 3 +- src/trace.h | 6 +- src/transports/local.c | 2 +- src/win32/findfile.c | 1 - src/win32/posix_w32.c | 2 +- tests-clar/checkout/tree.c | 2 +- tests-clar/clone/empty.c | 4 +- tests-clar/commit/write.c | 2 +- tests-clar/index/names.c | 22 +- tests-clar/index/reuc.c | 34 +-- tests-clar/merge/merge_helpers.c | 100 ++++---- tests-clar/merge/trees/automerge.c | 28 +-- tests-clar/merge/trees/modeconflict.c | 4 +- tests-clar/merge/trees/renames.c | 25 +- tests-clar/merge/trees/treediff.c | 105 ++++----- tests-clar/merge/trees/trivial.c | 38 +-- tests-clar/refs/branches/move.c | 22 +- tests-clar/refs/ref_helpers.c | 6 +- tests-clar/refs/revparse.c | 21 +- tests-clar/refs/setter.c | 16 +- tests-clar/reset/hard.c | 30 +-- tests-clar/status/submodules.c | 1 - tests-clar/trace/trace.c | 1 - 42 files changed, 479 insertions(+), 493 deletions(-) diff --git a/examples/rev-list.c b/examples/rev-list.c index d9ec15f76..1fb7ebf9f 100644 --- a/examples/rev-list.c +++ b/examples/rev-list.c @@ -117,4 +117,3 @@ int main (int argc, char **argv) return 0; } - diff --git a/include/git2/merge.h b/include/git2/merge.h index 738d8e028..955840569 100644 --- a/include/git2/merge.h +++ b/include/git2/merge.h @@ -33,7 +33,7 @@ typedef enum { /** * Automerge options for `git_merge_trees_opts`. - */ + */ typedef enum { GIT_MERGE_AUTOMERGE_NORMAL = 0, GIT_MERGE_AUTOMERGE_NONE = 1, @@ -45,10 +45,10 @@ typedef enum { typedef struct { unsigned int version; git_merge_tree_flags flags; - + /** Similarity to consider a file renamed (default 50) */ unsigned int rename_threshold; - + /** Maximum similarity sources to examine (overrides the * `merge.renameLimit` config) (default 200) */ @@ -56,7 +56,7 @@ typedef struct { /** Pluggable similarity metric; pass NULL to use internal metric */ git_diff_similarity_metric *metric; - + /** Flags for automerging content. */ git_merge_automerge_flags automerge_flags; } git_merge_tree_opts; diff --git a/include/git2/pack.h b/include/git2/pack.h index 118b8d554..5e431e62d 100644 --- a/include/git2/pack.h +++ b/include/git2/pack.h @@ -96,12 +96,12 @@ GIT_EXTERN(int) git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid * /** * Insert a commit object - * + * * This will add a commit as well as the completed referenced tree. - * + * * @param pb The packbuilder * @param id The oid of the commit - * + * * @return 0 or an error code */ GIT_EXTERN(int) git_packbuilder_insert_commit(git_packbuilder *pb, const git_oid *id); diff --git a/include/git2/sys/index.h b/include/git2/sys/index.h index f74637f84..a32e07036 100644 --- a/include/git2/sys/index.h +++ b/include/git2/sys/index.h @@ -177,4 +177,3 @@ GIT_EXTERN(void) git_index_reuc_clear(git_index *index); /** @} */ GIT_END_DECL #endif - diff --git a/include/git2/trace.h b/include/git2/trace.h index 7409b032d..f9b4d6ff6 100644 --- a/include/git2/trace.h +++ b/include/git2/trace.h @@ -32,7 +32,7 @@ typedef enum { /** Errors that do not impact the program's execution */ GIT_TRACE_ERROR = 2, - + /** Warnings that suggest abnormal data */ GIT_TRACE_WARN = 3, @@ -65,4 +65,3 @@ GIT_EXTERN(int) git_trace_set(git_trace_level_t level, git_trace_callback cb); /** @} */ GIT_END_DECL #endif - diff --git a/src/checkout.c b/src/checkout.c index 68028dfef..8f5575779 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -771,7 +771,7 @@ static int blob_content_to_link( if ((error = git_futils_mkpath2file(path, dir_mode)) < 0) return error; - + if ((error = git_blob__getbuf(&linktarget, blob)) < 0) return error; diff --git a/src/clone.c b/src/clone.c index 499195dcc..7ebdb5765 100644 --- a/src/clone.c +++ b/src/clone.c @@ -274,7 +274,7 @@ static int update_head_to_branch( int retcode; git_buf remote_branch_name = GIT_BUF_INIT; git_reference* remote_ref = NULL; - + assert(options->checkout_branch); if ((retcode = git_buf_printf(&remote_branch_name, GIT_REFS_REMOTES_DIR "%s/%s", diff --git a/src/diff_tform.c b/src/diff_tform.c index 201a0e896..e88525654 100644 --- a/src/diff_tform.c +++ b/src/diff_tform.c @@ -178,7 +178,7 @@ int git_diff_find_similar__hashsig_for_file( GIT_UNUSED(f); error = git_hashsig_create_fromfile((git_hashsig **)out, path, opt); - + if (error == GIT_EBUFS) { error = 0; giterr_clear(); @@ -195,7 +195,7 @@ int git_diff_find_similar__hashsig_for_buf( GIT_UNUSED(f); error = git_hashsig_create((git_hashsig **)out, buf, len, opt); - + if (error == GIT_EBUFS) { error = 0; giterr_clear(); @@ -437,7 +437,7 @@ static int similarity_measure( return -1; if (!cache[b_idx] && similarity_calc(diff, opts, b_idx, cache) < 0) return -1; - + /* some metrics may not wish to process this file (too big / too small) */ if (!cache[a_idx] || !cache[b_idx]) return 0; diff --git a/src/hashsig.c b/src/hashsig.c index 3a75aaaed..ab8d8b3f0 100644 --- a/src/hashsig.c +++ b/src/hashsig.c @@ -365,4 +365,3 @@ int git_hashsig_compare(const git_hashsig *a, const git_hashsig *b) return (hashsig_heap_compare(&a->mins, &b->mins) + hashsig_heap_compare(&a->maxs, &b->maxs)) / 2; } - diff --git a/src/index.c b/src/index.c index 53edb4874..4b3c2bb4b 100644 --- a/src/index.c +++ b/src/index.c @@ -381,7 +381,7 @@ void git_index_clear(git_index *index) git_index_reuc_clear(index); git_index_name_clear(index); - + git_futils_filestamp_set(&index->stamp, NULL); git_tree_cache_free(index->tree); @@ -1108,7 +1108,7 @@ const git_index_name_entry *git_index_name_get_byindex( git_index *index, size_t n) { assert(index); - + git_vector_sort(&index->names); return git_vector_get(&index->names, n); } @@ -1122,7 +1122,7 @@ int git_index_name_add(git_index *index, conflict_name = git__calloc(1, sizeof(git_index_name_entry)); GITERR_CHECK_ALLOC(conflict_name); - + if (ancestor) { conflict_name->ancestor = git__strdup(ancestor); GITERR_CHECK_ALLOC(conflict_name->ancestor); @@ -1137,7 +1137,7 @@ int git_index_name_add(git_index *index, conflict_name->theirs = git__strdup(theirs); GITERR_CHECK_ALLOC(conflict_name->theirs); } - + return git_vector_insert(&index->names, conflict_name); } @@ -1147,7 +1147,7 @@ void git_index_name_clear(git_index *index) git_index_name_entry *conflict_name; assert(index); - + git_vector_foreach(&index->names, i, conflict_name) { if (conflict_name->ancestor) git__free(conflict_name->ancestor); @@ -1160,7 +1160,7 @@ void git_index_name_clear(git_index *index) git__free(conflict_name); } - + git_vector_clear(&index->names); } @@ -1354,7 +1354,7 @@ static int read_reuc(git_index *index, const char *buffer, size_t size) static int read_conflict_names(git_index *index, const char *buffer, size_t size) { size_t len; - + /* This gets called multiple times, the vector might already be initialized */ if (index->names._alloc_size == 0 && git_vector_init(&index->names, 16, conflict_name_cmp) < 0) @@ -1375,7 +1375,7 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size \ buffer += len; \ size -= len; - + while (size) { git_index_name_entry *conflict_name = git__calloc(1, sizeof(git_index_name_entry)); GITERR_CHECK_ALLOC(conflict_name); @@ -1383,17 +1383,17 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size read_conflict_name(conflict_name->ancestor); read_conflict_name(conflict_name->ours); read_conflict_name(conflict_name->theirs); - + if (git_vector_insert(&index->names, conflict_name) < 0) return -1; } #undef read_conflict_name - + /* entries are guaranteed to be sorted on-disk */ index->names.sorted = 1; - - return 0; + + return 0; } static size_t read_entry(git_index_entry *dest, const void *buffer, size_t buffer_size) @@ -1724,7 +1724,7 @@ static int create_name_extension_data(git_buf *name_buf, git_index_name_entry *c error = git_buf_put(name_buf, "\0", 1); else error = git_buf_put(name_buf, conflict_name->ancestor, strlen(conflict_name->ancestor) + 1); - + if (error != 0) goto on_error; @@ -1753,20 +1753,20 @@ static int write_name_extension(git_index *index, git_filebuf *file) struct index_extension extension; size_t i; int error = 0; - + git_vector_foreach(out, i, conflict_name) { if ((error = create_name_extension_data(&name_buf, conflict_name)) < 0) goto done; } - + memset(&extension, 0x0, sizeof(struct index_extension)); memcpy(&extension.signature, INDEX_EXT_CONFLICT_NAME_SIG, 4); extension.extension_size = (uint32_t)name_buf.size; - + error = write_extension(file, &extension, &name_buf); - + git_buf_free(&name_buf); - + done: return error; } @@ -1844,7 +1844,7 @@ static int write_index(git_index *index, git_filebuf *file) /* write the rename conflict extension */ if (index->names.length > 0 && write_name_extension(index, file) < 0) return -1; - + /* write the reuc extension */ if (index->reuc.length > 0 && write_reuc_extension(index, file) < 0) return -1; diff --git a/src/merge.c b/src/merge.c index 117af8179..de5d65ac0 100644 --- a/src/merge.c +++ b/src/merge.c @@ -370,14 +370,14 @@ static int merge_conflict_resolve_trivial( if (conflict->type == GIT_MERGE_DIFF_DIRECTORY_FILE || conflict->type == GIT_MERGE_DIFF_RENAMED_ADDED) return 0; - + if (conflict->our_status == GIT_DELTA_RENAMED || conflict->their_status == GIT_DELTA_RENAMED) return 0; ours_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry); theirs_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry); - + ours_changed = (conflict->our_status != GIT_DELTA_UNMODIFIED); theirs_changed = (conflict->their_status != GIT_DELTA_UNMODIFIED); ours_theirs_differ = ours_changed && theirs_changed && @@ -433,7 +433,7 @@ static int merge_conflict_resolve_trivial( *resolved = 1; /* Note: trivial resolution does not update the REUC. */ - + return error; } @@ -486,9 +486,9 @@ static int merge_conflict_resolve_one_renamed( int ours_changed, theirs_changed; git_index_entry *merged; int error = 0; - + assert(resolved && diff_list && conflict); - + *resolved = 0; if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) || @@ -497,7 +497,7 @@ static int merge_conflict_resolve_one_renamed( ours_renamed = (conflict->our_status == GIT_DELTA_RENAMED); theirs_renamed = (conflict->their_status == GIT_DELTA_RENAMED); - + if (!ours_renamed && !theirs_renamed) return 0; @@ -509,7 +509,7 @@ static int merge_conflict_resolve_one_renamed( ours_changed = (git_oid__cmp(&conflict->ancestor_entry.oid, &conflict->our_entry.oid) != 0); theirs_changed = (git_oid__cmp(&conflict->ancestor_entry.oid, &conflict->their_entry.oid) != 0); - + /* if both are modified (and not to a common target) require a merge */ if (ours_changed && theirs_changed && git_oid__cmp(&conflict->our_entry.oid, &conflict->their_entry.oid) != 0) @@ -517,7 +517,7 @@ static int merge_conflict_resolve_one_renamed( if ((merged = git_pool_malloc(&diff_list->pool, sizeof(git_index_entry))) == NULL) return -1; - + if (ours_changed) memcpy(merged, &conflict->our_entry, sizeof(git_index_entry)); else @@ -527,12 +527,12 @@ static int merge_conflict_resolve_one_renamed( merged->path = conflict->our_entry.path; else merged->path = conflict->their_entry.path; - + *resolved = 1; - + git_vector_insert(&diff_list->staged, merged); git_vector_insert(&diff_list->resolved, (git_merge_diff *)conflict); - + return error; } @@ -550,11 +550,11 @@ static int merge_conflict_resolve_automerge( git_odb *odb = NULL; git_oid automerge_oid; int error = 0; - + assert(resolved && diff_list && conflict); - + *resolved = 0; - + if (automerge_flags == GIT_MERGE_AUTOMERGE_NONE) return 0; @@ -585,7 +585,7 @@ static int merge_conflict_resolve_automerge( !result.automergeable || (error = git_odb_write(&automerge_oid, odb, result.data, result.len, GIT_OBJ_BLOB)) < 0) goto done; - + if ((index_entry = git_pool_malloc(&diff_list->pool, sizeof(git_index_entry))) == NULL) GITERR_CHECK_ALLOC(index_entry); @@ -595,7 +595,7 @@ static int merge_conflict_resolve_automerge( index_entry->file_size = result.len; index_entry->mode = result.mode; git_oid_cpy(&index_entry->oid, &automerge_oid); - + git_vector_insert(&diff_list->staged, index_entry); git_vector_insert(&diff_list->resolved, (git_merge_diff *)conflict); @@ -607,7 +607,7 @@ done: git_merge_file_input_free(&theirs); git_merge_file_result_free(&result); git_odb_free(odb); - + return error; } @@ -619,16 +619,16 @@ static int merge_conflict_resolve( { int resolved = 0; int error = 0; - + *out = 0; - + if ((error = merge_conflict_resolve_trivial(&resolved, diff_list, conflict)) < 0) goto done; if (automerge_flags != GIT_MERGE_AUTOMERGE_NONE) { if (!resolved && (error = merge_conflict_resolve_one_removed(&resolved, diff_list, conflict)) < 0) goto done; - + if (!resolved && (error = merge_conflict_resolve_one_renamed(&resolved, diff_list, conflict)) < 0) goto done; @@ -637,7 +637,7 @@ static int merge_conflict_resolve( } *out = resolved; - + done: return error; } @@ -666,7 +666,7 @@ static int index_entry_similarity_exact( if (git_oid__cmp(&a->oid, &b->oid) == 0) return 100; - + return 0; } @@ -680,28 +680,28 @@ static int index_entry_similarity_calc( git_diff_file diff_file = {{{0}}}; git_off_t blobsize; int error; - + *out = NULL; if ((error = git_blob_lookup(&blob, repo, &entry->oid)) < 0) return error; - + git_oid_cpy(&diff_file.oid, &entry->oid); diff_file.path = entry->path; diff_file.size = entry->file_size; diff_file.mode = entry->mode; diff_file.flags = 0; - + blobsize = git_blob_rawsize(blob); /* file too big for rename processing */ if (!git__is_sizet(blobsize)) return 0; - + error = opts->metric->buffer_signature(out, &diff_file, git_blob_rawcontent(blob), (size_t)blobsize, opts->metric->payload); - + git_blob_free(blob); return error; @@ -718,16 +718,16 @@ static int index_entry_similarity_inexact( { int score = 0; int error = 0; - + if (GIT_MODE_TYPE(a->mode) != GIT_MODE_TYPE(b->mode)) return 0; - + /* update signature cache if needed */ if (!cache[a_idx] && (error = index_entry_similarity_calc(&cache[a_idx], repo, a, opts)) < 0) return error; if (!cache[b_idx] && (error = index_entry_similarity_calc(&cache[b_idx], repo, b, opts)) < 0) return error; - + /* some metrics may not wish to process this file (too big / too small) */ if (!cache[a_idx] || !cache[b_idx]) return 0; @@ -736,13 +736,13 @@ static int index_entry_similarity_inexact( if (opts->metric->similarity( &score, cache[a_idx], cache[b_idx], opts->metric->payload) < 0) return -1; - + /* clip score */ if (score < 0) score = 0; else if (score > 100) score = 100; - + return score; } @@ -758,7 +758,7 @@ static int merge_diff_mark_similarity( size_t i, j; git_merge_diff *conflict_src, *conflict_tgt; int similarity; - + git_vector_foreach(&diff_list->conflicts, i, conflict_src) { /* Items can be the source of a rename iff they have an item in the * ancestor slot and lack an item in the ours or theirs slot. */ @@ -766,63 +766,63 @@ static int merge_diff_mark_similarity( (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->our_entry) && GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->their_entry))) continue; - + git_vector_foreach(&diff_list->conflicts, j, conflict_tgt) { size_t our_idx = diff_list->conflicts.length + j; size_t their_idx = (diff_list->conflicts.length * 2) + j; - + if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->ancestor_entry)) continue; - + if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->our_entry) && !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->our_entry)) { similarity = similarity_fn(repo, &conflict_src->ancestor_entry, i, &conflict_tgt->our_entry, our_idx, cache, opts); - + if (similarity == GIT_EBUFS) - continue; + continue; else if (similarity < 0) return similarity; - + if (similarity > similarity_ours[i].similarity && similarity > similarity_ours[j].similarity) { /* Clear previous best similarity */ if (similarity_ours[i].similarity > 0) similarity_ours[similarity_ours[i].other_idx].similarity = 0; - + if (similarity_ours[j].similarity > 0) similarity_ours[similarity_ours[j].other_idx].similarity = 0; - + similarity_ours[i].similarity = similarity; similarity_ours[i].other_idx = j; - + similarity_ours[j].similarity = similarity; similarity_ours[j].other_idx = i; } } - + if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->their_entry) && !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->their_entry)) { similarity = similarity_fn(repo, &conflict_src->ancestor_entry, i, &conflict_tgt->their_entry, their_idx, cache, opts); - + if (similarity > similarity_theirs[i].similarity && similarity > similarity_theirs[j].similarity) { /* Clear previous best similarity */ if (similarity_theirs[i].similarity > 0) similarity_theirs[similarity_theirs[i].other_idx].similarity = 0; - + if (similarity_theirs[j].similarity > 0) similarity_theirs[similarity_theirs[j].other_idx].similarity = 0; - + similarity_theirs[i].similarity = similarity; similarity_theirs[i].other_idx = j; - + similarity_theirs[j].similarity = similarity; similarity_theirs[j].other_idx = i; } } } } - + return 0; } @@ -857,13 +857,13 @@ static void merge_diff_mark_rename_conflict( const git_merge_tree_opts *opts) { git_merge_diff *ours_source = NULL, *theirs_source = NULL; - + if (ours_renamed) ours_source = diff_list->conflicts.contents[ours_source_idx]; - + if (theirs_renamed) theirs_source = diff_list->conflicts.contents[theirs_source_idx]; - + /* Detect 2->1 conflicts */ if (ours_renamed && theirs_renamed) { /* Both renamed to the same target name. */ @@ -877,30 +877,30 @@ static void merge_diff_mark_rename_conflict( /* If our source was also renamed in theirs, this is a 1->2 */ if (similarity_theirs[ours_source_idx].similarity >= opts->rename_threshold) ours_source->type = GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2; - + else if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->their_entry)) { ours_source->type = GIT_MERGE_DIFF_RENAMED_ADDED; target->type = GIT_MERGE_DIFF_RENAMED_ADDED; } - + else if (!GIT_MERGE_INDEX_ENTRY_EXISTS(ours_source->their_entry)) ours_source->type = GIT_MERGE_DIFF_RENAMED_DELETED; - + else if (ours_source->type == GIT_MERGE_DIFF_MODIFIED_DELETED) ours_source->type = GIT_MERGE_DIFF_RENAMED_MODIFIED; } else if (theirs_renamed) { /* If their source was also renamed in ours, this is a 1->2 */ if (similarity_ours[theirs_source_idx].similarity >= opts->rename_threshold) theirs_source->type = GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2; - + else if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->our_entry)) { theirs_source->type = GIT_MERGE_DIFF_RENAMED_ADDED; target->type = GIT_MERGE_DIFF_RENAMED_ADDED; } - + else if (!GIT_MERGE_INDEX_ENTRY_EXISTS(theirs_source->our_entry)) theirs_source->type = GIT_MERGE_DIFF_RENAMED_DELETED; - + else if (theirs_source->type == GIT_MERGE_DIFF_MODIFIED_DELETED) theirs_source->type = GIT_MERGE_DIFF_RENAMED_MODIFIED; } @@ -915,7 +915,7 @@ GIT_INLINE(void) merge_diff_coalesce_rename( /* Coalesce the rename target into the rename source. */ memcpy(source_entry, target_entry, sizeof(git_index_entry)); *source_status = GIT_DELTA_RENAMED; - + memset(target_entry, 0x0, sizeof(git_index_entry)); *target_status = GIT_DELTA_UNMODIFIED; } @@ -930,50 +930,50 @@ static void merge_diff_list_coalesce_renames( bool ours_renamed = 0, theirs_renamed = 0; size_t ours_source_idx = 0, theirs_source_idx = 0; git_merge_diff *ours_source, *theirs_source, *target; - + for (i = 0; i < diff_list->conflicts.length; i++) { target = diff_list->conflicts.contents[i]; - + ours_renamed = 0; theirs_renamed = 0; - + if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->our_entry) && similarity_ours[i].similarity >= opts->rename_threshold) { ours_source_idx = similarity_ours[i].other_idx; - + ours_source = diff_list->conflicts.contents[ours_source_idx]; - + merge_diff_coalesce_rename( &ours_source->our_entry, &ours_source->our_status, &target->our_entry, &target->our_status); - + similarity_ours[ours_source_idx].similarity = 0; similarity_ours[i].similarity = 0; - + ours_renamed = 1; } - + /* insufficient to determine direction */ if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->their_entry) && similarity_theirs[i].similarity >= opts->rename_threshold) { theirs_source_idx = similarity_theirs[i].other_idx; - + theirs_source = diff_list->conflicts.contents[theirs_source_idx]; - + merge_diff_coalesce_rename( &theirs_source->their_entry, &theirs_source->their_status, &target->their_entry, &target->their_status); - + similarity_theirs[theirs_source_idx].similarity = 0; similarity_theirs[i].similarity = 0; - + theirs_renamed = 1; } - + merge_diff_mark_rename_conflict(diff_list, similarity_ours, ours_renamed, ours_source_idx, similarity_theirs, theirs_renamed, theirs_source_idx, @@ -984,7 +984,7 @@ static void merge_diff_list_coalesce_renames( static int merge_diff_empty(const git_vector *conflicts, size_t idx) { git_merge_diff *conflict = conflicts->contents[idx]; - + return (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry) && !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) && !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry)); @@ -1000,7 +1000,7 @@ static void merge_diff_list_count_candidates( *src_count = 0; *tgt_count = 0; - + git_vector_foreach(&diff_list->conflicts, i, entry) { if (GIT_MERGE_INDEX_ENTRY_EXISTS(entry->ancestor_entry) && (!GIT_MERGE_INDEX_ENTRY_EXISTS(entry->our_entry) || @@ -1021,20 +1021,20 @@ int git_merge_diff_list__find_renames( size_t cache_size = 0; size_t src_count, tgt_count, i; int error = 0; - + assert(diff_list && opts); - + if ((opts->flags & GIT_MERGE_TREE_FIND_RENAMES) == 0) return 0; - + similarity_ours = git__calloc(diff_list->conflicts.length, sizeof(struct merge_diff_similarity)); GITERR_CHECK_ALLOC(similarity_ours); - + similarity_theirs = git__calloc(diff_list->conflicts.length, sizeof(struct merge_diff_similarity)); GITERR_CHECK_ALLOC(similarity_theirs); - + /* Calculate similarity between items that were deleted from the ancestor * and added in the other branch. */ @@ -1048,7 +1048,7 @@ int git_merge_diff_list__find_renames( GITERR_CHECK_ALLOC(cache); merge_diff_list_count_candidates(diff_list, &src_count, &tgt_count); - + if (src_count > opts->target_limit || tgt_count > opts->target_limit) { /* TODO: report! */ } else { @@ -1063,7 +1063,7 @@ int git_merge_diff_list__find_renames( * into the old name. */ merge_diff_list_coalesce_renames(diff_list, similarity_ours, similarity_theirs, opts); - + /* And remove any entries that were merged and are now empty. */ git_vector_remove_matching(&diff_list->conflicts, merge_diff_empty); @@ -1094,7 +1094,7 @@ GIT_INLINE(const char *) merge_diff_path( return conflict->our_entry.path; else if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry)) return conflict->their_entry.path; - + return NULL; } @@ -1106,7 +1106,7 @@ GIT_INLINE(bool) merge_diff_any_side_added_or_modified( conflict->their_status == GIT_DELTA_ADDED || conflict->their_status == GIT_DELTA_MODIFIED) return true; - + return false; } @@ -1114,11 +1114,11 @@ GIT_INLINE(bool) path_is_prefixed(const char *parent, const char *child) { size_t child_len = strlen(child); size_t parent_len = strlen(parent); - + if (child_len < parent_len || strncmp(parent, child, parent_len) != 0) return 0; - + return (child[parent_len] == '/'); } @@ -1127,7 +1127,7 @@ GIT_INLINE(int) merge_diff_detect_df_conflict( git_merge_diff *conflict) { const char *cur_path = merge_diff_path(conflict); - + /* Determine if this is a D/F conflict or the child of one */ if (df_data->df_path && path_is_prefixed(df_data->df_path, cur_path)) @@ -1139,14 +1139,14 @@ GIT_INLINE(int) merge_diff_detect_df_conflict( merge_diff_any_side_added_or_modified(conflict) && path_is_prefixed(df_data->prev_path, cur_path)) { conflict->type = GIT_MERGE_DIFF_DF_CHILD; - + df_data->prev_conflict->type = GIT_MERGE_DIFF_DIRECTORY_FILE; df_data->df_path = df_data->prev_path; } - + df_data->prev_path = cur_path; df_data->prev_conflict = conflict; - + return 0; } @@ -1172,7 +1172,7 @@ GIT_INLINE(int) merge_diff_detect_type( conflict->type = GIT_MERGE_DIFF_MODIFIED_DELETED; else conflict->type = GIT_MERGE_DIFF_NONE; - + return 0; } @@ -1183,11 +1183,11 @@ GIT_INLINE(int) index_entry_dup( { if (src != NULL) { memcpy(out, src, sizeof(git_index_entry)); - + if ((out->path = git_pool_strdup(pool, src->path)) == NULL) return -1; } - + return 0; } @@ -1208,7 +1208,7 @@ GIT_INLINE(int) merge_delta_type_from_index_entries( else if (git_oid__cmp(&ancestor->oid, &other->oid) || ancestor->mode != other->mode) return GIT_DELTA_MODIFIED; - + return GIT_DELTA_UNMODIFIED; } @@ -1218,20 +1218,20 @@ static git_merge_diff *merge_diff_from_index_entries( { git_merge_diff *conflict; git_pool *pool = &diff_list->pool; - + if ((conflict = git_pool_malloc(pool, sizeof(git_merge_diff))) == NULL) return NULL; - + if (index_entry_dup(&conflict->ancestor_entry, pool, entries[TREE_IDX_ANCESTOR]) < 0 || index_entry_dup(&conflict->our_entry, pool, entries[TREE_IDX_OURS]) < 0 || index_entry_dup(&conflict->their_entry, pool, entries[TREE_IDX_THEIRS]) < 0) return NULL; - + conflict->our_status = merge_delta_type_from_index_entries( entries[TREE_IDX_ANCESTOR], entries[TREE_IDX_OURS]); conflict->their_status = merge_delta_type_from_index_entries( entries[TREE_IDX_ANCESTOR], entries[TREE_IDX_THEIRS]); - + return conflict; } @@ -1243,13 +1243,13 @@ static int merge_index_insert_conflict( const git_index_entry *tree_items[3]) { git_merge_diff *conflict; - + if ((conflict = merge_diff_from_index_entries(diff_list, tree_items)) == NULL || merge_diff_detect_type(conflict) < 0 || merge_diff_detect_df_conflict(merge_df_data, conflict) < 0 || git_vector_insert(&diff_list->conflicts, conflict) < 0) return -1; - + return 0; } @@ -1259,13 +1259,13 @@ static int merge_index_insert_unmodified( { int error = 0; git_index_entry *entry; - + entry = git_pool_malloc(&diff_list->pool, sizeof(git_index_entry)); GITERR_CHECK_ALLOC(entry); - + if ((error = index_entry_dup(entry, &diff_list->pool, tree_items[0])) >= 0) error = git_vector_insert(&diff_list->staged, entry); - + return error; } @@ -1282,40 +1282,40 @@ int git_merge_diff_list__find_differences( int cur_item_modified; size_t i, j; int error = 0; - + assert(diff_list && our_tree && their_tree); if ((error = git_iterator_for_tree(&iterators[TREE_IDX_ANCESTOR], (git_tree *)ancestor_tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 || (error = git_iterator_for_tree(&iterators[TREE_IDX_OURS], (git_tree *)our_tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 || (error = git_iterator_for_tree(&iterators[TREE_IDX_THEIRS], (git_tree *)their_tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0) goto done; - + /* Set up the iterators */ for (i = 0; i < 3; i++) { if ((error = git_iterator_current(&items[i], iterators[i])) < 0) goto done; } - + while (true) { for (i = 0; i < 3; i++) cur_items[i] = NULL; best_cur_item = NULL; cur_item_modified = 0; - + /* Find the next path(s) to consume from each iterator */ for (i = 0; i < 3; i++) { if (items[i] == NULL) { cur_item_modified = 1; continue; } - + if (best_cur_item == NULL) { best_cur_item = items[i]; cur_items[i] = items[i]; } else { int path_diff = entry_compare(items[i], best_cur_item); - + if (path_diff < 0) { /* * Found an item that sorts before our current item, make @@ -1332,21 +1332,21 @@ int git_merge_diff_list__find_differences( cur_item_modified = 1; } else if (path_diff == 0) { cur_items[i] = items[i]; - + if (!cur_item_modified) cur_item_modified = index_entry_cmp(best_cur_item, items[i]); } } } - + if (best_cur_item == NULL) break; - + if (cur_item_modified) error = merge_index_insert_conflict(diff_list, &df_data, cur_items); else error = merge_index_insert_unmodified(diff_list, cur_items); - + /* Advance each iterator that participated */ for (i = 0; i < 3; i++) { if (cur_items[i] != NULL && @@ -1354,29 +1354,29 @@ int git_merge_diff_list__find_differences( goto done; } } - + done: for (i = 0; i < 3; i++) git_iterator_free(iterators[i]); - + return error; } git_merge_diff_list *git_merge_diff_list__alloc(git_repository *repo) { git_merge_diff_list *diff_list = git__calloc(1, sizeof(git_merge_diff_list)); - + if (diff_list == NULL) return NULL; - + diff_list->repo = repo; - + if (git_vector_init(&diff_list->staged, 0, NULL) < 0 || git_vector_init(&diff_list->conflicts, 0, NULL) < 0 || git_vector_init(&diff_list->resolved, 0, NULL) < 0 || git_pool_init(&diff_list->pool, 1, 0) < 0) return NULL; - + return diff_list; } @@ -1387,48 +1387,48 @@ static int merge_tree_normalize_opts( { git_config *cfg = NULL; int error = 0; - + assert(repo && opts); - + if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) return error; - + if (given != NULL) memcpy(opts, given, sizeof(git_merge_tree_opts)); else { git_merge_tree_opts init = GIT_MERGE_TREE_OPTS_INIT; memcpy(opts, &init, sizeof(init)); - + opts->flags = GIT_MERGE_TREE_FIND_RENAMES; opts->rename_threshold = GIT_MERGE_TREE_RENAME_THRESHOLD; } - + if (!opts->target_limit) { int32_t limit = 0; - + opts->target_limit = GIT_MERGE_TREE_TARGET_LIMIT; - + if (git_config_get_int32(&limit, cfg, "merge.renameLimit") < 0) { giterr_clear(); - + if (git_config_get_int32(&limit, cfg, "diff.renameLimit") < 0) giterr_clear(); } - + if (limit > 0) opts->target_limit = limit; } - + /* assign the internal metric with whitespace flag as payload */ if (!opts->metric) { opts->metric = git__malloc(sizeof(git_diff_similarity_metric)); GITERR_CHECK_ALLOC(opts->metric); - + opts->metric->file_signature = git_diff_find_similar__hashsig_for_file; opts->metric->buffer_signature = git_diff_find_similar__hashsig_for_buf; opts->metric->free_signature = git_diff_find_similar__hashsig_free; opts->metric->similarity = git_diff_find_similar__calc_similarity; - + if (opts->flags & GIT_DIFF_FIND_IGNORE_WHITESPACE) opts->metric->payload = (void *)GIT_HASHSIG_IGNORE_WHITESPACE; else if (opts->flags & GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE) @@ -1436,7 +1436,7 @@ static int merge_tree_normalize_opts( else opts->metric->payload = (void *)GIT_HASHSIG_SMART_WHITESPACE; } - + return 0; } @@ -1450,20 +1450,20 @@ static int merge_index_insert_reuc( int mode[3] = { 0, 0, 0 }; git_oid const *oid[3] = { NULL, NULL, NULL }; size_t i; - + if (!GIT_MERGE_INDEX_ENTRY_EXISTS(*entry)) return 0; - + if ((reuc = git_index_reuc_get_bypath(index, entry->path)) != NULL) { for (i = 0; i < 3; i++) { mode[i] = reuc->mode[i]; oid[i] = &reuc->oid[i]; } } - + mode[idx] = entry->mode; oid[idx] = &entry->oid; - + return git_index_reuc_add(index, entry->path, mode[0], oid[0], mode[1], oid[1], mode[2], oid[2]); } @@ -1475,58 +1475,58 @@ int index_from_diff_list(git_index **out, git_merge_diff_list *diff_list) git_index_entry *entry; git_merge_diff *conflict; int error = 0; - + *out = NULL; - + if ((error = git_index_new(&index)) < 0) return error; - + git_vector_foreach(&diff_list->staged, i, entry) { if ((error = git_index_add(index, entry)) < 0) goto on_error; } - + git_vector_foreach(&diff_list->conflicts, i, conflict) { const git_index_entry *ancestor = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry) ? &conflict->ancestor_entry : NULL; - + const git_index_entry *ours = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ? &conflict->our_entry : NULL; - + const git_index_entry *theirs = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry) ? &conflict->their_entry : NULL; - + if ((error = git_index_conflict_add(index, ancestor, ours, theirs)) < 0) goto on_error; } - + /* Add each rename entry to the rename portion of the index. */ git_vector_foreach(&diff_list->conflicts, i, conflict) { const char *ancestor_path, *our_path, *their_path; - + if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry)) continue; - + ancestor_path = conflict->ancestor_entry.path; - + our_path = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ? conflict->our_entry.path : NULL; - + their_path = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry) ? conflict->their_entry.path : NULL; - + if ((our_path && strcmp(ancestor_path, our_path) != 0) || (their_path && strcmp(ancestor_path, their_path) != 0)) { if ((error = git_index_name_add(index, ancestor_path, our_path, their_path)) < 0) goto on_error; } } - + /* Add each entry in the resolved conflict to the REUC independently, since * the paths may differ due to renames. */ git_vector_foreach(&diff_list->resolved, i, conflict) { @@ -1537,7 +1537,7 @@ int index_from_diff_list(git_index **out, git_merge_diff_list *diff_list) const git_index_entry *ours = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ? &conflict->our_entry : NULL; - + const git_index_entry *theirs = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry) ? &conflict->their_entry : NULL; @@ -1545,22 +1545,22 @@ int index_from_diff_list(git_index **out, git_merge_diff_list *diff_list) if (ancestor != NULL && (error = merge_index_insert_reuc(index, TREE_IDX_ANCESTOR, ancestor)) < 0) goto on_error; - + if (ours != NULL && (error = merge_index_insert_reuc(index, TREE_IDX_OURS, ours)) < 0) goto on_error; - + if (theirs != NULL && (error = merge_index_insert_reuc(index, TREE_IDX_THEIRS, theirs)) < 0) goto on_error; } - + *out = index; return 0; - + on_error: git_index_free(index); - + return error; } @@ -1582,33 +1582,33 @@ int git_merge_trees( assert(out && repo && our_tree && their_tree); *out = NULL; - + if ((error = merge_tree_normalize_opts(repo, &opts, given_opts)) < 0) return error; diff_list = git_merge_diff_list__alloc(repo); GITERR_CHECK_ALLOC(diff_list); - + if ((error = git_merge_diff_list__find_differences(diff_list, ancestor_tree, our_tree, their_tree)) < 0 || (error = git_merge_diff_list__find_renames(repo, diff_list, &opts)) < 0) goto done; - + memcpy(&changes, &diff_list->conflicts, sizeof(git_vector)); git_vector_clear(&diff_list->conflicts); - + git_vector_foreach(&changes, i, conflict) { int resolved = 0; - + if ((error = merge_conflict_resolve(&resolved, diff_list, conflict, opts.automerge_flags)) < 0) goto done; - + if (!resolved) git_vector_insert(&diff_list->conflicts, conflict); } - + if (!given_opts || !given_opts->metric) git__free(opts.metric); - + error = index_from_diff_list(out, diff_list); done: @@ -1621,11 +1621,10 @@ void git_merge_diff_list__free(git_merge_diff_list *diff_list) { if (!diff_list) return; - + git_vector_free(&diff_list->staged); git_vector_free(&diff_list->conflicts); git_vector_free(&diff_list->resolved); git_pool_clear(&diff_list->pool); git__free(diff_list); } - diff --git a/src/merge.h b/src/merge.h index da1fdf472..50538b12b 100644 --- a/src/merge.h +++ b/src/merge.h @@ -24,46 +24,46 @@ typedef enum { /* No conflict - a change only occurs in one branch. */ GIT_MERGE_DIFF_NONE = 0, - + /* Occurs when a file is modified in both branches. */ GIT_MERGE_DIFF_BOTH_MODIFIED = (1 << 0), - + /* Occurs when a file is added in both branches. */ GIT_MERGE_DIFF_BOTH_ADDED = (1 << 1), - + /* Occurs when a file is deleted in both branches. */ GIT_MERGE_DIFF_BOTH_DELETED = (1 << 2), - + /* Occurs when a file is modified in one branch and deleted in the other. */ GIT_MERGE_DIFF_MODIFIED_DELETED = (1 << 3), - + /* Occurs when a file is renamed in one branch and modified in the other. */ GIT_MERGE_DIFF_RENAMED_MODIFIED = (1 << 4), - + /* Occurs when a file is renamed in one branch and deleted in the other. */ GIT_MERGE_DIFF_RENAMED_DELETED = (1 << 5), - + /* Occurs when a file is renamed in one branch and a file with the same * name is added in the other. Eg, A->B and new file B. Core git calls * this a "rename/delete". */ GIT_MERGE_DIFF_RENAMED_ADDED = (1 << 6), - + /* Occurs when both a file is renamed to the same name in the ours and * theirs branches. Eg, A->B and A->B in both. Automergeable. */ GIT_MERGE_DIFF_BOTH_RENAMED = (1 << 7), - + /* Occurs when a file is renamed to different names in the ours and theirs * branches. Eg, A->B and A->C. */ GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2 = (1 << 8), - + /* Occurs when two files are renamed to the same name in the ours and * theirs branches. Eg, A->C and B->C. */ GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1 = (1 << 9), - + /* Occurs when an item at a path in one branch is a directory, and an * item at the same path in a different branch is a file. */ GIT_MERGE_DIFF_DIRECTORY_FILE = (1 << 10), - + /* The child of a folder that is in a directory/file conflict. */ GIT_MERGE_DIFF_DF_CHILD = (1 << 11), } git_merge_diff_type_t; @@ -72,20 +72,20 @@ typedef enum { typedef struct { git_repository *repo; git_pool pool; - + /* Vector of git_index_entry that represent the merged items that * have been staged, either because only one side changed, or because * the two changes were non-conflicting and mergeable. These items * will be written as staged entries in the main index. */ git_vector staged; - + /* Vector of git_merge_diff entries that represent the conflicts that * have not been automerged. These items will be written to high-stage * entries in the main index. */ git_vector conflicts; - + /* Vector of git_merge_diff that have been automerged. These items * will be written to the REUC when the index is produced. */ @@ -97,12 +97,12 @@ typedef struct { */ typedef struct { git_merge_diff_type_t type; - + git_index_entry ancestor_entry; - + git_index_entry our_entry; git_delta_t our_status; - + git_index_entry their_entry; git_delta_t their_status; } git_merge_diff; diff --git a/src/merge_file.c b/src/merge_file.c index 4b3f3730b..c3477ccb9 100644 --- a/src/merge_file.c +++ b/src/merge_file.c @@ -28,12 +28,12 @@ GIT_INLINE(const char *) merge_file_best_path( return NULL; } - + if (strcmp(ancestor->path, ours->path) == 0) return theirs->path; else if(strcmp(ancestor->path, theirs->path) == 0) return ours->path; - + return NULL; } @@ -51,15 +51,15 @@ GIT_INLINE(int) merge_file_best_mode( if (ours->mode == GIT_FILEMODE_BLOB_EXECUTABLE || theirs->mode == GIT_FILEMODE_BLOB_EXECUTABLE) return GIT_FILEMODE_BLOB_EXECUTABLE; - + return GIT_FILEMODE_BLOB; } - + if (ancestor->mode == ours->mode) return theirs->mode; else if(ancestor->mode == theirs->mode) return ours->mode; - + return 0; } @@ -70,27 +70,27 @@ int git_merge_file_input_from_index_entry( { git_odb *odb = NULL; int error = 0; - + assert(input && repo && entry); - + if (entry->mode == 0) return 0; - + if ((error = git_repository_odb(&odb, repo)) < 0 || (error = git_odb_read(&input->odb_object, odb, &entry->oid)) < 0) goto done; - + input->mode = entry->mode; input->path = git__strdup(entry->path); input->mmfile.size = git_odb_object_size(input->odb_object); input->mmfile.ptr = (char *)git_odb_object_data(input->odb_object); - + if (input->label == NULL) input->label = entry->path; - + done: git_odb_free(odb); - + return error; } @@ -101,27 +101,27 @@ int git_merge_file_input_from_diff_file( { git_odb *odb = NULL; int error = 0; - + assert(input && repo && file); - + if (file->mode == 0) return 0; - + if ((error = git_repository_odb(&odb, repo)) < 0 || (error = git_odb_read(&input->odb_object, odb, &file->oid)) < 0) goto done; - + input->mode = file->mode; input->path = git__strdup(file->path); input->mmfile.size = git_odb_object_size(input->odb_object); input->mmfile.ptr = (char *)git_odb_object_data(input->odb_object); - + if (input->label == NULL) input->label = file->path; - + done: git_odb_free(odb); - + return error; } @@ -138,12 +138,12 @@ int git_merge_files( int error = 0; assert(out && ancestor && ours && theirs); - + memset(out, 0x0, sizeof(git_merge_file_result)); if (!GIT_MERGE_FILE_SIDE_EXISTS(ours) || !GIT_MERGE_FILE_SIDE_EXISTS(theirs)) return 0; - + memset(&xmparam, 0x0, sizeof(xmparam_t)); xmparam.ancestor = ancestor->label; xmparam.file1 = ours->label; @@ -154,7 +154,7 @@ int git_merge_files( if (flags == GIT_MERGE_AUTOMERGE_FAVOR_OURS) xmparam.favor = XDL_MERGE_FAVOR_OURS; - + if (flags == GIT_MERGE_AUTOMERGE_FAVOR_THEIRS) xmparam.favor = XDL_MERGE_FAVOR_THEIRS; @@ -164,7 +164,7 @@ int git_merge_files( error = -1; goto done; } - + out->automergeable = (xdl_result == 0); out->data = (unsigned char *)mmbuffer.ptr; out->len = mmbuffer.size; @@ -172,4 +172,3 @@ int git_merge_files( done: return error; } - diff --git a/src/merge_file.h b/src/merge_file.h index 1aa34893d..0af2f0a57 100644 --- a/src/merge_file.h +++ b/src/merge_file.h @@ -16,7 +16,7 @@ typedef struct { char *path; unsigned int mode; mmfile_t mmfile; - + git_odb_object *odb_object; } git_merge_file_input; @@ -24,10 +24,10 @@ typedef struct { typedef struct { bool automergeable; - + const char *path; int mode; - + unsigned char *data; size_t len; } git_merge_file_result; diff --git a/src/pathspec.c b/src/pathspec.c index d4eb12582..35c79ce82 100644 --- a/src/pathspec.c +++ b/src/pathspec.c @@ -141,7 +141,7 @@ bool git_pathspec_match_path( git_vector_foreach(vspec, i, match) { int result = (match->flags & GIT_ATTR_FNMATCH_MATCH_ALL) ? 0 : FNM_NOMATCH; - + if (result == FNM_NOMATCH) result = use_strcmp(match->pattern, path) ? FNM_NOMATCH : 0; diff --git a/src/refdb_fs.c b/src/refdb_fs.c index b9df83f81..f964c4182 100644 --- a/src/refdb_fs.c +++ b/src/refdb_fs.c @@ -217,7 +217,7 @@ static int packed_load(refdb_fs_backend *backend) backend->peeling_mode = PEELING_NONE; if (buffer_start[0] == '#') { - static const char *traits_header = "# pack-refs with: "; + static const char *traits_header = "# pack-refs with: "; if (git__prefixcmp(buffer_start, traits_header) == 0) { char *traits = (char *)buffer_start + strlen(traits_header); @@ -1060,7 +1060,7 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend) static int setup_namespace(git_buf *path, git_repository *repo) { - char *parts, *start, *end; + char *parts, *start, *end; /* Not all repositories have a path */ if (repo->path_repository == NULL) @@ -1091,7 +1091,7 @@ static int setup_namespace(git_buf *path, git_repository *repo) free(parts); /* Make sure that the folder with the namespace exists */ - if (git_futils_mkdir_r(git_buf_cstr(path), repo->path_repository, 0777) < 0) + if (git_futils_mkdir_r(git_buf_cstr(path), repo->path_repository, 0777) < 0) return -1; /* Return the root of the namespaced path, i.e. without the trailing '/refs' */ diff --git a/src/reset.c b/src/reset.c index c1e1f865e..cea212a93 100644 --- a/src/reset.c +++ b/src/reset.c @@ -32,7 +32,7 @@ int git_reset_default( int error; git_index *index = NULL; - assert(pathspecs != NULL && pathspecs->count > 0); + assert(pathspecs != NULL && pathspecs->count > 0); memset(&entry, 0, sizeof(git_index_entry)); diff --git a/src/revparse.c b/src/revparse.c index 05231e3fc..97fc91b54 100644 --- a/src/revparse.c +++ b/src/revparse.c @@ -855,4 +855,3 @@ int git_revparse( return error; } - diff --git a/src/signature.c b/src/signature.c index 48bdd81ab..1131fb789 100644 --- a/src/signature.c +++ b/src/signature.c @@ -173,7 +173,7 @@ int git_signature__parse(git_signature *sig, const char **buffer_out, tz_start = time_end + 1; - if ((tz_start[0] != '-' && tz_start[0] != '+') || + if ((tz_start[0] != '-' && tz_start[0] != '+') || git__strtol32(&offset, tz_start + 1, &tz_end, 10) < 0) return signature_error("malformed timezone"); diff --git a/src/trace.c b/src/trace.c index 159ac91cc..ee5039f56 100644 --- a/src/trace.c +++ b/src/trace.c @@ -25,7 +25,7 @@ int git_trace_set(git_trace_level_t level, git_trace_callback callback) git_trace__data.level = level; git_trace__data.callback = callback; GIT_MEMORY_BARRIER; - + return 0; #else GIT_UNUSED(level); @@ -36,4 +36,3 @@ int git_trace_set(git_trace_level_t level, git_trace_callback callback) return -1; #endif } - diff --git a/src/trace.h b/src/trace.h index f4bdff88a..77b1e03ef 100644 --- a/src/trace.h +++ b/src/trace.h @@ -25,14 +25,14 @@ GIT_INLINE(void) git_trace__write_fmt( git_trace_level_t level, const char *fmt, ...) { - git_trace_callback callback = git_trace__data.callback; + git_trace_callback callback = git_trace__data.callback; git_buf message = GIT_BUF_INIT; va_list ap; - + va_start(ap, fmt); git_buf_vprintf(&message, fmt, ap); va_end(ap); - + callback(level, git_buf_cstr(&message)); git_buf_free(&message); diff --git a/src/transports/local.c b/src/transports/local.c index 2530a847f..4bf1c876a 100644 --- a/src/transports/local.c +++ b/src/transports/local.c @@ -348,7 +348,7 @@ static int local_push( if ((error = git_repository_open(&remote_repo, push->remote->url)) < 0) return error; - /* We don't currently support pushing locally to non-bare repos. Proper + /* We don't currently support pushing locally to non-bare repos. Proper non-bare repo push support would require checking configs to see if we should override the default 'don't let this happen' behavior */ if (!remote_repo->is_bare) { diff --git a/src/win32/findfile.c b/src/win32/findfile.c index bc36b6b45..5dd3de13d 100644 --- a/src/win32/findfile.c +++ b/src/win32/findfile.c @@ -235,4 +235,3 @@ int git_win32__find_xdg_dirs(git_buf *out) return win32_find_existing_dirs(out, global_tmpls, temp); } - diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c index b9115836e..f9967e04a 100644 --- a/src/win32/posix_w32.c +++ b/src/win32/posix_w32.c @@ -535,7 +535,7 @@ int p_gettimeofday(struct timeval *tv, struct timezone *tz) /*converting file time to unix epoch*/ tmpres /= 10; /*convert into microseconds*/ - tmpres -= DELTA_EPOCH_IN_MICROSECS; + tmpres -= DELTA_EPOCH_IN_MICROSECS; tv->tv_sec = (long)(tmpres / 1000000UL); tv->tv_usec = (long)(tmpres % 1000000UL); } diff --git a/tests-clar/checkout/tree.c b/tests-clar/checkout/tree.c index 67357a942..462a46c83 100644 --- a/tests-clar/checkout/tree.c +++ b/tests-clar/checkout/tree.c @@ -363,7 +363,7 @@ void assert_conflict( git_index *index; git_object *hack_tree; git_reference *branch, *head; - git_buf file_path = GIT_BUF_INIT; + git_buf file_path = GIT_BUF_INIT; cl_git_pass(git_repository_index(&index, g_repo)); diff --git a/tests-clar/clone/empty.c b/tests-clar/clone/empty.c index f190523b6..f92fa6cbb 100644 --- a/tests-clar/clone/empty.c +++ b/tests-clar/clone/empty.c @@ -48,13 +48,13 @@ void test_clone_empty__can_clone_an_empty_local_repo_barely(void) cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&ref, g_repo_cloned, local_name)); /* ...one can still retrieve the name of the remote tracking reference */ - cl_assert_equal_i((int)strlen(expected_tracked_branch_name) + 1, + cl_assert_equal_i((int)strlen(expected_tracked_branch_name) + 1, git_branch_upstream_name(buffer, 1024, g_repo_cloned, local_name)); cl_assert_equal_s(expected_tracked_branch_name, buffer); /* ...and the name of the remote... */ - cl_assert_equal_i((int)strlen(expected_remote_name) + 1, + cl_assert_equal_i((int)strlen(expected_remote_name) + 1, git_branch_remote_name(buffer, 1024, g_repo_cloned, expected_tracked_branch_name)); cl_assert_equal_s(expected_remote_name, buffer); diff --git a/tests-clar/commit/write.c b/tests-clar/commit/write.c index e9946af89..73436b74b 100644 --- a/tests-clar/commit/write.c +++ b/tests-clar/commit/write.c @@ -115,7 +115,7 @@ void test_commit_write__root(void) head_old = git__strdup(git_reference_symbolic_target(head)); cl_assert(head_old != NULL); git_reference_free(head); - + cl_git_pass(git_reference_symbolic_create(&head, g_repo, "HEAD", branch_name, 1)); cl_git_pass(git_commit_create_v( diff --git a/tests-clar/index/names.c b/tests-clar/index/names.c index 68615531a..95a560ee4 100644 --- a/tests-clar/index/names.c +++ b/tests-clar/index/names.c @@ -21,7 +21,7 @@ void test_index_names__cleanup(void) { git_index_free(repo_index); repo_index = NULL; - + cl_git_sandbox_cleanup(); } @@ -32,14 +32,14 @@ void test_index_names__add(void) cl_git_pass(git_index_name_add(repo_index, "ancestor", "ours", "theirs")); cl_git_pass(git_index_name_add(repo_index, "ancestor2", "ours2", NULL)); cl_git_pass(git_index_name_add(repo_index, "ancestor3", NULL, "theirs3")); - + cl_assert(git_index_name_entrycount(repo_index) == 3); - + conflict_name = git_index_name_get_byindex(repo_index, 0); cl_assert(strcmp(conflict_name->ancestor, "ancestor") == 0); cl_assert(strcmp(conflict_name->ours, "ours") == 0); cl_assert(strcmp(conflict_name->theirs, "theirs") == 0); - + conflict_name = git_index_name_get_byindex(repo_index, 1); cl_assert(strcmp(conflict_name->ancestor, "ancestor2") == 0); cl_assert(strcmp(conflict_name->ours, "ours2") == 0); @@ -54,31 +54,31 @@ void test_index_names__add(void) void test_index_names__roundtrip(void) { const git_index_name_entry *conflict_name; - + cl_git_pass(git_index_name_add(repo_index, "ancestor", "ours", "theirs")); cl_git_pass(git_index_name_add(repo_index, "ancestor2", "ours2", NULL)); cl_git_pass(git_index_name_add(repo_index, "ancestor3", NULL, "theirs3")); - + cl_git_pass(git_index_write(repo_index)); git_index_clear(repo_index); cl_assert(git_index_name_entrycount(repo_index) == 0); - + cl_git_pass(git_index_read(repo_index)); cl_assert(git_index_name_entrycount(repo_index) == 3); - + conflict_name = git_index_name_get_byindex(repo_index, 0); cl_assert(strcmp(conflict_name->ancestor, "ancestor") == 0); cl_assert(strcmp(conflict_name->ours, "ours") == 0); cl_assert(strcmp(conflict_name->theirs, "theirs") == 0); - + conflict_name = git_index_name_get_byindex(repo_index, 1); cl_assert(strcmp(conflict_name->ancestor, "ancestor2") == 0); cl_assert(strcmp(conflict_name->ours, "ours2") == 0); cl_assert(conflict_name->theirs == NULL); - + conflict_name = git_index_name_get_byindex(repo_index, 2); cl_assert(strcmp(conflict_name->ancestor, "ancestor3") == 0); cl_assert(conflict_name->ours == NULL); cl_assert(strcmp(conflict_name->theirs, "theirs3") == 0); - + } diff --git a/tests-clar/index/reuc.c b/tests-clar/index/reuc.c index 0e38a92f3..69ed4a933 100644 --- a/tests-clar/index/reuc.c +++ b/tests-clar/index/reuc.c @@ -232,7 +232,7 @@ void test_index_reuc__remove(void) cl_git_pass(git_index_reuc_remove(repo_index, 0)); cl_git_fail(git_index_reuc_remove(repo_index, 1)); - + cl_assert_equal_i(1, git_index_reuc_entrycount(repo_index)); cl_assert(reuc = git_index_reuc_get_byindex(repo_index, 0)); @@ -283,7 +283,7 @@ void test_index_reuc__write(void) /* ensure sort order was round-tripped correct */ cl_assert(reuc = git_index_reuc_get_byindex(repo_index, 0)); cl_assert_equal_s("one.txt", reuc->path); - + cl_assert(reuc = git_index_reuc_get_byindex(repo_index, 1)); cl_assert_equal_s("two.txt", reuc->path); } @@ -296,41 +296,41 @@ static int reuc_entry_exists(void) void test_index_reuc__cleaned_on_reset_hard(void) { git_object *target; - + retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876"); - + test_index_reuc__add(); cl_git_pass(git_reset(repo, target, GIT_RESET_HARD)); cl_assert(reuc_entry_exists() == false); - + git_object_free(target); } void test_index_reuc__cleaned_on_reset_mixed(void) { git_object *target; - + retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876"); - test_index_reuc__add(); + test_index_reuc__add(); cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED)); cl_assert(reuc_entry_exists() == false); - + git_object_free(target); } void test_index_reuc__retained_on_reset_soft(void) { git_object *target; - + retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876"); - + git_reset(repo, target, GIT_RESET_HARD); test_index_reuc__add(); cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT)); cl_assert(reuc_entry_exists() == true); - + git_object_free(target); } @@ -339,7 +339,7 @@ void test_index_reuc__cleaned_on_checkout_tree(void) git_oid oid; git_object *obj; git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT; - + opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_UPDATE_ONLY; test_index_reuc__add(); @@ -347,16 +347,16 @@ void test_index_reuc__cleaned_on_checkout_tree(void) git_object_lookup(&obj, repo, &oid, GIT_OBJ_ANY); git_checkout_tree(repo, obj, &opts); cl_assert(reuc_entry_exists() == false); - + git_object_free(obj); } void test_index_reuc__cleaned_on_checkout_head(void) { git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT; - + opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_UPDATE_ONLY; - + test_index_reuc__add(); git_checkout_head(repo, &opts); cl_assert(reuc_entry_exists() == false); @@ -365,9 +365,9 @@ void test_index_reuc__cleaned_on_checkout_head(void) void test_index_reuc__retained_on_checkout_index(void) { git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT; - + opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_UPDATE_ONLY; - + test_index_reuc__add(); git_checkout_index(repo, repo_index, &opts); cl_assert(reuc_entry_exists() == true); diff --git a/tests-clar/merge/merge_helpers.c b/tests-clar/merge/merge_helpers.c index 71bb96781..bc31b1f44 100644 --- a/tests-clar/merge/merge_helpers.c +++ b/tests-clar/merge/merge_helpers.c @@ -56,11 +56,11 @@ void merge__dump_index_entries(git_vector *index_entries) { size_t i; const git_index_entry *index_entry; - + printf ("\nINDEX [%d]:\n", (int)index_entries->length); for (i = 0; i < index_entries->length; i++) { index_entry = index_entries->contents[i]; - + printf("%o ", index_entry->mode); printf("%s ", git_oid_allocfmt(&index_entry->oid)); printf("%d ", git_index_entry_stage(index_entry)); @@ -77,7 +77,7 @@ void merge__dump_names(git_index *index) for (i = 0; i < git_index_name_entrycount(index); i++) { conflict_name = git_index_name_get_byindex(index, i); - + printf("%s %s %s\n", conflict_name->ancestor, conflict_name->ours, conflict_name->theirs); } printf("\n"); @@ -91,7 +91,7 @@ void merge__dump_reuc(git_index *index) printf ("\nREUC:\n"); for (i = 0; i < git_index_reuc_entrycount(index); i++) { reuc = git_index_reuc_get_byindex(index, i); - + printf("%s ", reuc->path); printf("%o ", reuc->mode[0]); printf("%s\n", git_oid_allocfmt(&reuc->oid[0])); @@ -114,18 +114,18 @@ static int index_entry_eq_merge_index_entry(const struct merge_index_entry *expe test_oid = 1; } else test_oid = 0; - + if (actual->mode != expected->mode || (test_oid && git_oid_cmp(&actual->oid, &expected_oid) != 0) || git_index_entry_stage(actual) != expected->stage) return 0; - + if (actual->mode == 0 && (actual->path != NULL || strlen(expected->path) > 0)) return 0; if (actual->mode != 0 && (strcmp(actual->path, expected->path) != 0)) return 0; - + return 1; } @@ -133,7 +133,7 @@ static int name_entry_eq(const char *expected, const char *actual) { if (strlen(expected) == 0) return (actual == NULL) ? 1 : 0; - + return (strcmp(expected, actual) == 0) ? 1 : 0; } @@ -153,11 +153,11 @@ static int index_conflict_data_eq_merge_diff(const struct merge_index_conflict_d !index_entry_eq_merge_index_entry(&expected->ours.entry, &actual->our_entry) || !index_entry_eq_merge_index_entry(&expected->theirs.entry, &actual->their_entry)) return 0; - + if (expected->ours.status != actual->our_status || expected->theirs.status != actual->their_status) return 0; - + return 1; } @@ -165,48 +165,48 @@ int merge_test_merge_conflicts(git_vector *conflicts, const struct merge_index_c { git_merge_diff *actual; size_t i; - + if (conflicts->length != expected_len) return 0; for (i = 0; i < expected_len; i++) { actual = conflicts->contents[i]; - + if (!index_conflict_data_eq_merge_diff(&expected[i], actual)) return 0; } - return 1; + return 1; } int merge_test_index(git_index *index, const struct merge_index_entry expected[], size_t expected_len) { - size_t i; - const git_index_entry *index_entry; - + size_t i; + const git_index_entry *index_entry; + /* dump_index_entries(&index->entries); */ - if (git_index_entrycount(index) != expected_len) - return 0; - - for (i = 0; i < expected_len; i++) { - if ((index_entry = git_index_get_byindex(index, i)) == NULL) - return 0; - + if (git_index_entrycount(index) != expected_len) + return 0; + + for (i = 0; i < expected_len; i++) { + if ((index_entry = git_index_get_byindex(index, i)) == NULL) + return 0; + if (!index_entry_eq_merge_index_entry(&expected[i], index_entry)) return 0; - } - - return 1; + } + + return 1; } int merge_test_names(git_index *index, const struct merge_name_entry expected[], size_t expected_len) { size_t i; const git_index_name_entry *name_entry; - + /* dump_names(index); */ @@ -221,26 +221,26 @@ int merge_test_names(git_index *index, const struct merge_name_entry expected[], if (! name_entry_eq_merge_name_entry(&expected[i], name_entry)) return 0; } - + return 1; } int merge_test_reuc(git_index *index, const struct merge_reuc_entry expected[], size_t expected_len) { - size_t i; + size_t i; const git_index_reuc_entry *reuc_entry; - git_oid expected_oid; - + git_oid expected_oid; + /* dump_reuc(index); */ - - if (git_index_reuc_entrycount(index) != expected_len) - return 0; - - for (i = 0; i < expected_len; i++) { - if ((reuc_entry = git_index_reuc_get_byindex(index, i)) == NULL) - return 0; + + if (git_index_reuc_entrycount(index) != expected_len) + return 0; + + for (i = 0; i < expected_len; i++) { + if ((reuc_entry = git_index_reuc_get_byindex(index, i)) == NULL) + return 0; if (strcmp(reuc_entry->path, expected[i].path) != 0 || reuc_entry->mode[0] != expected[i].ancestor_mode || @@ -268,19 +268,19 @@ int merge_test_reuc(git_index *index, const struct merge_reuc_entry expected[], if (git_oid_cmp(&reuc_entry->oid[2], &expected_oid) != 0) return 0; } - } - - return 1; + } + + return 1; } int dircount(void *payload, git_buf *pathbuf) { int *entries = payload; size_t len = git_buf_len(pathbuf); - + if (len < 5 || strcmp(pathbuf->ptr + (git_buf_len(pathbuf) - 5), "/.git") != 0) (*entries)++; - + return 0; } @@ -289,22 +289,22 @@ int merge_test_workdir(git_repository *repo, const struct merge_index_entry expe size_t actual_len = 0, i; git_oid actual_oid, expected_oid; git_buf wd = GIT_BUF_INIT; - - git_buf_puts(&wd, repo->workdir); + + git_buf_puts(&wd, repo->workdir); git_path_direach(&wd, dircount, &actual_len); - + if (actual_len != expected_len) return 0; - + for (i = 0; i < expected_len; i++) { git_blob_create_fromworkdir(&actual_oid, repo, expected[i].path); git_oid_fromstr(&expected_oid, expected[i].oid_str); - + if (git_oid_cmp(&actual_oid, &expected_oid) != 0) return 0; } - + git_buf_free(&wd); - + return 1; } diff --git a/tests-clar/merge/trees/automerge.c b/tests-clar/merge/trees/automerge.c index 7592a926e..04a7beff6 100644 --- a/tests-clar/merge/trees/automerge.c +++ b/tests-clar/merge/trees/automerge.c @@ -93,7 +93,7 @@ void test_merge_trees_automerge__automerge(void) const git_index_entry *entry; git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT; git_blob *blob; - + struct merge_index_entry merge_index_entries[] = { ADDED_IN_MASTER_INDEX_ENTRY, AUTOMERGEABLE_INDEX_ENTRY, @@ -105,7 +105,7 @@ void test_merge_trees_automerge__automerge(void) { 0100644, "2bd0a343aeef7a2cf0d158478966a6e587ff3863", 3, "conflicting.txt" }, UNCHANGED_INDEX_ENTRY, - }; + }; struct merge_reuc_entry merge_reuc_entries[] = { AUTOMERGEABLE_REUC_ENTRY, @@ -120,10 +120,10 @@ void test_merge_trees_automerge__automerge(void) cl_assert((entry = git_index_get_bypath(index, "automergeable.txt", 0)) != NULL); cl_assert(entry->file_size == strlen(AUTOMERGEABLE_MERGED_FILE)); - + cl_git_pass(git_object_lookup((git_object **)&blob, repo, &entry->oid, GIT_OBJ_BLOB)); cl_assert(memcmp(git_blob_rawcontent(blob), AUTOMERGEABLE_MERGED_FILE, entry->file_size) == 0); - + git_index_free(index); git_blob_free(blob); } @@ -132,7 +132,7 @@ void test_merge_trees_automerge__favor_ours(void) { git_index *index; git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT; - + struct merge_index_entry merge_index_entries[] = { ADDED_IN_MASTER_INDEX_ENTRY, AUTOMERGEABLE_INDEX_ENTRY, @@ -148,9 +148,9 @@ void test_merge_trees_automerge__favor_ours(void) REMOVED_IN_BRANCH_REUC_ENTRY, REMOVED_IN_MASTER_REUC_ENTRY, }; - + opts.automerge_flags = GIT_MERGE_AUTOMERGE_FAVOR_OURS; - + cl_git_pass(merge_trees_from_branches(&index, repo, "master", THEIRS_AUTOMERGE_BRANCH, &opts)); cl_assert(merge_test_index(index, merge_index_entries, 6)); @@ -163,7 +163,7 @@ void test_merge_trees_automerge__favor_theirs(void) { git_index *index; git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT; - + struct merge_index_entry merge_index_entries[] = { ADDED_IN_MASTER_INDEX_ENTRY, AUTOMERGEABLE_INDEX_ENTRY, @@ -181,12 +181,12 @@ void test_merge_trees_automerge__favor_theirs(void) }; opts.automerge_flags = GIT_MERGE_AUTOMERGE_FAVOR_THEIRS; - + cl_git_pass(merge_trees_from_branches(&index, repo, "master", THEIRS_AUTOMERGE_BRANCH, &opts)); cl_assert(merge_test_index(index, merge_index_entries, 6)); cl_assert(merge_test_reuc(index, merge_reuc_entries, 4)); - + git_index_free(index); } @@ -194,7 +194,7 @@ void test_merge_trees_automerge__unrelated(void) { git_index *index; git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT; - + struct merge_index_entry merge_index_entries[] = { { 0100644, "233c0919c998ed110a4b6ff36f353aec8b713487", 0, "added-in-master.txt" }, { 0100644, "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf", 2, "automergeable.txt" }, @@ -208,10 +208,10 @@ void test_merge_trees_automerge__unrelated(void) { 0100644, "dfe3f22baa1f6fce5447901c3086bae368de6bdd", 0, "removed-in-branch.txt" }, { 0100644, "c8f06f2e3bb2964174677e91f0abead0e43c9e5d", 0, "unchanged.txt" }, }; - + cl_git_pass(merge_trees_from_branches(&index, repo, "master", THEIRS_UNRELATED_BRANCH, &opts)); - + cl_assert(merge_test_index(index, merge_index_entries, 11)); - + git_index_free(index); } diff --git a/tests-clar/merge/trees/modeconflict.c b/tests-clar/merge/trees/modeconflict.c index 0661ce5b3..d858b8f66 100644 --- a/tests-clar/merge/trees/modeconflict.c +++ b/tests-clar/merge/trees/modeconflict.c @@ -27,7 +27,7 @@ void test_merge_trees_modeconflict__cleanup(void) void test_merge_trees_modeconflict__df_conflict(void) { git_index *index; - + struct merge_index_entry merge_index_entries[] = { { 0100644, "49130a28ef567af9a6a6104c38773fedfa5f9742", 2, "dir-10" }, { 0100644, "6c06dcd163587c2cc18be44857e0b71116382aeb", 3, "dir-10" }, @@ -49,7 +49,7 @@ void test_merge_trees_modeconflict__df_conflict(void) { 0100644, "e49f917b448d1340b31d76e54ba388268fd4c922", 0, "file-4/new" }, { 0100644, "cab2cf23998b40f1af2d9d9a756dc9e285a8df4b", 2, "file-5/new" }, { 0100644, "f5504f36e6f4eb797a56fc5bac6c6c7f32969bf2", 3, "file-5/new" }, - }; + }; cl_git_pass(merge_trees_from_branches(&index, repo, DF_SIDE1_BRANCH, DF_SIDE2_BRANCH, NULL)); diff --git a/tests-clar/merge/trees/renames.c b/tests-clar/merge/trees/renames.c index dc0564bc4..427b6bd8f 100644 --- a/tests-clar/merge/trees/renames.c +++ b/tests-clar/merge/trees/renames.c @@ -72,14 +72,14 @@ void test_merge_trees_renames__index(void) { 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 2, "7-both-renamed.txt" }, { 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 3, "7-both-renamed.txt" }, }; - + struct merge_name_entry merge_name_entries[] = { { "3a-renamed-in-ours-deleted-in-theirs.txt", "3a-newname-in-ours-deleted-in-theirs.txt", "" }, - + { "3b-renamed-in-theirs-deleted-in-ours.txt", "", @@ -97,7 +97,7 @@ void test_merge_trees_renames__index(void) "", "4b-newname-in-theirs-added-in-ours.txt", }, - + { "5a-renamed-in-ours-added-in-theirs.txt", "5a-newname-in-ours-added-in-theirs.txt", @@ -115,13 +115,13 @@ void test_merge_trees_renames__index(void) "6-both-renamed-1-to-2-ours.txt", "6-both-renamed-1-to-2-theirs.txt", }, - + { "7-both-renamed-side-1.txt", "7-both-renamed.txt", "7-both-renamed-side-1.txt", }, - + { "7-both-renamed-side-2.txt", "7-both-renamed-side-2.txt", @@ -159,7 +159,7 @@ void test_merge_trees_renames__index(void) "", "", "241a1005cd9b980732741b74385b891142bcba28" }, - + { "1b-newname-in-theirs.txt", 0, 0, 0100644, "", @@ -194,11 +194,11 @@ void test_merge_trees_renames__index(void) cl_git_pass(merge_trees_from_branches(&index, repo, BRANCH_RENAME_OURS, BRANCH_RENAME_THEIRS, opts)); - + cl_assert(merge_test_index(index, merge_index_entries, 41)); cl_assert(merge_test_names(index, merge_name_entries, 9)); cl_assert(merge_test_reuc(index, merge_reuc_entries, 10)); - + git_index_free(index); } @@ -206,7 +206,7 @@ void test_merge_trees_renames__no_rename_index(void) { git_index *index; git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT; - + struct merge_index_entry merge_index_entries[] = { { 0100644, "68c6c84b091926c7d90aa6a79b2bc3bb6adccd8e", 0, "0a-no-change.txt" }, { 0100644, "f0ce2b8e4986084d9b308fb72709e414c23eb5e6", 0, "0b-duplicated-in-ours.txt" }, @@ -241,13 +241,12 @@ void test_merge_trees_renames__no_rename_index(void) { 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 2, "7-both-renamed.txt" }, { 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 3, "7-both-renamed.txt" }, }; - + cl_git_pass(merge_trees_from_branches(&index, repo, BRANCH_RENAME_OURS, BRANCH_RENAME_THEIRS, &opts)); - + cl_assert(merge_test_index(index, merge_index_entries, 32)); - + git_index_free(index); } - diff --git a/tests-clar/merge/trees/treediff.c b/tests-clar/merge/trees/treediff.c index 06ea94e0d..357859df3 100644 --- a/tests-clar/merge/trees/treediff.c +++ b/tests-clar/merge/trees/treediff.c @@ -58,37 +58,37 @@ static void test_find_differences( opts.metric->similarity = git_diff_find_similar__calc_similarity; opts.metric->payload = (void *)GIT_HASHSIG_SMART_WHITESPACE; - cl_git_pass(git_oid_fromstr(&ancestor_oid, ancestor_oidstr)); - cl_git_pass(git_oid_fromstr(&ours_oid, ours_oidstr)); - cl_git_pass(git_oid_fromstr(&theirs_oid, theirs_oidstr)); - - cl_git_pass(git_tree_lookup(&ancestor_tree, repo, &ancestor_oid)); - cl_git_pass(git_tree_lookup(&ours_tree, repo, &ours_oid)); - cl_git_pass(git_tree_lookup(&theirs_tree, repo, &theirs_oid)); - + cl_git_pass(git_oid_fromstr(&ancestor_oid, ancestor_oidstr)); + cl_git_pass(git_oid_fromstr(&ours_oid, ours_oidstr)); + cl_git_pass(git_oid_fromstr(&theirs_oid, theirs_oidstr)); + + cl_git_pass(git_tree_lookup(&ancestor_tree, repo, &ancestor_oid)); + cl_git_pass(git_tree_lookup(&ours_tree, repo, &ours_oid)); + cl_git_pass(git_tree_lookup(&theirs_tree, repo, &theirs_oid)); + cl_git_pass(git_merge_diff_list__find_differences(merge_diff_list, ancestor_tree, ours_tree, theirs_tree)); cl_git_pass(git_merge_diff_list__find_renames(repo, merge_diff_list, &opts)); /* dump_merge_index(merge_index); */ - - cl_assert(treediff_conflict_data_len == merge_diff_list->conflicts.length); + + cl_assert(treediff_conflict_data_len == merge_diff_list->conflicts.length); cl_assert(merge_test_merge_conflicts(&merge_diff_list->conflicts, treediff_conflict_data, treediff_conflict_data_len)); - git_tree_free(ancestor_tree); - git_tree_free(ours_tree); - git_tree_free(theirs_tree); - + git_tree_free(ancestor_tree); + git_tree_free(ours_tree); + git_tree_free(theirs_tree); + git_merge_diff_list__free(merge_diff_list); - + git__free(opts.metric); } void test_merge_trees_treediff__simple(void) { - struct merge_index_conflict_data treediff_conflict_data[] = { + struct merge_index_conflict_data treediff_conflict_data[] = { { { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "233c0919c998ed110a4b6ff36f353aec8b713487", 0, "added-in-master.txt" }, GIT_DELTA_ADDED }, @@ -96,41 +96,41 @@ void test_merge_trees_treediff__simple(void) GIT_MERGE_DIFF_NONE }, - { + { { { 0100644, "6212c31dab5e482247d7977e4f0dd3601decf13b", 0, "automergeable.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf", 0, "automergeable.txt" }, GIT_DELTA_MODIFIED }, { { 0100644, "058541fc37114bfc1dddf6bd6bffc7fae5c2e6fe", 0, "automergeable.txt" }, GIT_DELTA_MODIFIED }, GIT_MERGE_DIFF_BOTH_MODIFIED }, - + { { { 0100644, "ab6c44a2e84492ad4b41bb6bac87353e9d02ac8b", 0, "changed-in-branch.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "ab6c44a2e84492ad4b41bb6bac87353e9d02ac8b", 0, "changed-in-branch.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "4eb04c9e79e88f6640d01ff5b25ca2a60764f216", 0, "changed-in-branch.txt" }, GIT_DELTA_MODIFIED }, GIT_MERGE_DIFF_NONE }, - + { { { 0100644, "ab6c44a2e84492ad4b41bb6bac87353e9d02ac8b", 0, "changed-in-master.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "11deab00b2d3a6f5a3073988ac050c2d7b6655e2", 0, "changed-in-master.txt" }, GIT_DELTA_MODIFIED }, { { 0100644, "ab6c44a2e84492ad4b41bb6bac87353e9d02ac8b", 0, "changed-in-master.txt" }, GIT_DELTA_UNMODIFIED }, GIT_MERGE_DIFF_NONE }, - + { { { 0100644, "d427e0b2e138501a3d15cc376077a3631e15bd46", 0, "conflicting.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "4e886e602529caa9ab11d71f86634bd1b6e0de10", 0, "conflicting.txt" }, GIT_DELTA_MODIFIED }, { { 0100644, "2bd0a343aeef7a2cf0d158478966a6e587ff3863", 0, "conflicting.txt" }, GIT_DELTA_MODIFIED }, GIT_MERGE_DIFF_BOTH_MODIFIED }, - + { { { 0100644, "dfe3f22baa1f6fce5447901c3086bae368de6bdd", 0, "removed-in-branch.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "dfe3f22baa1f6fce5447901c3086bae368de6bdd", 0, "removed-in-branch.txt" }, GIT_DELTA_UNMODIFIED }, { { 0, "", 0, "" }, GIT_DELTA_DELETED }, GIT_MERGE_DIFF_NONE }, - + { { { 0100644, "5c3b68a71fc4fa5d362fd3875e53137c6a5ab7a5", 0, "removed-in-master.txt" }, GIT_DELTA_UNMODIFIED }, { { 0, "", 0, "" }, GIT_DELTA_DELETED }, @@ -138,13 +138,13 @@ void test_merge_trees_treediff__simple(void) GIT_MERGE_DIFF_NONE }, }; - + test_find_differences(TREE_OID_ANCESTOR, TREE_OID_MASTER, TREE_OID_BRANCH, treediff_conflict_data, 7); } void test_merge_trees_treediff__df_conflicts(void) { - struct merge_index_conflict_data treediff_conflict_data[] = { + struct merge_index_conflict_data treediff_conflict_data[] = { { { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "49130a28ef567af9a6a6104c38773fedfa5f9742", 0, "dir-10" }, GIT_DELTA_ADDED }, @@ -158,7 +158,7 @@ void test_merge_trees_treediff__df_conflicts(void) { { 0, "", 0, "" }, GIT_DELTA_DELETED }, GIT_MERGE_DIFF_BOTH_DELETED, }, - + { { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, @@ -172,7 +172,7 @@ void test_merge_trees_treediff__df_conflicts(void) { { 0, "", 0, "" }, GIT_DELTA_DELETED }, GIT_MERGE_DIFF_NONE, }, - + { { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, @@ -186,7 +186,7 @@ void test_merge_trees_treediff__df_conflicts(void) { { 0, "", 0, "" }, GIT_DELTA_DELETED }, GIT_MERGE_DIFF_DF_CHILD, }, - + { { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "e9ad6ec3e38364a3d07feda7c4197d4d845c53b5", 0, "dir-8" }, GIT_DELTA_ADDED }, @@ -200,7 +200,7 @@ void test_merge_trees_treediff__df_conflicts(void) { { 0100644, "f20c9063fa0bda9a397c96947a7b687305c49753", 0, "dir-8/file.txt" }, GIT_DELTA_UNMODIFIED }, GIT_MERGE_DIFF_NONE, }, - + { { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "3ef4d30382ca33fdeba9fda895a99e0891ba37aa", 0, "dir-9" }, GIT_DELTA_ADDED }, @@ -235,7 +235,7 @@ void test_merge_trees_treediff__df_conflicts(void) { { 0, "", 0, "" }, GIT_DELTA_DELETED }, GIT_MERGE_DIFF_DIRECTORY_FILE, }, - + { { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, @@ -277,7 +277,7 @@ void test_merge_trees_treediff__df_conflicts(void) { { 0, "", 0, "" }, GIT_DELTA_DELETED }, GIT_MERGE_DIFF_BOTH_DELETED, }, - + { { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "cab2cf23998b40f1af2d9d9a756dc9e285a8df4b", 0, "file-5/new" }, GIT_DELTA_ADDED }, @@ -285,7 +285,7 @@ void test_merge_trees_treediff__df_conflicts(void) GIT_MERGE_DIFF_BOTH_ADDED, }, }; - + test_find_differences(TREE_OID_DF_ANCESTOR, TREE_OID_DF_SIDE1, TREE_OID_DF_SIDE2, treediff_conflict_data, 20); } @@ -298,7 +298,7 @@ void test_merge_trees_treediff__strict_renames(void) { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, GIT_MERGE_DIFF_NONE, }, - + { { { 0100644, "6212c31dab5e482247d7977e4f0dd3601decf13b", 0, "automergeable.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf", 0, "automergeable.txt" }, GIT_DELTA_MODIFIED }, @@ -348,8 +348,8 @@ void test_merge_trees_treediff__strict_renames(void) GIT_MERGE_DIFF_NONE, }, }; - - test_find_differences(TREE_OID_ANCESTOR, TREE_OID_MASTER, TREE_OID_RENAMES1, treediff_conflict_data, 8); + + test_find_differences(TREE_OID_ANCESTOR, TREE_OID_MASTER, TREE_OID_RENAMES1, treediff_conflict_data, 8); } void test_merge_trees_treediff__rename_conflicts(void) @@ -375,7 +375,7 @@ void test_merge_trees_treediff__rename_conflicts(void) { { 0100644, "2f56120107d680129a5d9791b521cb1e73a2ed31", 0, "0c-duplicated-in-theirs.txt" }, GIT_DELTA_ADDED }, GIT_MERGE_DIFF_NONE, }, - + { { { 0100644, "2f56120107d680129a5d9791b521cb1e73a2ed31", 0, "0c-rewritten-in-theirs.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "efc9121fdedaf08ba180b53ebfbcf71bd488ed09", 0, "0c-rewritten-in-theirs.txt" }, GIT_DELTA_MODIFIED }, @@ -389,21 +389,21 @@ void test_merge_trees_treediff__rename_conflicts(void) { { 0100644, "0d872f8e871a30208305978ecbf9e66d864f1638", 0, "1a-renamed-in-ours-edited-in-theirs.txt" }, GIT_DELTA_MODIFIED }, GIT_MERGE_DIFF_RENAMED_MODIFIED, }, - + { { { 0100644, "d0d4594e16f2e19107e3fa7ea63e7aaaff305ffb", 0, "1a-renamed-in-ours.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "d0d4594e16f2e19107e3fa7ea63e7aaaff305ffb", 0, "1a-newname-in-ours.txt" }, GIT_DELTA_RENAMED }, { { 0100644, "d0d4594e16f2e19107e3fa7ea63e7aaaff305ffb", 0, "1a-renamed-in-ours.txt" }, GIT_DELTA_UNMODIFIED }, GIT_MERGE_DIFF_NONE, }, - + { { { 0100644, "241a1005cd9b980732741b74385b891142bcba28", 0, "1b-renamed-in-theirs-edited-in-ours.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "ed9523e62e453e50dd9be1606af19399b96e397a", 0, "1b-renamed-in-theirs-edited-in-ours.txt" }, GIT_DELTA_MODIFIED }, { { 0100644, "241a1005cd9b980732741b74385b891142bcba28", 0, "1b-newname-in-theirs-edited-in-ours.txt" }, GIT_DELTA_RENAMED }, GIT_MERGE_DIFF_RENAMED_MODIFIED, }, - + { { { 0100644, "2b5f1f181ee3b58ea751f5dd5d8f9b445520a136", 0, "1b-renamed-in-theirs.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "2b5f1f181ee3b58ea751f5dd5d8f9b445520a136", 0, "1b-renamed-in-theirs.txt" }, GIT_DELTA_UNMODIFIED }, @@ -417,28 +417,28 @@ void test_merge_trees_treediff__rename_conflicts(void) { { 0100644, "178940b450f238a56c0d75b7955cb57b38191982", 0, "2-newname-in-both.txt" }, GIT_DELTA_RENAMED }, GIT_MERGE_DIFF_BOTH_RENAMED, }, - + { { { 0100644, "18cb316b1cefa0f8a6946f0e201a8e1a6f845ab9", 0, "3a-renamed-in-ours-deleted-in-theirs.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "18cb316b1cefa0f8a6946f0e201a8e1a6f845ab9", 0, "3a-newname-in-ours-deleted-in-theirs.txt" }, GIT_DELTA_RENAMED }, { { 0, "", 0, "" }, GIT_DELTA_DELETED }, GIT_MERGE_DIFF_RENAMED_DELETED, }, - + { { { 0100644, "36219b49367146cb2e6a1555b5a9ebd4d0328495", 0, "3b-renamed-in-theirs-deleted-in-ours.txt" }, GIT_DELTA_UNMODIFIED }, { { 0, "", 0, "" }, GIT_DELTA_DELETED }, { { 0100644, "36219b49367146cb2e6a1555b5a9ebd4d0328495", 0, "3b-newname-in-theirs-deleted-in-ours.txt" }, GIT_DELTA_RENAMED }, GIT_MERGE_DIFF_RENAMED_DELETED, }, - + { { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "8b5b53cb2aa9ceb1139f5312fcfa3cc3c5a47c9a", 0, "4a-newname-in-ours-added-in-theirs.txt" }, GIT_DELTA_ADDED }, GIT_MERGE_DIFF_RENAMED_ADDED, - }, - + }, + { { { 0100644, "227792b52aaa0b238bea00ec7e509b02623f168c", 0, "4a-renamed-in-ours-added-in-theirs.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "227792b52aaa0b238bea00ec7e509b02623f168c", 0, "4a-newname-in-ours-added-in-theirs.txt" }, GIT_DELTA_RENAMED }, @@ -459,21 +459,21 @@ void test_merge_trees_treediff__rename_conflicts(void) { { 0100644, "98d52d07c0b0bbf2b46548f6aa521295c2cb55db", 0, "4b-newname-in-theirs-added-in-ours.txt" }, GIT_DELTA_RENAMED }, GIT_MERGE_DIFF_RENAMED_ADDED, }, - + { { { 0100644, "d8fa77b6833082c1ea36b7828a582d4c43882450", 0, "5-both-renamed-1-to-2.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "d8fa77b6833082c1ea36b7828a582d4c43882450", 0, "5-both-renamed-1-to-2-ours.txt" }, GIT_DELTA_RENAMED }, { { 0100644, "d8fa77b6833082c1ea36b7828a582d4c43882450", 0, "5-both-renamed-1-to-2-theirs.txt" }, GIT_DELTA_RENAMED }, GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2, }, - + { { { 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 0, "6-both-renamed-side-1.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 0, "6-both-renamed.txt" }, GIT_DELTA_RENAMED }, { { 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 0, "6-both-renamed-side-1.txt" }, GIT_DELTA_UNMODIFIED }, GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1, }, - + { { { 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 0, "6-both-renamed-side-2.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 0, "6-both-renamed-side-2.txt" }, GIT_DELTA_UNMODIFIED }, @@ -481,8 +481,7 @@ void test_merge_trees_treediff__rename_conflicts(void) GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1, }, }; - - test_find_differences(TREE_OID_RENAME_CONFLICT_ANCESTOR, + test_find_differences(TREE_OID_RENAME_CONFLICT_ANCESTOR, TREE_OID_RENAME_CONFLICT_OURS, TREE_OID_RENAME_CONFLICT_THEIRS, treediff_conflict_data, 18); } @@ -494,7 +493,7 @@ void test_merge_trees_treediff__best_renames(void) { { 0100644, "233c0919c998ed110a4b6ff36f353aec8b713487", 0, "added-in-master.txt" }, GIT_DELTA_ADDED }, { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, GIT_MERGE_DIFF_NONE, - }, + }, { { { 0100644, "6212c31dab5e482247d7977e4f0dd3601decf13b", 0, "automergeable.txt" }, GIT_DELTA_UNMODIFIED }, @@ -502,7 +501,7 @@ void test_merge_trees_treediff__best_renames(void) { { 0100644, "45299c1ca5e07bba1fd90843056fb559f96b1f5a", 0, "renamed-90.txt" }, GIT_DELTA_RENAMED }, GIT_MERGE_DIFF_RENAMED_MODIFIED, }, - + { { { 0100644, "ab6c44a2e84492ad4b41bb6bac87353e9d02ac8b", 0, "changed-in-master.txt" }, GIT_DELTA_UNMODIFIED }, { { 0100644, "11deab00b2d3a6f5a3073988ac050c2d7b6655e2", 0, "changed-in-master.txt" }, GIT_DELTA_MODIFIED }, @@ -523,7 +522,7 @@ void test_merge_trees_treediff__best_renames(void) { { 0100644, "5c3b68a71fc4fa5d362fd3875e53137c6a5ab7a5", 0, "removed-in-master.txt" }, GIT_DELTA_UNMODIFIED }, GIT_MERGE_DIFF_MODIFIED_DELETED, }, - + { { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, { { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED }, @@ -538,6 +537,6 @@ void test_merge_trees_treediff__best_renames(void) GIT_MERGE_DIFF_NONE, }, }; - - test_find_differences(TREE_OID_ANCESTOR, TREE_OID_MASTER, TREE_OID_RENAMES2, treediff_conflict_data, 7); + + test_find_differences(TREE_OID_ANCESTOR, TREE_OID_MASTER, TREE_OID_RENAMES2, treediff_conflict_data, 7); } diff --git a/tests-clar/merge/trees/trivial.c b/tests-clar/merge/trees/trivial.c index e6096e2dc..bfd5dfed3 100644 --- a/tests-clar/merge/trees/trivial.c +++ b/tests-clar/merge/trees/trivial.c @@ -34,7 +34,7 @@ static int merge_trivial(git_index **index, const char *ours, const char *theirs git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT; opts.automerge_flags |= automerge ? 0 : GIT_MERGE_AUTOMERGE_NONE; - + git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours); cl_git_pass(git_reference_name_to_id(&our_oid, repo, branch_buf.ptr)); cl_git_pass(git_commit_lookup(&our_commit, repo, &our_oid)); @@ -46,7 +46,7 @@ static int merge_trivial(git_index **index, const char *ours, const char *theirs cl_git_pass(git_merge_base(&ancestor_oid, repo, git_commit_id(our_commit), git_commit_id(their_commit))); cl_git_pass(git_commit_lookup(&ancestor_commit, repo, &ancestor_oid)); - + cl_git_pass(git_commit_tree(&ancestor_tree, ancestor_commit)); cl_git_pass(git_commit_tree(&our_tree, our_commit)); cl_git_pass(git_commit_tree(&their_tree, their_commit)); @@ -106,7 +106,7 @@ void test_merge_trees_trivial__3alt(void) cl_assert(entry = git_index_get_bypath(result, "new-in-3alt.txt", 0)); cl_assert(git_index_reuc_entrycount(result) == 0); cl_assert(merge_trivial_conflict_entrycount(result) == 0); - + git_index_free(result); } @@ -124,7 +124,7 @@ void test_merge_trees_trivial__4(void) cl_assert(merge_trivial_conflict_entrycount(result) == 2); cl_assert(entry = git_index_get_bypath(result, "new-and-different.txt", 2)); cl_assert(entry = git_index_get_bypath(result, "new-and-different.txt", 3)); - + git_index_free(result); } @@ -139,7 +139,7 @@ void test_merge_trees_trivial__5alt_1(void) cl_assert(entry = git_index_get_bypath(result, "new-and-same.txt", 0)); cl_assert(git_index_reuc_entrycount(result) == 0); cl_assert(merge_trivial_conflict_entrycount(result) == 0); - + git_index_free(result); } @@ -154,7 +154,7 @@ void test_merge_trees_trivial__5alt_2(void) cl_assert(entry = git_index_get_bypath(result, "modified-to-same.txt", 0)); cl_assert(git_index_reuc_entrycount(result) == 0); cl_assert(merge_trivial_conflict_entrycount(result) == 0); - + git_index_free(result); } @@ -171,7 +171,7 @@ void test_merge_trees_trivial__6(void) cl_assert(merge_trivial_conflict_entrycount(result) == 1); cl_assert(entry = git_index_get_bypath(result, "removed-in-both.txt", 1)); - + git_index_free(result); } @@ -189,7 +189,7 @@ void test_merge_trees_trivial__6_automerge(void) cl_assert(reuc = git_index_reuc_get_bypath(result, "removed-in-both.txt")); cl_assert(merge_trivial_conflict_entrycount(result) == 0); - + git_index_free(result); } @@ -207,7 +207,7 @@ void test_merge_trees_trivial__8(void) cl_assert(merge_trivial_conflict_entrycount(result) == 2); cl_assert(entry = git_index_get_bypath(result, "removed-in-8.txt", 1)); cl_assert(entry = git_index_get_bypath(result, "removed-in-8.txt", 3)); - + git_index_free(result); } @@ -226,7 +226,7 @@ void test_merge_trees_trivial__8_automerge(void) cl_assert(reuc = git_index_reuc_get_bypath(result, "removed-in-8.txt")); cl_assert(merge_trivial_conflict_entrycount(result) == 0); - + git_index_free(result); } @@ -244,7 +244,7 @@ void test_merge_trees_trivial__7(void) cl_assert(merge_trivial_conflict_entrycount(result) == 2); cl_assert(entry = git_index_get_bypath(result, "removed-in-7.txt", 1)); cl_assert(entry = git_index_get_bypath(result, "removed-in-7.txt", 3)); - + git_index_free(result); } @@ -262,7 +262,7 @@ void test_merge_trees_trivial__7_automerge(void) cl_assert(merge_trivial_conflict_entrycount(result) == 2); cl_assert(entry = git_index_get_bypath(result, "removed-in-7.txt", 1)); cl_assert(entry = git_index_get_bypath(result, "removed-in-7.txt", 3)); - + git_index_free(result); } @@ -280,7 +280,7 @@ void test_merge_trees_trivial__10(void) cl_assert(merge_trivial_conflict_entrycount(result) == 2); cl_assert(entry = git_index_get_bypath(result, "removed-in-10-branch.txt", 1)); cl_assert(entry = git_index_get_bypath(result, "removed-in-10-branch.txt", 2)); - + git_index_free(result); } @@ -299,7 +299,7 @@ void test_merge_trees_trivial__10_automerge(void) cl_assert(reuc = git_index_reuc_get_bypath(result, "removed-in-10-branch.txt")); cl_assert(merge_trivial_conflict_entrycount(result) == 0); - + git_index_free(result); } @@ -317,7 +317,7 @@ void test_merge_trees_trivial__9(void) cl_assert(merge_trivial_conflict_entrycount(result) == 2); cl_assert(entry = git_index_get_bypath(result, "removed-in-9-branch.txt", 1)); cl_assert(entry = git_index_get_bypath(result, "removed-in-9-branch.txt", 2)); - + git_index_free(result); } @@ -335,7 +335,7 @@ void test_merge_trees_trivial__9_automerge(void) cl_assert(merge_trivial_conflict_entrycount(result) == 2); cl_assert(entry = git_index_get_bypath(result, "removed-in-9-branch.txt", 1)); cl_assert(entry = git_index_get_bypath(result, "removed-in-9-branch.txt", 2)); - + git_index_free(result); } @@ -354,7 +354,7 @@ void test_merge_trees_trivial__13(void) cl_assert(git_index_reuc_entrycount(result) == 0); cl_assert(merge_trivial_conflict_entrycount(result) == 0); - + git_index_free(result); } @@ -373,7 +373,7 @@ void test_merge_trees_trivial__14(void) cl_assert(git_index_reuc_entrycount(result) == 0); cl_assert(merge_trivial_conflict_entrycount(result) == 0); - + git_index_free(result); } @@ -392,6 +392,6 @@ void test_merge_trees_trivial__11(void) cl_assert(entry = git_index_get_bypath(result, "modified-in-both.txt", 1)); cl_assert(entry = git_index_get_bypath(result, "modified-in-both.txt", 2)); cl_assert(entry = git_index_get_bypath(result, "modified-in-both.txt", 3)); - + git_index_free(result); } diff --git a/tests-clar/refs/branches/move.c b/tests-clar/refs/branches/move.c index 7267f941d..ecf14e006 100644 --- a/tests-clar/refs/branches/move.c +++ b/tests-clar/refs/branches/move.c @@ -24,7 +24,7 @@ void test_refs_branches_move__can_move_a_local_branch(void) cl_git_pass(git_branch_move(&new_ref, original_ref, NEW_BRANCH_NAME, 0)); cl_assert_equal_s(GIT_REFS_HEADS_DIR NEW_BRANCH_NAME, git_reference_name(new_ref)); - + git_reference_free(original_ref); git_reference_free(new_ref); } @@ -32,7 +32,7 @@ void test_refs_branches_move__can_move_a_local_branch(void) void test_refs_branches_move__can_move_a_local_branch_to_a_different_namespace(void) { git_reference *original_ref, *new_ref, *newer_ref; - + cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); /* Downward */ @@ -42,14 +42,14 @@ void test_refs_branches_move__can_move_a_local_branch_to_a_different_namespace(v /* Upward */ cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0)); git_reference_free(new_ref); - + git_reference_free(newer_ref); } void test_refs_branches_move__can_move_a_local_branch_to_a_partially_colliding_namespace(void) { git_reference *original_ref, *new_ref, *newer_ref; - + cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); /* Downward */ @@ -59,29 +59,29 @@ void test_refs_branches_move__can_move_a_local_branch_to_a_partially_colliding_n /* Upward */ cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0)); git_reference_free(new_ref); - + git_reference_free(newer_ref); } void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_collide_with_an_existing_one(void) { git_reference *original_ref, *new_ref; - + cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); cl_assert_equal_i(GIT_EEXISTS, git_branch_move(&new_ref, original_ref, "master", 0)); - + git_reference_free(original_ref); } void test_refs_branches_move__moving_a_branch_with_an_invalid_name_returns_EINVALIDSPEC(void) { git_reference *original_ref, *new_ref; - + cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); cl_assert_equal_i(GIT_EINVALIDSPEC, git_branch_move(&new_ref, original_ref, "Inv@{id", 0)); - + git_reference_free(original_ref); } @@ -98,11 +98,11 @@ void test_refs_branches_move__can_not_move_a_non_branch(void) void test_refs_branches_move__can_force_move_over_an_existing_branch(void) { git_reference *original_ref, *new_ref; - + cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); cl_git_pass(git_branch_move(&new_ref, original_ref, "master", 1)); - + git_reference_free(original_ref); git_reference_free(new_ref); } diff --git a/tests-clar/refs/ref_helpers.c b/tests-clar/refs/ref_helpers.c index 16ab9e6ef..7676e65a7 100644 --- a/tests-clar/refs/ref_helpers.c +++ b/tests-clar/refs/ref_helpers.c @@ -11,15 +11,15 @@ int reference_is_packed(git_reference *ref) int packed; assert(ref); - + if (git_buf_joinpath(&ref_path, git_repository_path(git_reference_owner(ref)), git_reference_name(ref)) < 0) return -1; packed = !git_path_isfile(ref_path.ptr); - + git_buf_free(&ref_path); - + return packed; } diff --git a/tests-clar/refs/revparse.c b/tests-clar/refs/revparse.c index 74472b175..43406e239 100644 --- a/tests-clar/refs/revparse.c +++ b/tests-clar/refs/revparse.c @@ -557,12 +557,12 @@ void test_refs_revparse__issue_994(void) /** * $ git rev-parse blah-7-gc47800c * c47800c7266a2be04c571c04d5a6614691ea99bd - * + * * $ git rev-parse HEAD~3 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 - * + * * $ git branch blah-7-gc47800c HEAD~3 - * + * * $ git rev-parse blah-7-gc47800c * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 */ @@ -592,15 +592,15 @@ void test_refs_revparse__try_to_retrieve_branch_before_described_tag(void) /** * $ git rev-parse a65fedf39aefe402d3bb6e24df4d4f5fe4547750 * a65fedf39aefe402d3bb6e24df4d4f5fe4547750 - * + * * $ git rev-parse HEAD~3 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 - * + * * $ git branch a65fedf39aefe402d3bb6e24df4d4f5fe4547750 HEAD~3 - * + * * $ git rev-parse a65fedf39aefe402d3bb6e24df4d4f5fe4547750 * a65fedf39aefe402d3bb6e24df4d4f5fe4547750 - * + * * $ git rev-parse heads/a65fedf39aefe402d3bb6e24df4d4f5fe4547750 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 */ @@ -631,12 +631,12 @@ void test_refs_revparse__try_to_retrieve_sha_before_branch(void) /** * $ git rev-parse c47800 * c47800c7266a2be04c571c04d5a6614691ea99bd - * + * * $ git rev-parse HEAD~3 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 - * + * * $ git branch c47800 HEAD~3 - * + * * $ git rev-parse c47800 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 */ @@ -694,4 +694,3 @@ void test_refs_revparse__parses_range_operator(void) "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_REVPARSE_RANGE | GIT_REVPARSE_MERGE_BASE); } - diff --git a/tests-clar/refs/setter.c b/tests-clar/refs/setter.c index 713af814f..6d875f9b6 100644 --- a/tests-clar/refs/setter.c +++ b/tests-clar/refs/setter.c @@ -25,7 +25,7 @@ void test_refs_setter__update_direct(void) { git_reference *ref, *test_ref, *new_ref; git_oid id; - + cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name)); cl_assert(git_reference_type(ref) == GIT_REF_OID); git_oid_cpy(&id, git_reference_target(ref)); @@ -48,7 +48,7 @@ void test_refs_setter__update_direct(void) void test_refs_setter__update_symbolic(void) { git_reference *head, *new_head; - + cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD")); cl_assert(git_reference_type(head) == GIT_REF_SYMBOLIC); cl_assert(strcmp(git_reference_symbolic_target(head), ref_master_name) == 0); @@ -56,7 +56,7 @@ void test_refs_setter__update_symbolic(void) cl_git_pass(git_reference_symbolic_set_target(&new_head, head, ref_test_name)); git_reference_free(new_head); git_reference_free(head); - + cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD")); cl_assert(git_reference_type(head) == GIT_REF_SYMBOLIC); cl_assert(strcmp(git_reference_symbolic_target(head), ref_test_name) == 0); @@ -68,13 +68,13 @@ void test_refs_setter__cant_update_direct_with_symbolic(void) // Overwrite an existing object id reference with a symbolic one git_reference *ref, *new; git_oid id; - + cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name)); cl_assert(git_reference_type(ref) == GIT_REF_OID); git_oid_cpy(&id, git_reference_target(ref)); - + cl_git_fail(git_reference_symbolic_set_target(&new, ref, ref_name)); - + git_reference_free(ref); } @@ -83,7 +83,7 @@ void test_refs_setter__cant_update_symbolic_with_direct(void) // Overwrite an existing symbolic reference with an object id one git_reference *ref, *new; git_oid id; - + cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name)); cl_assert(git_reference_type(ref) == GIT_REF_OID); git_oid_cpy(&id, git_reference_target(ref)); @@ -94,6 +94,6 @@ void test_refs_setter__cant_update_symbolic_with_direct(void) /* Can't set an OID on a direct ref */ cl_git_fail(git_reference_set_target(&new, ref, &id)); - + git_reference_free(ref); } diff --git a/tests-clar/reset/hard.c b/tests-clar/reset/hard.c index 62371f83f..1c0c84135 100644 --- a/tests-clar/reset/hard.c +++ b/tests-clar/reset/hard.c @@ -105,14 +105,14 @@ void test_reset_hard__cannot_reset_in_a_bare_repository(void) static void index_entry_init(git_index *index, int side, git_oid *oid) { git_index_entry entry; - + memset(&entry, 0x0, sizeof(git_index_entry)); - + entry.path = "conflicting_file"; entry.flags = (side << GIT_IDXENTRY_STAGESHIFT); entry.mode = 0100644; git_oid_cpy(&entry.oid, oid); - + cl_git_pass(git_index_add(index, &entry)); } @@ -122,19 +122,19 @@ static void unmerged_index_init(git_index *index, int entries) int write_ours = 2; int write_theirs = 4; git_oid ancestor, ours, theirs; - + git_oid_fromstr(&ancestor, "6bb0d9f700543ba3d318ba7075fc3bd696b4287b"); git_oid_fromstr(&ours, "b19a1e93bec1317dc6097229e12afaffbfa74dc2"); git_oid_fromstr(&theirs, "950b81b7eee953d050aa05a641f8e056c85dd1bd"); - + cl_git_rewritefile("status/conflicting_file", "conflicting file\n"); - + if (entries & write_ancestor) index_entry_init(index, 1, &ancestor); - + if (entries & write_ours) index_entry_init(index, 2, &ours); - + if (entries & write_theirs) index_entry_init(index, 3, &theirs); } @@ -143,24 +143,24 @@ void test_reset_hard__resetting_reverts_unmerged(void) { git_index *index; int entries; - + /* Ensure every permutation of non-zero stage entries results in the * path being cleaned up. */ for (entries = 1; entries < 8; entries++) { cl_git_pass(git_repository_index(&index, repo)); - + unmerged_index_init(index, entries); cl_git_pass(git_index_write(index)); - + retrieve_target_from_oid(&target, repo, "26a125ee1bfc5df1e1b2e9441bbe63c8a7ae989f"); cl_git_pass(git_reset(repo, target, GIT_RESET_HARD)); - + cl_assert(git_path_exists("status/conflicting_file") == 0); - + git_object_free(target); target = NULL; - - git_index_free(index); + + git_index_free(index); } } diff --git a/tests-clar/status/submodules.c b/tests-clar/status/submodules.c index 8365a7f5a..af8707721 100644 --- a/tests-clar/status/submodules.c +++ b/tests-clar/status/submodules.c @@ -219,4 +219,3 @@ void test_status_submodules__dirty_workdir_only(void) git_status_foreach_ext(g_repo, &opts, cb_status__match, &counts)); cl_assert_equal_i(6, counts.entry_count); } - diff --git a/tests-clar/trace/trace.c b/tests-clar/trace/trace.c index cc99cd187..87b325378 100644 --- a/tests-clar/trace/trace.c +++ b/tests-clar/trace/trace.c @@ -85,4 +85,3 @@ void test_trace_trace__writes_lower_level(void) cl_assert(written == 1); #endif } -