gitea should not modify a user's .gitconfig #3996

Closed
opened 2025-11-02 05:33:30 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @camh- on GitHub (Sep 21, 2019).

  • Gitea version (or commit ref): v1.9.3
  • Git version: 2.11.0
  • Operating system: Debian 9 (stretch)
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

When running gitea under a user account who has a ~/.gitconfig file, gitea modifies that file unnecessarily.

I built and ran gitea under my user account to start to get a feel for the tool and how to set it up. Ultimately I will run it under its own account, but to get started, I ran it under my account.

I do not have user.email set in my ~/.gitconfig global git config file. After I ran gitea, it set user.email to gitea@fake.local. I did not know it did that and when I made my next commit to another repo and pushed to github, it went with the wrong email address. This is now public and cannot be changed/fixed.

In the gitea source in modules/git/git.go in Init(), it says:

// Git requires setting user.name and user.email in order to commit changes.

This is not true. In git-config(1) it says under user.email:

Your email address to be recorded in any newly created commits. Can be overridden by the GIT_AUTHOR_EMAIL, GIT_COMMITTER_EMAIL, and EMAIL environment variables. See git-commit-tree(1).

I commit to different repos under different identities, so I use the environment to configure those identities setting $EMAIL to the correct email address for each identity. Because gitea does not check for $GIT_AUTHOR_EMAIL, $GIT_COMMITTER_EMAIL or $EMAIL, it erroneously assumes it must set the user.email config setting in the users ~/.gitconfig in order to commit changes.

I suggest that gitea should check what it requires more comprehensively according to what it documented by git, and if it is not set up properly, it should exit with an error rather than using a bad/incorrect config value that will be used for future non-gitea operations.

Note: the same applies to user.name which can be set by environment variables too.

While writing this, I also note that it has set core.quotepath and core.commitGraph too. These are far less intrusive but i feel gitea still should not do that. Modifying a user's config (especially without informing them) is not usually expected on Unix-like systems.

Originally created by @camh- on GitHub (Sep 21, 2019). - Gitea version (or commit ref): v1.9.3 - Git version: 2.11.0 - Operating system: Debian 9 (stretch) - 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 ## Description When running `gitea` under a user account who has a `~/.gitconfig` file, gitea modifies that file unnecessarily. I built and ran gitea under my user account to start to get a feel for the tool and how to set it up. Ultimately I will run it under its own account, but to get started, I ran it under my account. I do not have `user.email` set in my `~/.gitconfig` global git config file. After I ran gitea, it set `user.email` to `gitea@fake.local`. I did not know it did that and when I made my next commit to another repo and pushed to github, it went with the wrong email address. This is now public and cannot be changed/fixed. In the gitea source in `modules/git/git.go` in `Init()`, it says: ``` // Git requires setting user.name and user.email in order to commit changes. ``` This is not true. In `git-config(1)` it says under `user.email`: > Your email address to be recorded in any newly created commits. Can be overridden by the GIT_AUTHOR_EMAIL, GIT_COMMITTER_EMAIL, and EMAIL environment variables. See git-commit-tree(1). I commit to different repos under different identities, so I use the environment to configure those identities setting `$EMAIL` to the correct email address for each identity. Because gitea does not check for `$GIT_AUTHOR_EMAIL`, `$GIT_COMMITTER_EMAIL` or `$EMAIL`, it erroneously assumes it must set the `user.email` config setting in the users `~/.gitconfig` in order to commit changes. I suggest that gitea should check what it requires more comprehensively according to what it documented by git, and if it is not set up properly, it should exit with an error rather than using a bad/incorrect config value that will be used for future non-gitea operations. Note: the same applies to `user.name` which can be set by environment variables too. While writing this, I also note that it has set `core.quotepath` and `core.commitGraph` too. These are far less intrusive but i feel gitea still should not do that. Modifying a user's config (especially without informing them) is not usually expected on Unix-like systems.
GiteaMirror added the issue/confirmedtype/enhancement labels 2025-11-02 05:33:30 -06:00
Author
Owner

@stale[bot] commented on GitHub (Nov 21, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Nov 21, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3996