Skip to content

File history for renamed files, with '--follow' equivalent to show the complete history #34686

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

Chi-Iroh
Copy link

@Chi-Iroh Chi-Iroh commented Jun 10, 2025

Fixes #28253

Added a checkbox in the file history, so that we can toggle following renames.

I made a test repo, with a first commit creating a file, and a second one renaming it.
Here is what the history looks.

Rename following disabled :
image

Rename following enabled :
image

As a reminder, here's what it looks like now :
image

However, I have a question: I inserted a small spacing between the text and the checkbox, and as 1em and 1rem looked too big, I put 5px instead. Is it OK to use an absolute size in this context ?

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 10, 2025
@github-actions github-actions bot added modifies/translation modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/frontend labels Jun 10, 2025
Copy link
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the PR.

Although it needs more improvements to follow Gitea's code guideline, the idea is good enough.

I can help to make future improvements, before making more changes, I have some questions, see below.

@@ -253,7 +264,7 @@ func (repo *Repository) CommitsByFileAndRange(opts CommitsByFileAndRangeOptions)
Stdout: stdoutWriter,
Stderr: &stderr,
})
if err != nil {
if err != nil && err != io.ErrUnexpectedEOF {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why checking ErrUnexpectedEOF? When it would happen?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git log --pretty=format:%H output lacks a newline at the end, whereas git rev-list doesn't. So that's the fix I found to avoid error 500, please tell me if something better is needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think ErrUnexpectedEOF is right, ErrUnexpectedEOF only means something wrong happens, so it needs a clear fix.

Copy link
Author

@Chi-Iroh Chi-Iroh Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the core issue is in modules/git/repo_commit.go:279-281 :

length := objectFormat.FullLength()
commits := []*Commit{}
shaline := make([]byte, length+1)

From what I understand, shaline is expected to have a length of the hash's length + 1, presumably for the newline. So at line 283 (n, err := io.ReadFull(stdoutReader, shaline)), when the last output line is reached, only length bytes are read, instead of the expected length + 1 bytes, so it triggers ErrUnexpectedEOF.

If an EOF happens after reading some but not all the bytes, ReadFull returns ErrUnexpectedEOF.
https://pkg.go.dev/io#ReadFull

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wxiaoguang So, do I need to change something, or ErrUnexpectedEOF is fine ?

@wxiaoguang
Copy link
Contributor

The commit history became a mess. Please follow git's manual to maintain the commits, and then force-push after fixing the problems.

And one more thing, when review starts and there is no special requirement, please avoid rebase&force-push.

@Chi-Iroh
Copy link
Author

@wxiaoguang I'll be glad to fix what you'd like, but could you tell me what exactly is wrong ? I genuinely don't know what to do about the commits and don't understand why you said it's a mess.
Also, the forced pushes were because I made a mistake / forgot something important in a commit I just pushed, sorry for these.

And last, what about the failing checks ? The frontend one is because of a change silvermind asked me to do, and as far as I understand, the vulnerability one is unrelated with what I changed.

@wxiaoguang
Copy link
Contributor

I don't know what you have done on your side.

Now, these pages contains unrelated changes:

@Chi-Iroh
Copy link
Author

Chi-Iroh commented Jun 16, 2025

Ok, that's because I thought I ought to update my branch to upstream to check I didn't break something, so that's why these commits are here. I'll drop them with a rebase, is it ok for you ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/frontend modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/translation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File history for renamed files, with '--follow' equivalent to show the complete history
5 participants