-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Rename detection using diff.renames #1985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
a6ebc2b
c56c6d6
628e92c
710f383
7fb4147
a7c83ae
5a52d6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,23 +279,29 @@ static int normalize_find_opts( | |
git_repository_config__weakptr(&cfg, diff->repo) < 0) | ||
return -1; | ||
|
||
if (given != NULL) | ||
if (given) { | ||
memcpy(opts, given, sizeof(*opts)); | ||
else { | ||
const char *val = NULL; | ||
|
||
} else { | ||
GIT_INIT_STRUCTURE(opts, GIT_DIFF_FIND_OPTIONS_VERSION); | ||
} | ||
|
||
opts->flags = GIT_DIFF_FIND_RENAMES; | ||
if (!given || | ||
(given->flags & GIT_DIFF_FIND_ALL) == GIT_DIFF_FIND_BY_CONFIG) | ||
{ | ||
const char *val = NULL; | ||
|
||
if (git_config_get_string(&val, cfg, "diff.renames") < 0) | ||
giterr_clear(); | ||
else if (val && | ||
(!strcasecmp(val, "copies") || !strcasecmp(val, "copy"))) | ||
opts->flags = GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES; | ||
else if (val) { | ||
if (!strcasecmp(val, "false")) | ||
return GIT_PASSTHROUGH; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of using an error here, I think it is enough to just return 0 and then after the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice. I like that better. |
||
else if (!strcasecmp(val, "copies") || !strcasecmp(val, "copy")) | ||
opts->flags = GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES; | ||
else | ||
opts->flags = GIT_DIFF_FIND_RENAMES; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the above manipulation of flags should be updated to preserve the high-order bits that control whitespace, etc. The The other two can just get There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! I added a test that checks for clobberation. |
||
} | ||
|
||
GITERR_CHECK_VERSION(opts, GIT_DIFF_FIND_OPTIONS_VERSION, "git_diff_find_options"); | ||
GITERR_CHECK_VERSION(given, GIT_DIFF_FIND_OPTIONS_VERSION, "git_diff_find_options"); | ||
|
||
/* some flags imply others */ | ||
|
||
|
@@ -828,7 +834,7 @@ int git_diff_find_similar( | |
git_diff_file swap; | ||
|
||
if ((error = normalize_find_opts(diff, &opts, given_opts)) < 0) | ||
return error; | ||
return (error == GIT_PASSTHROUGH) ? 0 : error; | ||
|
||
num_deltas = diff->deltas.length; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably just be using
git__parse_bool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooooh, pretty. ✨