Add editor.c grouping functions for editing text files.
PATCH 1/1 Add editor.c grouping functions for editing text files.
The new file is grouping the previous function stripspace from "builtin-stripspace.c", the previous launch_editor from "builtin-tag.c", and a new function read_file, designed to be also shared with the upcoming "builtin-commit.c".
---
This change is committed on top of the current "next".
It is the first proposal for the file editor.c with some functions intended to be shared at least between the recent "builtin-tag.c" and the upcoming "builtin-commit.c" which Kristian is working on.
read_file is a reimplementation of the function read_path which was helping to Kristian in his builtin-commit.c:
http://article.gmane.org/gmane.comp.version-control.git/52892
launch_editor now is just the same that "builtin-tag.c" was using, but since it is currently different than the launch_editor from "builtin-commit.c", it will need more changes which should be discussed here. Every suggestion will be appreciated.
Makefile | 5 +- builtin-stripspace.c | 71 --------------------- builtin-tag.c | 47 +-------------- builtin.h | 1 - editor.c | 165 ++++++++++++++++++++++++++++++++++++++++++++++++++ editor.h | 10 +++ 6 files changed, 179 insertions(+), 120 deletions(-) create mode 100644 editor.c create mode 100644 editor.h
Makefile +3 -2
@@ -284,7 +284,7 @@ LIB_H = \ run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \ tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h \ utf8.h reflog-walk.h patch-ids.h attr.h decorate.h progress.h \ - mailmap.h remote.h + mailmap.h remote.h editor.h DIFF_OBJS = \ diff.o diff-lib.o diffcore-break.o diffcore-order.o \
@@ -306,7 +306,8 @@ LIB_OBJS = \ write_or_die.o trace.o list-objects.o grep.o match-trees.o \ alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \ color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \ - convert.o attr.o decorate.o progress.o mailmap.o symlinks.o remote.o + convert.o attr.o decorate.o progress.o mailmap.o symlinks.o remote.o \ + editor.o BUILTIN_OBJS = \ builtin-add.o \
builtin-stripspace.c +0 -71
77 lines not on this page · raw message
builtin-tag.c +1 -46
59 lines not on this page · raw message
builtin.h +0 -1
@@ -7,7 +7,6 @@ extern const char git_version_string[];extern const char git_usage_string[];extern void help_unknown_cmd (const char *cmd); -extern size_t stripspace (char *buffer,size_t length,int skip_comments);extern int write_tree (unsigned char *sha1,int missing_ok,const char *prefix);extern void prune_packed_objects (int );
editor.c new file +165 -0
165 lines not on this page · raw message
editor.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef EDITOR_H +#define EDITOR_H + +void launch_editor (const char *path,char **buffer,unsigned long *len); +#define ALLOW_STDIN 0x01 +int read_file (const char *path,int flags, +char ** return_buf,unsigned long * return_size); +size_t stripspace (char *buffer,size_t length,int skip_comments); + +#endif
Signature · 1 line
1.5.0