0

To explain the origin of my issue, I am currently working with a game engine/programming language (byond/dream maker) that is... janky, one of the limitations of this engine is that there is no way to set custom launch arguments for binaries.

Currently the workaround is that settings are defines in a file __build.dm that can be commented out to set them as true which are applied when building e.g

#define option1 //this one is enabled 
//#define option2 //this one is disabled

The problem is that this file is tracked so that options can be modified, but I don't want to push my changes since it's just enabling some debug settings. But I also want to be able to pull changes to options from upstream.

using .gitignore doesn't work because __build.dm needs to be tracked.

I've tried to use --assume-unchanged and --skip-worktree but the issue is that i have to resolve conflicts when syncing. I couldn't find a way to make it so it would automatically overwrite the local version in favour of the upstream one.

soapcyst
  • 5
  • 1
  • 1
    Does this answer your question? [How can I track system-specific config files in a repo/project?](https://stackoverflow.com/questions/2154948/how-can-i-track-system-specific-config-files-in-a-repo-project) – Jim Redmond Aug 25 '23 at 21:23
  • @JimRedmond I don't think so but I'm also unsure if I'm interpreting it correctly. From my understanding the smudge and clean functions change specified variables in the files so that they are suited for different environments when checking in/out a branch. What I need is for my changes to be ignored by git and that upstream changes will overwrite the specified files. – soapcyst Aug 25 '23 at 21:49

2 Answers2

1

Git doesn't provide a way to ignore changes to tracked files. From the FAQ:

Git doesn’t provide a way to do this. The reason is that if Git needs to overwrite this file, such as during a checkout, it doesn’t know whether the changes to the file are precious and should be kept, or whether they are irrelevant and can safely be destroyed. Therefore, it has to take the safe route and always preserve them.

It’s tempting to try to use certain features of git update-index, namely the assume-unchanged and skip-worktree bits, but these don’t work properly for this purpose and shouldn’t be used this way.

They do have a suggestion for config files, though:

If your goal is to modify a configuration file, it can often be helpful to have a file checked into the repository which is a template or set of defaults which can then be copied alongside and modified as appropriate. This second, modified file is usually ignored to prevent accidentally committing it.

bk2204
  • 64,793
  • 6
  • 84
  • 100
0

The propper way of handling this is to create temporary commits out of these __build.dm modifications.

Then when you are finishing up to merge into main or create a pull request you clean up the branch with an interactive rebase where you remove all such local, private, temporary commits. E.g. you trim down

pick 1002006 Change network retry strategy to exponential backoff 
pick 1002005 ==== debug logging in network code ====
pick 1002004 ==== disable option2 ====
pick 1002003 Make save functionality more responsive
pick 1002002 ==== enable option1 ====
pick 1002001 Fix some bug

to the following

pick 1002006 Change network retry strategy to exponential backoff 
pick 1002003 Make save functionality more responsive
pick 1002001 Fix some bug

You are not limited to just modifications of __build.dm, any temporary modification to any file is possible (debug logging, disable certain unit tests, etc).

hlovdal
  • 26,565
  • 10
  • 94
  • 165