Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ This is a simple attempt at re-creating some of the functionality of the `git` c
- `-p` flag to show the content of the object (pretty-print)
- `--allow-unknown-type` flag to allow unknown object types (to be used with `-t` or `-s`).
- `<object>` argument to specify the object to show.
- `show-ref` - List references in a local repository.
- `--head` flag to include the HEAD reference.
- `--tags` flag to show only tags.
- `--heads` flag to show only heads.
- `--hash=<n>` flag to only show the reference hashes (`n` is the number of characters to show, 4-40).
- `--abbrev=<n>` flag to abbreviate the hashes to `n` characters (4-40)

## Testing

Expand Down
2 changes: 1 addition & 1 deletion src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl CommandArgs for InitArgs {
std::fs::create_dir_all(object_dir)?;
std::fs::create_dir(init_path.join("refs"))?;

// Create the HEAD file with the initial branch.
// Create the main HEAD file.
std::fs::write(
init_path.join("HEAD"),
get_head_ref_content(&self.initial_branch),
Expand Down
3 changes: 3 additions & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use clap::Subcommand;
mod cat_file;
mod hash_object;
mod init;
mod show_ref;

impl Command {
pub fn run(self) -> anyhow::Result<()> {
Expand All @@ -14,6 +15,7 @@ impl Command {
Command::HashObject(args) => args.run(&mut stdout),
Command::Init(args) => args.run(&mut stdout),
Command::CatFile(args) => args.run(&mut stdout),
Command::ShowRef(args) => args.run(&mut stdout),
}
}
}
Expand All @@ -23,6 +25,7 @@ pub(crate) enum Command {
HashObject(hash_object::HashObjectArgs),
Init(init::InitArgs),
CatFile(cat_file::CatFileArgs),
ShowRef(show_ref::ShowRefArgs),
}

pub(crate) trait CommandArgs {
Expand Down
Loading
Loading