Skip to content

Commit 7aeb71a

Browse files
FirstLoveLifegitster
authored andcommitted
trailer: move process_trailers to trailer.h
This function would be used by trailer_process in following commits. Signed-off-by: Li Chen <chenl311@chinatelecom.cn> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6145e03 commit 7aeb71a

File tree

3 files changed

+39
-36
lines changed

3 files changed

+39
-36
lines changed

builtin/interpret-trailers.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -136,42 +136,6 @@ static void read_input_file(struct strbuf *sb, const char *file)
136136
strbuf_complete_line(sb);
137137
}
138138

139-
static void process_trailers(const struct process_trailer_options *opts,
140-
struct list_head *new_trailer_head,
141-
struct strbuf *sb, struct strbuf *out)
142-
{
143-
LIST_HEAD(head);
144-
struct trailer_block *trailer_block;
145-
146-
trailer_block = parse_trailers(opts, sb->buf, &head);
147-
148-
/* Print the lines before the trailer block */
149-
if (!opts->only_trailers)
150-
strbuf_add(out, sb->buf, trailer_block_start(trailer_block));
151-
152-
if (!opts->only_trailers && !blank_line_before_trailer_block(trailer_block))
153-
strbuf_addch(out, '\n');
154-
155-
if (!opts->only_input) {
156-
LIST_HEAD(config_head);
157-
LIST_HEAD(arg_head);
158-
parse_trailers_from_config(&config_head);
159-
parse_trailers_from_command_line_args(&arg_head, new_trailer_head);
160-
list_splice(&config_head, &arg_head);
161-
process_trailers_lists(&head, &arg_head);
162-
}
163-
164-
/* Print trailer block. */
165-
format_trailers(opts, &head, out);
166-
free_trailers(&head);
167-
168-
/* Print the lines after the trailer block as is. */
169-
if (!opts->only_trailers)
170-
strbuf_add(out, sb->buf + trailer_block_end(trailer_block),
171-
sb->len - trailer_block_end(trailer_block));
172-
trailer_block_release(trailer_block);
173-
}
174-
175139
static void interpret_trailers(const struct process_trailer_options *opts,
176140
struct list_head *new_trailer_head,
177141
const char *file)

trailer.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,3 +1235,39 @@ int amend_file_with_trailers(const char *path, const struct strvec *trailer_args
12351235
strvec_pushv(&run_trailer.args, trailer_args->v);
12361236
return run_command(&run_trailer);
12371237
}
1238+
1239+
void process_trailers(const struct process_trailer_options *opts,
1240+
struct list_head *new_trailer_head,
1241+
struct strbuf *sb, struct strbuf *out)
1242+
{
1243+
LIST_HEAD(head);
1244+
struct trailer_block *trailer_block;
1245+
1246+
trailer_block = parse_trailers(opts, sb->buf, &head);
1247+
1248+
/* Print the lines before the trailer block */
1249+
if (!opts->only_trailers)
1250+
strbuf_add(out, sb->buf, trailer_block_start(trailer_block));
1251+
1252+
if (!opts->only_trailers && !blank_line_before_trailer_block(trailer_block))
1253+
strbuf_addch(out, '\n');
1254+
1255+
if (!opts->only_input) {
1256+
LIST_HEAD(config_head);
1257+
LIST_HEAD(arg_head);
1258+
parse_trailers_from_config(&config_head);
1259+
parse_trailers_from_command_line_args(&arg_head, new_trailer_head);
1260+
list_splice(&config_head, &arg_head);
1261+
process_trailers_lists(&head, &arg_head);
1262+
}
1263+
1264+
/* Print trailer block. */
1265+
format_trailers(opts, &head, out);
1266+
free_trailers(&head);
1267+
1268+
/* Print the lines after the trailer block as is. */
1269+
if (!opts->only_trailers)
1270+
strbuf_add(out, sb->buf + trailer_block_end(trailer_block),
1271+
sb->len - trailer_block_end(trailer_block));
1272+
trailer_block_release(trailer_block);
1273+
}

trailer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,7 @@ void trailer_iterator_release(struct trailer_iterator *iter);
202202
*/
203203
int amend_file_with_trailers(const char *path, const struct strvec *trailer_args);
204204

205+
void process_trailers(const struct process_trailer_options *opts,
206+
struct list_head *new_trailer_head,
207+
struct strbuf *sb, struct strbuf *out);
205208
#endif /* TRAILER_H */

0 commit comments

Comments
 (0)