Repository: godotengine/godot
File: editor/version_control/version_control_editor_plugin.cpp (C++)

Code before:
	String current_remote = remote_select->get_selected_metadata();
	remote_select->clear();

	remote_select->set_disabled(remotes.is_empty());

	int i = 0;
	for (List<String>::ConstIterator itr = remotes.begin(); itr != remotes.end(); ++itr, ++i) {
		remote_select->add_icon_item(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("ArrowUp"), EditorStringName(EditorIcons)), *itr, i);
		remote_select->set_item_metadata(i, *itr);

		if (*itr == current_remote) {
			remote_select->select(i);
		}
	}
}

void VersionControlEditorPlugin::_commit() {
	CHECK_PLUGIN_INITIALIZED();

	String msg = commit_message->get_text().strip_edges();

	ERR_FAIL_COND_MSG(msg.is_empty(), "No commit message was provided.");

	EditorVCSInterface::get_singleton()->commit(msg);

	if (version_control_dock->get_current_layout() != EditorDock::DOCK_LAYOUT_FLOATING) {
		version_control_dock->hide();
	}

	commit_message->release_focus();
	commit_button->release_focus();
	commit_message->set_text("");

	_refresh_stage_area();
	_refresh_commit_list();
	_refresh_branch_list();
	_clear_diff();
}

void VersionControlEditorPlugin::_branch_item_selected(int p_index) {
	CHECK_PLUGIN_INITIALIZED();

	String branch_name = branch_select->get_item_text(p_index);
	EditorVCSInterface::get_singleton()->checkout_branch(branch_name);

	EditorFileSystem::get_singleton()->scan_changes();
	ScriptEditor::get_singleton()->reload_scripts();

	_refresh_branch_list();
	_refresh_commit_list();
	_refresh_stage_area();

Review comment (suggestion):
```suggestion
	if (version_control_dock->get_current_layout() == EditorDock::DOCK_LAYOUT_HORIZONTAL) {
```
If Version Control ever ends up as a side dock, hiding it won't make sense either.

Although ideally this should be controlled by DockTabContainer (i.e. via a method that decides if a dock can be hidden).

Code after:
		meta_data[SNAME("commit_id")] = commit.id;
		meta_data[SNAME("commit_title")] = commit_display_msg;
		meta_data[SNAME("commit_subtitle")] = commit.msg.substr(line_ending).strip_edges();
		meta_data[SNAME("commit_unix_timestamp")] = commit.unix_timestamp;
		meta_data[SNAME("commit_author")] = commit.author;
		meta_data[SNAME("commit_date_string")] = commit_date_string;

		item->set_text(0, commit_display_msg);
		item->set_text(1, commit.author.strip_edges());
		item->set_metadata(0, meta_data);
	}
}

void VersionControlEditorPlugin::_refresh_remote_list() {
	CHECK_PLUGIN_INITIALIZED();

	List<String> remotes = EditorVCSInterface::get_singleton()->get_remotes();

	String current_remote = remote_select->get_selected_metadata();
	remote_select->clear();

	remote_select->set_disabled(remotes.is_empty());

	int i = 0;
	for (List<String>::ConstIterator itr = remotes.begin(); itr != remotes.end(); ++itr, ++i) {
		remote_select->add_icon_item(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("ArrowUp"), EditorStringName(EditorIcons)), *itr, i);
		remote_select->set_item_metadata(i, *itr);

		if (*itr == current_remote) {
			remote_select->select(i);
		}
	}
}

void VersionControlEditorPlugin::_commit() {
	CHECK_PLUGIN_INITIALIZED();

	String msg = commit_message->get_text().strip_edges();

	ERR_FAIL_COND_MSG(msg.is_empty(), "No commit message was provided.");

	EditorVCSInterface::get_singleton()->commit(msg);

	if (version_control_dock->get_current_layout() == EditorDock::DOCK_LAYOUT_HORIZONTAL) {
		version_control_dock->hide();
	}

	commit_message->release_focus();
	commit_button->release_focus();
	commit_message->set_text("");