]>
Commit | Line | Data |
---|---|---|
ae563542 LT |
1 | #ifndef REVISION_H |
2 | #define REVISION_H | |
3 | ||
ef3ca954 | 4 | #include "commit.h" |
6b61ec05 | 5 | #include "parse-options.h" |
0843acfd | 6 | #include "grep.h" |
894a9d33 | 7 | #include "notes.h" |
cf394719 | 8 | #include "pretty.h" |
19ecb564 | 9 | #include "diff.h" |
87be2523 | 10 | #include "commit-slab-decl.h" |
6b61ec05 | 11 | |
208acbfb | 12 | /* Remember to update object flag allocation in object.h */ |
ae563542 LT |
13 | #define SEEN (1u<<0) |
14 | #define UNINTERESTING (1u<<1) | |
7dc0fe3b | 15 | #define TREESAME (1u<<2) |
765ac8ec | 16 | #define SHOWN (1u<<3) |
7ae0b0cb | 17 | #define TMP_MARK (1u<<4) /* for isolated cases; clean after use */ |
384e99a4 | 18 | #define BOUNDARY (1u<<5) |
2b064697 | 19 | #define CHILD_SHOWN (1u<<6) |
1b65a5aa | 20 | #define ADDED (1u<<7) /* Parents already parsed and added? */ |
577ed5c2 | 21 | #define SYMMETRIC_LEFT (1u<<8) |
adbbb31e | 22 | #define PATCHSAME (1u<<9) |
7f34a46f | 23 | #define BOTTOM (1u<<10) |
99c9aa95 MD |
24 | /* |
25 | * Indicates object was reached by traversal. i.e. not given by user on | |
26 | * command-line or stdin. | |
27 | * NEEDSWORK: NOT_USER_GIVEN doesn't apply to commits because we only support | |
28 | * filtering trees and blobs, but it may be useful to support filtering commits | |
29 | * in the future. | |
30 | */ | |
31 | #define NOT_USER_GIVEN (1u<<25) | |
1b32dece | 32 | #define TRACK_LINEAR (1u<<26) |
99c9aa95 | 33 | #define ALL_REV_FLAGS (((1u<<11)-1) | NOT_USER_GIVEN | TRACK_LINEAR) |
ae563542 | 34 | |
33e7018c LH |
35 | #define DECORATE_SHORT_REFS 1 |
36 | #define DECORATE_FULL_REFS 2 | |
37 | ||
91539833 | 38 | struct log_info; |
2abf3503 NTND |
39 | struct repository; |
40 | struct rev_info; | |
894a9d33 | 41 | struct string_list; |
53d00b39 | 42 | struct saved_parents; |
87be2523 | 43 | define_shared_commit_slab(revision_sources, char *); |
8efdc326 | 44 | |
281eee47 JH |
45 | struct rev_cmdline_info { |
46 | unsigned int nr; | |
47 | unsigned int alloc; | |
48 | struct rev_cmdline_entry { | |
49 | struct object *item; | |
50 | const char *name; | |
51 | enum { | |
52 | REV_CMD_REF, | |
53 | REV_CMD_PARENTS_ONLY, | |
54 | REV_CMD_LEFT, | |
55 | REV_CMD_RIGHT, | |
a765499a | 56 | REV_CMD_MERGE_BASE, |
281eee47 JH |
57 | REV_CMD_REV |
58 | } whence; | |
59 | unsigned flags; | |
60 | } *rev; | |
61 | }; | |
62 | ||
ca92e59e MZ |
63 | #define REVISION_WALK_WALK 0 |
64 | #define REVISION_WALK_NO_WALK_SORTED 1 | |
65 | #define REVISION_WALK_NO_WALK_UNSORTED 2 | |
66 | ||
ae563542 LT |
67 | struct rev_info { |
68 | /* Starting list */ | |
69 | struct commit_list *commits; | |
1f1e895f | 70 | struct object_array pending; |
2abf3503 | 71 | struct repository *repo; |
ae563542 | 72 | |
86ab4906 JH |
73 | /* Parents of shown commits */ |
74 | struct object_array boundary_commits; | |
75 | ||
281eee47 JH |
76 | /* The end-points specified by the end user */ |
77 | struct rev_cmdline_info cmdline; | |
78 | ||
e7b432c5 JH |
79 | /* excluding from --branches, --refs, etc. expansion */ |
80 | struct string_list *ref_excludes; | |
81 | ||
ae563542 LT |
82 | /* Basic information */ |
83 | const char *prefix; | |
02e54220 | 84 | const char *def; |
afe069d1 | 85 | struct pathspec prune_data; |
08f704f2 | 86 | |
7ba82629 JK |
87 | /* |
88 | * Whether the arguments parsed by setup_revisions() included any | |
89 | * "input" revisions that might still have yielded an empty pending | |
90 | * list (e.g., patterns like "--all" or "--glob"). | |
91 | */ | |
92 | int rev_input_given; | |
93 | ||
a12cbe23 JK |
94 | /* |
95 | * Whether we read from stdin due to the --stdin option. | |
96 | */ | |
97 | int read_from_stdin; | |
98 | ||
08f704f2 JH |
99 | /* topo-sort */ |
100 | enum rev_sort_order sort_order; | |
101 | ||
e35b6ac5 SG |
102 | unsigned int early_output; |
103 | ||
104 | unsigned int ignore_missing:1, | |
2db1a43f | 105 | ignore_missing_links:1; |
cdcefbc9 | 106 | |
ae563542 LT |
107 | /* Traversal flags */ |
108 | unsigned int dense:1, | |
53b2c823 | 109 | prune:1, |
ca92e59e | 110 | no_walk:2, |
ae563542 | 111 | remove_empty_trees:1, |
9202434c | 112 | simplify_history:1, |
ae563542 | 113 | topo_order:1, |
6546b593 | 114 | simplify_merges:1, |
78892e32 | 115 | simplify_by_decoration:1, |
ff9445be | 116 | single_worktree:1, |
ae563542 LT |
117 | tag_objects:1, |
118 | tree_objects:1, | |
119 | blob_objects:1, | |
5a48d240 | 120 | verify_objects:1, |
d9a83684 | 121 | edge_hint:1, |
1684c1b2 | 122 | edge_hint_aggressive:1, |
d9a83684 | 123 | limited:1, |
03a9683d | 124 | unpacked:1, |
86ab4906 | 125 | boundary:2, |
f69c5018 | 126 | count:1, |
74bd9029 | 127 | left_right:1, |
60adf7d7 MG |
128 | left_only:1, |
129 | right_only:1, | |
885cf808 AS |
130 | rewrite_parents:1, |
131 | print_parents:1, | |
d467a525 | 132 | show_decorations:1, |
0053e902 | 133 | reverse:1, |
498bcd31 | 134 | reverse_output_stage:1, |
d7a17cad | 135 | cherry_pick:1, |
adbbb31e | 136 | cherry_mark:1, |
ad3f9a71 | 137 | bisect:1, |
ebdc94f3 | 138 | ancestry_path:1, |
12da1d1f | 139 | first_parent_only:1, |
ce5b6f9b | 140 | line_level_traverse:1, |
f3d618d2 | 141 | tree_blobs_in_commit_order:1, |
df11e196 | 142 | |
7c0fe330 MD |
143 | /* |
144 | * Blobs are shown without regard for their existence. | |
145 | * But not so for trees: unless exclude_promisor_objects | |
146 | * is set and the tree in question is a promisor object; | |
147 | * OR ignore_missing_links is set, the revision walker | |
148 | * dies with a "bad tree object HASH" message when | |
149 | * encountering a missing tree. For callers that can | |
150 | * handle missing trees and want them to be filterable | |
151 | * and showable, set this to true. The revision walker | |
152 | * will filter and show such a missing tree as usual, | |
153 | * but will not attempt to recurse into this tree | |
154 | * object. | |
155 | */ | |
156 | do_not_die_on_missing_tree:1, | |
157 | ||
df11e196 JT |
158 | /* for internal use only */ |
159 | exclude_promisor_objects:1; | |
ae563542 | 160 | |
cd2bdc53 LT |
161 | /* Diff flags */ |
162 | unsigned int diff:1, | |
163 | full_diff:1, | |
164 | show_root_diff:1, | |
165 | no_commit_id:1, | |
166 | verbose_header:1, | |
167 | ignore_merges:1, | |
168 | combine_merges:1, | |
169 | dense_combined_merges:1, | |
170 | always_show_header:1; | |
171 | ||
172 | /* Format info */ | |
91539833 | 173 | unsigned int shown_one:1, |
bd1470b8 | 174 | shown_dashes:1, |
02e54220 | 175 | show_merge:1, |
66b2ed09 JH |
176 | show_notes:1, |
177 | show_notes_given:1, | |
0c37f1fc | 178 | show_signature:1, |
66b2ed09 | 179 | pretty_given:1, |
4da45bef | 180 | abbrev_commit:1, |
0c47695a | 181 | abbrev_commit_given:1, |
3a30aa17 | 182 | zero_commit:1, |
7fefda5c | 183 | use_terminator:1, |
f4ea32f0 | 184 | missing_newline:1, |
9553d2b2 JK |
185 | date_mode_explicit:1, |
186 | preserve_subject:1; | |
8b3dce56 | 187 | unsigned int disable_stdin:1; |
1b32dece NTND |
188 | /* --show-linear-break */ |
189 | unsigned int track_linear:1, | |
190 | track_first_time:1, | |
191 | linear:1; | |
8b3dce56 | 192 | |
a5481a6c | 193 | struct date_mode date_mode; |
0893eec8 JH |
194 | int expand_tabs_in_log; /* unset if negative */ |
195 | int expand_tabs_in_log_default; | |
106d710b | 196 | |
cd2bdc53 LT |
197 | unsigned int abbrev; |
198 | enum cmit_fmt commit_format; | |
91539833 | 199 | struct log_info *loginfo; |
596524b3 | 200 | int nr, total; |
698ce6f8 | 201 | const char *mime_boundary; |
108dab28 SB |
202 | const char *patch_suffix; |
203 | int numbered_files; | |
5fe10fe8 | 204 | int reroll_count; |
e1a37346 | 205 | char *message_id; |
a9080475 | 206 | struct ident_split from_ident; |
b079c50e | 207 | struct string_list *ref_message_ids; |
5289c56a | 208 | int add_signoff; |
20ff0680 | 209 | const char *extra_headers; |
52883fbd | 210 | const char *log_reencode; |
2d9e4a47 | 211 | const char *subject_prefix; |
c112f689 | 212 | int no_inline; |
9fa3465d | 213 | int show_log_size; |
0e2913b0 | 214 | struct string_list *mailmap; |
cd2bdc53 | 215 | |
8ecae9b0 | 216 | /* Filter by commit log message */ |
0843acfd | 217 | struct grep_opt grep_filter; |
22dfa8a2 CJ |
218 | /* Negate the match of grep_filter */ |
219 | int invert_grep; | |
8ecae9b0 | 220 | |
7fefda5c AS |
221 | /* Display history graph */ |
222 | struct git_graph *graph; | |
223 | ||
ae563542 | 224 | /* special limits */ |
d5db6c9e | 225 | int skip_count; |
ae563542 | 226 | int max_count; |
dddbad72 JS |
227 | timestamp_t max_age; |
228 | timestamp_t min_age; | |
ad5aeede MG |
229 | int min_parents; |
230 | int max_parents; | |
a330de31 VM |
231 | int (*include_check)(struct commit *, void *); |
232 | void *include_check_data; | |
8efdc326 | 233 | |
cd2bdc53 | 234 | /* diff info for patches and for paths limiting */ |
c4e05b1a | 235 | struct diff_options diffopt; |
cd2bdc53 | 236 | struct diff_options pruning; |
c4e05b1a | 237 | |
8860fd42 | 238 | struct reflog_walk_info *reflog_info; |
f35f5603 | 239 | struct decoration children; |
faf0156b | 240 | struct decoration merge_simplification; |
d0af663e | 241 | struct decoration treesame; |
894a9d33 TR |
242 | |
243 | /* notes-specific options: which refs to show */ | |
244 | struct display_notes_opt notes_opt; | |
f69c5018 | 245 | |
126facf8 ES |
246 | /* interdiff */ |
247 | const struct object_id *idiff_oid1; | |
248 | const struct object_id *idiff_oid2; | |
5ac290f9 | 249 | const char *idiff_title; |
126facf8 | 250 | |
31e2617a ES |
251 | /* range-diff */ |
252 | const char *rdiff1; | |
253 | const char *rdiff2; | |
254 | int creation_factor; | |
4ee99689 | 255 | const char *rdiff_title; |
31e2617a | 256 | |
f69c5018 TR |
257 | /* commit counts */ |
258 | int count_left; | |
259 | int count_right; | |
b388e14b | 260 | int count_same; |
12da1d1f TR |
261 | |
262 | /* line level range that we are chasing */ | |
263 | struct decoration line_log_data; | |
53d00b39 TR |
264 | |
265 | /* copies of the parent lists, for --full-diff display */ | |
266 | struct saved_parents *saved_parents_slab; | |
1b32dece NTND |
267 | |
268 | struct commit_list *previous_parents; | |
269 | const char *break_bar; | |
87be2523 NTND |
270 | |
271 | struct revision_sources *sources; | |
ae563542 LT |
272 | }; |
273 | ||
d16ec9cd | 274 | int ref_excluded(struct string_list *, const char *path); |
ff32d342 JH |
275 | void clear_ref_exclusion(struct string_list **); |
276 | void add_ref_exclusion(struct string_list **, const char *exclude); | |
277 | ||
278 | ||
8efdc326 | 279 | #define REV_TREE_SAME 0 |
ceff8e7a LT |
280 | #define REV_TREE_NEW 1 /* Only new files */ |
281 | #define REV_TREE_OLD 2 /* Only files removed */ | |
282 | #define REV_TREE_DIFFERENT 3 /* Mixed changes */ | |
8efdc326 | 283 | |
ae563542 | 284 | /* revision.c */ |
cdcefbc9 | 285 | typedef void (*show_early_output_fn_t)(struct rev_info *, struct commit_list *); |
4dc1db0b | 286 | extern volatile show_early_output_fn_t show_early_output; |
8efdc326 | 287 | |
32962c9b JH |
288 | struct setup_revision_opt { |
289 | const char *def; | |
b4490059 | 290 | void (*tweak)(struct rev_info *, struct setup_revision_opt *); |
2abf3503 | 291 | const char *submodule; /* TODO: drop this and use rev_info->repo */ |
6d5b93f2 | 292 | int assume_dashdash; |
d5f6b1d7 | 293 | unsigned revarg_opt; |
32962c9b JH |
294 | }; |
295 | ||
2abf3503 NTND |
296 | #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS |
297 | #define init_revisions(revs, prefix) repo_init_revisions(the_repository, revs, prefix) | |
298 | #endif | |
299 | void repo_init_revisions(struct repository *r, | |
300 | struct rev_info *revs, | |
301 | const char *prefix); | |
d16ec9cd NTND |
302 | int setup_revisions(int argc, const char **argv, struct rev_info *revs, |
303 | struct setup_revision_opt *); | |
304 | void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx, | |
305 | const struct option *options, | |
306 | const char * const usagestr[]); | |
8e676e8b | 307 | #define REVARG_CANNOT_BE_FILENAME 01 |
d5f6b1d7 | 308 | #define REVARG_COMMITTISH 02 |
d16ec9cd NTND |
309 | int handle_revision_arg(const char *arg, struct rev_info *revs, |
310 | int flags, unsigned revarg_opt); | |
5d6f0935 | 311 | |
d16ec9cd NTND |
312 | void reset_revision_walk(void); |
313 | int prepare_revision_walk(struct rev_info *revs); | |
314 | struct commit *get_revision(struct rev_info *revs); | |
315 | char *get_revision_mark(const struct rev_info *revs, | |
316 | const struct commit *commit); | |
317 | void put_revision_mark(const struct rev_info *revs, | |
318 | const struct commit *commit); | |
a4a88b2b | 319 | |
d16ec9cd | 320 | void mark_parents_uninteresting(struct commit *commit); |
b3c7eef9 | 321 | void mark_tree_uninteresting(struct repository *r, struct tree *tree); |
ae563542 | 322 | |
d16ec9cd | 323 | void show_object_with_name(FILE *, struct object *, const char *); |
91f17516 | 324 | |
d16ec9cd NTND |
325 | void add_pending_object(struct rev_info *revs, |
326 | struct object *obj, const char *name); | |
327 | void add_pending_oid(struct rev_info *revs, | |
328 | const char *name, const struct object_id *oid, | |
329 | unsigned int flags); | |
ae563542 | 330 | |
d16ec9cd NTND |
331 | void add_head_to_pending(struct rev_info *); |
332 | void add_reflogs_to_pending(struct rev_info *, unsigned int flags); | |
333 | void add_index_objects_to_pending(struct rev_info *, unsigned int flags); | |
3384a2df | 334 | |
252a7c02 LT |
335 | enum commit_action { |
336 | commit_ignore, | |
337 | commit_show, | |
338 | commit_error | |
339 | }; | |
340 | ||
d16ec9cd NTND |
341 | enum commit_action get_commit_action(struct rev_info *revs, |
342 | struct commit *commit); | |
343 | enum commit_action simplify_commit(struct rev_info *revs, | |
344 | struct commit *commit); | |
252a7c02 | 345 | |
c7edcae0 BY |
346 | enum rewrite_result { |
347 | rewrite_one_ok, | |
348 | rewrite_one_noparents, | |
349 | rewrite_one_error | |
350 | }; | |
351 | ||
352 | typedef enum rewrite_result (*rewrite_parent_fn_t)(struct rev_info *revs, struct commit **pp); | |
353 | ||
d16ec9cd NTND |
354 | int rewrite_parents(struct rev_info *revs, |
355 | struct commit *commit, | |
356 | rewrite_parent_fn_t rewrite_parent); | |
53d00b39 TR |
357 | |
358 | /* | |
0131c490 JH |
359 | * The log machinery saves the original parent list so that |
360 | * get_saved_parents() can later tell what the real parents of the | |
361 | * commits are, when commit->parents has been modified by history | |
362 | * simpification. | |
53d00b39 TR |
363 | * |
364 | * get_saved_parents() will transparently return commit->parents if | |
365 | * history simplification is off. | |
366 | */ | |
d16ec9cd | 367 | struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit); |
53d00b39 | 368 | |
ae563542 | 369 | #endif |