Internal server error with custom gitignore #3580

Closed
opened 2025-11-02 05:17:57 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @MarcoNovaro on GitHub (Jul 12, 2019).

  • Gitea version (or commit ref): 1.10.0+dev-26-gf03e5b7c3
  • Git version: 2.17.0
  • Operating system: Windows 10
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

I tried to include a custom .gitignore file, following the instructions in this page.
In particular, I created a file named "Everything" (without extension), with the following contents:

# Ignore everything
*
# But descend into directories
!*/

When creating the new repository, I get a 500 "Internal server error" error.

This is working with other custom gitignore files, as for instance I tried with:

  • an empty file
  • a simple file containing only *.exe

Update

I noticed that the problem is created from the first "*" on the file.
In fact, the following file works correctly:

# Ignore everything
#*
# But descend into directories
!*/
Originally created by @MarcoNovaro on GitHub (Jul 12, 2019). - Gitea version (or commit ref): 1.10.0+dev-26-gf03e5b7c3 - Git version: 2.17.0 - Operating system: Windows 10 - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description I tried to include a custom .gitignore file, following the instructions in [this page](https://docs.gitea.io/en-us/customizing-gitea/). In particular, I created a file named "Everything" (without extension), with the following contents: ``` # Ignore everything * # But descend into directories !*/ ``` When creating the new repository, I get a 500 "Internal server error" error. This is working with other custom gitignore files, as for instance I tried with: * an empty file * a simple file containing only `*.exe` ### Update I noticed that the problem is created from the first "*" on the file. In fact, the following file **works** correctly: ``` # Ignore everything #* # But descend into directories !*/ ```
Author
Owner

@lunny commented on GitHub (Jul 12, 2019):

Any logs on your console or file?

@lunny commented on GitHub (Jul 12, 2019): Any logs on your console or file?
Author
Owner

@MarcoNovaro commented on GitHub (Jul 12, 2019):

The log does not seem to have any important information.
The only error I see is:

2019/07/12 13:03:50 routers/repo/repo.go:148:handleCreateError() [E] CreatePost: initRepository: initRepoCommit: git commit: 
2019/07/12 13:03:50 .../xorm/session_get.go:99:nocacheGet() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `passwd`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `diff_view_style`, `theme` FROM `user` WHERE `id`=? LIMIT 1 []interface {}{1}
2019/07/12 13:03:50 .../xorm/session_raw.go:87:queryRow() [I] [SQL] SELECT count(*) FROM `notification` WHERE (user_id = ?) AND (status = ?) []interface {}{1, 0x1}
2019/07/12 13:03:51 .../xorm/session_get.go:99:nocacheGet() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `passwd`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `diff_view_style`, `theme` FROM `user` WHERE `id`=? LIMIT 1 []interface {}{1}
2019/07/12 13:03:51 .../xorm/session_raw.go:87:queryRow() [I] [SQL] SELECT count(*) FROM `notification` WHERE (user_id = ?) AND (status = ?) []interface {}{1, 0x1}
@MarcoNovaro commented on GitHub (Jul 12, 2019): The log does not seem to have any important information. The only error I see is: ``` 2019/07/12 13:03:50 routers/repo/repo.go:148:handleCreateError() [E] CreatePost: initRepository: initRepoCommit: git commit: 2019/07/12 13:03:50 .../xorm/session_get.go:99:nocacheGet() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `passwd`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `diff_view_style`, `theme` FROM `user` WHERE `id`=? LIMIT 1 []interface {}{1} 2019/07/12 13:03:50 .../xorm/session_raw.go:87:queryRow() [I] [SQL] SELECT count(*) FROM `notification` WHERE (user_id = ?) AND (status = ?) []interface {}{1, 0x1} 2019/07/12 13:03:51 .../xorm/session_get.go:99:nocacheGet() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `passwd`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `diff_view_style`, `theme` FROM `user` WHERE `id`=? LIMIT 1 []interface {}{1} 2019/07/12 13:03:51 .../xorm/session_raw.go:87:queryRow() [I] [SQL] SELECT count(*) FROM `notification` WHERE (user_id = ?) AND (status = ?) []interface {}{1, 0x1} ```
Author
Owner

@MarcoNovaro commented on GitHub (Jul 12, 2019):

I did a further test, and added additional information to the original issue

@MarcoNovaro commented on GitHub (Jul 12, 2019): I did a further test, and added additional information to the original issue
Author
Owner

@jolheiser commented on GitHub (Jul 12, 2019):

# Ignore everything
*
# But descend into directories
!*/

The reason the above doesn't work is because it is still ignoring everything.
It doesn't matter if you descend into directories if you still ignore everything.

I suspect the error is because you are attempting to initialize a repository (which means a commit), but there are no files available to commit because your .gitignore excludes everything (including itself)

This question from StackOverflow explains this somewhat.

@jolheiser commented on GitHub (Jul 12, 2019): ``` # Ignore everything * # But descend into directories !*/ ``` The reason the above doesn't work is because it is still ignoring everything. It doesn't matter if you descend into directories if you *still* ignore everything. I suspect the error is because you are attempting to initialize a repository (which means a commit), but there are no files available to commit because your `.gitignore` excludes everything (including itself) [This question](https://stackoverflow.com/questions/987142/make-gitignore-ignore-everything-except-a-few-files) from StackOverflow explains this somewhat.
Author
Owner

@MarcoNovaro commented on GitHub (Jul 15, 2019):

I suspect the error is because you are attempting to initialize a repository (which means a commit), but there are no files available to commit because your .gitignore excludes everything (including itself)

Thank you for your hint.
Actually, this was the problem, since using the following .gitignore file:

# Ignore all fils
*
# But descend into directories
!*/
# Don't ignore the .gitignore file
!.gitignore
!.gitattributes

the problem is solved, and the repository is created correctly.

@MarcoNovaro commented on GitHub (Jul 15, 2019): > I suspect the error is because you are attempting to initialize a repository (which means a commit), but there are no files available to commit because your `.gitignore` excludes everything (including itself) Thank you for your hint. Actually, this was the problem, since using the following .gitignore file: ``` # Ignore all fils * # But descend into directories !*/ # Don't ignore the .gitignore file !.gitignore !.gitattributes ``` the problem is solved, and the repository is created correctly.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3580