Merge branch 'jc/mailinfo-lib'

The implementation of "git mailinfo" was refactored so that a
mailinfo() function can be directly called from inside a process.

* jc/mailinfo-lib: (34 commits)
  mailinfo: remove calls to exit() and die() deep in the callchain
  mailinfo: handle charset conversion errors in the caller
  mailinfo: libify
  mailinfo: keep the parsed log message in a strbuf
  mailinfo: handle_commit_msg() shouldn't be called after finding patchbreak
  mailinfo: move content/content_top to struct mailinfo
  mailinfo: move [ps]_hdr_data to struct mailinfo
  mailinfo: move cmitmsg and patchfile to struct mailinfo
  mailinfo: move charset to struct mailinfo
  mailinfo: move transfer_encoding to struct mailinfo
  mailinfo: move check for metainfo_charset to convert_to_utf8()
  mailinfo: move metainfo_charset to struct mailinfo
  mailinfo: move use_scissors and use_inbody_headers to struct mailinfo
  mailinfo: move add_message_id and message_id to struct mailinfo
  mailinfo: move patch_lines to struct mailinfo
  mailinfo: move filter/header stage to struct mailinfo
  mailinfo: move global "FILE *fin, *fout" to struct mailinfo
  mailinfo: move keep_subject & keep_non_patch_bracket to struct mailinfo
  mailinfo: introduce "struct mailinfo" to hold globals
  mailinfo: move global "line" into mailinfo() function
  ...
This commit is contained in:
Junio C Hamano 2015-10-29 13:59:21 -07:00
commit ba5312da19
4 changed files with 1099 additions and 1035 deletions

View File

@ -731,6 +731,7 @@ LIB_OBJS += list-objects.o
LIB_OBJS += ll-merge.o
LIB_OBJS += lockfile.o
LIB_OBJS += log-tree.o
LIB_OBJS += mailinfo.o
LIB_OBJS += mailmap.o
LIB_OBJS += match-trees.o
LIB_OBJS += merge.o

File diff suppressed because it is too large Load Diff

1037
mailinfo.c Normal file

File diff suppressed because it is too large Load Diff

41
mailinfo.h Normal file
View File

@ -0,0 +1,41 @@
#ifndef MAILINFO_H
#define MAILINFO_H
#define MAX_BOUNDARIES 5
struct mailinfo {
FILE *input;
FILE *output;
FILE *patchfile;
struct strbuf name;
struct strbuf email;
int keep_subject;
int keep_non_patch_brackets_in_subject;
int add_message_id;
int use_scissors;
int use_inbody_headers;
const char *metainfo_charset;
struct strbuf *content[MAX_BOUNDARIES];
struct strbuf **content_top;
struct strbuf charset;
char *message_id;
enum {
TE_DONTCARE, TE_QP, TE_BASE64
} transfer_encoding;
int patch_lines;
int filter_stage; /* still reading log or are we copying patch? */
int header_stage; /* still checking in-body headers? */
struct strbuf **p_hdr_data;
struct strbuf **s_hdr_data;
struct strbuf log_message;
int input_error;
};
extern void setup_mailinfo(struct mailinfo *);
extern int mailinfo(struct mailinfo *, const char *msg, const char *patch);
extern void clear_mailinfo(struct mailinfo *);
#endif /* MAILINFO_H */