Skip to content

environment: move excludes_file into repo_config_values#8

Open
malon7782 wants to merge 1 commit into
masterfrom
excludes-file-4
Open

environment: move excludes_file into repo_config_values#8
malon7782 wants to merge 1 commit into
masterfrom
excludes-file-4

Conversation

@malon7782

Copy link
Copy Markdown
Owner

The global variable 'excludes_file' is used to track the path to the global ignore file. If this variable is NULL, 'setup_standard_excludes()' in 'dir.c' forcefully evaluates and assigns the XDG default path to it.

Continue the libification effort by encapsulating this lazy-loading fallback logic into a proper getter and moving the variable into 'struct repo_config_values'.

Since 'excludes_file' is a dynamically allocated string, it requires proper heap memory management. Introduce repo_config_values_clear() and wire it up in 'repo_clear()' to safely free this memory when a repository instance is destroyed. Also clean up the heap-allocated 'attributes_file' in this new destructor while we are at it.

Note on transition:

Submodules are currently not supported by repo_config_values(). Since repo_clear() cleans up all repository instances (including submodules), we must bypass them in repo_config_values_clear() to prevent hitting the BUG() in repository.c:59. In the future when submodules are supported, this check should be removed.

Mentored-by: Christian Couder christian.couder@gmail.com
Mentored-by: Ayush Chandekar ayu.chandekar@gmail.com
Mentored-by: Olamide Caleb Bello belkid98@gmail.com

The global variable 'excludes_file' is used to track the path to the
global ignore file. If this variable is NULL, 'setup_standard_excludes()'
in 'dir.c' forcefully evaluates and assigns the XDG default path to it.

Continue the libification effort by encapsulating this lazy-loading
fallback logic into a proper getter and moving the variable into
'struct repo_config_values'.

Since 'excludes_file' is a dynamically allocated string, it requires
proper heap memory management. Introduce repo_config_values_clear()
and wire it up in 'repo_clear()' to safely free this memory when a
repository instance is destroyed. Also clean up the heap-allocated
'attributes_file' in this new destructor while we are at it.

Note on transition:

Submodules are currently not supported by repo_config_values().
Since repo_clear() cleans up all repository instances (including
submodules), we must bypass them in repo_config_values_clear() to
prevent hitting the BUG() in repository.c:59. In the future when
submodules are supported, this check should be removed.

Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Ayush Chandekar <ayu.chandekar@gmail.com>
Mentored-by: Olamide Caleb Bello <belkid98@gmail.com>
Signed-off-by: Tian Yuchen <cat@malon.dev>
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.

1 participant