[go: up one dir, main page]

Skip to content

Incorrect link-to-file target when browsing history for renamed files

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

When browsing the history of a file within the repository, a list of commits is provided that alter this file, together with a browse button that allows showing the file (and repository) state at the moment of that particular commit. This link will always contain the current filepath of the file, however if the file has been renamed at some point in its history, this causes the links before that commit to direct the user to a non-existing file, namely the new filename within an older repository state.

In such cases, one would expect the old path to be used, so that the correct file is shown. This would possibly go accompanied by a status banner notifying the user that this is an old file location which differs from the one in the current state of the repository.

Steps to reproduce

  1. Have/create a project with >= 1 commit
  2. Move a file from path A to path B in commit C
  3. Open history for file at path B
  4. Click Browse Directory on any commit before commit C

Example Project

https://gitlab.com/jnoordsij/git-history-link-bug-mwe/-/commits/main/bar?ref_type=heads

What is the current bug behavior?

When clicking the Browse Directory button on commit foo, one is linked to https://gitlab.com/jnoordsij/git-history-link-bug-mwe/-/tree/9d644ff34186d98f53638e39e99cf65e2b024a15/bar, which does not exist and hence redirects to https://gitlab.com/jnoordsij/git-history-link-bug-mwe/-/tree/9d644ff34186d98f53638e39e99cf65e2b024a15 with status message "bar" did not exist on "9d644ff34186d98f53638e39e99cf65e2b024a15".

What is the expected correct behavior?

When clicking the Browse Directory button on commit foo, one is linked to https://gitlab.com/jnoordsij/git-history-link-bug-mwe/-/tree/9d644ff34186d98f53638e39e99cf65e2b024a15/foo, which is the previous location of bar.

Relevant logs and/or screenshots

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

Edited by 🤖 GitLab Bot 🤖