From 6a8bbbf82e21d90ef3609aae5046aef54024b5e0 Mon Sep 17 00:00:00 2001 From: Galin Simeonov Date: Fri, 1 Oct 2021 14:05:00 +0300 Subject: Added tree like output --- git_part.h | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'git_part.h') diff --git a/git_part.h b/git_part.h index c42230b..e16b02e 100644 --- a/git_part.h +++ b/git_part.h @@ -4,15 +4,41 @@ #include #include +struct Index_File +{ + FILE *out; + + /*these are used in treelike output*/ + _Bool branches[MAX_CUTOFF]; + /* + offsets between different branches, if the dir name is long this prevents + skewed branches below + */ + int offset[MAX_CUTOFF]; + int indentation; +}; + +struct Index_File *get_index_file(int dir_fd,const char *name); +void release_index_file(struct Index_File *index); + int print_diff_line(const git_diff_delta *delta,const git_diff_hunk *hunk,const git_diff_line *line,FILE *out); void print_diff(FILE *out,git_tree *parent_tree,git_tree *current_tree,git_repository *repo); void print_headers_and_commit_message(FILE *where,git_commit *current_commit,const git_oid *current,_Bool has_diff); void print_commits(int dir_fd,const git_reference *branch, git_repository *repo); void print_commit(git_commit *current_commit,git_commit *parent_commit,FILE *log_file,int diff_directory_fd,git_repository *repo); void print_files_top(int dir_fd,git_commit *top_commit,git_repository *repo); -void print_files(int dir_fd,git_tree *tree,git_repository *repo); -int print_entry(FILE *index_file,const git_tree_entry *entry,int base_dir_fd,git_repository *repo); +void print_files(struct Index_File *index_file,int dir_fd,git_tree *tree,git_repository *repo); +int print_entry(struct Index_File *index_file,const git_tree_entry *entry,int base_dir_fd,git_repository *repo); +static inline void print_tree_entry(struct Index_File *index_file,const char *name,git_object *obj,int base_dir_fd,git_repository *repo); +static inline void print_blob_entry(struct Index_File *index_file,const char *name,git_object *obj,int base_dir_fd,git_repository *repo); void print_branches(git_repository *repo); +void print_indentation_for_treelike_output(struct Index_File *out); + +void increment_indentation(struct Index_File *index,const char *name); +void decrement_indentation(struct Index_File *index); +void indentation_set_is_not_final(struct Index_File *index,_Bool is_final); +void print_files_in_another_index(int base_dir_fd,const char *entry_oid,const char *name,git_tree *tree,git_repository *repo); + #endif -- cgit v1.2.3