Skip to content

Conversation

meain
Copy link
Contributor

@meain meain commented Jun 29, 2025

Previously, we were producing simple conflict markers by just putting original and generated code into conflict markers. In this implementation, if we have git available, we pass the original and new version through git to produce a more fine grained set of conflicts.

Fixes #932

meain and others added 2 commits June 29, 2025 15:31
Previously, we were producing simple conflict markers by placing
both the original and generated code into conflict markers. if git
is available, pass the original and new version through git to
produce a more fine grained set of conflicts.

* gptel-rewrite.el (gptel--git-merge-conflicts,
gptel--rewrite-merge, gptel--simple-merge-conflicts): Implement by
using two new functions to handle simple and git-based merging.
These functions accept the original and replacement strings as
arguments.
* gptel-rewrite.el (gptel--rewrite-merge-git)
(gptel--rewrite-merge-simple): Rename from
`gptel--git-merge-conflicts' and `gptel--simple-merge-conflicts'.

(gptel--rewrite-merge): Modify the request buffer directly instead
of passing strings around.  Use `call-process' instead of
`shell-command-to-string', which generates a lot more garbage.
@karthink karthink force-pushed the meain/git-conflicts branch from 23742ad to 62f644b Compare June 29, 2025 22:37
@karthink
Copy link
Owner

Thanks @meain. I rewrote the two functions to act on buffer regions instead of passing strings. (The previous, "functional" approach is garbage heavy.)

Can you check if they still work correctly?

@meain
Copy link
Contributor Author

meain commented Jun 30, 2025

The previous, "functional" approach is garbage heavy

Aah, that is something I had not considered.

Can you check if they still work correctly?

Yup, looks good to me :D

@karthink karthink merged commit 70a713f into karthink:master Jun 30, 2025
@karthink
Copy link
Owner

Merged, thanks for the PR @meain!

Aah, that is something I had not considered.

To be fair, it's not much of an issue since the text being rewritten will usually consist of a few paragraphs or functions at most, which isn't much garbage even when it's duplicated twice as a string and again across three separate buffers (as happens when using shell-command-to-string and passing strings around.)

But I never touch working gptel code to improve performance -- plenty of other things to do! So I thought it might be worth getting it right the first time here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better and more fine grained conflicts for rewrite merge

2 participants