|
SVCS - English Documentation
|
Manages the Staging Area (Index) of the VCS repository. More...
#include <Index.hxx>
Public Member Functions | |
| Index (const fs::path &vcs_root_path, fs::path repo_root_path, ObjectStorage &storage) | |
| Constructs the Index manager, setting up paths and loading the index. | |
| ~Index () | |
| Destructor. | |
| void | addEntry (const IndexEntry &entry) |
| Adds or updates an entry in the staging area. | |
| const IndexEntry * | getEntry (const fs::path &file_path) const |
| Retrieves an entry from the index by its relative file path. | |
| void | load () |
| Loads the index entries from the index file on disk (temporary text format). | |
| void | save () const |
| Saves the current state of the index entries to the index file (temporary text format). | |
| bool | write () const |
| Another saving function (like load) but returns bool. | |
| bool | isFileModified (const fs::path &file_path) const |
| Checks if a file in the working directory has been modified since it was last staged. | |
| void | stage_file (const fs::path &relative_path) |
| Stages a file by creating a Blob object, saving it to storage, and updating the Index entry (Core logic of 'svcs add'). | |
| std::string | createTreeObject () |
| Creates the hierarchical Tree structure based on the current staged entries and saves the Tree objects to ObjectStorage. | |
Manages the Staging Area (Index) of the VCS repository.
The Index class is responsible for reading and writing the list of staged files to the index file (.svcs/index), managing the 'svcs add' operation, and providing the necessary structure for commit creation.
| svcs::core::Index::Index | ( | const fs::path & | vcs_root_path, |
| fs::path | repo_root_path, | ||
| ObjectStorage & | storage ) |
Constructs the Index manager, setting up paths and loading the index.
| vcs_root_path | The path to the VCS control directory (e.g., .svcs). |
| repo_root_path | The path to the repository's working directory root. |
| storage | Reference to the ObjectStorage instance. |
| void svcs::core::Index::addEntry | ( | const IndexEntry & | entry | ) |
Adds or updates an entry in the staging area.
| entry | The IndexEntry object to be added or updated. |
| std::string svcs::core::Index::createTreeObject | ( | ) |
Creates the hierarchical Tree structure based on the current staged entries and saves the Tree objects to ObjectStorage.
| std::runtime_error | If the index is empty or tree creation fails. |
|
nodiscard |
Retrieves an entry from the index by its relative file path.
| file_path | The relative path of the file. |
|
nodiscard |
Checks if a file in the working directory has been modified since it was last staged.
| file_path | The relative path of the file to check. |
| void svcs::core::Index::load | ( | ) |
Loads the index entries from the index file on disk (temporary text format).
| std::runtime_error | If the index file cannot be read. |
| void svcs::core::Index::save | ( | ) | const |
Saves the current state of the index entries to the index file (temporary text format).
| std::runtime_error | If the index file cannot be written. |
| void svcs::core::Index::stage_file | ( | const fs::path & | relative_path | ) |
|
nodiscard |
Another saving function (like load) but returns bool.
| std::runtime_error | If the index file cannot be written. |