Skip to content

Refactor getpatch/getdiff functions and remove unnecessary fallback#32817

Merged
lunny merged 6 commits into
go-gitea:mainfrom
lunny:lunny/refactor_diff_funcs
Dec 24, 2024
Merged

Refactor getpatch/getdiff functions and remove unnecessary fallback#32817
lunny merged 6 commits into
go-gitea:mainfrom
lunny:lunny/refactor_diff_funcs

Conversation

@lunny
Copy link
Copy Markdown
Member

@lunny lunny commented Dec 12, 2024

Extract from #32786

git diff a..b is equal to git diff a b which is different from git diff a...b. For the pull request, we should always use git diff a...b.

@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Dec 12, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 12, 2024
@lunny lunny added this to the 1.24.0 milestone Dec 17, 2024
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Dec 19, 2024
Comment thread modules/git/repo_compare.go
@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Dec 23, 2024
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Dec 24, 2024
Copy link
Copy Markdown
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.

To be honest, I do not think the parseCompareArgs behavior is right.

It sometimes returns {"a..b"}, sometimes returns {"a", "b"}, does it really make sense? Why not make callers just pass "a...b" or "a..b"? And what's the use case for parsing a b (space separator)?

@lunny
Copy link
Copy Markdown
Member Author

lunny commented Dec 24, 2024

To be honest, I do not think the parseCompareArgs behavior is right.

It sometimes returns {"a..b"}, sometimes returns {"a", "b"}, does it really make sense? Why not make callers just pass "a...b" or "a..b"? And what's the use case for parsing a b (space separator)?

We can strictly parseCompareArgs only accept a...b and a..b and refuse a b if you think that's a problem. Although git supports both a..b and a b. I think it's just a habit or legacy reason.

Comment thread services/pull/patch.go Outdated
@wxiaoguang
Copy link
Copy Markdown
Contributor

wxiaoguang commented Dec 24, 2024

and refuse a b if you think that's a problem. Although git supports both a..b and a b. I think it's just a habit or legacy reason.

Yes, it is absolutely a problem. It is not a right habit or legacy reason. Git does NOT support git diff "a b". It only accepts git diff "a" "b" as separate arguments (aka "slice" in Golang), not in ONE string.

@pull-request-size pull-request-size Bot added size/M and removed size/L labels Dec 24, 2024
@wxiaoguang wxiaoguang changed the title Refactor getpatch/getdiff functions and remove fallback automatically Refactor getpatch/getdiff functions and remove unnecessary fallback Dec 24, 2024
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Dec 24, 2024
@lunny lunny merged commit b8b690f into go-gitea:main Dec 24, 2024
@lunny lunny deleted the lunny/refactor_diff_funcs branch December 24, 2024 06:29
zjjhot added a commit to zjjhot/gitea that referenced this pull request Dec 25, 2024
* giteaofficial/main:
  demilestone should not include milestone (go-gitea#32923)
  fix textarea newline handle (go-gitea#32966)
  Fix Azure blob object `Seek`  (go-gitea#32974)
  Fix maven pom inheritance (go-gitea#32943)
  Refactor arch route handlers (go-gitea#32972)
  [skip ci] Updated translations via Crowdin
  Refactor tmpl and blob_excerpt (go-gitea#32967)
  Clarify path param naming (go-gitea#32969)
  Refactor getpatch/getdiff functions and remove unnecessary fallback (go-gitea#32817)
  Refactor request context (go-gitea#32956)
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Mar 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/refactoring Existing code has been cleaned up. There should be no new functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants