gitlab-org--gitlab-foss/app/models
Dmitriy Zaporozhets 08b4d8b6ac Merge branch 'disable-git-follow' into 'master'
Disable --follow in `git log` to avoid loading duplicate commit data in infinite scroll

`git` doesn't work properly when `--follow` and `--skip` are specified together. We could even be **omitting commits in the Web log** as a result.

Here are the gory details. Let's say you ran:

```
git log -n=5 --skip=2 README
```

This is the working case since it omits `--follow`. This is what happens:

1. `git` starts at `HEAD` and traverses down the tree until it finds the top-most commit relevant to README.
2. Once this is found, this commit is returned via `get_revision_1()`.
3. If the `skip_count` is positive, decrement and repeat step 2. Otherwise go onto step 4.
4. `show_log()` gets called with that commit.
5. Repeat step 1 until we have all five entries.

That's exactly what we want. What happens when you use `--follow`? You have to understand how step 1 is performed:

* When you specify a pathspec on the command-line (e.g. README), a flag `prune` [gets set here](https://github.com/git/git/blob/master/revision.c#L2351).
* If the `prune` flag is active, `get_commit_action()` determines whether the commit should be [scanned for matching paths](https://github.com/git/git/blob/master/revision.c#L2989).
* In the case of `--follow`, however, `prune` is [disabled here](https://github.com/git/git/blob/master/revision.c#L2350).
* As a result, a commit is never scanned for matching paths and therefore never pruned. `HEAD` will always get returned as the first commit, even if it's not relevant to the README.
* Making matters worse, the `--skip` in the example above would actually skip a every other entry after `HEAD` N times. If README were changed in these skipped commits, we would actually miss information!

Since git uses a matching algorithm to determine whether a file was renamed, I
believe `git` needs to generate a diff of each commit to do this and traverse
each commit one-by-one to do this. I think that's the rationale for disabling
the `prune` functionality since you can't just do a simple string comparison.

Closes #4181, #4229, #3574, #2410

See merge request !2210
2015-12-28 12:05:55 +00:00
..
ci Merge branch 'issue_3452' 2015-12-21 17:43:58 +01:00
concerns Merge branch 'mention-all' into 'master' 2015-12-27 21:09:16 +00:00
hooks Migrate CI::Services and CI::WebHooks to Services and WebHooks 2015-12-10 16:04:08 +01:00
members
network
project_services Deprecate GitLabCiService making it to always be inactive 2015-12-22 00:28:38 +01:00
.gitkeep
ability.rb Avoid allocations in Ability class. 2015-12-16 11:51:37 +08:00
abuse_report.rb Streamline the "Report button" 2015-09-29 21:47:01 +02:00
application_setting.rb WIP require two factor authentication 2015-12-24 19:00:18 -02:00
audit_event.rb
broadcast_message.rb Add custom ColorValidator 2015-12-07 16:57:26 -05:00
commit.rb Merge branch 'master' into tmp-reference-pipeline-and-caching 2015-12-10 14:04:34 +01:00
commit_range.rb Satisfy Rubocop 2015-12-02 10:54:24 +01:00
commit_status.rb Fix errors 2015-12-11 18:02:09 +01:00
deploy_key.rb
deploy_keys_project.rb
diff_line.rb
email.rb
event.rb Don't show project fork event as imported 2015-12-02 10:56:05 +01:00
external_issue.rb
forked_project_link.rb
generic_commit_status.rb Annotate models 2015-11-13 19:22:46 +01:00
global_label.rb Refactor global and group milestones logic 2015-11-16 14:07:38 +01:00
global_milestone.rb Fix Error 500 when global milestones have slashes 2015-12-22 13:15:32 -08:00
group.rb Group methods for filtering public/visible groups 2015-11-18 13:05:45 +01:00
identity.rb Fix identity and user retrieval when special characters are used 2015-12-22 13:23:35 -05:00
issue.rb Fix issue related cross-project MRs 2015-12-21 15:36:08 +01:00
jira_issue.rb Backport JIRA service 2015-12-18 14:19:48 -06:00
key.rb
label.rb Add custom ColorValidator 2015-12-07 16:57:26 -05:00
label_link.rb
lfs_object.rb Update annotations 2015-12-08 21:00:01 -08:00
lfs_objects_project.rb Update annotations 2015-12-08 21:00:01 -08:00
member.rb Refactor ability changes 2015-11-17 15:49:37 +01:00
merge_request.rb Backport JIRA service 2015-12-18 14:19:48 -06:00
merge_request_diff.rb Add ignore white space option in merge request diff 2015-11-13 16:53:53 +09:00
milestone.rb Use "Any Label" and "Any Milestone" in selects rather than the ambiguous "Any" option 2015-12-02 14:10:43 +01:00
namespace.rb Fixed Rubocop offenses 2015-12-15 00:53:52 -02:00
note.rb revert back vote buttons to issue and MR pages 2015-12-25 14:11:19 +02:00
notification.rb Added Global to the drop downs and updated the label of the button to show the current level instead of `Notifications` 2015-09-16 19:46:24 -05:00
personal_snippet.rb
project.rb Merge branch 'fix/visibility-level-setting-in-forked-projects' into 'master' 2015-12-24 12:09:38 +00:00
project_import_data.rb
project_snippet.rb
project_team.rb Improve ProjectTeam#max_member_access performance 2015-10-15 12:05:01 +02:00
project_wiki.rb Make ProjectWiki touch Project#last_activity_at after wiki actions 2015-11-16 13:08:25 -05:00
protected_branch.rb
release.rb Annotate models 2015-11-13 19:22:46 +01:00
repository.rb Disable --follow in `git log` to avoid loading duplicate commit data in infinite scroll 2015-12-25 01:28:33 -08:00
security_event.rb
sent_notification.rb Add custom LineCodeValidator 2015-12-07 16:57:26 -05:00
service.rb Migrate CI::Project to Project 2015-12-11 18:02:09 +01:00
snippet.rb Autolink first so we don't pick up numeric anchors as issue references. 2015-12-01 15:53:32 +01:00
subscription.rb
tree.rb
user.rb Merge branch 'add_email_unlock' into 'master' 2015-12-21 17:53:20 +00:00
users_star_project.rb Touch project when toggling stars to update cache 2015-12-03 16:08:08 -02:00
wiki_page.rb