I want to easily and nicely diff my gd scripts.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By raould
:warning: Old Version Published before Godot 3 was released.

I wish Godot saved things in a way that was immediately friendly to version control systems and also to human eyes. I want to be able to do side by side diffs to see what I have done since my last commit. That is not fun with the .tscn format as far as I can tell.

I have seen in other Q&A that there are some ways maybe to configure Godot to use text files or something, I can’t say I have followed up on it. I do not think Godot should default to making it hard to diff things. I don’t think I should have to find some place to reconfigure and reexport and whatever all my stuff. At least for my gd scripts. I know some things are more inherently binary, but not gd scripts.

thanks for a great tool.

What are you asking for?
By default Godot let you save scenes in .tscn, which is text-based and friendly to version control because data is ordered before saving. If lines change unexpectedly, that might be a bug.
There is no diff tool built in Godot because that’s not the job of a game engine, it depends on what you use (Git, SVN, Mercurial, Perforce…).

Zylann | 2016-08-24 23:38

Thank you for your comment. I mean that the .tscn file is all mushed together. Lines are mushed together. Also, entire gd scripts are mushed together into the file. It is not very human readable or diffable. I would suggest letting things be individual flies, and not mushing lines together since “\n” only takes up at most a few bytes.

raould | 2016-08-25 05:42

What do you mean?
If you ask Godot to create “built-in” script, of course they will end up in the .tscn file. If you want them in a separate file (which I do), make sure the option is not checked when creating a script.
Also, what do you mean by “mushed together”? What are you using to open /diff the files?
Do you mean there are no line breaks/newlines?

Zylann | 2016-08-25 08:10

Yeah, it seems weird, the .tscn files are fine for my git version control. Each child node, property, resource, etc. is on it’s own line.

rgrams | 2016-08-25 18:29

Thanks for the messages! Various things…

(1) I think it would be more usable with [version control, any text editor, diff programs, unix utilities, etc.] if it were multiple files e.g. one per script. one per material, one per node possibly even – by default. Having to even know about “the option” is to me backwards usability, for me and my personal preferences anyway. The files can be in a directory structure like “bundles”, down one level in the project, if that makes it look any cleaner (ie. replace the file *.tscn with a folder of the same name, and the individual files inside it)

(2) The “\n\t” etc. inside the *.tscn file on linux show up at literal “\n\n” rather than as any sort of actual newline (example below). I know cross-platform line endings are a nightmare. Git supports doing it automagically across platforms for whatever it is worth for example.

Nothing is a show stopper, it is more about solid end to end usability for software project management.

[sub_resource type=“GDScript” id=9]
script/source = "extends Spatial\n\nonready var k_player = get_node( "/root/Spatial/player" )\nonready var k_ground = get_node( "/root/Spatial/grou
nd" )\nonready var theta = PI # 0 radians is north/up.\n# todo: kinematics to get it on the ground for real?\nonready var radius = k_ground.get_scal
e().y + get_scale().y\nonready var z = k_player.get_translation().z\nonready var origin_transform = Transform( Vector3(1,0,0), \\n\tVector3(0,1,0), …

raould | 2016-08-26 05:05