Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create inline conflict markers when copying on a project with already existing files #2005

Open
DanieleIsoni opened this issue Mar 3, 2025 · 3 comments

Comments

@DanieleIsoni
Copy link

Actual Situation

Now when we do copier copy on an existing project we can decide to override an already existing file or skipping it, but not merging the content of the 2 files

Desired Situation

It would be great if we could merge those two files, maybe putting conflict markers on the whole content of the existing file and the new content from the template.

This would be very useful in files like .gitignore or .tool-versions.

Proposed solution

No response

@pawamoy
Copy link
Contributor

pawamoy commented Mar 3, 2025

I don't think it's possible to merge two files with zero common history. There's your existing file with its own Git history, and there's the freshly generated file from copier copy. You can easily get a diff from your file to the new file, but I don't see how you could merge the two 🤔 I suppose your project is tracked by Git, so just overwrite and then stage or unstage parts of the diff manually, just like you would manually resolve conflicts.

@DanieleIsoni
Copy link
Author

DanieleIsoni commented Mar 4, 2025

The use case I hade in mind was to generate a project with template-1 and put in its tasks a command to add to the same project the template-2, but those 2 template have files that needs to be merged (e.g.: .gitignore and .tool-versions). But since the tasks are run just after the copy of template-1, it is not yet git tracked.

I thought what could be done is;

<<<<<<<
template-1 whole file content
=======
template-2 whole file content
>>>>>>>

Does it make more sense now?

@pawamoy
Copy link
Contributor

pawamoy commented Mar 4, 2025

Right, templates that modify the same files is an unsolved problem yet 🙂

Your tasks could definitely git init; git add -A; git commit -m initial before applying the second template. Then nothing prevents the user from deleting the .git folder once they manually "merged" relevant files, to start fresh again.

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

No branches or pull requests

2 participants