summaryrefslogtreecommitdiff
path: root/src/status.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2013-08-05 14:06:41 -0500
committerEdward Thomson <ethomson@microsoft.com>2013-08-05 14:09:56 -0500
commite38f0d69aba011d02ba5cabc648fee6c6f4dcc29 (patch)
treef72232c64d0ff51ff6f8b7cbe9b8f7a0ebb47850 /src/status.c
parent9b7d02ff2d9b87d61778ee7ef5e2d43bf4c561f0 (diff)
downloadlibgit2-e38f0d69aba011d02ba5cabc648fee6c6f4dcc29.tar.gz
Add rename from rewrites to status
In git_diff_paired_foreach, temporarily resort the index->workdir diff list by index path so that we can track a rename in the workdir from head->index->workdir.
Diffstat (limited to 'src/status.c')
-rw-r--r--src/status.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/src/status.c b/src/status.c
index ccb8d37da..b2353258b 100644
--- a/src/status.c
+++ b/src/status.c
@@ -225,24 +225,6 @@ static git_status_list *git_status_list_alloc(git_index *index)
return status;
}
-/*
-static int newfile_cmp(const void *a, const void *b)
-{
- const git_diff_delta *delta_a = a;
- const git_diff_delta *delta_b = b;
-
- return git__strcmp(delta_a->new_file.path, delta_b->new_file.path);
-}
-
-static int newfile_casecmp(const void *a, const void *b)
-{
- const git_diff_delta *delta_a = a;
- const git_diff_delta *delta_b = b;
-
- return git__strcasecmp(delta_a->new_file.path, delta_b->new_file.path);
-}
-*/
-
int git_status_list_new(
git_status_list **out,
git_repository *repo,
@@ -251,7 +233,7 @@ int git_status_list_new(
git_index *index = NULL;
git_status_list *status = NULL;
git_diff_options diffopt = GIT_DIFF_OPTIONS_INIT;
- git_diff_find_options findopts_i2w = GIT_DIFF_FIND_OPTIONS_INIT;
+ git_diff_find_options findopt = GIT_DIFF_FIND_OPTIONS_INIT;
git_tree *head = NULL;
git_status_show_t show =
opts ? opts->show : GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
@@ -284,6 +266,7 @@ int git_status_list_new(
}
diffopt.flags = GIT_DIFF_INCLUDE_TYPECHANGE;
+ findopt.flags = GIT_DIFF_FIND_FOR_UNTRACKED;
if ((flags & GIT_STATUS_OPT_INCLUDE_UNTRACKED) != 0)
diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_UNTRACKED;
@@ -300,7 +283,9 @@ int git_status_list_new(
if ((flags & GIT_STATUS_OPT_EXCLUDE_SUBMODULES) != 0)
diffopt.flags = diffopt.flags | GIT_DIFF_IGNORE_SUBMODULES;
- findopts_i2w.flags |= GIT_DIFF_FIND_FOR_UNTRACKED;
+ if ((flags & GIT_STATUS_OPT_RENAMES_FROM_REWRITES) != 0)
+ findopt.flags = findopt.flags | GIT_DIFF_FIND_AND_BREAK_REWRITES |
+ GIT_DIFF_FIND_RENAMES_FROM_REWRITES;
if (show != GIT_STATUS_SHOW_WORKDIR_ONLY) {
if ((error = git_diff_tree_to_index(
@@ -308,7 +293,7 @@ int git_status_list_new(
goto done;
if ((flags & GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX) != 0 &&
- (error = git_diff_find_similar(status->head2idx, NULL)) < 0)
+ (error = git_diff_find_similar(status->head2idx, &findopt)) < 0)
goto done;
}
@@ -318,7 +303,7 @@ int git_status_list_new(
goto done;
if ((flags & GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR) != 0 &&
- (error = git_diff_find_similar(status->idx2wd, &findopts_i2w)) < 0)
+ (error = git_diff_find_similar(status->idx2wd, &findopt)) < 0)
goto done;
}