aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git
Commit message (Collapse)AuthorAgeFilesLines
* Fix the issue with error message logging for the `check-attr` command on ↵Giteabot2025-03-271-1/+2
| | | | | | | | | | | | | | Windows OS. (#34035) (#34036) Backport #34035 by charles7668 Close #34022 , #33550 This error message always appears when using the `check-attr` command, even though it works correctly. The issue occurs when the stdin writer is closed, so I added a special case to handle and check the error message when the exit code is 1. Co-authored-by: charles <30816317+charles7668@users.noreply.github.com>
* Try to fix check-attr bug (#34029) (#34033)Giteabot2025-03-271-1/+1
| | | | | Backport #34029 by wxiaoguang Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Try to figure out attribute checker problem (#33901) (#33902)wxiaoguang2025-03-173-15/+94
| | | Backport #33901
* Fix `GetCommitBranchStart` bug (#33298) (#33421)Giteabot2025-02-012-5/+5
| | | | | | | | | | | | | | Backport #33298 by Zettat123 Fix #33265 Fix #33370 This PR also fixes some bugs in `TestGitGeneral`. --------- Co-authored-by: Zettat123 <zettat123@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix mirror bug (#33224) (#33225)Giteabot2025-01-121-0/+2
| | | | | | | | Backport #33224 by lunny Fix #33200 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix `git remote` error check, fix dependencies, fix js error (#33129) (#33133)wxiaoguang2025-01-081-0/+10
| | | | | | | | | | | | | And update some dependencies to fix bugs. Backport #33129, #33136 Fix #32889 Fix #33141 Fix #33139 --------- Co-authored-by: yp05327 <576951401@qq.com>
* Inherit submodules from template repository content (#16237) (#33068)wxiaoguang2025-01-0215-71/+221
| | | | | Backport #16237 (it more likely a bug fix) Co-authored-by: Steffen Schröter <steffen@vexar.de>
* Use gitrepo.GetTreePathLatestCommit to get file lastest commit instead from ↵Giteabot2024-12-302-0/+26
| | | | latest commit cache (#32987) (#33046)
* Fix commit range paging (#32944) (#32962)Giteabot2024-12-232-4/+24
| | | | | Backport #32944 by wxiaoguang Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Enable tenv and testifylint rules (#32852)TheFox0x72024-12-156-11/+11
| | | | Enables tenv and testifylint linters closes: https://github.com/go-gitea/gitea/issues/32842
* Update golangci-lint to v1.62.2, fix issues (#32845)silverwind2024-12-151-5/+5
| | | Update it and fix new issues related to `redefines-builtin-id`
* Make API "compare" accept commit IDs (#32801)wxiaoguang2024-12-123-3/+43
|
* Use batch database operations instead of one by one to optimze api pulls ↵Lunny Xiao2024-12-111-8/+30
| | | | | | | | | | | | | | | | | | | | (#32680) Resolve #31492 The response time for the Pull Requests API has improved significantly, dropping from over `2000ms` to about `350ms` on my local machine. It's about `6` times faster. A key area for further optimization lies in batch-fetching data for `apiPullRequest.ChangedFiles, apiPullRequest.Additions, and apiPullRequest.Deletions`. Tests `TestAPIViewPulls` does exist and new tests added. - This PR also fixes some bugs in `GetDiff` functions. - This PR also fixes data inconsistent in test data. For a pull request, the head branch's reference should be equal to the reference in `pull/xxx/head`.
* Support "merge upstream branch" (Sync fork) (#32741)wxiaoguang2024-12-061-1/+1
| | | | | | | | | Add basic "sync fork" support (GitHub-like) <details> ![image](https://github.com/user-attachments/assets/e71473f4-4518-48c7-b9e2-fedfcd564fc3) </details>
* Fix gogit `GetRefCommitID` (#32705)Zettat1232024-12-032-2/+34
|
* Fix submodule parsing (#32571)Lunny Xiao2024-11-2020-360/+492
| | | | | | | Fix #32568, parse `.gitmodules` correctly --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Reduce integration test overhead (#32475)Rowan Bohde2024-11-1416-51/+0
| | | | | | | | | | | | | In profiling integration tests, I found a couple places where per-test overhead could be reduced: * Avoiding disk IO by synchronizing instead of deleting & copying test Git repository data. This saves ~100ms per test on my machine * When flushing queues in `PrintCurrentTest`, invoke `FlushWithContext` in a parallel. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor LFS SSH and internal routers (#32473)wxiaoguang2024-11-121-3/+2
| | | | | | | | | | | | | | | | | | Gitea instance keeps reporting a lot of errors like "LFS SSH transfer connection denied, pure SSH protocol is disabled". When starting debugging the problem, there are more problems found. Try to address most of them: * avoid unnecessary server side error logs (change `fail()` to not log them) * figure out the broken tests/user2/lfs.git (added comments) * avoid `migratePushMirrors` failure when a repository doesn't exist (ignore them) * avoid "Authorization" (internal&lfs) header conflicts, remove the tricky "swapAuth" and use "X-Gitea-Internal-Auth" * make internal token comparing constant time (it wasn't a serous problem because in a real world it's nearly impossible to timing-attack the token, but good to fix and backport) * avoid duplicate routers (introduce AddOwnerRepoGitLFSRoutes) * avoid "internal (private)" routes using session/web context (they should use private context) * fix incorrect "path" usages (use "filepath") * fix incorrect mocked route point handling (need to check func nil correctly) * split some tests from "git general tests" to "git misc tests" (to keep "git_general_test.go" simple) Still no correct result for Git LFS SSH tests. So the code is kept there (`tests/integration/git_lfs_ssh_test.go`) and a FIXME explains the details.
* Fix git error handling (#32401)wxiaoguang2024-11-022-34/+10
|
* Fix clean tmp dir (#32360)Lunny Xiao2024-10-291-13/+23
| | | | | | | | | | | | Try to fix #31792 Credit to @jeroenlaylo Copied from https://github.com/go-gitea/gitea/issues/31792#issuecomment-2311920520 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* update git book link to v2 (#32221)Ehsan Shirvanian2024-10-091-2/+2
| | | | | | Fix the dead link `https://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository` for empty repositories to help how to clone the repository to `https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository` which is v2 of the git book. This also updates download git links
* bump to go 1.23 (#31855)techknowlogick2024-09-101-1/+1
|
* Refactor the usage of batch catfile (#31754)Lunny Xiao2024-08-2013-72/+179
| | | | | | | | | | When opening a repository, it will call `ensureValidRepository` and also `CatFileBatch`. But sometimes these will not be used until repository closed. So it's a waste of CPU to invoke 3 times git command for every open repository. This PR removed all of these from `OpenRepository` but only kept checking whether the folder exists. When a batch is necessary, the necessary functions will be invoked.
* Fix `IsObjectExist` with gogit (#31790)Jason Song2024-08-093-9/+119
| | | | | | | | | | | | | Fix #31271. When gogit is enabled, `IsObjectExist` calls `repo.gogitRepo.ResolveRevision`, which is not correct. It's for checking references not objects, it could work with commit hash since it's both a valid reference and a commit object, but it doesn't work with blob objects. So it causes #31271 because it reports that all blob objects do not exist.
* Add `TAGS` to `TEST_TAGS` and fix bugs found with gogit (#31791)Jason Song2024-08-072-1/+15
| | | | | | | | | | | Found at https://github.com/go-gitea/gitea/pull/31790#issuecomment-2272898915 `unit-tests-gogit` never work since the workflow set `TAGS` with `gogit`, but the Makefile use `TEST_TAGS`. This PR adds the values of `TAGS` to `TEST_TAGS`, ensuring that setting `TAGS` is always acceptable and avoiding confusion about which one should be set.
* Fix protected branch files detection on pre_receive hook (#31778)Lunny Xiao2024-08-064-7/+74
| | | | | | | | | | | | | | | Fix #31738 When pushing a new branch, the old commit is zero. Most git commands cannot recognize the zero commit id. To get the changed files in the push, we need to get the first diverge commit of this branch. In most situations, we could check commits one by one until one commit is contained by another branch. Then we will think that commit is the diverge point. And in a pre-receive hook, this will be more difficult because all commits haven't been merged and they actually stored in a temporary place by git. So we need to bring some envs to let git know the commit exist.
* Fix slow patch checking with commits that add or remove many files (#31548)Brecht Van Lommel2024-07-041-8/+27
| | | | | | | | | | | | | Running git update-index for every individual file is slow, so add and remove everything with a single git command. When such a big commit lands in the default branch, it could cause PR creation and patch checking for all open PRs to be slow, or time out entirely. For example, a commit that removes 1383 files was measured to take more than 60 seconds and timed out. With this change checking took about a second. This is related to #27967, though this will not help with commits that change many lines in few files.
* Refactor sha1 and time-limited code (#31023)wxiaoguang2024-05-202-0/+25
| | | | | | | Remove "EncodeSha1", it shouldn't be used as a general purpose hasher (just like we have removed "EncodeMD5" in #28622) Rewrite the "time-limited code" related code and write better tests, the old code doesn't seem quite right.
* Make "sync branch" also sync object format and add tests (#30878)wxiaoguang2024-05-061-27/+0
|
* Make sure git version&feature are always prepared (#30877)wxiaoguang2024-05-0612-124/+93
| | | Otherwise there would be more similar issues like #29287
* Improve grep search (#30843)wxiaoguang2024-05-032-0/+22
| | | | Reduce the context line number to 1, make "git grep" search respect the include/exclude patter, and fix #30785
* Resolve lint for unused parameter and unnecessary type arguments (#30750)Chongyi Zheng2024-04-296-24/+14
| | | | | | | | | | Resolve all cases for `unused parameter` and `unnecessary type arguments` Related: #30729 --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Update misspell to 0.5.1 and add `misspellings.csv` (#30573)silverwind2024-04-271-1/+1
| | | | | | Misspell 0.5.0 supports passing a csv file to extend the list of misspellings, so I added some common ones from the codebase. There is at least one typo in a API response so we need to decided whether to revert that and then likely remove the dict entry.
* Fix incorrect object id hash function (#30708)wxiaoguang2024-04-263-15/+8
| | | | | | | | | | | | | Great thanks to @oliverpool for figuring out the problem and proposing a fix. Regression of #28138 Incorrect hash causes the user's LFS files get all deleted when running `doctor fix all` (by the way, remove unused/non-standard comments) Co-authored-by: Giteabot <teabot@gitea.io>
* Deduplicate lfs common code (#30704)wxiaoguang2024-04-263-48/+42
|
* Enable more `revive` linter rules (#30608)silverwind2024-04-225-11/+8
| | | | | | | | | | | Noteable additions: - `redefines-builtin-id` forbid variable names that shadow go builtins - `empty-lines` remove unnecessary empty lines that `gofumpt` does not remove for some reason - `superfluous-else` eliminate more superfluous `else` branches Rules are also sorted alphabetically and I cleaned up various parts of `.golangci.yml`.
* Fix commit file status parser (#30602)wxiaoguang2024-04-191-1/+1
| | | Try to fix #30492
* Refactor cache and disable go-chi cache (#30417)wxiaoguang2024-04-131-11/+4
| | | use built-in cache package to wrap external go-chi cache package
* Limit the max line length when parsing git grep output (#30418)wxiaoguang2024-04-122-4/+26
|
* Refactor commit signature parser (#30228)wxiaoguang2024-04-017-98/+134
| | | | | | | To make it more flexible and support SSH signature. The existing tests are not changed, there are also tests covering `parseTagRef` which also calls `parsePayloadSignature` now. Add some new tests to `Test_parseTagData`
* Include encoding in signature payload (#30174)KN4CK3R2024-03-293-0/+75
| | | | | | | | | | | | | Fixes #30119 Include the encoding in the signature payload. before ![grafik](https://github.com/go-gitea/gitea/assets/1666336/01ab94a3-8af5-4d6f-be73-a10b65a15421) after ![grafik](https://github.com/go-gitea/gitea/assets/1666336/3a37d438-c70d-4d69-b178-d170e74aa683)
* Fix git grep search limit, add test (#30071)wxiaoguang2024-03-252-1/+17
| | | Fix #30069
* Support repo code search without setting up an indexer (#29998)wxiaoguang2024-03-244-7/+159
| | | | | | | | | | | | | | | | | By using git's ability, end users (especially small instance users) do not need to enable the indexer, they could also benefit from the code searching feature. Fix #29996 ![image](https://github.com/go-gitea/gitea/assets/2114189/11b7e458-88a4-480d-b4d7-72ee59406dd1) ![image](https://github.com/go-gitea/gitea/assets/2114189/0fe777d5-c95c-4288-a818-0427680805b6) --------- Co-authored-by: silverwind <me@silverwind.io>
* Fix some pending problems (#29985)wxiaoguang2024-03-222-6/+5
| | | | | | | | | | | | | | | | | These changes are quite independent and trivial, so I don't want to open too many PRs. * https://github.com/go-gitea/gitea/pull/29882#discussion_r1529607091 * the `f.Close` should be called properly * the error message could be more meaningful (https://github.com/go-gitea/gitea/pull/29882#pullrequestreview-1942557935) * https://github.com/go-gitea/gitea/pull/29859#pullrequestreview-1942324716 * the new translation strings don't take arguments * https://github.com/go-gitea/gitea/pull/28710#discussion_r1443778807 * stale for long time * #28140 * a form was forgotten to be changed to work with backend code
* Fix loadOneBranch panic (#29938)wxiaoguang2024-03-201-1/+1
| | | | | | Try to fix #29936 Far from ideal, but still better than panic.
* Fix missing error check of bufio.Scanner (#29882)coldWater2024-03-192-0/+9
| | | maybe more
* Lazy load object format with command line and don't do it in OpenRepository ↵Lunny Xiao2024-03-1215-31/+72
| | | | | | | (#29712) Most time, when invoking `git.OpenRepository`, `objectFormat` will not be used, so it's a waste to invoke commandline to get the object format. This PR make it a lazy operation, only invoke that when necessary.
* remove repetitive words (#29695)pengqiseven2024-03-111-1/+1
| | | Signed-off-by: pengqiseven <912170095@qq.com>
* Move get/set default branch from git package to gitrepo package to hide ↵Lunny Xiao2024-03-081-9/+2
| | | | repopath (#29126)
* Make wiki default branch name changable (#29603)wxiaoguang2024-03-062-4/+4
| | | | | | | | | Fix #29000 Fix #28685 Fix #18568 Related: #27497 And by the way fix #24036, add a Cancel button there (one line)