add status config and command line options for rename detection
PATCH 1/1 add status config and command line options for rename detection
Add a new config status.renames setting to enable turning off rename detection during status. This setting will default to the value of diff.renames.
Add a new config status.renamelimit setting to to enable bounding the time spent finding out inexact renames during status. This setting will default to the value of diff.renamelimit.
Add status --no-renames command line option that enables overriding the config setting from the command line. Add --find-renames[=<n>] to enable detecting renames and optionaly setting the similarity index from the command line.
---
Notes:
Base Ref:
Web-Diff: https://github.com/benpeart/git/commit/aa977d2964
Checkout: git fetch https://github.com/benpeart/git status-renames-v1 && git checkout aa977d2964Documentation/config.txt | 9 ++++ builtin/commit.c | 57 +++++++++++++++++++++++++ diff.c | 2 +- diff.h | 1 + t/t7525-status-rename.sh | 90 ++++++++++++++++++++++++++++++++++++++++ wt-status.c | 12 ++++++ wt-status.h | 4 +- 7 files changed, 173 insertions(+), 2 deletions(-) create mode 100644 t/t7525-status-rename.sh
Documentation/config.txt +9 -0
@@ -3119,6 +3119,15 @@ status.displayCommentPrefix:: behavior of linkgit:git-status[1] in Git 1.8.4 and previous. Defaults to false. +status.renameLimit:: + The number of files to consider when performing rename detection; + if not specified, defaults to the value of diff.renameLimit. + +status.renames:: + Whether and how Git detects renames. If set to "false", + rename detection is disabled. If set to "true", basic rename + detection is enabled. Defaults to the value of diff.renames. + status.showStash:: If set to true, linkgit:git-status[1] will display the number of entries currently stashed away.
builtin/commit.c +57 -0
92 lines not on this page · raw message
diff.c +1 -1
@@ -177,7 +177,7 @@ static int parse_submodule_params(struct diff_options *options, const char *valureturn 0 ; } -static int git_config_rename (const char *var,const char *value) +int git_config_rename (const char *var,const char *value) {if (!value)return DIFF_DETECT_RENAME ;
diff.h +1 -0
@@ -324,6 +324,7 @@ extern int git_diff_ui_config(const char *var, const char *value, void *cb);extern void diff_setup (struct diff_options *);extern int diff_opt_parse (struct diff_options *,const char **,int ,const char *);extern void diff_setup_done (struct diff_options *); +extern int git_config_rename (const char *var,const char *value);#define DIFF_DETECT_RENAME 1#define DIFF_DETECT_COPY 2
t/t7525-status-rename.sh new file +90 -0
90 lines not on this page · raw message
wt-status.c +12 -0
@@ -138,6 +138,9 @@ void wt_status_prepare(struct wt_status *s) s->show_stash =0 ; s->ahead_behind_flags =AHEAD_BEHIND_UNSPECIFIED ; s->display_comment_prefix =0 ; + s->detect_rename =-1 ; + s->rename_score =-1 ; + s->rename_limit =-1 ; }static void wt_longstatus_print_unmerged_header (struct wt_status *s)
@@ -592,6 +595,9 @@ static void wt_status_collect_changes_worktree(struct wt_status *s) } rev.diffopt.format_callback = wt_status_collect_changed_cb; rev.diffopt.format_callback_data = s; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score;copy_pathspec (&rev.prune_data, &s->pathspec);run_diff_files (&rev,0 ); }
@@ -625,6 +631,9 @@ static void wt_status_collect_changes_index(struct wt_status *s) rev.diffopt.output_format |=DIFF_FORMAT_CALLBACK ; rev.diffopt.format_callback = wt_status_collect_updated_cb; rev.diffopt.format_callback_data = s; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score;copy_pathspec (&rev.prune_data, &s->pathspec);run_diff_index (&rev,1 ); }
@@ -982,6 +991,9 @@ static void wt_longstatus_print_verbose(struct wt_status *s)setup_revisions (0 ,NULL , &rev, &opt); rev.diffopt.output_format |=DIFF_FORMAT_PATCH ; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score; rev.diffopt.file = s->fp; rev.diffopt.close_file =0 ;/*
wt-status.h +3 -1
@@ -89,7 +89,9 @@ struct wt_status {int show_stash;int hints;enum ahead_behind_flags ahead_behind_flags; - +int detect_rename; +int rename_score; +int rename_limit;enum wt_status_format status_format;unsigned char sha1_commit[GIT_MAX_RAWSZ ];/* when not Initial */
base-commit: a92ae92585d8db14b7871f760f157256cd96742c
Signature · 1 line
2.17.0.windows.1
Quoted 2 lines · Ben Peart
Add a new config status.renames setting to enable turning off rename detection during status. This setting will default to the value of diff.renames.
Please add the reason you need this config key in the commit message. My guess (probably correct) is on super large repo (how large?), rename detection is just too slow (how long?) that it practically makes git-status unusable.
This information could be helpful when we optimize rename detection to be more efficient.
Quoted 11 lines
Add a new config status.renamelimit setting to to enable bounding the time spent finding out inexact renames during status. This setting will default to the value of diff.renamelimit.
Add status --no-renames command line option that enables overriding the config setting from the command line. Add --find-renames[=<n>] to enable detecting renames and optionaly setting the similarity index from the command line.
Origional-Patch-by Alejandro Pauly <[email protected]>Signed-off-by Ben Peart <[email protected]>
Signature · 1 line
Duy
Quoted 9 lines · Duy Nguyen
Quoted 2 lines · Ben Peart
Add a new config status.renames setting to enable turning off rename detection during status. This setting will default to the value of diff.renames.
Please add the reason you need this config key in the commit message. My guess (probably correct) is on super large repo (how large?), rename detection is just too slow (how long?) that it practically makes git-status unusable.
Yes, the reasons for this change are the same as for the patch that added these same flags for merge and have to do with the poor performance of rename detection with large repos. I'll update the commit message to be more descriptive (see below) and correct some spelling errors.
add status config and command line options for rename detection
After performing a merge that has conflicts, git status will by default attempt to detect renames which causes many objects to be examined. In a virtualized repo, those objects do not exist locally so the rename logic triggers them to be fetched from the server. This results in the status call taking hours to complete on very large repos. Even in a small repo (the GVFS repo) turning off break and rename detection has a significant impact:
git status --no-renames:
31 secs., 105 loose object downloads
git status --no-breaks
7 secs., 17 loose object downloads
git status --no-breaks --no-renames
1 sec., 1 loose object download
Add a new config status.renames setting to enable turning off rename detection during status. This setting will default to the value of diff.renames.
Add a new config status.renamelimit setting to to enable bounding the time spent finding out inexact renames during status. This setting will default to the value of diff.renamelimit.
Add status --no-renames command line option that enables overriding the config setting from the command line. Add --find-renames[=<n>] to enable detecting renames and optionally setting the similarity index from the command line.
Note: I removed the --no-breaks command line option from the original patch as it will no longer be needed once the default has been changed [1] to turn it off.
[1] https://public-inbox.org/git/[email protected]/
Quoted 14 lines
This information could be helpful when we optimize rename detection to be more efficient.
Quoted 11 lines
Add a new config status.renamelimit setting to to enable bounding the time spent finding out inexact renames during status. This setting will default to the value of diff.renamelimit.
Add status --no-renames command line option that enables overriding the config setting from the command line. Add --find-renames[=<n>] to enable detecting renames and optionaly setting the similarity index from the command line.
Origional-Patch-by Alejandro Pauly <[email protected]>Signed-off-by Ben Peart <[email protected]>
Hi Ben,
Overall I think this is good, but I have lots of nit-picky things to bring up. :-)
Quoted 3 lines · Ben Peart
Add status --no-renames command line option that enables overriding the config setting from the command line. Add --find-renames[=<n>] to enable detecting renames and optionaly setting the similarity index from the command line.
s/optionaly/optionally/
Quoted 2 lines
Notes:
Base Ref:
No base ref? ;-)
Documentation/config.txt status.displayCommentPrefix:: · line 3129
Quoted 8 lines
Documentation/config.txt +8
-0+status.renameLimit:: + The number of files to consider when performing rename detection; + if not specified, defaults to the value of diff.renameLimit. + +status.renames:: + Whether and how Git detects renames. If set to "false", + rename detection is disabled. If set to "true", basic rename + detection is enabled. Defaults to the value of diff.renames.
I suspect that status.renames should mention "copy", just as diff.renames does. (We didn't mention it in merge.renames, because merge isn't an operation for which copy detection can be useful -- at least not until the diffstat at the end of the merge is controlled by merge.renames as well...)
Also, do these two config settings only affect 'git status', or does it also affect the status shown when composing a commit message (assuming the user hasn't turned commit.status off)? Does it affect git commit --dry-run too?
builtin/commit.c static int have_option_m; · line 115
Quoted 10 lines
builtin/commit.c +4
-0@@ -109,6 +109,10 @@ static int have_option_m;static struct strbuf message =STRBUF_INIT ;static enum wt_status_format status_format =STATUS_FORMAT_UNSPECIFIED ; +static int diff_detect_rename =-1 ; +static int status_detect_rename =-1 ; +static int diff_rename_limit =-1 ; +static int status_rename_limit =-1 ;
Could we replace these four variables with just two: detect_rename and rename_limit? Keeping these separate invites people to write code using only one of the settings rather than the appropriate inherited mixture of them, resulting in a weird bug. More on this below...
builtin/commit.c static int git_status_config(const char *k, const char *v, void *cb) · line 1283
Quoted 12 lines
builtin/commit.c +8
-0@@ -1259,11 +1273,29 @@ static int git_status_config(const char *k, const char *v, void *cb)return error (_ ("Invalid untracked files mode '%s'" ), v);return 0 ; } +if (!strcmp (k,"diff.renamelimit" )) { + diff_rename_limit =git_config_int (k, v); +return 0 ; + } +if (!strcmp (k,"status.renamelimit" )) { + status_rename_limit =git_config_int (k, v); +return 0 ; + }
Here, since you're already checking diff.renamelimit first, you can just set rename_limit in both blocks and not need both diff_rename_limit and status_rename_limit. (Similar can be said for diff.renames/status.renames.)
<snip>
builtin/commit.c int cmd_status(int argc, const char **argv, const char *prefix) · line 1335
Quoted 8 lines
builtin/commit.c +4
-0@@ -1297,6 +1329,10 @@ int cmd_status(int argc, const char **argv, const char *prefix)N_ ("ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)" ), PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },OPT_COLUMN (0 ,"column" , &s.colopts,N_ ("list untracked files in columns" )), +OPT_BOOL (0 ,"no-renames" , &no_renames,N_ ("do not detect renames" )), + { OPTION_CALLBACK, 'M', "find-renames", &rename_score_arg, +N_ ("n" ),N_ ("detect renames, optionally set similarity index" ), + PARSE_OPT_OPTARG, opt_parse_rename_score },
Should probably also document these options in Documentation/git-status.txt (and maybe Documentation/git-commit.txt as well).
Not sure if we want to add a flag for copy detection (similar to git-diff's -C/--find-copies and --find-copies-harder), or just leave that for when someone finds a need. If left out, might want to just mention that it was considered and intentionally omitted for now in the commit message.
builtin/commit.c int cmd_status(int argc, const char **argv, const char *prefix) · line 1377
Quoted 7 lines
builtin/commit.c +3
-0@@ -1336,6 +1372,27 @@ int cmd_status(int argc, const char **argv, const char *prefix) s.ignore_submodule_arg = ignore_submodule_arg; s.status_format = status_format; s.verbose = verbose; + s.detect_rename = no_renames >=0 ? !no_renames : + status_detect_rename >=0 ? status_detect_rename : + diff_detect_rename >= 0 ? diff_detect_rename :
Combining the four vars into two as mentioned above would allow combining the last two lines above into one.
builtin/commit.c int cmd_status(int argc, const char **argv, const char *prefix) · line 1379
Quoted 1 line
builtin/commit.c +1
-0+if ((intptr_t )rename_score_arg !=-1 ) {
I don't understand why rename_score_arg is a (char*) and then you need to cast to intptr_t, but that may just be because I haven't done much of anything with option parsing. A quick look at the docs isn't making it clear to me, though; could you enlighten me?
builtin/commit.c int cmd_status(int argc, const char **argv, const char *prefix) · line 1379
Quoted 1 line
builtin/commit.c +1
-0+ s.detect_rename =DIFF_DETECT_RENAME ;
What if status.renames is 'copy' but someone wants to override the score for detecting renames and pass --find-renames=40? Does the --find-renames override and degrade the 'copy'? I think it'd make more sense to increase s.detect_rename to at least DIFF_DETECT_RENAME, rather than just outright setting it here.
builtin/commit.c int cmd_status(int argc, const char **argv, const char *prefix) · line 1385
Quoted 5 lines
builtin/commit.c +5
-0+if (rename_score_arg) + s.rename_score =parse_rename_score (&rename_score_arg); + } + s.rename_limit = status_rename_limit >=0 ? status_rename_limit : + diff_rename_limit >= 0 ? diff_rename_limit :
Again, combination of variables could allow these last two lines to be combined.
builtin/commit.c int cmd_status(int argc, const char **argv, const char *prefix) · line 1395
Quoted 10 lines
builtin/commit.c +10
-0+ s.rename_limit; + +/* +* We do not have logic to handle the detection of copies. In +* fact, it may not even make sense to add such logic: would we +* really want a change to a base file to be propagated through +* multiple other files by a merge? +*/ +if (s.detect_rename >DIFF_DETECT_RENAME ) + s.detect_rename =DIFF_DETECT_RENAME ;
This comment and code made sense in merge-recursive.c (which doesn't show detected diffs/renames/copies but just uses them for internal processing logic). It does not make sense here; git status could show detected copies much like git diff -C --name-status shows it. In fact, a quick grep for DIFF_STATUS_COPIED shows multiple hits in wt-status.c, so I suspect it already has the necessary logic for displaying copies.
I looked over the rest of the patch. Nice testcases. Adding a couple more testcases around copy detection could be useful.
Quoted 6 lines · Elijah Newren
Hi Ben,
Overall I think this is good, but I have lots of nit-picky things to bring up. :-)
Thank you for the review. I appreciate the extra set of eyes on these changes. Especially when dealing with the merge logic and settings which I am unfamiliar with.
Quoted 7 lines
I suspect that status.renames should mention "copy", just as diff.renames does. (We didn't mention it in merge.renames, because merge isn't an operation for which copy detection can be useful -- at least not until the diffstat at the end of the merge is controlled by merge.renames as well...)
I wasn't supporting copy (as you noticed later in the patch) but will update the patch to do so and update the documentation appropriately.
Quoted 5 lines
Also, do these two config settings only affect 'git status', or does it also affect the status shown when composing a commit message (assuming the user hasn't turned commit.status off)? Does it affect
git commit --dry-runtoo?
The config settings only affect 'git status'
Quoted 5 lines
Quoted 5 lines
builtin/commit.c +0
-0@@ -109,6 +109,10 @@ static int have_option_m;static struct strbuf message =STRBUF_INIT ;
Quoted 11 lines
builtin/commit.c static int have_option_m; · line 115
Quoted 5 lines
builtin/commit.c +4
-0static enum wt_status_format status_format =STATUS_FORMAT_UNSPECIFIED ; +static int diff_detect_rename =-1 ; +static int status_detect_rename =-1 ; +static int diff_rename_limit =-1 ; +static int status_rename_limit =-1 ;Could we replace these four variables with just two:
detect_renameandrename_limit? Keeping these separate invites people to write code using only one of the settings rather than the appropriate inherited mixture of them, resulting in a weird bug. More on this below...
This model was inherited from the diff code and replicated to the merge code. However, it would be nice to get rid of these 4 static variables.
See below for a proposal on how to do that...
Quoted 9 lines
Quoted 9 lines
builtin/commit.c +5
-0@@ -1259,11 +1273,29 @@ static int git_status_config(const char *k, const char *v, void *cb)return error (_ ("Invalid untracked files mode '%s'" ), v);return 0 ; } +if (!strcmp (k,"diff.renamelimit" )) { + diff_rename_limit =git_config_int (k, v); +return 0 ; + } +if (!strcmp (k,"status.renamelimit" )) {
Quoted 8 lines
builtin/commit.c static int git_status_config(const char *k, const char *v, void *cb) · line 1283
Quoted 3 lines
builtin/commit.c +3
-0+ status_rename_limit =git_config_int (k, v); +return 0 ; + }Here, since you're already checking diff.renamelimit first, you can just set
rename_limitin both blocks and not need bothdiff_rename_limitandstatus_rename_limit. (Similar can be said for diff.renames/status.renames.)
It really doesn't work that way - the call back is called for every config setting and there is no specific order they are called with. Typically, you just test for and save off any that you care about like I"m doing here.
I can update the logic here so that as I save off the settings that it will also enforce the priority model (ie the diff setting can't override the status setting) and then compute the final value once I have the command line arguments as they override either config setting (if present).
On the plus side, this change passes the red/green test but it now splits the priority logic into two places and doesn't match with how diff and merge handle this same issue.
Quoted 15 lines
<snip>
builtin/commit.c int cmd_status(int argc, const char **argv, const char *prefix) · line 1335
Quoted 8 lines
builtin/commit.c +4
-0@@ -1297,6 +1329,10 @@ int cmd_status(int argc, const char **argv, const char *prefix)N_ ("ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)" ), PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },OPT_COLUMN (0 ,"column" , &s.colopts,N_ ("list untracked files in columns" )), +OPT_BOOL (0 ,"no-renames" , &no_renames,N_ ("do not detect renames" )), + { OPTION_CALLBACK, 'M', "find-renames", &rename_score_arg, +N_ ("n" ),N_ ("detect renames, optionally set similarity index" ), + PARSE_OPT_OPTARG, opt_parse_rename_score },Should probably also document these options in
Documentation/git-status.txt(and maybeDocumentation/git-commit.txtas well).
Good point, will do.
Quoted 7 lines
Not sure if we want to add a flag for copy detection (similar to git-diff's -C/--find-copies and --find-copies-harder), or just leave that for when someone finds a need. If left out, might want to just mention that it was considered and intentionally omitted for now in the commit message.
I tend to only implement the features I know are actually needed so intentionally omitted this (along with many other potential diff options).
Quoted 7 lines
builtin/commit.c int cmd_status(int argc, const char **argv, const char *prefix) · line 1379
Quoted 1 line
builtin/commit.c +1
-0+if ((intptr_t )rename_score_arg !=-1 ) {I don't understand why
rename_score_argis a (char*) and then you need to cast tointptr_t, but that may just be because I haven't done much of anything with option parsing. A quick look at the docs isn't making it clear to me, though; could you enlighten me?
Yes, it is related to making parse_options() do what we need. -1 means the command line option wasn't passed so use the default. NULL means the command line argument was passed but without the optional score. A non NULL, non -1 value means the optional score was passed and needs to be parsed. The (intptr_t_) cast is to enable comparing a pointer to an integer (-1) without generating a compiler warning.
Quoted 8 lines
builtin/commit.c int cmd_status(int argc, const char **argv, const char *prefix) · line 1337
Quoted 1 line
builtin/commit.c +1
-0+ s.detect_rename =DIFF_DETECT_RENAME ;What if status.renames is 'copy' but someone wants to override the score for detecting renames and pass --find-renames=40? Does the --find-renames override and degrade the 'copy'? I think it'd make more sense to increase s.detect_rename to at least
DIFF_DETECT_RENAME, rather than just outright setting it here.
I understand your argument and agree that it makes some sense. I am matching the same logic in merge-recursive.c which just sets detect_rename to 1 in this case. I believe more strongly that they should be consistent than in one option over the other.
If I'm reading the merge logic for this case incorrectly or if you're willing to patch the merge logic to match :), I'm happy to change this to:
if (s.detect_rename < DIFF_DETECT_RENAME) s.detect_rename = DIFF_DETECT_RENAME;
Quoted 11 lines
builtin/commit.c int cmd_status(int argc, const char **argv, const char *prefix) · line 1395
Quoted 10 lines
builtin/commit.c +10
-0+ s.rename_limit; + +/* +* We do not have logic to handle the detection of copies. In +* fact, it may not even make sense to add such logic: would we +* really want a change to a base file to be propagated through +* multiple other files by a merge? +*/ +if (s.detect_rename >DIFF_DETECT_RENAME ) + s.detect_rename =DIFF_DETECT_RENAME ;
Quoted 8 lines
This comment and code made sense in
merge-recursive.c(which doesn't show detected diffs/renames/copies but just uses them for internal processing logic). It does not make sense here; git status could show detected copies much likegit diff -C --name-statusshows it. In fact, a quick grep forDIFF_STATUS_COPIEDshows multiple hits inwt-status.c, so I suspect it already has the necessary logic for displaying copies.
Clearly I was following my similar patch series for merge too closely without thinking through how they should be different. Thanks for catching this. Gone. :)
PATCH v2 1/1 add status config and command line options for rename detection
In reply to Ben PeartAfter performing a merge that has conflicts, git status will by default attempt to detect renames which causes many objects to be examined. In a virtualized repo, those objects do not exist locally so the rename logic triggers them to be fetched from the server. This results in the status call taking hours to complete on very large repos. Even in a small repo (the GVFS repo) turning off break and rename detection has a significant impact:
git status --no-renames:
31 secs., 105 loose object downloads
git status --no-breaks
7 secs., 17 loose object downloads
git status --no-breaks --no-renames
1 sec., 1 loose object download
Add a new config status.renames setting to enable turning off rename detection during status. This setting will default to the value of diff.renames.
Add a new config status.renamelimit setting to to enable bounding the time spent finding out inexact renames during status. This setting will default to the value of diff.renamelimit.
Add status --no-renames command line option that enables overriding the config setting from the command line. Add --find-renames[=<n>] to enable detecting renames and optionally setting the similarity index from the command line.
Note: I removed the --no-breaks command line option from the original patch as it will no longer be needed once the default has been changed [1] to turn it off.
[1] https://public-inbox.org/git/[email protected]/
---
Notes:
Base Ref: master
Web-Diff: https://github.com/benpeart/git/commit/823212725b
Checkout: git fetch https://github.com/benpeart/git status-renames-v2 && git checkout 823212725b
### Interdiff (v1..v2):
diff --git a/Documentation/config.txt b/Documentation/config.txt
index b79b83c587..9c8eca05b1 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -3126,7 +3126,8 @@ status.renameLimit::
status.renames::
Whether and how Git detects renames. If set to "false",
rename detection is disabled. If set to "true", basic rename
- detection is enabled. Defaults to the value of diff.renames.
+ detection is enabled. If set to "copies" or "copy", Git will
+ detect copies, as well. Defaults to the value of diff.renames.
status.showStash::
If set to true, linkgit:git-status[1] will display the number of
diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
index c16e27e63d..c4467ffb98 100644
--- a/Documentation/git-status.txt
+++ b/Documentation/git-status.txt
@@ -135,6 +135,16 @@ ignored, then the directory is not shown, but all contents are shown.
Display or do not display detailed ahead/behind counts for the
branch relative to its upstream branch. Defaults to true.
+--renames::
+--no-renames::
+ Turn on/off rename detection regardless of user configuration.
+ See also linkgit:git-diff[1] `--no-renames`.
+
+--find-renames[=<n>]::
+ Turn on rename detection, optionally setting the similarity
+ threshold.
+ See also linkgit:git-diff[1] `--find-renames`.
+
<pathspec>...::
See the 'pathspec' entry in linkgit:gitglossary[7].
diff --git a/builtin/commit.c b/builtin/commit.c
index a545096ddd..db886277f4 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -109,10 +109,6 @@ static int have_option_m;
static struct strbuf message = STRBUF_INIT;
static enum wt_status_format status_format = STATUS_FORMAT_UNSPECIFIED;
-static int diff_detect_rename = -1;
-static int status_detect_rename = -1;
-static int diff_rename_limit = -1;
-static int status_rename_limit = -1;
static int opt_parse_porcelain(const struct option *opt, const char *arg, int unset)
{
@@ -1274,19 +1270,21 @@ static int git_status_config(const char *k, const char *v, void *cb)
return 0;
}
if (!strcmp(k, "diff.renamelimit")) {
- diff_rename_limit = git_config_int(k, v);
+ if (s->rename_limit == -1)
+ s->rename_limit = git_config_int(k, v);
return 0;
}
if (!strcmp(k, "status.renamelimit")) {
- status_rename_limit = git_config_int(k, v);
+ s->rename_limit = git_config_int(k, v);
return 0;
}
if (!strcmp(k, "diff.renames")) {
- diff_detect_rename = git_config_rename(k, v);
+ if (s->detect_rename == -1)
+ s->detect_rename = git_config_rename(k, v);
return 0;
}
if (!strcmp(k, "status.renames")) {
- status_detect_rename = git_config_rename(k, v);
+ s->detect_rename = git_config_rename(k, v);
return 0;
}
return git_diff_ui_config(k, v, NULL);
@@ -1372,27 +1370,13 @@ int cmd_status(int argc, const char **argv, const char *prefix)
s.ignore_submodule_arg = ignore_submodule_arg;
s.status_format = status_format;
s.verbose = verbose;
- s.detect_rename = no_renames >= 0 ? !no_renames :
- status_detect_rename >= 0 ? status_detect_rename :
- diff_detect_rename >= 0 ? diff_detect_rename :
- s.detect_rename;
+ if (no_renames != -1)
+ s.detect_rename = !no_renames;
if ((intptr_t)rename_score_arg != -1) {
s.detect_rename = DIFF_DETECT_RENAME;
if (rename_score_arg)
s.rename_score = parse_rename_score(&rename_score_arg);
}
- s.rename_limit = status_rename_limit >= 0 ? status_rename_limit :
- diff_rename_limit >= 0 ? diff_rename_limit :
- s.rename_limit;
-
- /*
- * We do not have logic to handle the detection of copies. In
- * fact, it may not even make sense to add such logic: would we
- * really want a change to a base file to be propagated through
- * multiple other files by a merge?
- */
- if (s.detect_rename > DIFF_DETECT_RENAME)
- s.detect_rename = DIFF_DETECT_RENAME;
wt_status_collect(&s);
### PatchesDocumentation/config.txt | 10 ++++ Documentation/git-status.txt | 10 ++++ builtin/commit.c | 41 ++++++++++++++++ diff.c | 2 +- diff.h | 1 + t/t7525-status-rename.sh | 90 ++++++++++++++++++++++++++++++++++++ wt-status.c | 12 +++++ wt-status.h | 4 +- 8 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 t/t7525-status-rename.sh
Documentation/config.txt +10 -0
@@ -3119,6 +3119,16 @@ status.displayCommentPrefix:: behavior of linkgit:git-status[1] in Git 1.8.4 and previous. Defaults to false. +status.renameLimit:: + The number of files to consider when performing rename detection; + if not specified, defaults to the value of diff.renameLimit. + +status.renames:: + Whether and how Git detects renames. If set to "false", + rename detection is disabled. If set to "true", basic rename + detection is enabled. If set to "copies" or "copy", Git will + detect copies, as well. Defaults to the value of diff.renames. + status.showStash:: If set to true, linkgit:git-status[1] will display the number of entries currently stashed away.
Documentation/git-status.txt +10 -0
@@ -135,6 +135,16 @@ ignored, then the directory is not shown, but all contents are shown. Display or do not display detailed ahead/behind counts for the branch relative to its upstream branch. Defaults to true. +--renames:: +--no-renames:: + Turn on/off rename detection regardless of user configuration. + See also linkgit:git-diff[1] `--no-renames`. + +--find-renames[=<n>]:: + Turn on rename detection, optionally setting the similarity + threshold. + See also linkgit:git-diff[1] `--find-renames`. + <pathspec>...:: See the 'pathspec' entry in linkgit:gitglossary[7].
builtin/commit.c +41 -0
70 lines not on this page · raw message
diff.c +1 -1
@@ -177,7 +177,7 @@ static int parse_submodule_params(struct diff_options *options, const char *valureturn 0 ; } -static int git_config_rename (const char *var,const char *value) +int git_config_rename (const char *var,const char *value) {if (!value)return DIFF_DETECT_RENAME ;
diff.h +1 -0
@@ -324,6 +324,7 @@ extern int git_diff_ui_config(const char *var, const char *value, void *cb);extern void diff_setup (struct diff_options *);extern int diff_opt_parse (struct diff_options *,const char **,int ,const char *);extern void diff_setup_done (struct diff_options *); +extern int git_config_rename (const char *var,const char *value);#define DIFF_DETECT_RENAME 1#define DIFF_DETECT_COPY 2
t/t7525-status-rename.sh new file +90 -0
90 lines not on this page · raw message
wt-status.c +12 -0
@@ -138,6 +138,9 @@ void wt_status_prepare(struct wt_status *s) s->show_stash =0 ; s->ahead_behind_flags =AHEAD_BEHIND_UNSPECIFIED ; s->display_comment_prefix =0 ; + s->detect_rename =-1 ; + s->rename_score =-1 ; + s->rename_limit =-1 ; }static void wt_longstatus_print_unmerged_header (struct wt_status *s)
@@ -592,6 +595,9 @@ static void wt_status_collect_changes_worktree(struct wt_status *s) } rev.diffopt.format_callback = wt_status_collect_changed_cb; rev.diffopt.format_callback_data = s; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score;copy_pathspec (&rev.prune_data, &s->pathspec);run_diff_files (&rev,0 ); }
@@ -625,6 +631,9 @@ static void wt_status_collect_changes_index(struct wt_status *s) rev.diffopt.output_format |=DIFF_FORMAT_CALLBACK ; rev.diffopt.format_callback = wt_status_collect_updated_cb; rev.diffopt.format_callback_data = s; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score;copy_pathspec (&rev.prune_data, &s->pathspec);run_diff_index (&rev,1 ); }
@@ -982,6 +991,9 @@ static void wt_longstatus_print_verbose(struct wt_status *s)setup_revisions (0 ,NULL , &rev, &opt); rev.diffopt.output_format |=DIFF_FORMAT_PATCH ; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score; rev.diffopt.file = s->fp; rev.diffopt.close_file =0 ;/*
wt-status.h +3 -1
@@ -89,7 +89,9 @@ struct wt_status {int show_stash;int hints;enum ahead_behind_flags ahead_behind_flags; - +int detect_rename; +int rename_score; +int rename_limit;enum wt_status_format status_format;unsigned char sha1_commit[GIT_MAX_RAWSZ ];/* when not Initial */
base-commit: a92ae92585d8db14b7871f760f157256cd96742c
Signature · 1 line
2.17.0.windows.1
Hi Ben,
Quoted 6 lines · Ben Peart
After performing a merge that has conflicts, git status will by default attempt to detect renames which causes many objects to be examined. In a virtualized repo, those objects do not exist locally so the rename logic triggers them to be fetched from the server. This results in the status call taking hours to complete on very large repos. Even in a small repo (the GVFS repo) turning off break and rename detection has a significant impact:
It'd be nice if you could show that impact by comparing 'git status' to 'git status --no-renames', for some repo. Showing only the latter gives us no way to assess the impact.
Quoted 8 lines
git status --no-renames:
31 secs., 105 loose object downloadsgit status --no-breaks
7 secs., 17 loose object downloadsgit status --no-breaks --no-renames
1 sec., 1 loose object download
This patch doesn't add a --no-breaks option and it doesn't exist previously, so adding it to the commit message serves to confuse rather than help. I'd just drop the last two of these (and redo the timing for --no-renames assuming you are built on em/status-rename-config).
Quoted 6 lines
Add a new config status.renames setting to enable turning off rename detection during status. This setting will default to the value of diff.renames.
Add a new config status.renamelimit setting to to enable bounding the time spent finding out inexact renames during status. This setting will default to the value of diff.renamelimit.
It may be worth mentioning that these config settings also affect 'git commit' (and it does, in my testing, which I think is a good thing).
Quoted 3 lines
Add status --no-renames command line option that enables overriding the config setting from the command line. Add --find-renames[=<n>] to enable detecting renames and optionally setting the similarity index from the command line.
The command line options are specific to 'git status'. I don't really have a strong opinion on whether they should also be added to git-commit; I suspect users would be more likely to use the config options in order to set it once and forget about it and that users would be more likely to want to override their config setting for status than for commit.
Quoted 4 lines
Note: I removed the --no-breaks command line option from the original patch as it will no longer be needed once the default has been changed [1] to turn it off.
I'd just drop these lines from the commit message, and instead mention that your patch depends on em/status-rename-config.
Quoted 6 lines
Original-Patch-by Alejandro Pauly <[email protected]>Signed-off-by Ben Peart <[email protected]>---
Notes:
Base Ref: master
This patch does not apply to master; it has conflicts.
Quoted 1 line
Web-Diff: https://github.com/benpeart/git/commit/823212725b
This web diff shows em/status-rename-config as the parent commit, not master. Since your commit message mentions you want the change to break detection provided by that series, just listing it as the explicit base seems like the right way to go.
Quoted 1 line
### Interdiff (v1..v2):
Thanks.
builtin/commit.c int cmd_status(int argc, const char **argv, const char *prefix) · line 1376
Quoted 2 lines
builtin/commit.c +2
-0+if ((intptr_t )rename_score_arg !=-1 ) { + s.detect_rename =DIFF_DETECT_RENAME ;
I'd still prefer this was a
if (s.detect_rename < DIFF_DETECT_RENAME)
s.detect_rename = DIFF_DETECT_RENAME;
If a user specifies they are willing to pay for copy detection, but then just passes --find-renames=40% because they want to find more renames, it seems odd to disable copy detection to me.
Quoted 1 line
+++
b/t/t7525-status-rename.sh
Testcases look good. It'd be nice to also add a few testcases where copy detection is turned on -- in particular, I'd like to see one with --find-renames=$DIFFERENT_THAN_DEFAULT being passed when merge.renames=copies.
Quoted 5 lines
t/t7525-status-rename.sh new file +5
-0+test_expect_success 'setup' ' + echo 1 >original && + git add . && + git commit -m"Adding original file." && + mv original renamed &&
t/t7525-status-rename.sh line 20
Quoted 10 lines
t/t7525-status-rename.sh new file +8
-0+ echo 2 >> renamed && + git add . +' +cat >.gitignore <<\EOF +.gitignore +expect* +actual* +EOF
Can this just be included in the setup?
Everything else in the patch looked good to me.
Quoted 10 lines · Elijah Newren
Hi Ben,
Quoted 6 lines · Ben Peart
After performing a merge that has conflicts, git status will by default attempt to detect renames which causes many objects to be examined. In a virtualized repo, those objects do not exist locally so the rename logic triggers them to be fetched from the server. This results in the status call taking hours to complete on very large repos. Even in a small repo (the GVFS repo) turning off break and rename detection has a significant impact:
Quoted 4 lines
It'd be nice if you could show that impact by comparing 'git status' to 'git status --no-renames', for some repo. Showing only the latter gives us no way to assess the impact.
Given the example perf impact is arbitrary (the actual example that triggered this patch took status from 2+ hours to seconds) and can't be replicated using the current performance tools in git, I'm just going drop the specific numbers. I believe the patch is worth while just to give users the flexibility to control these behaviors.
Quoted 6 lines
Quoted 6 lines
git status --no-renames:
31 secs., 105 loose object downloadsgit status --no-breaks
7 secs., 17 loose object downloads
Quoted 9 lines
Quoted 2 lines
git status --no-breaks --no-renames
1 sec., 1 loose object downloadThis patch doesn't add a --no-breaks option and it doesn't exist previously, so adding it to the commit message serves to confuse rather than help. I'd just drop the last two of these (and redo the timing for --no-renames assuming you are built on em/status-rename-config).
OK
Quoted 10 lines
Quoted 6 lines
Add a new config status.renames setting to enable turning off rename detection during status. This setting will default to the value of diff.renames.
Add a new config status.renamelimit setting to to enable bounding the time spent finding out inexact renames during status. This setting will default to the value of diff.renamelimit.
It may be worth mentioning that these config settings also affect 'git commit' (and it does, in my testing, which I think is a good thing).
I agree this is a good thing as the other status settings behave the same way. I'll update the documentation to reflect this as well.
Quoted 11 lines
Quoted 3 lines
Add status --no-renames command line option that enables overriding the config setting from the command line. Add --find-renames[=<n>] to enable detecting renames and optionally setting the similarity index from the command line.
The command line options are specific to 'git status'. I don't really have a strong opinion on whether they should also be added to git-commit; I suspect users would be more likely to use the config options in order to set it once and forget about it and that users would be more likely to want to override their config setting for status than for commit.
Quoted 8 lines
Quoted 4 lines
Note: I removed the --no-breaks command line option from the original patch as it will no longer be needed once the default has been changed [1] to turn it off.
I'd just drop these lines from the commit message, and instead mention that your patch depends on em/status-rename-config.
OK
Quoted 11 lines
builtin/commit.c int cmd_status(int argc, const char **argv, const char *prefix) · line 1376
Quoted 2 lines
builtin/commit.c +2
-0+if ((intptr_t )rename_score_arg !=-1 ) { + s.detect_rename =DIFF_DETECT_RENAME ;I'd still prefer this was a
if (s.detect_rename <DIFF_DETECT_RENAME)
s.detect_rename =DIFF_DETECT_RENAME;If a user specifies they are willing to pay for copy detection, but then just passes --find-renames=40% because they want to find more renames, it seems odd to disable copy detection to me.
I agree and will change it. It is unfortunate this will behave differently than it does with merge. Fixing the merge behavior to match is outside the scope of this patch.
Quoted 7 lines
Quoted 1 line
+++
b/t/t7525-status-rename.shTestcases look good. It'd be nice to also add a few testcases where copy detection is turned on -- in particular, I'd like to see one with --find-renames=$DIFFERENT_THAN_DEFAULT being passed when merge.renames=copies.
OK. I also added tests to verify the settings correctly impact commit.
Quoted 11 lines
Quoted 9 lines
t/t7525-status-rename.sh new file +8
-0+test_expect_success 'setup' ' + echo 1 >original && + git add . && + git commit -m"Adding original file." && + mv original renamed && + echo 2 >> renamed && + git add . +'
Quoted 8 lines
t/t7525-status-rename.sh line 20
Quoted 5 lines
t/t7525-status-rename.sh new file +5
-0+cat >.gitignore <<\EOF +.gitignore +expect* +actual* +EOFCan this just be included in the setup?
OK
Quoted 3 lines
Everything else in the patch looked good to me.
Hi Ben,
Quoted 9 lines · Ben Peart
Quoted 2 lines · Elijah Newren
On Thu, May 10, 2018 at 7:16 AM, Ben Peart <[email protected]> wrote:
Given the example perf impact is arbitrary (the actual example that triggered this patch took status from 2+ hours to seconds) and can't be replicated using the current performance tools in git, I'm just going drop the specific numbers. I believe the patch is worth while just to give users the flexibility to control these behaviors.
Your parenthetical statement of timing going from hours to seconds I think would be great; I don't think we need precise numbers.
Quoted 8 lines
Quoted 8 lines
builtin/commit.c int cmd_status(int argc, const char **argv, const char *prefix) · line 1376
Quoted 2 lines
builtin/commit.c +2
-0+if ((intptr_t )rename_score_arg !=-1 ) { + s.detect_rename =DIFF_DETECT_RENAME ;I'd still prefer this was a
if (s.detect_rename <DIFF_DETECT_RENAME)
s.detect_rename =DIFF_DETECT_RENAME;
Quoted 8 lines
Quoted 4 lines
If a user specifies they are willing to pay for copy detection, but then just passes --find-renames=40% because they want to find more renames, it seems odd to disable copy detection to me.
I agree and will change it. It is unfortunate this will behave differently than it does with merge. Fixing the merge behavior to match is outside the scope of this patch.
I agree that changing merge is outside the scope of this patch, but I'm curious what change you have in mind for it to "make it match". In particular, merge-recursive.c already has (or will shortly have)
+ if (opts.detect_rename > DIFF_DETECT_RENAME)
+ opts.detect_rename = DIFF_DETECT_RENAME;
from your commit 85b460305ce7 ("merge: add merge.renames config setting", 2018-05-02), so I'm not sure why we'd want to carefully propagate a larger value for o->{diff,merge}_detect_rename prior to this point. If it's just "future proofing" because you suspect that copy information could be useful to the merging algorithm and we'll eventually get rid of these two lines of code, then I could get behind such a change, though color me skeptical that copy information would ever turn out to be useful in that context.
The one place copy detection does make sense inside a merge is for the diffstat shown at the end (from builtin/merge.c), but it currently isn't controlled by any configuration setting at all. When it is hooked up, it'd probably store the value separately from merge-recursive's internal o->{diff,merge}_detect_rename anyway, because builtin/merge.c's diffstat should be controlled by the relevant confiig settings and flags (merge.renames, diff.renames, -Xfind-renames, etc.) regardless of which merge strategy (recursive, resolve, octopus, ours, ort) is employed. And when that is hooked up, I agree with you that it should look like what you've done with status.renames here. In fact, if you'd like to take a crack at it, I think you'd do a great job. :-) If not, it's on my list of things to do.
Quoted 7 lines
Quoted 5 lines
Testcases look good. It'd be nice to also add a few testcases where copy detection is turned on -- in particular, I'd like to see one with --find-renames=$DIFFERENT_THAN_DEFAULT being passed when merge.renames=copies.
OK. I also added tests to verify the settings correctly impact commit.
Nice!
Quoted 38 lines · Elijah Newren
Hi Ben,
Quoted 9 lines · Ben Peart
Quoted 2 lines · Elijah Newren
On Thu, May 10, 2018 at 7:16 AM, Ben Peart <[email protected]> wrote:
Given the example perf impact is arbitrary (the actual example that triggered this patch took status from 2+ hours to seconds) and can't be replicated using the current performance tools in git, I'm just going drop the specific numbers. I believe the patch is worth while just to give users the flexibility to control these behaviors.
Your parenthetical statement of timing going from hours to seconds I think would be great; I don't think we need precise numbers.
Quoted 8 lines
Quoted 8 lines
builtin/commit.c int cmd_status(int argc, const char **argv, const char *prefix) · line 1376
Quoted 2 lines
builtin/commit.c +2
-0+if ((intptr_t )rename_score_arg !=-1 ) { + s.detect_rename =DIFF_DETECT_RENAME ;I'd still prefer this was a
if (s.detect_rename <DIFF_DETECT_RENAME)
s.detect_rename =DIFF_DETECT_RENAME;Quoted 8 lines
Quoted 4 lines
If a user specifies they are willing to pay for copy detection, but then just passes --find-renames=40% because they want to find more renames, it seems odd to disable copy detection to me.
I agree and will change it. It is unfortunate this will behave differently than it does with merge. Fixing the merge behavior to match is outside the scope of this patch.
I agree that changing merge is outside the scope of this patch, but I'm curious what change you have in mind for it to "make it match". In particular,
merge-recursive.calready has (or will shortly have)(quoted diff) +2
-0+ if (opts.detect_rename > DIFF_DETECT_RENAME) + opts.detect_rename = DIFF_DETECT_RENAME;
Quoted 2 lines
from your commit
85b460305ce7("merge: add merge.renames config setting", 2018-05-02),
This is a good point that I missed. With that recent change to merge, it no longer matters that the settings parsing code caps detect_rename at DIFF_DETECT_RENAME because it will cap it later anyway so there is no need to change the merge option behavior.
Quoted 5 lines
The one place copy detection does make sense inside a merge is for the diffstat shown at the end (from
builtin/merge.c), but it currently isn't controlled by any configuration setting at all. When it is hooked up, it'd probably store the value separately from merge-recursive's internal o->{diff,merge}_detect_rename anyway,
Quoted 9 lines
because builtin/merge.c's diffstat should be controlled by the relevant confiig settings and flags (merge.renames, diff.renames, -Xfind-renames, etc.) regardless of which merge strategy (recursive, resolve, octopus, ours, ort) is employed. And when that is hooked up, I agree with you that it should look like what you've done with status.renames here. In fact, if you'd like to take a crack at it, I think you'd do a great job. :-) If not, it's on my list of things to do.
Thanks but I'll leave that to you. :) I have a large backlog of patches I would like to see pushed through the mailing list into master. We've been sitting on this one for over a year. If the current rate is any indication, it will take man years to get caught up.
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
Testcases look good. It'd be nice to also add a few testcases where copy detection is turned on -- in particular, I'd like to see one with --find-renames=$DIFFERENT_THAN_DEFAULT being passed when merge.renames=copies.
OK. I also added tests to verify the settings correctly impact commit.
Nice!
Quoted 11 lines · Elijah Newren
Quoted 4 lines
Note: I removed the --no-breaks command line option from the original patch as it will no longer be needed once the default has been changed [1] to turn it off.
I'd just drop these lines from the commit message, and instead mention that your patch depends on em/status-rename-config.
Quoted 3 lines
Original-Patch-by Alejandro Pauly <[email protected]>Signed-off-by Ben Peart <[email protected]>---
Other things seem to have been resolved between you two already, so I'll only comment on a minor tangent here.
Quoted 6 lines
Quoted 2 lines
Notes:
Base Ref: masterThis patch does not apply to master; it has conflicts.
Quoted 1 line
Web-Diff: https://github.com/benpeart/git/commit/823212725b
As Git is distributed, unlike tags that are meant to be global among project participants by convention, a branch name can never be used as a trustable base among developers. Your 'master' branch may point at a different commit from mine, and my 'master' branch today may point at a different commit from mine yesterday.
I've seen patches that used a similar note below the three-dash line that named an exact commit object name. That is a lot more reliable way to convey the information necessary to consturct the exact state the contributor worked on.
Quoted 4 lines
This web diff shows em/status-rename-config as the parent commit, not master. Since your commit message mentions you want the change to break detection provided by that series, just listing it as the explicit base seems like the right way to go.
Thanks for digging. That would work well, too.
Quoted 10 lines · Ben Peart
Documentation/config.txt | 10 ++++ Documentation/git-status.txt | 10 ++++ builtin/commit.c | 41 ++++++++++++++++ diff.c | 2 +- diff.h | 1 + t/t7525-status-rename.sh | 90 ++++++++++++++++++++++++++++++++++++ wt-status.c | 12 +++++ wt-status.h | 4 +- 8 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 t/t7525-status-rename.sh
I'll mark the new script as executable (otherwise the test will not even start).
PATCH v3 1/1 add status config and command line options for rename detection
In reply to Ben PeartAfter performing a merge that has conflicts git status will, by default, attempt to detect renames which causes many objects to be examined. In a virtualized repo, those objects do not exist locally so the rename logic triggers them to be fetched from the server. This results in the status call taking hours to complete on very large repos vs seconds with this patch.
Add a new config status.renames setting to enable turning off rename detection during status and commit. This setting will default to the value of diff.renames.
Add a new config status.renamelimit setting to to enable bounding the time spent finding out inexact renames during status and commit. This setting will default to the value of diff.renamelimit.
Add --no-renames command line option to status that enables overriding the config setting from the command line. Add --find-renames[=<n>] command line option to status that enables detecting renames and optionally setting the similarity index.
This patch depends on em/status-rename-config
---
Notes:
Base Ref: commit dc6b1d92ca9c0c538daa244e3910bb8b2a50d959 (em/status-rename-config)
Web-Diff: https://github.com/benpeart/git/commit/5bac43610b
Checkout: git fetch https://github.com/benpeart/git status-renames-v3 && git checkout 5bac43610b
### Interdiff (v2..v3):
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 9c8eca05b1..88884f1ead 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -3120,14 +3120,16 @@ status.displayCommentPrefix::
Defaults to false.
status.renameLimit::
- The number of files to consider when performing rename detection;
- if not specified, defaults to the value of diff.renameLimit.
+ The number of files to consider when performing rename detection
+ in linkgit:git-status[1] and linkgit:git-commit[1]. Defaults to
+ the value of diff.renameLimit.
status.renames::
- Whether and how Git detects renames. If set to "false",
- rename detection is disabled. If set to "true", basic rename
- detection is enabled. If set to "copies" or "copy", Git will
- detect copies, as well. Defaults to the value of diff.renames.
+ Whether and how Git detects renames in linkgit:git-status[1] and
+ linkgit:git-commit[1] . If set to "false", rename detection is
+ disabled. If set to "true", basic rename detection is enabled.
+ If set to "copies" or "copy", Git will detect copies, as well.
+ Defaults to the value of diff.renames.
status.showStash::
If set to true, linkgit:git-status[1] will display the number of
diff --git a/builtin/commit.c b/builtin/commit.c
index db886277f4..b50e33ef48 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1373,6 +1373,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
if (no_renames != -1)
s.detect_rename = !no_renames;
if ((intptr_t)rename_score_arg != -1) {
+ if (s.detect_rename < DIFF_DETECT_RENAME)
s.detect_rename = DIFF_DETECT_RENAME;
if (rename_score_arg)
s.rename_score = parse_rename_score(&rename_score_arg);
diff --git a/t/t7525-status-rename.sh b/t/t7525-status-rename.sh
old mode 100644
new mode 100755
index 311df8038a..ef8b1b3078
--- a/t/t7525-status-rename.sh
+++ b/t/t7525-status-rename.sh
@@ -10,14 +10,13 @@ test_expect_success 'setup' '
git commit -m"Adding original file." &&
mv original renamed &&
echo 2 >> renamed &&
- git add .
-'
-
-cat >.gitignore <<\EOF
+ git add . &&
+ cat >.gitignore <<-\EOF
.gitignore
expect*
actual*
EOF
+'
test_expect_success 'status no-options' '
git status >actual &&
@@ -63,7 +62,18 @@ test_expect_success 'status status.renames=true' '
test_i18ngrep "renamed:" actual
'
-test_expect_success 'status config overriden' '
+test_expect_success 'commit honors status.renames=false' '
+ git -c status.renames=false commit --dry-run >actual &&
+ test_i18ngrep "deleted:" actual &&
+ test_i18ngrep "new file:" actual
+'
+
+test_expect_success 'commit honors status.renames=true' '
+ git -c status.renames=true commit --dry-run >actual &&
+ test_i18ngrep "renamed:" actual
+'
+
+test_expect_success 'status config overridden' '
git -c status.renames=true status --no-renames >actual &&
test_i18ngrep "deleted:" actual &&
test_i18ngrep "new file:" actual
@@ -87,4 +97,17 @@ test_expect_success 'status score=01%' '
test_i18ngrep "renamed:" actual
'
+test_expect_success 'copies not overridden by find-rename' '
+ cp renamed copy &&
+ git add copy &&
+
+ git -c status.renames=copies status -M=01% >actual &&
+ test_i18ngrep "copied:" actual &&
+ test_i18ngrep "renamed:" actual &&
+
+ git -c status.renames=copies status --find-rename=01% >actual &&
+ test_i18ngrep "copied:" actual &&
+ test_i18ngrep "renamed:" actual
+'
+
test_done
### PatchesDocumentation/config.txt | 12 ++++ Documentation/git-status.txt | 10 ++++ builtin/commit.c | 42 +++++++++++++ diff.c | 2 +- diff.h | 1 + t/t7525-status-rename.sh | 113 +++++++++++++++++++++++++++++++++++ wt-status.c | 12 ++++ wt-status.h | 4 +- 8 files changed, 194 insertions(+), 2 deletions(-) create mode 100755 t/t7525-status-rename.sh
Documentation/config.txt +12 -0
@@ -3119,6 +3119,18 @@ status.displayCommentPrefix:: behavior of linkgit:git-status[1] in Git 1.8.4 and previous. Defaults to false. +status.renameLimit:: + The number of files to consider when performing rename detection + in linkgit:git-status[1] and linkgit:git-commit[1]. Defaults to + the value of diff.renameLimit. + +status.renames:: + Whether and how Git detects renames in linkgit:git-status[1] and + linkgit:git-commit[1] . If set to "false", rename detection is + disabled. If set to "true", basic rename detection is enabled. + If set to "copies" or "copy", Git will detect copies, as well. + Defaults to the value of diff.renames. + status.showStash:: If set to true, linkgit:git-status[1] will display the number of entries currently stashed away.
Documentation/git-status.txt +10 -0
@@ -135,6 +135,16 @@ ignored, then the directory is not shown, but all contents are shown. Display or do not display detailed ahead/behind counts for the branch relative to its upstream branch. Defaults to true. +--renames:: +--no-renames:: + Turn on/off rename detection regardless of user configuration. + See also linkgit:git-diff[1] `--no-renames`. + +--find-renames[=<n>]:: + Turn on rename detection, optionally setting the similarity + threshold. + See also linkgit:git-diff[1] `--find-renames`. + <pathspec>...:: See the 'pathspec' entry in linkgit:gitglossary[7].
builtin/commit.c +42 -0
71 lines not on this page · raw message
diff.c +1 -1
@@ -177,7 +177,7 @@ static int parse_submodule_params(struct diff_options *options, const char *valureturn 0 ; } -static int git_config_rename (const char *var,const char *value) +int git_config_rename (const char *var,const char *value) {if (!value)return DIFF_DETECT_RENAME ;
diff.h +1 -0
@@ -324,6 +324,7 @@ extern int git_diff_ui_config(const char *var, const char *value, void *cb);extern void diff_setup (struct diff_options *);extern int diff_opt_parse (struct diff_options *,const char **,int ,const char *);extern void diff_setup_done (struct diff_options *); +extern int git_config_rename (const char *var,const char *value);#define DIFF_DETECT_RENAME 1#define DIFF_DETECT_COPY 2
t/t7525-status-rename.sh new file +113 -0
113 lines not on this page · raw message
wt-status.c +12 -0
@@ -138,6 +138,9 @@ void wt_status_prepare(struct wt_status *s) s->show_stash =0 ; s->ahead_behind_flags =AHEAD_BEHIND_UNSPECIFIED ; s->display_comment_prefix =0 ; + s->detect_rename =-1 ; + s->rename_score =-1 ; + s->rename_limit =-1 ; }static void wt_longstatus_print_unmerged_header (struct wt_status *s)
@@ -592,6 +595,9 @@ static void wt_status_collect_changes_worktree(struct wt_status *s) } rev.diffopt.format_callback = wt_status_collect_changed_cb; rev.diffopt.format_callback_data = s; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score;copy_pathspec (&rev.prune_data, &s->pathspec);run_diff_files (&rev,0 ); }
@@ -625,6 +631,9 @@ static void wt_status_collect_changes_index(struct wt_status *s) rev.diffopt.output_format |=DIFF_FORMAT_CALLBACK ; rev.diffopt.format_callback = wt_status_collect_updated_cb; rev.diffopt.format_callback_data = s; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score;copy_pathspec (&rev.prune_data, &s->pathspec);run_diff_index (&rev,1 ); }
@@ -982,6 +991,9 @@ static void wt_longstatus_print_verbose(struct wt_status *s)setup_revisions (0 ,NULL , &rev, &opt); rev.diffopt.output_format |=DIFF_FORMAT_PATCH ; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score; rev.diffopt.file = s->fp; rev.diffopt.close_file =0 ;/*
wt-status.h +3 -1
@@ -89,7 +89,9 @@ struct wt_status {int show_stash;int hints;enum ahead_behind_flags ahead_behind_flags; - +int detect_rename; +int rename_score; +int rename_limit;enum wt_status_format status_format;unsigned char sha1_commit[GIT_MAX_RAWSZ ];/* when not Initial */
base-commit: dc6b1d92ca9c0c538daa244e3910bb8b2a50d959
Signature · 1 line
2.17.0.windows.1
Hi Ben,
Quoted 10 lines · Ben Peart
After performing a merge that has conflicts git status will, by default, attempt to detect renames which causes many objects to be examined. In a virtualized repo, those objects do not exist locally so the rename logic triggers them to be fetched from the server. This results in the status call taking hours to complete on very large repos vs seconds with this patch.
Add a new config status.renames setting to enable turning off rename detection during status and commit. This setting will default to the value of diff.renames.
Quoted 8 lines
Add a new config status.renamelimit setting to to enable bounding the time spent finding out inexact renames during status and commit. This setting will default to the value of diff.renamelimit.
Add --no-renames command line option to status that enables overriding the config setting from the command line. Add --find-renames[=<n>] command line option to status that enables detecting renames and optionally setting the similarity index.
Any chance I could get you to re-wrap this at a smaller column width? Doesn't fit in my (80-char) terminal when I run git log; a couple lines run over by a couple characters. (Sorry for not noticing this earlier)
Quoted 1 line
This patch depends on em/status-rename-config
I'd leave this line for the notes. It's useful information now, but won't be to someone looking at the commit a year from now, so it probably doesn't belong in the commit message.
With those two changes:
Quoted 5 lines · Ben Peart
After performing a merge that has conflicts git status will, by default, attempt to detect renames which causes many objects to be examined. In a virtualized repo, those objects do not exist locally so the rename logic triggers them to be fetched from the server. This results in the status call taking hours to complete on very large repos vs seconds with this patch.
I see where your need comes from, but as you based this on my little patch one can achieve this already with tweaking diff.renames itself. I do wonder why there is a special need for the status command here. And if there is, I personally would like it more in a style that you could take all the options provided by diff.*-configuration and prefix that with status, eg status.diff.renames = true. What do you think? If you really only need this for merges, maybe a more specialised option is called for that only kicks in when there is a merge going on?
I would like that status behaves as similar as possible to diff/show/log. Special options will pull away from that again - passing -m to show or log will lead to the same performance issues, correct? Could it be feasible to impose an overall time limit on the detection?
And after writing this I wonder what were your experience with just tweaking renameLimit - setting it very low should have helped the fetching from server part already, shouldn't it?
Quoted 4 lines
Add --no-renames command line option to status that enables overriding the config setting from the command line. Add --find-renames[=<n>] command line option to status that enables detecting renames and optionally setting the similarity index.
Would it be reasonable to extend this so that we just use the same machinery for parsing command line options for the diffcore options and pass this along? It seems to me that git status wants the same init as diff/show/log has anyway. But I like the direction towards passing more command line options to the git status command.
Quoted 22 lines
static void
wt_longstatus_print_unmerged_header(struct wt_status *s)wt-status.c +6
-0@@ -592,6 +595,9 @@ static void wt_status_collect_changes_worktree(struct wt_status *s) } rev.diffopt.format_callback = wt_status_collect_changed_cb; rev.diffopt.format_callback_data = s; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score;copy_pathspec (&rev.prune_data, &s->pathspec);run_diff_files (&rev,0 ); }@@ -625,6 +631,9 @@ static void wt_status_collect_changes_index(struct wt_status *s) rev.diffopt.output_format |=DIFF_FORMAT_CALLBACK ; rev.diffopt.format_callback = wt_status_collect_updated_cb; rev.diffopt.format_callback_data = s; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score;copy_pathspec (&rev.prune_data, &s->pathspec);run_diff_index (&rev,1 ); }
wt-status.c static void wt_longstatus_print_verbose(struct wt_status *s) · line 999
Quoted 9 lines
wt-status.c +3
-0@@ -982,6 +991,9 @@ static void wt_longstatus_print_verbose(struct wt_status *s)setup_revisions (0 ,NULL , &rev, &opt); rev.diffopt.output_format |=DIFF_FORMAT_PATCH ; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score; rev.diffopt.file = s->fp; rev.diffopt.close_file =0 ;/*
Somehow I am inclined that those should be factored out to a common method if the rest of the patch stays as it is.
Greetings,
Eckhard
Quoted 10 lines · Eckhard Maaß
Quoted 5 lines · Ben Peart
After performing a merge that has conflicts git status will, by default, attempt to detect renames which causes many objects to be examined. In a virtualized repo, those objects do not exist locally so the rename logic triggers them to be fetched from the server. This results in the status call taking hours to complete on very large repos vs seconds with this patch.
I see where your need comes from, but as you based this on my little patch one can achieve this already with tweaking diff.renames itself. I do wonder why there is a special need for the status command here
The rename detection feature is nice and we'd like to leave it on whenever possible. The performance issues only occur when in the middle of a merge - normal status commands behave reasonably. As a result, we don't want to just turn it off completely by setting diff.renames.
Until we come up with a more elegant solution, we currently turn it off completely for merge via the new merge settings and then intercept calls to status and if there is a MERGE_HEAD we turn it off for status just for that specific call. I view this as a temporary solution so would not want to put that logic into git proper as it is quite specific to when running git on a virtualized repo.
Quoted 11 lines
if there is, I personally would like it more in a style that you could take all the options provided by diff.*-configuration and prefix that with status, eg status.diff.renames = true. What do you think? If you really only need this for merges, maybe a more specialised option is called for that only kicks in when there is a merge going on?
I would like that status behaves as similar as possible to diff/show/log. Special options will pull away from that again - passing -m to show or log will lead to the same performance issues, correct? Could it be feasible to impose an overall time limit on the detection?
I agree that they should behave as similar as possible which is why all the new settings default to the diff setting when not explicitly set. I believe this is a good model - if you don't do anything special you get the default/same behavior but if you know and need special behavior, you now have that option.
Quoted 9 lines
And after writing this I wonder what were your experience with just tweaking renameLimit - setting it very low should have helped the fetching from server part already, shouldn't it?
Quoted 4 lines
Add --no-renames command line option to status that enables overriding the config setting from the command line. Add --find-renames[=<n>] command line option to status that enables detecting renames and optionally setting the similarity index.
Quoted 6 lines
Would it be reasonable to extend this so that we just use the same machinery for parsing command line options for the diffcore options and pass this along? It seems to me that git status wants the same init as diff/show/log has anyway. But I like the direction towards passing more command line options to the git status command.
I agree that it is unfortunate that diff/merge/status all parse and deal with config settings differently. I'd be happy to see someone tackle that and move the code to a single, coherent model but that is beyond the scope of this patch.
Quoted 24 lines
Quoted 24 lines
static void
wt_longstatus_print_unmerged_header(struct wt_status *s)wt-status.c +6
-0@@ -592,6 +595,9 @@ static void wt_status_collect_changes_worktree(struct wt_status *s) } rev.diffopt.format_callback = wt_status_collect_changed_cb; rev.diffopt.format_callback_data = s; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score;copy_pathspec (&rev.prune_data, &s->pathspec);run_diff_files (&rev,0 ); }@@ -625,6 +631,9 @@ static void wt_status_collect_changes_index(struct wt_status *s) rev.diffopt.output_format |=DIFF_FORMAT_CALLBACK ; rev.diffopt.format_callback = wt_status_collect_updated_cb; rev.diffopt.format_callback_data = s; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score;copy_pathspec (&rev.prune_data, &s->pathspec);run_diff_index (&rev,1 ); }@@ -982,6 +991,9 @@ static void wt_longstatus_print_verbose(struct wt_status *s)setup_revisions (0 ,NULL , &rev, &opt);
Quoted 11 lines
wt-status.c static void wt_longstatus_print_verbose(struct wt_status *s) · line 999
Quoted 7 lines
wt-status.c +3
-0rev.diffopt.output_format |=DIFF_FORMAT_PATCH ; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score; rev.diffopt.file = s->fp; rev.diffopt.close_file =0 ;/* Somehow I am inclined that those should be factored out to a common method if the rest of the patch stays as it is.
I debated that as well but given the logic is so simple, opted to stick with this. I also debated whether it would be clearer in the form:
if (s->detect_rename >= 0)
rev.diffopt.detect_rename = s->detect_rename;
But decided git contributes are used to seeing dense code :) and this style better matched what I saw in the merge settings.
Quoted 3 lines
Greetings,
Eckhard
PATCH v4 1/1 add status config and command line options for rename detection
In reply to Ben PeartAfter performing a merge that has conflicts git status will, by default, attempt to detect renames which causes many objects to be examined. In a virtualized repo, those objects do not exist locally so the rename logic triggers them to be fetched from the server. This results in the status call taking hours to complete on very large repos vs seconds with this patch.
Add a new config status.renames setting to enable turning off rename detection during status and commit. This setting will default to the value of diff.renames.
Add a new config status.renamelimit setting to to enable bounding the time spent finding out inexact renames during status and commit. This setting will default to the value of diff.renamelimit.
Add --no-renames command line option to status that enables overriding the config setting from the command line. Add --find-renames[=<n>] command line option to status that enables detecting renames and optionally setting the similarity index.
---
Notes:
Base Ref: commit dc6b1d92ca9c0c538daa244e3910bb8b2a50d959 (em/status-rename-config)
Web-Diff: https://github.com/benpeart/git/commit/95974d512b
Checkout: git fetch https://github.com/benpeart/git status-renames-v4 && git checkout 95974d512b
### Interdiff (v3..v4):
### PatchesDocumentation/config.txt | 12 ++++ Documentation/git-status.txt | 10 ++++ builtin/commit.c | 42 +++++++++++++ diff.c | 2 +- diff.h | 1 + t/t7525-status-rename.sh | 113 +++++++++++++++++++++++++++++++++++ wt-status.c | 12 ++++ wt-status.h | 4 +- 8 files changed, 194 insertions(+), 2 deletions(-) create mode 100755 t/t7525-status-rename.sh
Documentation/config.txt +12 -0
@@ -3119,6 +3119,18 @@ status.displayCommentPrefix:: behavior of linkgit:git-status[1] in Git 1.8.4 and previous. Defaults to false. +status.renameLimit:: + The number of files to consider when performing rename detection + in linkgit:git-status[1] and linkgit:git-commit[1]. Defaults to + the value of diff.renameLimit. + +status.renames:: + Whether and how Git detects renames in linkgit:git-status[1] and + linkgit:git-commit[1] . If set to "false", rename detection is + disabled. If set to "true", basic rename detection is enabled. + If set to "copies" or "copy", Git will detect copies, as well. + Defaults to the value of diff.renames. + status.showStash:: If set to true, linkgit:git-status[1] will display the number of entries currently stashed away.
Documentation/git-status.txt +10 -0
@@ -135,6 +135,16 @@ ignored, then the directory is not shown, but all contents are shown. Display or do not display detailed ahead/behind counts for the branch relative to its upstream branch. Defaults to true. +--renames:: +--no-renames:: + Turn on/off rename detection regardless of user configuration. + See also linkgit:git-diff[1] `--no-renames`. + +--find-renames[=<n>]:: + Turn on rename detection, optionally setting the similarity + threshold. + See also linkgit:git-diff[1] `--find-renames`. + <pathspec>...:: See the 'pathspec' entry in linkgit:gitglossary[7].
builtin/commit.c +42 -0
71 lines not on this page · raw message
diff.c +1 -1
@@ -177,7 +177,7 @@ static int parse_submodule_params(struct diff_options *options, const char *valureturn 0 ; } -static int git_config_rename (const char *var,const char *value) +int git_config_rename (const char *var,const char *value) {if (!value)return DIFF_DETECT_RENAME ;
diff.h +1 -0
@@ -324,6 +324,7 @@ extern int git_diff_ui_config(const char *var, const char *value, void *cb);extern void diff_setup (struct diff_options *);extern int diff_opt_parse (struct diff_options *,const char **,int ,const char *);extern void diff_setup_done (struct diff_options *); +extern int git_config_rename (const char *var,const char *value);#define DIFF_DETECT_RENAME 1#define DIFF_DETECT_COPY 2
t/t7525-status-rename.sh new file +113 -0
113 lines not on this page · raw message
wt-status.c +12 -0
@@ -138,6 +138,9 @@ void wt_status_prepare(struct wt_status *s) s->show_stash =0 ; s->ahead_behind_flags =AHEAD_BEHIND_UNSPECIFIED ; s->display_comment_prefix =0 ; + s->detect_rename =-1 ; + s->rename_score =-1 ; + s->rename_limit =-1 ; }static void wt_longstatus_print_unmerged_header (struct wt_status *s)
@@ -592,6 +595,9 @@ static void wt_status_collect_changes_worktree(struct wt_status *s) } rev.diffopt.format_callback = wt_status_collect_changed_cb; rev.diffopt.format_callback_data = s; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score;copy_pathspec (&rev.prune_data, &s->pathspec);run_diff_files (&rev,0 ); }
@@ -625,6 +631,9 @@ static void wt_status_collect_changes_index(struct wt_status *s) rev.diffopt.output_format |=DIFF_FORMAT_CALLBACK ; rev.diffopt.format_callback = wt_status_collect_updated_cb; rev.diffopt.format_callback_data = s; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score;copy_pathspec (&rev.prune_data, &s->pathspec);run_diff_index (&rev,1 ); }
@@ -982,6 +991,9 @@ static void wt_longstatus_print_verbose(struct wt_status *s)setup_revisions (0 ,NULL , &rev, &opt); rev.diffopt.output_format |=DIFF_FORMAT_PATCH ; + rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score; rev.diffopt.file = s->fp; rev.diffopt.close_file =0 ;/*
wt-status.h +3 -1
@@ -89,7 +89,9 @@ struct wt_status {int show_stash;int hints;enum ahead_behind_flags ahead_behind_flags; - +int detect_rename; +int rename_score; +int rename_limit;enum wt_status_format status_format;unsigned char sha1_commit[GIT_MAX_RAWSZ ];/* when not Initial */
base-commit: dc6b1d92ca9c0c538daa244e3910bb8b2a50d959
Signature · 1 line
2.17.0.windows.1