Commit 6957f73c by Vicent Martí

Merge pull request #1578 from nulltoken/fix/whitespaces

Fix trailing whitespaces
parents f0ab7372 1fed6b07
...@@ -117,4 +117,3 @@ int main (int argc, char **argv) ...@@ -117,4 +117,3 @@ int main (int argc, char **argv)
return 0; return 0;
} }
...@@ -33,7 +33,7 @@ typedef enum { ...@@ -33,7 +33,7 @@ typedef enum {
/** /**
* Automerge options for `git_merge_trees_opts`. * Automerge options for `git_merge_trees_opts`.
*/ */
typedef enum { typedef enum {
GIT_MERGE_AUTOMERGE_NORMAL = 0, GIT_MERGE_AUTOMERGE_NORMAL = 0,
GIT_MERGE_AUTOMERGE_NONE = 1, GIT_MERGE_AUTOMERGE_NONE = 1,
...@@ -45,10 +45,10 @@ typedef enum { ...@@ -45,10 +45,10 @@ typedef enum {
typedef struct { typedef struct {
unsigned int version; unsigned int version;
git_merge_tree_flags flags; git_merge_tree_flags flags;
/** Similarity to consider a file renamed (default 50) */ /** Similarity to consider a file renamed (default 50) */
unsigned int rename_threshold; unsigned int rename_threshold;
/** Maximum similarity sources to examine (overrides the /** Maximum similarity sources to examine (overrides the
* `merge.renameLimit` config) (default 200) * `merge.renameLimit` config) (default 200)
*/ */
...@@ -56,7 +56,7 @@ typedef struct { ...@@ -56,7 +56,7 @@ typedef struct {
/** Pluggable similarity metric; pass NULL to use internal metric */ /** Pluggable similarity metric; pass NULL to use internal metric */
git_diff_similarity_metric *metric; git_diff_similarity_metric *metric;
/** Flags for automerging content. */ /** Flags for automerging content. */
git_merge_automerge_flags automerge_flags; git_merge_automerge_flags automerge_flags;
} git_merge_tree_opts; } git_merge_tree_opts;
......
...@@ -96,12 +96,12 @@ GIT_EXTERN(int) git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid * ...@@ -96,12 +96,12 @@ GIT_EXTERN(int) git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *
/** /**
* Insert a commit object * Insert a commit object
* *
* This will add a commit as well as the completed referenced tree. * This will add a commit as well as the completed referenced tree.
* *
* @param pb The packbuilder * @param pb The packbuilder
* @param id The oid of the commit * @param id The oid of the commit
* *
* @return 0 or an error code * @return 0 or an error code
*/ */
GIT_EXTERN(int) git_packbuilder_insert_commit(git_packbuilder *pb, const git_oid *id); GIT_EXTERN(int) git_packbuilder_insert_commit(git_packbuilder *pb, const git_oid *id);
......
...@@ -177,4 +177,3 @@ GIT_EXTERN(void) git_index_reuc_clear(git_index *index); ...@@ -177,4 +177,3 @@ GIT_EXTERN(void) git_index_reuc_clear(git_index *index);
/** @} */ /** @} */
GIT_END_DECL GIT_END_DECL
#endif #endif
...@@ -32,7 +32,7 @@ typedef enum { ...@@ -32,7 +32,7 @@ typedef enum {
/** Errors that do not impact the program's execution */ /** Errors that do not impact the program's execution */
GIT_TRACE_ERROR = 2, GIT_TRACE_ERROR = 2,
/** Warnings that suggest abnormal data */ /** Warnings that suggest abnormal data */
GIT_TRACE_WARN = 3, GIT_TRACE_WARN = 3,
...@@ -65,4 +65,3 @@ GIT_EXTERN(int) git_trace_set(git_trace_level_t level, git_trace_callback cb); ...@@ -65,4 +65,3 @@ GIT_EXTERN(int) git_trace_set(git_trace_level_t level, git_trace_callback cb);
/** @} */ /** @} */
GIT_END_DECL GIT_END_DECL
#endif #endif
...@@ -771,7 +771,7 @@ static int blob_content_to_link( ...@@ -771,7 +771,7 @@ static int blob_content_to_link(
if ((error = git_futils_mkpath2file(path, dir_mode)) < 0) if ((error = git_futils_mkpath2file(path, dir_mode)) < 0)
return error; return error;
if ((error = git_blob__getbuf(&linktarget, blob)) < 0) if ((error = git_blob__getbuf(&linktarget, blob)) < 0)
return error; return error;
......
...@@ -274,7 +274,7 @@ static int update_head_to_branch( ...@@ -274,7 +274,7 @@ static int update_head_to_branch(
int retcode; int retcode;
git_buf remote_branch_name = GIT_BUF_INIT; git_buf remote_branch_name = GIT_BUF_INIT;
git_reference* remote_ref = NULL; git_reference* remote_ref = NULL;
assert(options->checkout_branch); assert(options->checkout_branch);
if ((retcode = git_buf_printf(&remote_branch_name, GIT_REFS_REMOTES_DIR "%s/%s", if ((retcode = git_buf_printf(&remote_branch_name, GIT_REFS_REMOTES_DIR "%s/%s",
......
...@@ -178,7 +178,7 @@ int git_diff_find_similar__hashsig_for_file( ...@@ -178,7 +178,7 @@ int git_diff_find_similar__hashsig_for_file(
GIT_UNUSED(f); GIT_UNUSED(f);
error = git_hashsig_create_fromfile((git_hashsig **)out, path, opt); error = git_hashsig_create_fromfile((git_hashsig **)out, path, opt);
if (error == GIT_EBUFS) { if (error == GIT_EBUFS) {
error = 0; error = 0;
giterr_clear(); giterr_clear();
...@@ -195,7 +195,7 @@ int git_diff_find_similar__hashsig_for_buf( ...@@ -195,7 +195,7 @@ int git_diff_find_similar__hashsig_for_buf(
GIT_UNUSED(f); GIT_UNUSED(f);
error = git_hashsig_create((git_hashsig **)out, buf, len, opt); error = git_hashsig_create((git_hashsig **)out, buf, len, opt);
if (error == GIT_EBUFS) { if (error == GIT_EBUFS) {
error = 0; error = 0;
giterr_clear(); giterr_clear();
...@@ -437,7 +437,7 @@ static int similarity_measure( ...@@ -437,7 +437,7 @@ static int similarity_measure(
return -1; return -1;
if (!cache[b_idx] && similarity_calc(diff, opts, b_idx, cache) < 0) if (!cache[b_idx] && similarity_calc(diff, opts, b_idx, cache) < 0)
return -1; return -1;
/* some metrics may not wish to process this file (too big / too small) */ /* some metrics may not wish to process this file (too big / too small) */
if (!cache[a_idx] || !cache[b_idx]) if (!cache[a_idx] || !cache[b_idx])
return 0; return 0;
......
...@@ -365,4 +365,3 @@ int git_hashsig_compare(const git_hashsig *a, const git_hashsig *b) ...@@ -365,4 +365,3 @@ int git_hashsig_compare(const git_hashsig *a, const git_hashsig *b)
return (hashsig_heap_compare(&a->mins, &b->mins) + return (hashsig_heap_compare(&a->mins, &b->mins) +
hashsig_heap_compare(&a->maxs, &b->maxs)) / 2; hashsig_heap_compare(&a->maxs, &b->maxs)) / 2;
} }
...@@ -381,7 +381,7 @@ void git_index_clear(git_index *index) ...@@ -381,7 +381,7 @@ void git_index_clear(git_index *index)
git_index_reuc_clear(index); git_index_reuc_clear(index);
git_index_name_clear(index); git_index_name_clear(index);
git_futils_filestamp_set(&index->stamp, NULL); git_futils_filestamp_set(&index->stamp, NULL);
git_tree_cache_free(index->tree); git_tree_cache_free(index->tree);
...@@ -1108,7 +1108,7 @@ const git_index_name_entry *git_index_name_get_byindex( ...@@ -1108,7 +1108,7 @@ const git_index_name_entry *git_index_name_get_byindex(
git_index *index, size_t n) git_index *index, size_t n)
{ {
assert(index); assert(index);
git_vector_sort(&index->names); git_vector_sort(&index->names);
return git_vector_get(&index->names, n); return git_vector_get(&index->names, n);
} }
...@@ -1122,7 +1122,7 @@ int git_index_name_add(git_index *index, ...@@ -1122,7 +1122,7 @@ int git_index_name_add(git_index *index,
conflict_name = git__calloc(1, sizeof(git_index_name_entry)); conflict_name = git__calloc(1, sizeof(git_index_name_entry));
GITERR_CHECK_ALLOC(conflict_name); GITERR_CHECK_ALLOC(conflict_name);
if (ancestor) { if (ancestor) {
conflict_name->ancestor = git__strdup(ancestor); conflict_name->ancestor = git__strdup(ancestor);
GITERR_CHECK_ALLOC(conflict_name->ancestor); GITERR_CHECK_ALLOC(conflict_name->ancestor);
...@@ -1137,7 +1137,7 @@ int git_index_name_add(git_index *index, ...@@ -1137,7 +1137,7 @@ int git_index_name_add(git_index *index,
conflict_name->theirs = git__strdup(theirs); conflict_name->theirs = git__strdup(theirs);
GITERR_CHECK_ALLOC(conflict_name->theirs); GITERR_CHECK_ALLOC(conflict_name->theirs);
} }
return git_vector_insert(&index->names, conflict_name); return git_vector_insert(&index->names, conflict_name);
} }
...@@ -1147,7 +1147,7 @@ void git_index_name_clear(git_index *index) ...@@ -1147,7 +1147,7 @@ void git_index_name_clear(git_index *index)
git_index_name_entry *conflict_name; git_index_name_entry *conflict_name;
assert(index); assert(index);
git_vector_foreach(&index->names, i, conflict_name) { git_vector_foreach(&index->names, i, conflict_name) {
if (conflict_name->ancestor) if (conflict_name->ancestor)
git__free(conflict_name->ancestor); git__free(conflict_name->ancestor);
...@@ -1160,7 +1160,7 @@ void git_index_name_clear(git_index *index) ...@@ -1160,7 +1160,7 @@ void git_index_name_clear(git_index *index)
git__free(conflict_name); git__free(conflict_name);
} }
git_vector_clear(&index->names); git_vector_clear(&index->names);
} }
...@@ -1354,7 +1354,7 @@ static int read_reuc(git_index *index, const char *buffer, size_t size) ...@@ -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) static int read_conflict_names(git_index *index, const char *buffer, size_t size)
{ {
size_t len; size_t len;
/* This gets called multiple times, the vector might already be initialized */ /* This gets called multiple times, the vector might already be initialized */
if (index->names._alloc_size == 0 && if (index->names._alloc_size == 0 &&
git_vector_init(&index->names, 16, conflict_name_cmp) < 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 ...@@ -1375,7 +1375,7 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size
\ \
buffer += len; \ buffer += len; \
size -= len; size -= len;
while (size) { while (size) {
git_index_name_entry *conflict_name = git__calloc(1, sizeof(git_index_name_entry)); git_index_name_entry *conflict_name = git__calloc(1, sizeof(git_index_name_entry));
GITERR_CHECK_ALLOC(conflict_name); GITERR_CHECK_ALLOC(conflict_name);
...@@ -1383,17 +1383,17 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size ...@@ -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->ancestor);
read_conflict_name(conflict_name->ours); read_conflict_name(conflict_name->ours);
read_conflict_name(conflict_name->theirs); read_conflict_name(conflict_name->theirs);
if (git_vector_insert(&index->names, conflict_name) < 0) if (git_vector_insert(&index->names, conflict_name) < 0)
return -1; return -1;
} }
#undef read_conflict_name #undef read_conflict_name
/* entries are guaranteed to be sorted on-disk */ /* entries are guaranteed to be sorted on-disk */
index->names.sorted = 1; index->names.sorted = 1;
return 0; return 0;
} }
static size_t read_entry(git_index_entry *dest, const void *buffer, size_t buffer_size) 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 ...@@ -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); error = git_buf_put(name_buf, "\0", 1);
else else
error = git_buf_put(name_buf, conflict_name->ancestor, strlen(conflict_name->ancestor) + 1); error = git_buf_put(name_buf, conflict_name->ancestor, strlen(conflict_name->ancestor) + 1);
if (error != 0) if (error != 0)
goto on_error; goto on_error;
...@@ -1753,20 +1753,20 @@ static int write_name_extension(git_index *index, git_filebuf *file) ...@@ -1753,20 +1753,20 @@ static int write_name_extension(git_index *index, git_filebuf *file)
struct index_extension extension; struct index_extension extension;
size_t i; size_t i;
int error = 0; int error = 0;
git_vector_foreach(out, i, conflict_name) { git_vector_foreach(out, i, conflict_name) {
if ((error = create_name_extension_data(&name_buf, conflict_name)) < 0) if ((error = create_name_extension_data(&name_buf, conflict_name)) < 0)
goto done; goto done;
} }
memset(&extension, 0x0, sizeof(struct index_extension)); memset(&extension, 0x0, sizeof(struct index_extension));
memcpy(&extension.signature, INDEX_EXT_CONFLICT_NAME_SIG, 4); memcpy(&extension.signature, INDEX_EXT_CONFLICT_NAME_SIG, 4);
extension.extension_size = (uint32_t)name_buf.size; extension.extension_size = (uint32_t)name_buf.size;
error = write_extension(file, &extension, &name_buf); error = write_extension(file, &extension, &name_buf);
git_buf_free(&name_buf); git_buf_free(&name_buf);
done: done:
return error; return error;
} }
...@@ -1844,7 +1844,7 @@ static int write_index(git_index *index, git_filebuf *file) ...@@ -1844,7 +1844,7 @@ static int write_index(git_index *index, git_filebuf *file)
/* write the rename conflict extension */ /* write the rename conflict extension */
if (index->names.length > 0 && write_name_extension(index, file) < 0) if (index->names.length > 0 && write_name_extension(index, file) < 0)
return -1; return -1;
/* write the reuc extension */ /* write the reuc extension */
if (index->reuc.length > 0 && write_reuc_extension(index, file) < 0) if (index->reuc.length > 0 && write_reuc_extension(index, file) < 0)
return -1; return -1;
......
...@@ -24,46 +24,46 @@ ...@@ -24,46 +24,46 @@
typedef enum { typedef enum {
/* No conflict - a change only occurs in one branch. */ /* No conflict - a change only occurs in one branch. */
GIT_MERGE_DIFF_NONE = 0, GIT_MERGE_DIFF_NONE = 0,
/* Occurs when a file is modified in both branches. */ /* Occurs when a file is modified in both branches. */
GIT_MERGE_DIFF_BOTH_MODIFIED = (1 << 0), GIT_MERGE_DIFF_BOTH_MODIFIED = (1 << 0),
/* Occurs when a file is added in both branches. */ /* Occurs when a file is added in both branches. */
GIT_MERGE_DIFF_BOTH_ADDED = (1 << 1), GIT_MERGE_DIFF_BOTH_ADDED = (1 << 1),
/* Occurs when a file is deleted in both branches. */ /* Occurs when a file is deleted in both branches. */
GIT_MERGE_DIFF_BOTH_DELETED = (1 << 2), GIT_MERGE_DIFF_BOTH_DELETED = (1 << 2),
/* Occurs when a file is modified in one branch and deleted in the other. */ /* Occurs when a file is modified in one branch and deleted in the other. */
GIT_MERGE_DIFF_MODIFIED_DELETED = (1 << 3), GIT_MERGE_DIFF_MODIFIED_DELETED = (1 << 3),
/* Occurs when a file is renamed in one branch and modified in the other. */ /* Occurs when a file is renamed in one branch and modified in the other. */
GIT_MERGE_DIFF_RENAMED_MODIFIED = (1 << 4), GIT_MERGE_DIFF_RENAMED_MODIFIED = (1 << 4),
/* Occurs when a file is renamed in one branch and deleted in the other. */ /* Occurs when a file is renamed in one branch and deleted in the other. */
GIT_MERGE_DIFF_RENAMED_DELETED = (1 << 5), GIT_MERGE_DIFF_RENAMED_DELETED = (1 << 5),
/* Occurs when a file is renamed in one branch and a file with the same /* 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 * name is added in the other. Eg, A->B and new file B. Core git calls
* this a "rename/delete". */ * this a "rename/delete". */
GIT_MERGE_DIFF_RENAMED_ADDED = (1 << 6), GIT_MERGE_DIFF_RENAMED_ADDED = (1 << 6),
/* Occurs when both a file is renamed to the same name in the ours and /* 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. */ * theirs branches. Eg, A->B and A->B in both. Automergeable. */
GIT_MERGE_DIFF_BOTH_RENAMED = (1 << 7), GIT_MERGE_DIFF_BOTH_RENAMED = (1 << 7),
/* Occurs when a file is renamed to different names in the ours and theirs /* Occurs when a file is renamed to different names in the ours and theirs
* branches. Eg, A->B and A->C. */ * branches. Eg, A->B and A->C. */
GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2 = (1 << 8), GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2 = (1 << 8),
/* Occurs when two files are renamed to the same name in the ours and /* Occurs when two files are renamed to the same name in the ours and
* theirs branches. Eg, A->C and B->C. */ * theirs branches. Eg, A->C and B->C. */
GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1 = (1 << 9), 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 /* 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. */ * item at the same path in a different branch is a file. */
GIT_MERGE_DIFF_DIRECTORY_FILE = (1 << 10), GIT_MERGE_DIFF_DIRECTORY_FILE = (1 << 10),
/* The child of a folder that is in a directory/file conflict. */ /* The child of a folder that is in a directory/file conflict. */
GIT_MERGE_DIFF_DF_CHILD = (1 << 11), GIT_MERGE_DIFF_DF_CHILD = (1 << 11),
} git_merge_diff_type_t; } git_merge_diff_type_t;
...@@ -72,20 +72,20 @@ typedef enum { ...@@ -72,20 +72,20 @@ typedef enum {
typedef struct { typedef struct {
git_repository *repo; git_repository *repo;
git_pool pool; git_pool pool;
/* Vector of git_index_entry that represent the merged items that /* Vector of git_index_entry that represent the merged items that
* have been staged, either because only one side changed, or because * have been staged, either because only one side changed, or because
* the two changes were non-conflicting and mergeable. These items * the two changes were non-conflicting and mergeable. These items
* will be written as staged entries in the main index. * will be written as staged entries in the main index.
*/ */
git_vector staged; git_vector staged;
/* Vector of git_merge_diff entries that represent the conflicts that /* Vector of git_merge_diff entries that represent the conflicts that
* have not been automerged. These items will be written to high-stage * have not been automerged. These items will be written to high-stage
* entries in the main index. * entries in the main index.
*/ */
git_vector conflicts; git_vector conflicts;
/* Vector of git_merge_diff that have been automerged. These items /* Vector of git_merge_diff that have been automerged. These items
* will be written to the REUC when the index is produced. * will be written to the REUC when the index is produced.
*/ */
...@@ -97,12 +97,12 @@ typedef struct { ...@@ -97,12 +97,12 @@ typedef struct {
*/ */
typedef struct { typedef struct {
git_merge_diff_type_t type; git_merge_diff_type_t type;
git_index_entry ancestor_entry; git_index_entry ancestor_entry;
git_index_entry our_entry; git_index_entry our_entry;
git_delta_t our_status; git_delta_t our_status;
git_index_entry their_entry; git_index_entry their_entry;
git_delta_t their_status; git_delta_t their_status;
} git_merge_diff; } git_merge_diff;
......
...@@ -28,12 +28,12 @@ GIT_INLINE(const char *) merge_file_best_path( ...@@ -28,12 +28,12 @@ GIT_INLINE(const char *) merge_file_best_path(
return NULL; return NULL;
} }
if (strcmp(ancestor->path, ours->path) == 0) if (strcmp(ancestor->path, ours->path) == 0)
return theirs->path; return theirs->path;
else if(strcmp(ancestor->path, theirs->path) == 0) else if(strcmp(ancestor->path, theirs->path) == 0)
return ours->path; return ours->path;
return NULL; return NULL;
} }
...@@ -51,15 +51,15 @@ GIT_INLINE(int) merge_file_best_mode( ...@@ -51,15 +51,15 @@ GIT_INLINE(int) merge_file_best_mode(
if (ours->mode == GIT_FILEMODE_BLOB_EXECUTABLE || if (ours->mode == GIT_FILEMODE_BLOB_EXECUTABLE ||
theirs->mode == GIT_FILEMODE_BLOB_EXECUTABLE) theirs->mode == GIT_FILEMODE_BLOB_EXECUTABLE)
return GIT_FILEMODE_BLOB_EXECUTABLE; return GIT_FILEMODE_BLOB_EXECUTABLE;
return GIT_FILEMODE_BLOB; return GIT_FILEMODE_BLOB;
} }
if (ancestor->mode == ours->mode) if (ancestor->mode == ours->mode)
return theirs->mode; return theirs->mode;
else if(ancestor->mode == theirs->mode) else if(ancestor->mode == theirs->mode)
return ours->mode; return ours->mode;
return 0; return 0;
} }
...@@ -70,27 +70,27 @@ int git_merge_file_input_from_index_entry( ...@@ -70,27 +70,27 @@ int git_merge_file_input_from_index_entry(
{ {
git_odb *odb = NULL; git_odb *odb = NULL;
int error = 0; int error = 0;
assert(input && repo && entry); assert(input && repo && entry);
if (entry->mode == 0) if (entry->mode == 0)
return 0; return 0;
if ((error = git_repository_odb(&odb, repo)) < 0 || if ((error = git_repository_odb(&odb, repo)) < 0 ||
(error = git_odb_read(&input->odb_object, odb, &entry->oid)) < 0) (error = git_odb_read(&input->odb_object, odb, &entry->oid)) < 0)
goto done; goto done;
input->mode = entry->mode; input->mode = entry->mode;
input->path = git__strdup(entry->path); input->path = git__strdup(entry->path);
input->mmfile.size = git_odb_object_size(input->odb_object); input->mmfile.size = git_odb_object_size(input->odb_object);
input->mmfile.ptr = (char *)git_odb_object_data(input->odb_object); input->mmfile.ptr = (char *)git_odb_object_data(input->odb_object);
if (input->label == NULL) if (input->label == NULL)
input->label = entry->path; input->label = entry->path;
done: done:
git_odb_free(odb); git_odb_free(odb);
return error; return error;
} }
...@@ -101,27 +101,27 @@ int git_merge_file_input_from_diff_file( ...@@ -101,27 +101,27 @@ int git_merge_file_input_from_diff_file(
{ {
git_odb *odb = NULL; git_odb *odb = NULL;
int error = 0; int error = 0;
assert(input && repo && file); assert(input && repo && file);
if (file->mode == 0) if (file->mode == 0)
return 0; return 0;
if ((error = git_repository_odb(&odb, repo)) < 0 || if ((error = git_repository_odb(&odb, repo)) < 0 ||
(error = git_odb_read(&input->odb_object, odb, &file->oid)) < 0) (error = git_odb_read(&input->odb_object, odb, &file->oid)) < 0)
goto done; goto done;
input->mode = file->mode; input->mode = file->mode;
input->path = git__strdup(file->path); input->path = git__strdup(file->path);
input->mmfile.size = git_odb_object_size(input->odb_object); input->mmfile.size = git_odb_object_size(input->odb_object);
input->mmfile.ptr = (char *)git_odb_object_data(input->odb_object); input->mmfile.ptr = (char *)git_odb_object_data(input->odb_object);
if (input->label == NULL) if (input->label == NULL)
input->label = file->path; input->label = file->path;
done: done:
git_odb_free(odb); git_odb_free(odb);
return error; return error;
} }
...@@ -138,12 +138,12 @@ int git_merge_files( ...@@ -138,12 +138,12 @@ int git_merge_files(
int error = 0; int error = 0;
assert(out && ancestor && ours && theirs); assert(out && ancestor && ours && theirs);
memset(out, 0x0, sizeof(git_merge_file_result)); memset(out, 0x0, sizeof(git_merge_file_result));
if (!GIT_MERGE_FILE_SIDE_EXISTS(ours) || !GIT_MERGE_FILE_SIDE_EXISTS(theirs)) if (!GIT_MERGE_FILE_SIDE_EXISTS(ours) || !GIT_MERGE_FILE_SIDE_EXISTS(theirs))
return 0; return 0;
memset(&xmparam, 0x0, sizeof(xmparam_t)); memset(&xmparam, 0x0, sizeof(xmparam_t));
xmparam.ancestor = ancestor->label; xmparam.ancestor = ancestor->label;
xmparam.file1 = ours->label; xmparam.file1 = ours->label;
...@@ -154,7 +154,7 @@ int git_merge_files( ...@@ -154,7 +154,7 @@ int git_merge_files(
if (flags == GIT_MERGE_AUTOMERGE_FAVOR_OURS) if (flags == GIT_MERGE_AUTOMERGE_FAVOR_OURS)
xmparam.favor = XDL_MERGE_FAVOR_OURS; xmparam.favor = XDL_MERGE_FAVOR_OURS;
if (flags == GIT_MERGE_AUTOMERGE_FAVOR_THEIRS) if (flags == GIT_MERGE_AUTOMERGE_FAVOR_THEIRS)
xmparam.favor = XDL_MERGE_FAVOR_THEIRS; xmparam.favor = XDL_MERGE_FAVOR_THEIRS;
...@@ -164,7 +164,7 @@ int git_merge_files( ...@@ -164,7 +164,7 @@ int git_merge_files(
error = -1; error = -1;
goto done; goto done;
} }
out->automergeable = (xdl_result == 0); out->automergeable = (xdl_result == 0);
out->data = (unsigned char *)mmbuffer.ptr; out->data = (unsigned char *)mmbuffer.ptr;
out->len = mmbuffer.size; out->len = mmbuffer.size;
...@@ -172,4 +172,3 @@ int git_merge_files( ...@@ -172,4 +172,3 @@ int git_merge_files(
done: done:
return error; return error;
} }
...@@ -16,7 +16,7 @@ typedef struct { ...@@ -16,7 +16,7 @@ typedef struct {
char *path; char *path;
unsigned int mode; unsigned int mode;
mmfile_t mmfile; mmfile_t mmfile;
git_odb_object *odb_object; git_odb_object *odb_object;
} git_merge_file_input; } git_merge_file_input;
...@@ -24,10 +24,10 @@ typedef struct { ...@@ -24,10 +24,10 @@ typedef struct {
typedef struct { typedef struct {
bool automergeable; bool automergeable;
const char *path; const char *path;
int mode; int mode;
unsigned char *data; unsigned char *data;
size_t len; size_t len;
} git_merge_file_result; } git_merge_file_result;
......
...@@ -141,7 +141,7 @@ bool git_pathspec_match_path( ...@@ -141,7 +141,7 @@ bool git_pathspec_match_path(
git_vector_foreach(vspec, i, match) { git_vector_foreach(vspec, i, match) {
int result = (match->flags & GIT_ATTR_FNMATCH_MATCH_ALL) ? 0 : FNM_NOMATCH; int result = (match->flags & GIT_ATTR_FNMATCH_MATCH_ALL) ? 0 : FNM_NOMATCH;
if (result == FNM_NOMATCH) if (result == FNM_NOMATCH)
result = use_strcmp(match->pattern, path) ? FNM_NOMATCH : 0; result = use_strcmp(match->pattern, path) ? FNM_NOMATCH : 0;
......
...@@ -217,7 +217,7 @@ static int packed_load(refdb_fs_backend *backend) ...@@ -217,7 +217,7 @@ static int packed_load(refdb_fs_backend *backend)
backend->peeling_mode = PEELING_NONE; backend->peeling_mode = PEELING_NONE;
if (buffer_start[0] == '#') { 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) { if (git__prefixcmp(buffer_start, traits_header) == 0) {
char *traits = (char *)buffer_start + strlen(traits_header); char *traits = (char *)buffer_start + strlen(traits_header);
...@@ -1060,7 +1060,7 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend) ...@@ -1060,7 +1060,7 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
static int setup_namespace(git_buf *path, git_repository *repo) static int setup_namespace(git_buf *path, git_repository *repo)
{ {
char *parts, *start, *end; char *parts, *start, *end;
/* Not all repositories have a path */ /* Not all repositories have a path */
if (repo->path_repository == NULL) if (repo->path_repository == NULL)
...@@ -1091,7 +1091,7 @@ static int setup_namespace(git_buf *path, git_repository *repo) ...@@ -1091,7 +1091,7 @@ static int setup_namespace(git_buf *path, git_repository *repo)
free(parts); free(parts);
/* Make sure that the folder with the namespace exists */ /* 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 -1;
/* Return the root of the namespaced path, i.e. without the trailing '/refs' */ /* Return the root of the namespaced path, i.e. without the trailing '/refs' */
......
...@@ -32,7 +32,7 @@ int git_reset_default( ...@@ -32,7 +32,7 @@ int git_reset_default(
int error; int error;
git_index *index = NULL; git_index *index = NULL;
assert(pathspecs != NULL && pathspecs->count > 0); assert(pathspecs != NULL && pathspecs->count > 0);
memset(&entry, 0, sizeof(git_index_entry)); memset(&entry, 0, sizeof(git_index_entry));
......
...@@ -855,4 +855,3 @@ int git_revparse( ...@@ -855,4 +855,3 @@ int git_revparse(
return error; return error;
} }
...@@ -173,7 +173,7 @@ int git_signature__parse(git_signature *sig, const char **buffer_out, ...@@ -173,7 +173,7 @@ int git_signature__parse(git_signature *sig, const char **buffer_out,
tz_start = time_end + 1; 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) git__strtol32(&offset, tz_start + 1, &tz_end, 10) < 0)
return signature_error("malformed timezone"); return signature_error("malformed timezone");
......
...@@ -25,7 +25,7 @@ int git_trace_set(git_trace_level_t level, git_trace_callback callback) ...@@ -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.level = level;
git_trace__data.callback = callback; git_trace__data.callback = callback;
GIT_MEMORY_BARRIER; GIT_MEMORY_BARRIER;
return 0; return 0;
#else #else
GIT_UNUSED(level); GIT_UNUSED(level);
...@@ -36,4 +36,3 @@ int git_trace_set(git_trace_level_t level, git_trace_callback callback) ...@@ -36,4 +36,3 @@ int git_trace_set(git_trace_level_t level, git_trace_callback callback)
return -1; return -1;
#endif #endif
} }
...@@ -25,14 +25,14 @@ GIT_INLINE(void) git_trace__write_fmt( ...@@ -25,14 +25,14 @@ GIT_INLINE(void) git_trace__write_fmt(
git_trace_level_t level, git_trace_level_t level,
const char *fmt, ...) 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; git_buf message = GIT_BUF_INIT;
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
git_buf_vprintf(&message, fmt, ap); git_buf_vprintf(&message, fmt, ap);
va_end(ap); va_end(ap);
callback(level, git_buf_cstr(&message)); callback(level, git_buf_cstr(&message));
git_buf_free(&message); git_buf_free(&message);
......
...@@ -348,7 +348,7 @@ static int local_push( ...@@ -348,7 +348,7 @@ static int local_push(
if ((error = git_repository_open(&remote_repo, push->remote->url)) < 0) if ((error = git_repository_open(&remote_repo, push->remote->url)) < 0)
return error; 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 non-bare repo push support would require checking configs to see if
we should override the default 'don't let this happen' behavior */ we should override the default 'don't let this happen' behavior */
if (!remote_repo->is_bare) { if (!remote_repo->is_bare) {
......
...@@ -235,4 +235,3 @@ int git_win32__find_xdg_dirs(git_buf *out) ...@@ -235,4 +235,3 @@ int git_win32__find_xdg_dirs(git_buf *out)
return win32_find_existing_dirs(out, global_tmpls, temp); return win32_find_existing_dirs(out, global_tmpls, temp);
} }
...@@ -535,7 +535,7 @@ int p_gettimeofday(struct timeval *tv, struct timezone *tz) ...@@ -535,7 +535,7 @@ int p_gettimeofday(struct timeval *tv, struct timezone *tz)
/*converting file time to unix epoch*/ /*converting file time to unix epoch*/
tmpres /= 10; /*convert into microseconds*/ tmpres /= 10; /*convert into microseconds*/
tmpres -= DELTA_EPOCH_IN_MICROSECS; tmpres -= DELTA_EPOCH_IN_MICROSECS;
tv->tv_sec = (long)(tmpres / 1000000UL); tv->tv_sec = (long)(tmpres / 1000000UL);
tv->tv_usec = (long)(tmpres % 1000000UL); tv->tv_usec = (long)(tmpres % 1000000UL);
} }
......
...@@ -363,7 +363,7 @@ void assert_conflict( ...@@ -363,7 +363,7 @@ void assert_conflict(
git_index *index; git_index *index;
git_object *hack_tree; git_object *hack_tree;
git_reference *branch, *head; 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)); cl_git_pass(git_repository_index(&index, g_repo));
......
...@@ -48,13 +48,13 @@ void test_clone_empty__can_clone_an_empty_local_repo_barely(void) ...@@ -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)); 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 */ /* ...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)); git_branch_upstream_name(buffer, 1024, g_repo_cloned, local_name));
cl_assert_equal_s(expected_tracked_branch_name, buffer); cl_assert_equal_s(expected_tracked_branch_name, buffer);
/* ...and the name of the remote... */ /* ...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)); git_branch_remote_name(buffer, 1024, g_repo_cloned, expected_tracked_branch_name));
cl_assert_equal_s(expected_remote_name, buffer); cl_assert_equal_s(expected_remote_name, buffer);
......
...@@ -115,7 +115,7 @@ void test_commit_write__root(void) ...@@ -115,7 +115,7 @@ void test_commit_write__root(void)
head_old = git__strdup(git_reference_symbolic_target(head)); head_old = git__strdup(git_reference_symbolic_target(head));
cl_assert(head_old != NULL); cl_assert(head_old != NULL);
git_reference_free(head); git_reference_free(head);
cl_git_pass(git_reference_symbolic_create(&head, g_repo, "HEAD", branch_name, 1)); cl_git_pass(git_reference_symbolic_create(&head, g_repo, "HEAD", branch_name, 1));
cl_git_pass(git_commit_create_v( cl_git_pass(git_commit_create_v(
......
...@@ -21,7 +21,7 @@ void test_index_names__cleanup(void) ...@@ -21,7 +21,7 @@ void test_index_names__cleanup(void)
{ {
git_index_free(repo_index); git_index_free(repo_index);
repo_index = NULL; repo_index = NULL;
cl_git_sandbox_cleanup(); cl_git_sandbox_cleanup();
} }
...@@ -32,14 +32,14 @@ void test_index_names__add(void) ...@@ -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, "ancestor", "ours", "theirs"));
cl_git_pass(git_index_name_add(repo_index, "ancestor2", "ours2", NULL)); 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_name_add(repo_index, "ancestor3", NULL, "theirs3"));
cl_assert(git_index_name_entrycount(repo_index) == 3); cl_assert(git_index_name_entrycount(repo_index) == 3);
conflict_name = git_index_name_get_byindex(repo_index, 0); conflict_name = git_index_name_get_byindex(repo_index, 0);
cl_assert(strcmp(conflict_name->ancestor, "ancestor") == 0); cl_assert(strcmp(conflict_name->ancestor, "ancestor") == 0);
cl_assert(strcmp(conflict_name->ours, "ours") == 0); cl_assert(strcmp(conflict_name->ours, "ours") == 0);
cl_assert(strcmp(conflict_name->theirs, "theirs") == 0); cl_assert(strcmp(conflict_name->theirs, "theirs") == 0);
conflict_name = git_index_name_get_byindex(repo_index, 1); conflict_name = git_index_name_get_byindex(repo_index, 1);
cl_assert(strcmp(conflict_name->ancestor, "ancestor2") == 0); cl_assert(strcmp(conflict_name->ancestor, "ancestor2") == 0);
cl_assert(strcmp(conflict_name->ours, "ours2") == 0); cl_assert(strcmp(conflict_name->ours, "ours2") == 0);
...@@ -54,31 +54,31 @@ void test_index_names__add(void) ...@@ -54,31 +54,31 @@ void test_index_names__add(void)
void test_index_names__roundtrip(void) void test_index_names__roundtrip(void)
{ {
const git_index_name_entry *conflict_name; 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, "ancestor", "ours", "theirs"));
cl_git_pass(git_index_name_add(repo_index, "ancestor2", "ours2", NULL)); 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_name_add(repo_index, "ancestor3", NULL, "theirs3"));
cl_git_pass(git_index_write(repo_index)); cl_git_pass(git_index_write(repo_index));
git_index_clear(repo_index); git_index_clear(repo_index);
cl_assert(git_index_name_entrycount(repo_index) == 0); cl_assert(git_index_name_entrycount(repo_index) == 0);
cl_git_pass(git_index_read(repo_index)); cl_git_pass(git_index_read(repo_index));
cl_assert(git_index_name_entrycount(repo_index) == 3); cl_assert(git_index_name_entrycount(repo_index) == 3);
conflict_name = git_index_name_get_byindex(repo_index, 0); conflict_name = git_index_name_get_byindex(repo_index, 0);
cl_assert(strcmp(conflict_name->ancestor, "ancestor") == 0); cl_assert(strcmp(conflict_name->ancestor, "ancestor") == 0);
cl_assert(strcmp(conflict_name->ours, "ours") == 0); cl_assert(strcmp(conflict_name->ours, "ours") == 0);
cl_assert(strcmp(conflict_name->theirs, "theirs") == 0); cl_assert(strcmp(conflict_name->theirs, "theirs") == 0);
conflict_name = git_index_name_get_byindex(repo_index, 1); conflict_name = git_index_name_get_byindex(repo_index, 1);
cl_assert(strcmp(conflict_name->ancestor, "ancestor2") == 0); cl_assert(strcmp(conflict_name->ancestor, "ancestor2") == 0);
cl_assert(strcmp(conflict_name->ours, "ours2") == 0); cl_assert(strcmp(conflict_name->ours, "ours2") == 0);
cl_assert(conflict_name->theirs == NULL); cl_assert(conflict_name->theirs == NULL);
conflict_name = git_index_name_get_byindex(repo_index, 2); conflict_name = git_index_name_get_byindex(repo_index, 2);
cl_assert(strcmp(conflict_name->ancestor, "ancestor3") == 0); cl_assert(strcmp(conflict_name->ancestor, "ancestor3") == 0);
cl_assert(conflict_name->ours == NULL); cl_assert(conflict_name->ours == NULL);
cl_assert(strcmp(conflict_name->theirs, "theirs3") == 0); cl_assert(strcmp(conflict_name->theirs, "theirs3") == 0);
} }
...@@ -232,7 +232,7 @@ void test_index_reuc__remove(void) ...@@ -232,7 +232,7 @@ void test_index_reuc__remove(void)
cl_git_pass(git_index_reuc_remove(repo_index, 0)); cl_git_pass(git_index_reuc_remove(repo_index, 0));
cl_git_fail(git_index_reuc_remove(repo_index, 1)); cl_git_fail(git_index_reuc_remove(repo_index, 1));
cl_assert_equal_i(1, git_index_reuc_entrycount(repo_index)); cl_assert_equal_i(1, git_index_reuc_entrycount(repo_index));
cl_assert(reuc = git_index_reuc_get_byindex(repo_index, 0)); cl_assert(reuc = git_index_reuc_get_byindex(repo_index, 0));
...@@ -283,7 +283,7 @@ void test_index_reuc__write(void) ...@@ -283,7 +283,7 @@ void test_index_reuc__write(void)
/* ensure sort order was round-tripped correct */ /* ensure sort order was round-tripped correct */
cl_assert(reuc = git_index_reuc_get_byindex(repo_index, 0)); cl_assert(reuc = git_index_reuc_get_byindex(repo_index, 0));
cl_assert_equal_s("one.txt", reuc->path); cl_assert_equal_s("one.txt", reuc->path);
cl_assert(reuc = git_index_reuc_get_byindex(repo_index, 1)); cl_assert(reuc = git_index_reuc_get_byindex(repo_index, 1));
cl_assert_equal_s("two.txt", reuc->path); cl_assert_equal_s("two.txt", reuc->path);
} }
...@@ -296,41 +296,41 @@ static int reuc_entry_exists(void) ...@@ -296,41 +296,41 @@ static int reuc_entry_exists(void)
void test_index_reuc__cleaned_on_reset_hard(void) void test_index_reuc__cleaned_on_reset_hard(void)
{ {
git_object *target; git_object *target;
retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876"); retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876");
test_index_reuc__add(); test_index_reuc__add();
cl_git_pass(git_reset(repo, target, GIT_RESET_HARD)); cl_git_pass(git_reset(repo, target, GIT_RESET_HARD));
cl_assert(reuc_entry_exists() == false); cl_assert(reuc_entry_exists() == false);
git_object_free(target); git_object_free(target);
} }
void test_index_reuc__cleaned_on_reset_mixed(void) void test_index_reuc__cleaned_on_reset_mixed(void)
{ {
git_object *target; git_object *target;
retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876"); 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_git_pass(git_reset(repo, target, GIT_RESET_MIXED));
cl_assert(reuc_entry_exists() == false); cl_assert(reuc_entry_exists() == false);
git_object_free(target); git_object_free(target);
} }
void test_index_reuc__retained_on_reset_soft(void) void test_index_reuc__retained_on_reset_soft(void)
{ {
git_object *target; git_object *target;
retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876"); retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876");
git_reset(repo, target, GIT_RESET_HARD); git_reset(repo, target, GIT_RESET_HARD);
test_index_reuc__add(); test_index_reuc__add();
cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT)); cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT));
cl_assert(reuc_entry_exists() == true); cl_assert(reuc_entry_exists() == true);
git_object_free(target); git_object_free(target);
} }
...@@ -339,7 +339,7 @@ void test_index_reuc__cleaned_on_checkout_tree(void) ...@@ -339,7 +339,7 @@ void test_index_reuc__cleaned_on_checkout_tree(void)
git_oid oid; git_oid oid;
git_object *obj; git_object *obj;
git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT; git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_UPDATE_ONLY; opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_UPDATE_ONLY;
test_index_reuc__add(); test_index_reuc__add();
...@@ -347,16 +347,16 @@ void test_index_reuc__cleaned_on_checkout_tree(void) ...@@ -347,16 +347,16 @@ void test_index_reuc__cleaned_on_checkout_tree(void)
git_object_lookup(&obj, repo, &oid, GIT_OBJ_ANY); git_object_lookup(&obj, repo, &oid, GIT_OBJ_ANY);
git_checkout_tree(repo, obj, &opts); git_checkout_tree(repo, obj, &opts);
cl_assert(reuc_entry_exists() == false); cl_assert(reuc_entry_exists() == false);
git_object_free(obj); git_object_free(obj);
} }
void test_index_reuc__cleaned_on_checkout_head(void) void test_index_reuc__cleaned_on_checkout_head(void)
{ {
git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT; git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_UPDATE_ONLY; opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_UPDATE_ONLY;
test_index_reuc__add(); test_index_reuc__add();
git_checkout_head(repo, &opts); git_checkout_head(repo, &opts);
cl_assert(reuc_entry_exists() == false); cl_assert(reuc_entry_exists() == false);
...@@ -365,9 +365,9 @@ void test_index_reuc__cleaned_on_checkout_head(void) ...@@ -365,9 +365,9 @@ void test_index_reuc__cleaned_on_checkout_head(void)
void test_index_reuc__retained_on_checkout_index(void) void test_index_reuc__retained_on_checkout_index(void)
{ {
git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT; git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_UPDATE_ONLY; opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_UPDATE_ONLY;
test_index_reuc__add(); test_index_reuc__add();
git_checkout_index(repo, repo_index, &opts); git_checkout_index(repo, repo_index, &opts);
cl_assert(reuc_entry_exists() == true); cl_assert(reuc_entry_exists() == true);
......
...@@ -56,11 +56,11 @@ void merge__dump_index_entries(git_vector *index_entries) ...@@ -56,11 +56,11 @@ void merge__dump_index_entries(git_vector *index_entries)
{ {
size_t i; size_t i;
const git_index_entry *index_entry; const git_index_entry *index_entry;
printf ("\nINDEX [%d]:\n", (int)index_entries->length); printf ("\nINDEX [%d]:\n", (int)index_entries->length);
for (i = 0; i < index_entries->length; i++) { for (i = 0; i < index_entries->length; i++) {
index_entry = index_entries->contents[i]; index_entry = index_entries->contents[i];
printf("%o ", index_entry->mode); printf("%o ", index_entry->mode);
printf("%s ", git_oid_allocfmt(&index_entry->oid)); printf("%s ", git_oid_allocfmt(&index_entry->oid));
printf("%d ", git_index_entry_stage(index_entry)); printf("%d ", git_index_entry_stage(index_entry));
...@@ -77,7 +77,7 @@ void merge__dump_names(git_index *index) ...@@ -77,7 +77,7 @@ void merge__dump_names(git_index *index)
for (i = 0; i < git_index_name_entrycount(index); i++) { for (i = 0; i < git_index_name_entrycount(index); i++) {
conflict_name = git_index_name_get_byindex(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("%s %s %s\n", conflict_name->ancestor, conflict_name->ours, conflict_name->theirs);
} }
printf("\n"); printf("\n");
...@@ -91,7 +91,7 @@ void merge__dump_reuc(git_index *index) ...@@ -91,7 +91,7 @@ void merge__dump_reuc(git_index *index)
printf ("\nREUC:\n"); printf ("\nREUC:\n");
for (i = 0; i < git_index_reuc_entrycount(index); i++) { for (i = 0; i < git_index_reuc_entrycount(index); i++) {
reuc = git_index_reuc_get_byindex(index, i); reuc = git_index_reuc_get_byindex(index, i);
printf("%s ", reuc->path); printf("%s ", reuc->path);
printf("%o ", reuc->mode[0]); printf("%o ", reuc->mode[0]);
printf("%s\n", git_oid_allocfmt(&reuc->oid[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 ...@@ -114,18 +114,18 @@ static int index_entry_eq_merge_index_entry(const struct merge_index_entry *expe
test_oid = 1; test_oid = 1;
} else } else
test_oid = 0; test_oid = 0;
if (actual->mode != expected->mode || if (actual->mode != expected->mode ||
(test_oid && git_oid_cmp(&actual->oid, &expected_oid) != 0) || (test_oid && git_oid_cmp(&actual->oid, &expected_oid) != 0) ||
git_index_entry_stage(actual) != expected->stage) git_index_entry_stage(actual) != expected->stage)
return 0; return 0;
if (actual->mode == 0 && (actual->path != NULL || strlen(expected->path) > 0)) if (actual->mode == 0 && (actual->path != NULL || strlen(expected->path) > 0))
return 0; return 0;
if (actual->mode != 0 && (strcmp(actual->path, expected->path) != 0)) if (actual->mode != 0 && (strcmp(actual->path, expected->path) != 0))
return 0; return 0;
return 1; return 1;
} }
...@@ -133,7 +133,7 @@ static int name_entry_eq(const char *expected, const char *actual) ...@@ -133,7 +133,7 @@ static int name_entry_eq(const char *expected, const char *actual)
{ {
if (strlen(expected) == 0) if (strlen(expected) == 0)
return (actual == NULL) ? 1 : 0; return (actual == NULL) ? 1 : 0;
return (strcmp(expected, actual) == 0) ? 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 ...@@ -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->ours.entry, &actual->our_entry) ||
!index_entry_eq_merge_index_entry(&expected->theirs.entry, &actual->their_entry)) !index_entry_eq_merge_index_entry(&expected->theirs.entry, &actual->their_entry))
return 0; return 0;
if (expected->ours.status != actual->our_status || if (expected->ours.status != actual->our_status ||
expected->theirs.status != actual->their_status) expected->theirs.status != actual->their_status)
return 0; return 0;
return 1; return 1;
} }
...@@ -165,48 +165,48 @@ int merge_test_merge_conflicts(git_vector *conflicts, const struct merge_index_c ...@@ -165,48 +165,48 @@ int merge_test_merge_conflicts(git_vector *conflicts, const struct merge_index_c
{ {
git_merge_diff *actual; git_merge_diff *actual;
size_t i; size_t i;
if (conflicts->length != expected_len) if (conflicts->length != expected_len)
return 0; return 0;
for (i = 0; i < expected_len; i++) { for (i = 0; i < expected_len; i++) {
actual = conflicts->contents[i]; actual = conflicts->contents[i];
if (!index_conflict_data_eq_merge_diff(&expected[i], actual)) if (!index_conflict_data_eq_merge_diff(&expected[i], actual))
return 0; return 0;
} }
return 1; return 1;
} }
int merge_test_index(git_index *index, const struct merge_index_entry expected[], size_t expected_len) int merge_test_index(git_index *index, const struct merge_index_entry expected[], size_t expected_len)
{ {
size_t i; size_t i;
const git_index_entry *index_entry; const git_index_entry *index_entry;
/* /*
dump_index_entries(&index->entries); dump_index_entries(&index->entries);
*/ */
if (git_index_entrycount(index) != expected_len) if (git_index_entrycount(index) != expected_len)
return 0; return 0;
for (i = 0; i < expected_len; i++) { for (i = 0; i < expected_len; i++) {
if ((index_entry = git_index_get_byindex(index, i)) == NULL) if ((index_entry = git_index_get_byindex(index, i)) == NULL)
return 0; return 0;
if (!index_entry_eq_merge_index_entry(&expected[i], index_entry)) if (!index_entry_eq_merge_index_entry(&expected[i], index_entry))
return 0; return 0;
} }
return 1; return 1;
} }
int merge_test_names(git_index *index, const struct merge_name_entry expected[], size_t expected_len) int merge_test_names(git_index *index, const struct merge_name_entry expected[], size_t expected_len)
{ {
size_t i; size_t i;
const git_index_name_entry *name_entry; const git_index_name_entry *name_entry;
/* /*
dump_names(index); dump_names(index);
*/ */
...@@ -221,26 +221,26 @@ int merge_test_names(git_index *index, const struct merge_name_entry expected[], ...@@ -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)) if (! name_entry_eq_merge_name_entry(&expected[i], name_entry))
return 0; return 0;
} }
return 1; return 1;
} }
int merge_test_reuc(git_index *index, const struct merge_reuc_entry expected[], size_t expected_len) 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; const git_index_reuc_entry *reuc_entry;
git_oid expected_oid; git_oid expected_oid;
/* /*
dump_reuc(index); dump_reuc(index);
*/ */
if (git_index_reuc_entrycount(index) != expected_len) if (git_index_reuc_entrycount(index) != expected_len)
return 0; return 0;
for (i = 0; i < expected_len; i++) { for (i = 0; i < expected_len; i++) {
if ((reuc_entry = git_index_reuc_get_byindex(index, i)) == NULL) if ((reuc_entry = git_index_reuc_get_byindex(index, i)) == NULL)
return 0; return 0;
if (strcmp(reuc_entry->path, expected[i].path) != 0 || if (strcmp(reuc_entry->path, expected[i].path) != 0 ||
reuc_entry->mode[0] != expected[i].ancestor_mode || 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[], ...@@ -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) if (git_oid_cmp(&reuc_entry->oid[2], &expected_oid) != 0)
return 0; return 0;
} }
} }
return 1; return 1;
} }
int dircount(void *payload, git_buf *pathbuf) int dircount(void *payload, git_buf *pathbuf)
{ {
int *entries = payload; int *entries = payload;
size_t len = git_buf_len(pathbuf); size_t len = git_buf_len(pathbuf);
if (len < 5 || strcmp(pathbuf->ptr + (git_buf_len(pathbuf) - 5), "/.git") != 0) if (len < 5 || strcmp(pathbuf->ptr + (git_buf_len(pathbuf) - 5), "/.git") != 0)
(*entries)++; (*entries)++;
return 0; return 0;
} }
...@@ -289,22 +289,22 @@ int merge_test_workdir(git_repository *repo, const struct merge_index_entry expe ...@@ -289,22 +289,22 @@ int merge_test_workdir(git_repository *repo, const struct merge_index_entry expe
size_t actual_len = 0, i; size_t actual_len = 0, i;
git_oid actual_oid, expected_oid; git_oid actual_oid, expected_oid;
git_buf wd = GIT_BUF_INIT; 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); git_path_direach(&wd, dircount, &actual_len);
if (actual_len != expected_len) if (actual_len != expected_len)
return 0; return 0;
for (i = 0; i < expected_len; i++) { for (i = 0; i < expected_len; i++) {
git_blob_create_fromworkdir(&actual_oid, repo, expected[i].path); git_blob_create_fromworkdir(&actual_oid, repo, expected[i].path);
git_oid_fromstr(&expected_oid, expected[i].oid_str); git_oid_fromstr(&expected_oid, expected[i].oid_str);
if (git_oid_cmp(&actual_oid, &expected_oid) != 0) if (git_oid_cmp(&actual_oid, &expected_oid) != 0)
return 0; return 0;
} }
git_buf_free(&wd); git_buf_free(&wd);
return 1; return 1;
} }
...@@ -93,7 +93,7 @@ void test_merge_trees_automerge__automerge(void) ...@@ -93,7 +93,7 @@ void test_merge_trees_automerge__automerge(void)
const git_index_entry *entry; const git_index_entry *entry;
git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT; git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT;
git_blob *blob; git_blob *blob;
struct merge_index_entry merge_index_entries[] = { struct merge_index_entry merge_index_entries[] = {
ADDED_IN_MASTER_INDEX_ENTRY, ADDED_IN_MASTER_INDEX_ENTRY,
AUTOMERGEABLE_INDEX_ENTRY, AUTOMERGEABLE_INDEX_ENTRY,
...@@ -105,7 +105,7 @@ void test_merge_trees_automerge__automerge(void) ...@@ -105,7 +105,7 @@ void test_merge_trees_automerge__automerge(void)
{ 0100644, "2bd0a343aeef7a2cf0d158478966a6e587ff3863", 3, "conflicting.txt" }, { 0100644, "2bd0a343aeef7a2cf0d158478966a6e587ff3863", 3, "conflicting.txt" },
UNCHANGED_INDEX_ENTRY, UNCHANGED_INDEX_ENTRY,
}; };
struct merge_reuc_entry merge_reuc_entries[] = { struct merge_reuc_entry merge_reuc_entries[] = {
AUTOMERGEABLE_REUC_ENTRY, AUTOMERGEABLE_REUC_ENTRY,
...@@ -120,10 +120,10 @@ void test_merge_trees_automerge__automerge(void) ...@@ -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 = git_index_get_bypath(index, "automergeable.txt", 0)) != NULL);
cl_assert(entry->file_size == strlen(AUTOMERGEABLE_MERGED_FILE)); 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_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); cl_assert(memcmp(git_blob_rawcontent(blob), AUTOMERGEABLE_MERGED_FILE, entry->file_size) == 0);
git_index_free(index); git_index_free(index);
git_blob_free(blob); git_blob_free(blob);
} }
...@@ -132,7 +132,7 @@ void test_merge_trees_automerge__favor_ours(void) ...@@ -132,7 +132,7 @@ void test_merge_trees_automerge__favor_ours(void)
{ {
git_index *index; git_index *index;
git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT; git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT;
struct merge_index_entry merge_index_entries[] = { struct merge_index_entry merge_index_entries[] = {
ADDED_IN_MASTER_INDEX_ENTRY, ADDED_IN_MASTER_INDEX_ENTRY,
AUTOMERGEABLE_INDEX_ENTRY, AUTOMERGEABLE_INDEX_ENTRY,
...@@ -148,9 +148,9 @@ void test_merge_trees_automerge__favor_ours(void) ...@@ -148,9 +148,9 @@ void test_merge_trees_automerge__favor_ours(void)
REMOVED_IN_BRANCH_REUC_ENTRY, REMOVED_IN_BRANCH_REUC_ENTRY,
REMOVED_IN_MASTER_REUC_ENTRY, REMOVED_IN_MASTER_REUC_ENTRY,
}; };
opts.automerge_flags = GIT_MERGE_AUTOMERGE_FAVOR_OURS; opts.automerge_flags = GIT_MERGE_AUTOMERGE_FAVOR_OURS;
cl_git_pass(merge_trees_from_branches(&index, repo, "master", THEIRS_AUTOMERGE_BRANCH, &opts)); 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_index(index, merge_index_entries, 6));
...@@ -163,7 +163,7 @@ void test_merge_trees_automerge__favor_theirs(void) ...@@ -163,7 +163,7 @@ void test_merge_trees_automerge__favor_theirs(void)
{ {
git_index *index; git_index *index;
git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT; git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT;
struct merge_index_entry merge_index_entries[] = { struct merge_index_entry merge_index_entries[] = {
ADDED_IN_MASTER_INDEX_ENTRY, ADDED_IN_MASTER_INDEX_ENTRY,
AUTOMERGEABLE_INDEX_ENTRY, AUTOMERGEABLE_INDEX_ENTRY,
...@@ -181,12 +181,12 @@ void test_merge_trees_automerge__favor_theirs(void) ...@@ -181,12 +181,12 @@ void test_merge_trees_automerge__favor_theirs(void)
}; };
opts.automerge_flags = GIT_MERGE_AUTOMERGE_FAVOR_THEIRS; opts.automerge_flags = GIT_MERGE_AUTOMERGE_FAVOR_THEIRS;
cl_git_pass(merge_trees_from_branches(&index, repo, "master", THEIRS_AUTOMERGE_BRANCH, &opts)); 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_index(index, merge_index_entries, 6));
cl_assert(merge_test_reuc(index, merge_reuc_entries, 4)); cl_assert(merge_test_reuc(index, merge_reuc_entries, 4));
git_index_free(index); git_index_free(index);
} }
...@@ -194,7 +194,7 @@ void test_merge_trees_automerge__unrelated(void) ...@@ -194,7 +194,7 @@ void test_merge_trees_automerge__unrelated(void)
{ {
git_index *index; git_index *index;
git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT; git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT;
struct merge_index_entry merge_index_entries[] = { struct merge_index_entry merge_index_entries[] = {
{ 0100644, "233c0919c998ed110a4b6ff36f353aec8b713487", 0, "added-in-master.txt" }, { 0100644, "233c0919c998ed110a4b6ff36f353aec8b713487", 0, "added-in-master.txt" },
{ 0100644, "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf", 2, "automergeable.txt" }, { 0100644, "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf", 2, "automergeable.txt" },
...@@ -208,10 +208,10 @@ void test_merge_trees_automerge__unrelated(void) ...@@ -208,10 +208,10 @@ void test_merge_trees_automerge__unrelated(void)
{ 0100644, "dfe3f22baa1f6fce5447901c3086bae368de6bdd", 0, "removed-in-branch.txt" }, { 0100644, "dfe3f22baa1f6fce5447901c3086bae368de6bdd", 0, "removed-in-branch.txt" },
{ 0100644, "c8f06f2e3bb2964174677e91f0abead0e43c9e5d", 0, "unchanged.txt" }, { 0100644, "c8f06f2e3bb2964174677e91f0abead0e43c9e5d", 0, "unchanged.txt" },
}; };
cl_git_pass(merge_trees_from_branches(&index, repo, "master", THEIRS_UNRELATED_BRANCH, &opts)); cl_git_pass(merge_trees_from_branches(&index, repo, "master", THEIRS_UNRELATED_BRANCH, &opts));
cl_assert(merge_test_index(index, merge_index_entries, 11)); cl_assert(merge_test_index(index, merge_index_entries, 11));
git_index_free(index); git_index_free(index);
} }
...@@ -27,7 +27,7 @@ void test_merge_trees_modeconflict__cleanup(void) ...@@ -27,7 +27,7 @@ void test_merge_trees_modeconflict__cleanup(void)
void test_merge_trees_modeconflict__df_conflict(void) void test_merge_trees_modeconflict__df_conflict(void)
{ {
git_index *index; git_index *index;
struct merge_index_entry merge_index_entries[] = { struct merge_index_entry merge_index_entries[] = {
{ 0100644, "49130a28ef567af9a6a6104c38773fedfa5f9742", 2, "dir-10" }, { 0100644, "49130a28ef567af9a6a6104c38773fedfa5f9742", 2, "dir-10" },
{ 0100644, "6c06dcd163587c2cc18be44857e0b71116382aeb", 3, "dir-10" }, { 0100644, "6c06dcd163587c2cc18be44857e0b71116382aeb", 3, "dir-10" },
...@@ -49,7 +49,7 @@ void test_merge_trees_modeconflict__df_conflict(void) ...@@ -49,7 +49,7 @@ void test_merge_trees_modeconflict__df_conflict(void)
{ 0100644, "e49f917b448d1340b31d76e54ba388268fd4c922", 0, "file-4/new" }, { 0100644, "e49f917b448d1340b31d76e54ba388268fd4c922", 0, "file-4/new" },
{ 0100644, "cab2cf23998b40f1af2d9d9a756dc9e285a8df4b", 2, "file-5/new" }, { 0100644, "cab2cf23998b40f1af2d9d9a756dc9e285a8df4b", 2, "file-5/new" },
{ 0100644, "f5504f36e6f4eb797a56fc5bac6c6c7f32969bf2", 3, "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)); cl_git_pass(merge_trees_from_branches(&index, repo, DF_SIDE1_BRANCH, DF_SIDE2_BRANCH, NULL));
......
...@@ -72,14 +72,14 @@ void test_merge_trees_renames__index(void) ...@@ -72,14 +72,14 @@ void test_merge_trees_renames__index(void)
{ 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 2, "7-both-renamed.txt" }, { 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 2, "7-both-renamed.txt" },
{ 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 3, "7-both-renamed.txt" }, { 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 3, "7-both-renamed.txt" },
}; };
struct merge_name_entry merge_name_entries[] = { struct merge_name_entry merge_name_entries[] = {
{ {
"3a-renamed-in-ours-deleted-in-theirs.txt", "3a-renamed-in-ours-deleted-in-theirs.txt",
"3a-newname-in-ours-deleted-in-theirs.txt", "3a-newname-in-ours-deleted-in-theirs.txt",
"" ""
}, },
{ {
"3b-renamed-in-theirs-deleted-in-ours.txt", "3b-renamed-in-theirs-deleted-in-ours.txt",
"", "",
...@@ -97,7 +97,7 @@ void test_merge_trees_renames__index(void) ...@@ -97,7 +97,7 @@ void test_merge_trees_renames__index(void)
"", "",
"4b-newname-in-theirs-added-in-ours.txt", "4b-newname-in-theirs-added-in-ours.txt",
}, },
{ {
"5a-renamed-in-ours-added-in-theirs.txt", "5a-renamed-in-ours-added-in-theirs.txt",
"5a-newname-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) ...@@ -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-ours.txt",
"6-both-renamed-1-to-2-theirs.txt", "6-both-renamed-1-to-2-theirs.txt",
}, },
{ {
"7-both-renamed-side-1.txt", "7-both-renamed-side-1.txt",
"7-both-renamed.txt", "7-both-renamed.txt",
"7-both-renamed-side-1.txt", "7-both-renamed-side-1.txt",
}, },
{ {
"7-both-renamed-side-2.txt", "7-both-renamed-side-2.txt",
"7-both-renamed-side-2.txt", "7-both-renamed-side-2.txt",
...@@ -159,7 +159,7 @@ void test_merge_trees_renames__index(void) ...@@ -159,7 +159,7 @@ void test_merge_trees_renames__index(void)
"", "",
"", "",
"241a1005cd9b980732741b74385b891142bcba28" }, "241a1005cd9b980732741b74385b891142bcba28" },
{ "1b-newname-in-theirs.txt", { "1b-newname-in-theirs.txt",
0, 0, 0100644, 0, 0, 0100644,
"", "",
...@@ -194,11 +194,11 @@ void test_merge_trees_renames__index(void) ...@@ -194,11 +194,11 @@ void test_merge_trees_renames__index(void)
cl_git_pass(merge_trees_from_branches(&index, repo, cl_git_pass(merge_trees_from_branches(&index, repo,
BRANCH_RENAME_OURS, BRANCH_RENAME_THEIRS, BRANCH_RENAME_OURS, BRANCH_RENAME_THEIRS,
opts)); opts));
cl_assert(merge_test_index(index, merge_index_entries, 41)); cl_assert(merge_test_index(index, merge_index_entries, 41));
cl_assert(merge_test_names(index, merge_name_entries, 9)); cl_assert(merge_test_names(index, merge_name_entries, 9));
cl_assert(merge_test_reuc(index, merge_reuc_entries, 10)); cl_assert(merge_test_reuc(index, merge_reuc_entries, 10));
git_index_free(index); git_index_free(index);
} }
...@@ -206,7 +206,7 @@ void test_merge_trees_renames__no_rename_index(void) ...@@ -206,7 +206,7 @@ void test_merge_trees_renames__no_rename_index(void)
{ {
git_index *index; git_index *index;
git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT; git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT;
struct merge_index_entry merge_index_entries[] = { struct merge_index_entry merge_index_entries[] = {
{ 0100644, "68c6c84b091926c7d90aa6a79b2bc3bb6adccd8e", 0, "0a-no-change.txt" }, { 0100644, "68c6c84b091926c7d90aa6a79b2bc3bb6adccd8e", 0, "0a-no-change.txt" },
{ 0100644, "f0ce2b8e4986084d9b308fb72709e414c23eb5e6", 0, "0b-duplicated-in-ours.txt" }, { 0100644, "f0ce2b8e4986084d9b308fb72709e414c23eb5e6", 0, "0b-duplicated-in-ours.txt" },
...@@ -241,13 +241,12 @@ void test_merge_trees_renames__no_rename_index(void) ...@@ -241,13 +241,12 @@ void test_merge_trees_renames__no_rename_index(void)
{ 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 2, "7-both-renamed.txt" }, { 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 2, "7-both-renamed.txt" },
{ 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 3, "7-both-renamed.txt" }, { 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 3, "7-both-renamed.txt" },
}; };
cl_git_pass(merge_trees_from_branches(&index, repo, cl_git_pass(merge_trees_from_branches(&index, repo,
BRANCH_RENAME_OURS, BRANCH_RENAME_THEIRS, BRANCH_RENAME_OURS, BRANCH_RENAME_THEIRS,
&opts)); &opts));
cl_assert(merge_test_index(index, merge_index_entries, 32)); cl_assert(merge_test_index(index, merge_index_entries, 32));
git_index_free(index); git_index_free(index);
} }
...@@ -34,7 +34,7 @@ static int merge_trivial(git_index **index, const char *ours, const char *theirs ...@@ -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; git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT;
opts.automerge_flags |= automerge ? 0 : GIT_MERGE_AUTOMERGE_NONE; opts.automerge_flags |= automerge ? 0 : GIT_MERGE_AUTOMERGE_NONE;
git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours); 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_reference_name_to_id(&our_oid, repo, branch_buf.ptr));
cl_git_pass(git_commit_lookup(&our_commit, repo, &our_oid)); 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 ...@@ -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_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_lookup(&ancestor_commit, repo, &ancestor_oid));
cl_git_pass(git_commit_tree(&ancestor_tree, ancestor_commit)); 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(&our_tree, our_commit));
cl_git_pass(git_commit_tree(&their_tree, their_commit)); cl_git_pass(git_commit_tree(&their_tree, their_commit));
...@@ -106,7 +106,7 @@ void test_merge_trees_trivial__3alt(void) ...@@ -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(entry = git_index_get_bypath(result, "new-in-3alt.txt", 0));
cl_assert(git_index_reuc_entrycount(result) == 0); cl_assert(git_index_reuc_entrycount(result) == 0);
cl_assert(merge_trivial_conflict_entrycount(result) == 0); cl_assert(merge_trivial_conflict_entrycount(result) == 0);
git_index_free(result); git_index_free(result);
} }
...@@ -124,7 +124,7 @@ void test_merge_trees_trivial__4(void) ...@@ -124,7 +124,7 @@ void test_merge_trees_trivial__4(void)
cl_assert(merge_trivial_conflict_entrycount(result) == 2); 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", 2));
cl_assert(entry = git_index_get_bypath(result, "new-and-different.txt", 3)); cl_assert(entry = git_index_get_bypath(result, "new-and-different.txt", 3));
git_index_free(result); git_index_free(result);
} }
...@@ -139,7 +139,7 @@ void test_merge_trees_trivial__5alt_1(void) ...@@ -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(entry = git_index_get_bypath(result, "new-and-same.txt", 0));
cl_assert(git_index_reuc_entrycount(result) == 0); cl_assert(git_index_reuc_entrycount(result) == 0);
cl_assert(merge_trivial_conflict_entrycount(result) == 0); cl_assert(merge_trivial_conflict_entrycount(result) == 0);
git_index_free(result); git_index_free(result);
} }
...@@ -154,7 +154,7 @@ void test_merge_trees_trivial__5alt_2(void) ...@@ -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(entry = git_index_get_bypath(result, "modified-to-same.txt", 0));
cl_assert(git_index_reuc_entrycount(result) == 0); cl_assert(git_index_reuc_entrycount(result) == 0);
cl_assert(merge_trivial_conflict_entrycount(result) == 0); cl_assert(merge_trivial_conflict_entrycount(result) == 0);
git_index_free(result); git_index_free(result);
} }
...@@ -171,7 +171,7 @@ void test_merge_trees_trivial__6(void) ...@@ -171,7 +171,7 @@ void test_merge_trees_trivial__6(void)
cl_assert(merge_trivial_conflict_entrycount(result) == 1); cl_assert(merge_trivial_conflict_entrycount(result) == 1);
cl_assert(entry = git_index_get_bypath(result, "removed-in-both.txt", 1)); cl_assert(entry = git_index_get_bypath(result, "removed-in-both.txt", 1));
git_index_free(result); git_index_free(result);
} }
...@@ -189,7 +189,7 @@ void test_merge_trees_trivial__6_automerge(void) ...@@ -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(reuc = git_index_reuc_get_bypath(result, "removed-in-both.txt"));
cl_assert(merge_trivial_conflict_entrycount(result) == 0); cl_assert(merge_trivial_conflict_entrycount(result) == 0);
git_index_free(result); git_index_free(result);
} }
...@@ -207,7 +207,7 @@ void test_merge_trees_trivial__8(void) ...@@ -207,7 +207,7 @@ void test_merge_trees_trivial__8(void)
cl_assert(merge_trivial_conflict_entrycount(result) == 2); 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", 1));
cl_assert(entry = git_index_get_bypath(result, "removed-in-8.txt", 3)); cl_assert(entry = git_index_get_bypath(result, "removed-in-8.txt", 3));
git_index_free(result); git_index_free(result);
} }
...@@ -226,7 +226,7 @@ void test_merge_trees_trivial__8_automerge(void) ...@@ -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(reuc = git_index_reuc_get_bypath(result, "removed-in-8.txt"));
cl_assert(merge_trivial_conflict_entrycount(result) == 0); cl_assert(merge_trivial_conflict_entrycount(result) == 0);
git_index_free(result); git_index_free(result);
} }
...@@ -244,7 +244,7 @@ void test_merge_trees_trivial__7(void) ...@@ -244,7 +244,7 @@ void test_merge_trees_trivial__7(void)
cl_assert(merge_trivial_conflict_entrycount(result) == 2); 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", 1));
cl_assert(entry = git_index_get_bypath(result, "removed-in-7.txt", 3)); cl_assert(entry = git_index_get_bypath(result, "removed-in-7.txt", 3));
git_index_free(result); git_index_free(result);
} }
...@@ -262,7 +262,7 @@ void test_merge_trees_trivial__7_automerge(void) ...@@ -262,7 +262,7 @@ void test_merge_trees_trivial__7_automerge(void)
cl_assert(merge_trivial_conflict_entrycount(result) == 2); 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", 1));
cl_assert(entry = git_index_get_bypath(result, "removed-in-7.txt", 3)); cl_assert(entry = git_index_get_bypath(result, "removed-in-7.txt", 3));
git_index_free(result); git_index_free(result);
} }
...@@ -280,7 +280,7 @@ void test_merge_trees_trivial__10(void) ...@@ -280,7 +280,7 @@ void test_merge_trees_trivial__10(void)
cl_assert(merge_trivial_conflict_entrycount(result) == 2); 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", 1));
cl_assert(entry = git_index_get_bypath(result, "removed-in-10-branch.txt", 2)); cl_assert(entry = git_index_get_bypath(result, "removed-in-10-branch.txt", 2));
git_index_free(result); git_index_free(result);
} }
...@@ -299,7 +299,7 @@ void test_merge_trees_trivial__10_automerge(void) ...@@ -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(reuc = git_index_reuc_get_bypath(result, "removed-in-10-branch.txt"));
cl_assert(merge_trivial_conflict_entrycount(result) == 0); cl_assert(merge_trivial_conflict_entrycount(result) == 0);
git_index_free(result); git_index_free(result);
} }
...@@ -317,7 +317,7 @@ void test_merge_trees_trivial__9(void) ...@@ -317,7 +317,7 @@ void test_merge_trees_trivial__9(void)
cl_assert(merge_trivial_conflict_entrycount(result) == 2); 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", 1));
cl_assert(entry = git_index_get_bypath(result, "removed-in-9-branch.txt", 2)); cl_assert(entry = git_index_get_bypath(result, "removed-in-9-branch.txt", 2));
git_index_free(result); git_index_free(result);
} }
...@@ -335,7 +335,7 @@ void test_merge_trees_trivial__9_automerge(void) ...@@ -335,7 +335,7 @@ void test_merge_trees_trivial__9_automerge(void)
cl_assert(merge_trivial_conflict_entrycount(result) == 2); 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", 1));
cl_assert(entry = git_index_get_bypath(result, "removed-in-9-branch.txt", 2)); cl_assert(entry = git_index_get_bypath(result, "removed-in-9-branch.txt", 2));
git_index_free(result); git_index_free(result);
} }
...@@ -354,7 +354,7 @@ void test_merge_trees_trivial__13(void) ...@@ -354,7 +354,7 @@ void test_merge_trees_trivial__13(void)
cl_assert(git_index_reuc_entrycount(result) == 0); cl_assert(git_index_reuc_entrycount(result) == 0);
cl_assert(merge_trivial_conflict_entrycount(result) == 0); cl_assert(merge_trivial_conflict_entrycount(result) == 0);
git_index_free(result); git_index_free(result);
} }
...@@ -373,7 +373,7 @@ void test_merge_trees_trivial__14(void) ...@@ -373,7 +373,7 @@ void test_merge_trees_trivial__14(void)
cl_assert(git_index_reuc_entrycount(result) == 0); cl_assert(git_index_reuc_entrycount(result) == 0);
cl_assert(merge_trivial_conflict_entrycount(result) == 0); cl_assert(merge_trivial_conflict_entrycount(result) == 0);
git_index_free(result); git_index_free(result);
} }
...@@ -392,6 +392,6 @@ void test_merge_trees_trivial__11(void) ...@@ -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", 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", 2));
cl_assert(entry = git_index_get_bypath(result, "modified-in-both.txt", 3)); cl_assert(entry = git_index_get_bypath(result, "modified-in-both.txt", 3));
git_index_free(result); git_index_free(result);
} }
...@@ -24,7 +24,7 @@ void test_refs_branches_move__can_move_a_local_branch(void) ...@@ -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_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)); cl_assert_equal_s(GIT_REFS_HEADS_DIR NEW_BRANCH_NAME, git_reference_name(new_ref));
git_reference_free(original_ref); git_reference_free(original_ref);
git_reference_free(new_ref); git_reference_free(new_ref);
} }
...@@ -32,7 +32,7 @@ void test_refs_branches_move__can_move_a_local_branch(void) ...@@ -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) void test_refs_branches_move__can_move_a_local_branch_to_a_different_namespace(void)
{ {
git_reference *original_ref, *new_ref, *newer_ref; git_reference *original_ref, *new_ref, *newer_ref;
cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2"));
/* Downward */ /* Downward */
...@@ -42,14 +42,14 @@ void test_refs_branches_move__can_move_a_local_branch_to_a_different_namespace(v ...@@ -42,14 +42,14 @@ void test_refs_branches_move__can_move_a_local_branch_to_a_different_namespace(v
/* Upward */ /* Upward */
cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0)); cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0));
git_reference_free(new_ref); git_reference_free(new_ref);
git_reference_free(newer_ref); git_reference_free(newer_ref);
} }
void test_refs_branches_move__can_move_a_local_branch_to_a_partially_colliding_namespace(void) void test_refs_branches_move__can_move_a_local_branch_to_a_partially_colliding_namespace(void)
{ {
git_reference *original_ref, *new_ref, *newer_ref; git_reference *original_ref, *new_ref, *newer_ref;
cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2"));
/* Downward */ /* Downward */
...@@ -59,29 +59,29 @@ void test_refs_branches_move__can_move_a_local_branch_to_a_partially_colliding_n ...@@ -59,29 +59,29 @@ void test_refs_branches_move__can_move_a_local_branch_to_a_partially_colliding_n
/* Upward */ /* Upward */
cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0)); cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0));
git_reference_free(new_ref); git_reference_free(new_ref);
git_reference_free(newer_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) 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; git_reference *original_ref, *new_ref;
cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); 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)); cl_assert_equal_i(GIT_EEXISTS, git_branch_move(&new_ref, original_ref, "master", 0));
git_reference_free(original_ref); git_reference_free(original_ref);
} }
void test_refs_branches_move__moving_a_branch_with_an_invalid_name_returns_EINVALIDSPEC(void) void test_refs_branches_move__moving_a_branch_with_an_invalid_name_returns_EINVALIDSPEC(void)
{ {
git_reference *original_ref, *new_ref; git_reference *original_ref, *new_ref;
cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); 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)); cl_assert_equal_i(GIT_EINVALIDSPEC, git_branch_move(&new_ref, original_ref, "Inv@{id", 0));
git_reference_free(original_ref); git_reference_free(original_ref);
} }
...@@ -98,11 +98,11 @@ void test_refs_branches_move__can_not_move_a_non_branch(void) ...@@ -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) void test_refs_branches_move__can_force_move_over_an_existing_branch(void)
{ {
git_reference *original_ref, *new_ref; git_reference *original_ref, *new_ref;
cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2"));
cl_git_pass(git_branch_move(&new_ref, original_ref, "master", 1)); cl_git_pass(git_branch_move(&new_ref, original_ref, "master", 1));
git_reference_free(original_ref); git_reference_free(original_ref);
git_reference_free(new_ref); git_reference_free(new_ref);
} }
......
...@@ -11,15 +11,15 @@ int reference_is_packed(git_reference *ref) ...@@ -11,15 +11,15 @@ int reference_is_packed(git_reference *ref)
int packed; int packed;
assert(ref); assert(ref);
if (git_buf_joinpath(&ref_path, if (git_buf_joinpath(&ref_path,
git_repository_path(git_reference_owner(ref)), git_repository_path(git_reference_owner(ref)),
git_reference_name(ref)) < 0) git_reference_name(ref)) < 0)
return -1; return -1;
packed = !git_path_isfile(ref_path.ptr); packed = !git_path_isfile(ref_path.ptr);
git_buf_free(&ref_path); git_buf_free(&ref_path);
return packed; return packed;
} }
...@@ -557,12 +557,12 @@ void test_refs_revparse__issue_994(void) ...@@ -557,12 +557,12 @@ void test_refs_revparse__issue_994(void)
/** /**
* $ git rev-parse blah-7-gc47800c * $ git rev-parse blah-7-gc47800c
* c47800c7266a2be04c571c04d5a6614691ea99bd * c47800c7266a2be04c571c04d5a6614691ea99bd
* *
* $ git rev-parse HEAD~3 * $ git rev-parse HEAD~3
* 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045
* *
* $ git branch blah-7-gc47800c HEAD~3 * $ git branch blah-7-gc47800c HEAD~3
* *
* $ git rev-parse blah-7-gc47800c * $ git rev-parse blah-7-gc47800c
* 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045
*/ */
...@@ -592,15 +592,15 @@ void test_refs_revparse__try_to_retrieve_branch_before_described_tag(void) ...@@ -592,15 +592,15 @@ void test_refs_revparse__try_to_retrieve_branch_before_described_tag(void)
/** /**
* $ git rev-parse a65fedf39aefe402d3bb6e24df4d4f5fe4547750 * $ git rev-parse a65fedf39aefe402d3bb6e24df4d4f5fe4547750
* a65fedf39aefe402d3bb6e24df4d4f5fe4547750 * a65fedf39aefe402d3bb6e24df4d4f5fe4547750
* *
* $ git rev-parse HEAD~3 * $ git rev-parse HEAD~3
* 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045
* *
* $ git branch a65fedf39aefe402d3bb6e24df4d4f5fe4547750 HEAD~3 * $ git branch a65fedf39aefe402d3bb6e24df4d4f5fe4547750 HEAD~3
* *
* $ git rev-parse a65fedf39aefe402d3bb6e24df4d4f5fe4547750 * $ git rev-parse a65fedf39aefe402d3bb6e24df4d4f5fe4547750
* a65fedf39aefe402d3bb6e24df4d4f5fe4547750 * a65fedf39aefe402d3bb6e24df4d4f5fe4547750
* *
* $ git rev-parse heads/a65fedf39aefe402d3bb6e24df4d4f5fe4547750 * $ git rev-parse heads/a65fedf39aefe402d3bb6e24df4d4f5fe4547750
* 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045
*/ */
...@@ -631,12 +631,12 @@ void test_refs_revparse__try_to_retrieve_sha_before_branch(void) ...@@ -631,12 +631,12 @@ void test_refs_revparse__try_to_retrieve_sha_before_branch(void)
/** /**
* $ git rev-parse c47800 * $ git rev-parse c47800
* c47800c7266a2be04c571c04d5a6614691ea99bd * c47800c7266a2be04c571c04d5a6614691ea99bd
* *
* $ git rev-parse HEAD~3 * $ git rev-parse HEAD~3
* 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045
* *
* $ git branch c47800 HEAD~3 * $ git branch c47800 HEAD~3
* *
* $ git rev-parse c47800 * $ git rev-parse c47800
* 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045
*/ */
...@@ -694,4 +694,3 @@ void test_refs_revparse__parses_range_operator(void) ...@@ -694,4 +694,3 @@ void test_refs_revparse__parses_range_operator(void)
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750",
GIT_REVPARSE_RANGE | GIT_REVPARSE_MERGE_BASE); GIT_REVPARSE_RANGE | GIT_REVPARSE_MERGE_BASE);
} }
...@@ -25,7 +25,7 @@ void test_refs_setter__update_direct(void) ...@@ -25,7 +25,7 @@ void test_refs_setter__update_direct(void)
{ {
git_reference *ref, *test_ref, *new_ref; git_reference *ref, *test_ref, *new_ref;
git_oid id; git_oid id;
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name)); cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name));
cl_assert(git_reference_type(ref) == GIT_REF_OID); cl_assert(git_reference_type(ref) == GIT_REF_OID);
git_oid_cpy(&id, git_reference_target(ref)); git_oid_cpy(&id, git_reference_target(ref));
...@@ -48,7 +48,7 @@ void test_refs_setter__update_direct(void) ...@@ -48,7 +48,7 @@ void test_refs_setter__update_direct(void)
void test_refs_setter__update_symbolic(void) void test_refs_setter__update_symbolic(void)
{ {
git_reference *head, *new_head; git_reference *head, *new_head;
cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD")); cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
cl_assert(git_reference_type(head) == GIT_REF_SYMBOLIC); cl_assert(git_reference_type(head) == GIT_REF_SYMBOLIC);
cl_assert(strcmp(git_reference_symbolic_target(head), ref_master_name) == 0); cl_assert(strcmp(git_reference_symbolic_target(head), ref_master_name) == 0);
...@@ -56,7 +56,7 @@ void test_refs_setter__update_symbolic(void) ...@@ -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)); cl_git_pass(git_reference_symbolic_set_target(&new_head, head, ref_test_name));
git_reference_free(new_head); git_reference_free(new_head);
git_reference_free(head); git_reference_free(head);
cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD")); cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
cl_assert(git_reference_type(head) == GIT_REF_SYMBOLIC); cl_assert(git_reference_type(head) == GIT_REF_SYMBOLIC);
cl_assert(strcmp(git_reference_symbolic_target(head), ref_test_name) == 0); 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) ...@@ -68,13 +68,13 @@ void test_refs_setter__cant_update_direct_with_symbolic(void)
// Overwrite an existing object id reference with a symbolic one // Overwrite an existing object id reference with a symbolic one
git_reference *ref, *new; git_reference *ref, *new;
git_oid id; git_oid id;
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name)); cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name));
cl_assert(git_reference_type(ref) == GIT_REF_OID); cl_assert(git_reference_type(ref) == GIT_REF_OID);
git_oid_cpy(&id, git_reference_target(ref)); git_oid_cpy(&id, git_reference_target(ref));
cl_git_fail(git_reference_symbolic_set_target(&new, ref, ref_name)); cl_git_fail(git_reference_symbolic_set_target(&new, ref, ref_name));
git_reference_free(ref); git_reference_free(ref);
} }
...@@ -83,7 +83,7 @@ void test_refs_setter__cant_update_symbolic_with_direct(void) ...@@ -83,7 +83,7 @@ void test_refs_setter__cant_update_symbolic_with_direct(void)
// Overwrite an existing symbolic reference with an object id one // Overwrite an existing symbolic reference with an object id one
git_reference *ref, *new; git_reference *ref, *new;
git_oid id; git_oid id;
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name)); cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name));
cl_assert(git_reference_type(ref) == GIT_REF_OID); cl_assert(git_reference_type(ref) == GIT_REF_OID);
git_oid_cpy(&id, git_reference_target(ref)); git_oid_cpy(&id, git_reference_target(ref));
...@@ -94,6 +94,6 @@ void test_refs_setter__cant_update_symbolic_with_direct(void) ...@@ -94,6 +94,6 @@ void test_refs_setter__cant_update_symbolic_with_direct(void)
/* Can't set an OID on a direct ref */ /* Can't set an OID on a direct ref */
cl_git_fail(git_reference_set_target(&new, ref, &id)); cl_git_fail(git_reference_set_target(&new, ref, &id));
git_reference_free(ref); git_reference_free(ref);
} }
...@@ -105,14 +105,14 @@ void test_reset_hard__cannot_reset_in_a_bare_repository(void) ...@@ -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) static void index_entry_init(git_index *index, int side, git_oid *oid)
{ {
git_index_entry entry; git_index_entry entry;
memset(&entry, 0x0, sizeof(git_index_entry)); memset(&entry, 0x0, sizeof(git_index_entry));
entry.path = "conflicting_file"; entry.path = "conflicting_file";
entry.flags = (side << GIT_IDXENTRY_STAGESHIFT); entry.flags = (side << GIT_IDXENTRY_STAGESHIFT);
entry.mode = 0100644; entry.mode = 0100644;
git_oid_cpy(&entry.oid, oid); git_oid_cpy(&entry.oid, oid);
cl_git_pass(git_index_add(index, &entry)); cl_git_pass(git_index_add(index, &entry));
} }
...@@ -122,19 +122,19 @@ static void unmerged_index_init(git_index *index, int entries) ...@@ -122,19 +122,19 @@ static void unmerged_index_init(git_index *index, int entries)
int write_ours = 2; int write_ours = 2;
int write_theirs = 4; int write_theirs = 4;
git_oid ancestor, ours, theirs; git_oid ancestor, ours, theirs;
git_oid_fromstr(&ancestor, "6bb0d9f700543ba3d318ba7075fc3bd696b4287b"); git_oid_fromstr(&ancestor, "6bb0d9f700543ba3d318ba7075fc3bd696b4287b");
git_oid_fromstr(&ours, "b19a1e93bec1317dc6097229e12afaffbfa74dc2"); git_oid_fromstr(&ours, "b19a1e93bec1317dc6097229e12afaffbfa74dc2");
git_oid_fromstr(&theirs, "950b81b7eee953d050aa05a641f8e056c85dd1bd"); git_oid_fromstr(&theirs, "950b81b7eee953d050aa05a641f8e056c85dd1bd");
cl_git_rewritefile("status/conflicting_file", "conflicting file\n"); cl_git_rewritefile("status/conflicting_file", "conflicting file\n");
if (entries & write_ancestor) if (entries & write_ancestor)
index_entry_init(index, 1, &ancestor); index_entry_init(index, 1, &ancestor);
if (entries & write_ours) if (entries & write_ours)
index_entry_init(index, 2, &ours); index_entry_init(index, 2, &ours);
if (entries & write_theirs) if (entries & write_theirs)
index_entry_init(index, 3, &theirs); index_entry_init(index, 3, &theirs);
} }
...@@ -143,24 +143,24 @@ void test_reset_hard__resetting_reverts_unmerged(void) ...@@ -143,24 +143,24 @@ void test_reset_hard__resetting_reverts_unmerged(void)
{ {
git_index *index; git_index *index;
int entries; int entries;
/* Ensure every permutation of non-zero stage entries results in the /* Ensure every permutation of non-zero stage entries results in the
* path being cleaned up. */ * path being cleaned up. */
for (entries = 1; entries < 8; entries++) { for (entries = 1; entries < 8; entries++) {
cl_git_pass(git_repository_index(&index, repo)); cl_git_pass(git_repository_index(&index, repo));
unmerged_index_init(index, entries); unmerged_index_init(index, entries);
cl_git_pass(git_index_write(index)); cl_git_pass(git_index_write(index));
retrieve_target_from_oid(&target, repo, "26a125ee1bfc5df1e1b2e9441bbe63c8a7ae989f"); retrieve_target_from_oid(&target, repo, "26a125ee1bfc5df1e1b2e9441bbe63c8a7ae989f");
cl_git_pass(git_reset(repo, target, GIT_RESET_HARD)); cl_git_pass(git_reset(repo, target, GIT_RESET_HARD));
cl_assert(git_path_exists("status/conflicting_file") == 0); cl_assert(git_path_exists("status/conflicting_file") == 0);
git_object_free(target); git_object_free(target);
target = NULL; target = NULL;
git_index_free(index); git_index_free(index);
} }
} }
......
...@@ -219,4 +219,3 @@ void test_status_submodules__dirty_workdir_only(void) ...@@ -219,4 +219,3 @@ void test_status_submodules__dirty_workdir_only(void)
git_status_foreach_ext(g_repo, &opts, cb_status__match, &counts)); git_status_foreach_ext(g_repo, &opts, cb_status__match, &counts));
cl_assert_equal_i(6, counts.entry_count); cl_assert_equal_i(6, counts.entry_count);
} }
...@@ -85,4 +85,3 @@ void test_trace_trace__writes_lower_level(void) ...@@ -85,4 +85,3 @@ void test_trace_trace__writes_lower_level(void)
cl_assert(written == 1); cl_assert(written == 1);
#endif #endif
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment