Skip to content

Unable to merge tracking into base: file name too long #29907

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

Closed
yp05327 opened this issue Mar 19, 2024 · 11 comments · Fixed by #30489
Closed

Unable to merge tracking into base: file name too long #29907

yp05327 opened this issue Mar 19, 2024 · 11 comments · Fixed by #30489
Labels

Comments

@yp05327
Copy link
Contributor

yp05327 commented Mar 19, 2024

Description

  • create a repo, add a file with long name (over 255 in linux)
  • create a new branch, and commit some changes
  • create a PR
  • commit some changes to default branch
  • go to the PR, you will see Update branch by merge button, and press it, then you will get this error:
    image

Gitea Version

latest

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

build

Database

None

@yp05327
Copy link
Contributor Author

yp05327 commented Mar 22, 2024

https://serverfault.com/questions/9546/filename-length-limits-on-linux
It seems that the max length of filename in Linux is 255, but we can create a file with a name longer than this limit from Web UI.

image

@yp05327
Copy link
Contributor Author

yp05327 commented Mar 22, 2024

This was added in #29389 which is not correct enough.
#29389 (comment)

The 500 maxlength is from TreePath

But the definition of this maxlength was 500 from long long ago, and this doesn't make sense as the max path length is 4096 in linux and for windows, it depends on the version:
https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
So we need to make some changes.
image

@lunny
Copy link
Member

lunny commented Mar 22, 2024

The normal file system should allow file path length below 256?

@yp05327
Copy link
Contributor Author

yp05327 commented Mar 22, 2024

The normal file system should allow file path length below 256?

Updated my comment above

@lunny
Copy link
Member

lunny commented Apr 15, 2024

Can we set git config like below in Gitea internal configuration? Windows special configuration.

git config core.longpaths true

@yp05327
Copy link
Contributor Author

yp05327 commented Apr 15, 2024

This may work in Windows, as Windows don't have file name length limit.
But in Linux, there's a limit of file name length, you can use getconf NAME_MAX . to see value.

@silverwind
Copy link
Member

core.longpaths

Is that a windows-specific option? I don't find it on https://git-scm.com/docs/git-config.

@lunny
Copy link
Member

lunny commented Apr 15, 2024

I just tested GH web editor, the filename can be longer than 255.

silverwind pushed a commit that referenced this issue Apr 15, 2024
Quick/Partly fix #29907

In Linux and MacOS, by default the max file name length is 255.
In windows, it depends on the version and settings, and has no file name
length limitation, but has path length limitation.
By default it is 260, considering path length is longer than filename,
so I think it is ok to do this.

For Windows, see
https://learn.microsoft.com/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
For Linux, see
https://github.com/torvalds/linux/blob/master/include/uapi/linux/limits.h#L12-L13
For MacOS, see
https://discussions.apple.com/thread/254788848?sortBy=best
GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue Apr 15, 2024
Quick/Partly fix go-gitea#29907

In Linux and MacOS, by default the max file name length is 255.
In windows, it depends on the version and settings, and has no file name
length limitation, but has path length limitation.
By default it is 260, considering path length is longer than filename,
so I think it is ok to do this.

For Windows, see
https://learn.microsoft.com/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
For Linux, see
https://github.com/torvalds/linux/blob/master/include/uapi/linux/limits.h#L12-L13
For MacOS, see
https://discussions.apple.com/thread/254788848?sortBy=best
silverwind pushed a commit that referenced this issue Apr 15, 2024
Backport #30489 by @yp05327

Quick/Partly fix #29907

In Linux and MacOS, by default the max file name length is 255.
In windows, it depends on the version and settings, and has no file name
length limitation, but has path length limitation.
By default it is 260, considering path length is longer than filename,
so I think it is ok to do this.

For Windows, see
https://learn.microsoft.com/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
For Linux, see
https://github.com/torvalds/linux/blob/master/include/uapi/linux/limits.h#L12-L13
For MacOS, see
https://discussions.apple.com/thread/254788848?sortBy=best

Co-authored-by: yp05327 <[email protected]>
@yp05327 yp05327 reopened this Apr 16, 2024
@yp05327
Copy link
Contributor Author

yp05327 commented Apr 16, 2024

I tried git config core.longpaths true, in Windows it works with no error.
But in Linux, we still has this problem.
So maybe we need detecting how long the filename can be in different OS.

@silverwind
Copy link
Member

silverwind commented Apr 16, 2024

I tried git config core.longpaths true, in Windows it works with no error. But in Linux, we still has this problem. So maybe we need detecting how long the filename can be in different OS.

No, let's just set on a common denominator, e.g. 255. We want repos to be portable.

@yp05327
Copy link
Contributor Author

yp05327 commented Apr 17, 2024

Ok, I will close this issue.

@yp05327 yp05327 closed this as completed Apr 17, 2024
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jul 16, 2024
project-mirrors-bot-tu bot pushed a commit to project-mirrors/forgejo-as-gitea-fork that referenced this issue Jan 23, 2025
Backport go-gitea#30489 by @yp05327

Quick/Partly fix go-gitea#29907

In Linux and MacOS, by default the max file name length is 255.
In windows, it depends on the version and settings, and has no file name
length limitation, but has path length limitation.
By default it is 260, considering path length is longer than filename,
so I think it is ok to do this.

For Windows, see
https://learn.microsoft.com/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
For Linux, see
https://github.com/torvalds/linux/blob/master/include/uapi/linux/limits.h#L12-L13
For MacOS, see
https://discussions.apple.com/thread/254788848?sortBy=best

Co-authored-by: yp05327 <[email protected]>
(cherry picked from commit f52b1db)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants