Imported Upstream version 2.24.2
[platform/upstream/git.git] / revision.h
index 9741302..4134dc6 100644 (file)
@@ -1,11 +1,13 @@
 #ifndef REVISION_H
 #define REVISION_H
 
+#include "commit.h"
 #include "parse-options.h"
 #include "grep.h"
 #include "notes.h"
-#include "commit.h"
+#include "pretty.h"
 #include "diff.h"
+#include "commit-slab-decl.h"
 
 /* Remember to update object flag allocation in object.h */
 #define SEEN           (1u<<0)
 #define SYMMETRIC_LEFT (1u<<8)
 #define PATCHSAME      (1u<<9)
 #define BOTTOM         (1u<<10)
+/*
+ * Indicates object was reached by traversal. i.e. not given by user on
+ * command-line or stdin.
+ * NEEDSWORK: NOT_USER_GIVEN doesn't apply to commits because we only support
+ * filtering trees and blobs, but it may be useful to support filtering commits
+ * in the future.
+ */
+#define NOT_USER_GIVEN (1u<<25)
 #define TRACK_LINEAR   (1u<<26)
-#define ALL_REV_FLAGS  (((1u<<11)-1) | TRACK_LINEAR)
+#define ALL_REV_FLAGS  (((1u<<11)-1) | NOT_USER_GIVEN | TRACK_LINEAR)
+
+#define TOPO_WALK_EXPLORED     (1u<<27)
+#define TOPO_WALK_INDEGREE     (1u<<28)
 
 #define DECORATE_SHORT_REFS    1
 #define DECORATE_FULL_REFS     2
 
-struct rev_info;
 struct log_info;
+struct repository;
+struct rev_info;
 struct string_list;
 struct saved_parents;
+define_shared_commit_slab(revision_sources, char *);
 
 struct rev_cmdline_info {
        unsigned int nr;
@@ -52,10 +67,14 @@ struct rev_cmdline_info {
 #define REVISION_WALK_NO_WALK_SORTED 1
 #define REVISION_WALK_NO_WALK_UNSORTED 2
 
+struct oidset;
+struct topo_walk_info;
+
 struct rev_info {
        /* Starting list */
        struct commit_list *commits;
        struct object_array pending;
+       struct repository *repo;
 
        /* Parents of shown commits */
        struct object_array boundary_commits;
@@ -71,23 +90,36 @@ struct rev_info {
        const char *def;
        struct pathspec prune_data;
 
+       /*
+        * Whether the arguments parsed by setup_revisions() included any
+        * "input" revisions that might still have yielded an empty pending
+        * list (e.g., patterns like "--all" or "--glob").
+        */
+       int rev_input_given;
+
+       /*
+        * Whether we read from stdin due to the --stdin option.
+        */
+       int read_from_stdin;
+
        /* topo-sort */
        enum rev_sort_order sort_order;
 
-       unsigned int    early_output:1,
-                       ignore_missing:1,
+       unsigned int early_output;
+
+       unsigned int    ignore_missing:1,
                        ignore_missing_links:1;
 
        /* Traversal flags */
        unsigned int    dense:1,
                        prune:1,
                        no_walk:2,
-                       show_all:1,
                        remove_empty_trees:1,
                        simplify_history:1,
                        topo_order:1,
                        simplify_merges:1,
                        simplify_by_decoration:1,
+                       single_worktree:1,
                        tag_objects:1,
                        tree_objects:1,
                        blob_objects:1,
@@ -103,7 +135,6 @@ struct rev_info {
                        right_only:1,
                        rewrite_parents:1,
                        print_parents:1,
-                       show_source:1,
                        show_decorations:1,
                        reverse:1,
                        reverse_output_stage:1,
@@ -112,7 +143,26 @@ struct rev_info {
                        bisect:1,
                        ancestry_path:1,
                        first_parent_only:1,
-                       line_level_traverse:1;
+                       line_level_traverse:1,
+                       tree_blobs_in_commit_order:1,
+
+                       /*
+                        * Blobs are shown without regard for their existence.
+                        * But not so for trees: unless exclude_promisor_objects
+                        * is set and the tree in question is a promisor object;
+                        * OR ignore_missing_links is set, the revision walker
+                        * dies with a "bad tree object HASH" message when
+                        * encountering a missing tree. For callers that can
+                        * handle missing trees and want them to be filterable
+                        * and showable, set this to true. The revision walker
+                        * will filter and show such a missing tree as usual,
+                        * but will not attempt to recurse into this tree
+                        * object.
+                        */
+                       do_not_die_on_missing_tree:1,
+
+                       /* for internal use only */
+                       exclude_promisor_objects:1;
 
        /* Diff flags */
        unsigned int    diff:1,
@@ -122,6 +172,7 @@ struct rev_info {
                        verbose_header:1,
                        ignore_merges:1,
                        combine_merges:1,
+                       combined_all_paths:1,
                        dense_combined_merges:1,
                        always_show_header:1;
 
@@ -135,18 +186,20 @@ struct rev_info {
                        pretty_given:1,
                        abbrev_commit:1,
                        abbrev_commit_given:1,
+                       zero_commit:1,
                        use_terminator:1,
                        missing_newline:1,
                        date_mode_explicit:1,
                        preserve_subject:1;
        unsigned int    disable_stdin:1;
-       unsigned int    leak_pending:1;
        /* --show-linear-break */
        unsigned int    track_linear:1,
                        track_first_time:1,
                        linear:1;
 
        struct date_mode date_mode;
+       int             expand_tabs_in_log; /* unset if negative */
+       int             expand_tabs_in_log_default;
 
        unsigned int    abbrev;
        enum cmit_fmt   commit_format;
@@ -178,8 +231,8 @@ struct rev_info {
        /* special limits */
        int skip_count;
        int max_count;
-       unsigned long max_age;
-       unsigned long min_age;
+       timestamp_t max_age;
+       timestamp_t min_age;
        int min_parents;
        int max_parents;
        int (*include_check)(struct commit *, void *);
@@ -197,6 +250,17 @@ struct rev_info {
        /* notes-specific options: which refs to show */
        struct display_notes_opt notes_opt;
 
+       /* interdiff */
+       const struct object_id *idiff_oid1;
+       const struct object_id *idiff_oid2;
+       const char *idiff_title;
+
+       /* range-diff */
+       const char *rdiff1;
+       const char *rdiff2;
+       int creation_factor;
+       const char *rdiff_title;
+
        /* commit counts */
        int count_left;
        int count_right;
@@ -210,9 +274,13 @@ struct rev_info {
 
        struct commit_list *previous_parents;
        const char *break_bar;
+
+       struct revision_sources *sources;
+
+       struct topo_walk_info *topo_walk_info;
 };
 
-extern int ref_excluded(struct string_list *, const char *path);
+int ref_excluded(struct string_list *, const char *path);
 void clear_ref_exclusion(struct string_list **);
 void add_ref_exclusion(struct string_list **, const char *exclude);
 
@@ -229,46 +297,51 @@ extern volatile show_early_output_fn_t show_early_output;
 struct setup_revision_opt {
        const char *def;
        void (*tweak)(struct rev_info *, struct setup_revision_opt *);
-       const char *submodule;
-       int assume_dashdash;
+       const char *submodule;  /* TODO: drop this and use rev_info->repo */
+       unsigned int    assume_dashdash:1,
+                       allow_exclude_promisor_objects:1;
        unsigned revarg_opt;
 };
 
-extern void init_revisions(struct rev_info *revs, const char *prefix);
-extern int setup_revisions(int argc, const char **argv, struct rev_info *revs,
-                          struct setup_revision_opt *);
-extern void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
-                              const struct option *options,
-                              const char * const usagestr[]);
+#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
+#define init_revisions(revs, prefix) repo_init_revisions(the_repository, revs, prefix)
+#endif
+void repo_init_revisions(struct repository *r,
+                        struct rev_info *revs,
+                        const char *prefix);
+int setup_revisions(int argc, const char **argv, struct rev_info *revs,
+                   struct setup_revision_opt *);
+void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
+                       const struct option *options,
+                       const char * const usagestr[]);
 #define REVARG_CANNOT_BE_FILENAME 01
 #define REVARG_COMMITTISH 02
-extern int handle_revision_arg(const char *arg, struct rev_info *revs,
-                              int flags, unsigned revarg_opt);
-
-extern void reset_revision_walk(void);
-extern int prepare_revision_walk(struct rev_info *revs);
-extern struct commit *get_revision(struct rev_info *revs);
-extern char *get_revision_mark(const struct rev_info *revs,
-                              const struct commit *commit);
-extern void put_revision_mark(const struct rev_info *revs,
-                             const struct commit *commit);
+int handle_revision_arg(const char *arg, struct rev_info *revs,
+                       int flags, unsigned revarg_opt);
 
-extern void mark_parents_uninteresting(struct commit *commit);
-extern void mark_tree_uninteresting(struct tree *tree);
+void reset_revision_walk(void);
+int prepare_revision_walk(struct rev_info *revs);
+struct commit *get_revision(struct rev_info *revs);
+char *get_revision_mark(const struct rev_info *revs,
+                       const struct commit *commit);
+void put_revision_mark(const struct rev_info *revs,
+                      const struct commit *commit);
 
-char *path_name(struct strbuf *path, const char *name);
+void mark_parents_uninteresting(struct commit *commit);
+void mark_tree_uninteresting(struct repository *r, struct tree *tree);
+void mark_trees_uninteresting_sparse(struct repository *r, struct oidset *trees);
 
-extern void show_object_with_name(FILE *, struct object *, const char *);
+void show_object_with_name(FILE *, struct object *, const char *);
 
-extern void add_pending_object(struct rev_info *revs,
-                              struct object *obj, const char *name);
-extern void add_pending_sha1(struct rev_info *revs,
-                            const char *name, const unsigned char *sha1,
-                            unsigned int flags);
+void add_pending_object(struct rev_info *revs,
+                       struct object *obj, const char *name);
+void add_pending_oid(struct rev_info *revs,
+                    const char *name, const struct object_id *oid,
+                    unsigned int flags);
 
-extern void add_head_to_pending(struct rev_info *);
-extern void add_reflogs_to_pending(struct rev_info *, unsigned int flags);
-extern void add_index_objects_to_pending(struct rev_info *, unsigned int flags);
+void add_head_to_pending(struct rev_info *);
+void add_reflogs_to_pending(struct rev_info *, unsigned int flags);
+void add_index_objects_to_pending(struct rev_info *, unsigned int flags);
 
 enum commit_action {
        commit_ignore,
@@ -276,10 +349,10 @@ enum commit_action {
        commit_error
 };
 
-extern enum commit_action get_commit_action(struct rev_info *revs,
-                                           struct commit *commit);
-extern enum commit_action simplify_commit(struct rev_info *revs,
-                                         struct commit *commit);
+enum commit_action get_commit_action(struct rev_info *revs,
+                                    struct commit *commit);
+enum commit_action simplify_commit(struct rev_info *revs,
+                                  struct commit *commit);
 
 enum rewrite_result {
        rewrite_one_ok,
@@ -289,8 +362,9 @@ enum rewrite_result {
 
 typedef enum rewrite_result (*rewrite_parent_fn_t)(struct rev_info *revs, struct commit **pp);
 
-extern int rewrite_parents(struct rev_info *revs, struct commit *commit,
-       rewrite_parent_fn_t rewrite_parent);
+int rewrite_parents(struct rev_info *revs,
+                   struct commit *commit,
+                   rewrite_parent_fn_t rewrite_parent);
 
 /*
  * The log machinery saves the original parent list so that
@@ -301,6 +375,6 @@ extern int rewrite_parents(struct rev_info *revs, struct commit *commit,
  * get_saved_parents() will transparently return commit->parents if
  * history simplification is off.
  */
-extern struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit);
+struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit);
 
 #endif