git/revision.c

#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "object-name.h"
#include "object-file.h"
#include "object-store-ll.h"
#include "oidset.h"
#include "tag.h"
#include "blob.h"
#include "tree.h"
#include "commit.h"
#include "diff.h"
#include "diff-merges.h"
#include "refs.h"
#include "revision.h"
#include "repository.h"
#include "graph.h"
#include "grep.h"
#include "reflog-walk.h"
#include "patch-ids.h"
#include "decorate.h"
#include "string-list.h"
#include "line-log.h"
#include "mailmap.h"
#include "commit-slab.h"
#include "cache-tree.h"
#include "bisect.h"
#include "packfile.h"
#include "worktree.h"
#include "path.h"
#include "read-cache.h"
#include "setup.h"
#include "sparse-index.h"
#include "strvec.h"
#include "trace2.h"
#include "commit-reach.h"
#include "commit-graph.h"
#include "prio-queue.h"
#include "hashmap.h"
#include "utf8.h"
#include "bloom.h"
#include "json-writer.h"
#include "list-objects-filter-options.h"
#include "resolve-undo.h"
#include "parse-options.h"
#include "wildmatch.h"

volatile show_early_output_fn_t show_early_output;

static const char *term_bad;
static const char *term_good;

implement_shared_commit_slab(revision_sources, char *);

static inline int want_ancestry(const struct rev_info *revs);

void show_object_with_name(FILE *out, struct object *obj, const char *name)
{}

static void mark_blob_uninteresting(struct blob *blob)
{}

static void mark_tree_contents_uninteresting(struct repository *r,
					     struct tree *tree)
{}

void mark_tree_uninteresting(struct repository *r, struct tree *tree)
{}

struct path_and_oids_entry {};

static int path_and_oids_cmp(const void *hashmap_cmp_fn_data UNUSED,
			     const struct hashmap_entry *eptr,
			     const struct hashmap_entry *entry_or_key,
			     const void *keydata UNUSED)
{}

static void paths_and_oids_clear(struct hashmap *map)
{}

static void paths_and_oids_insert(struct hashmap *map,
				  const char *path,
				  const struct object_id *oid)
{}

static void add_children_by_path(struct repository *r,
				 struct tree *tree,
				 struct hashmap *map)
{}

void mark_trees_uninteresting_sparse(struct repository *r,
				     struct oidset *trees)
{}

struct commit_stack {};
#define COMMIT_STACK_INIT

static void commit_stack_push(struct commit_stack *stack, struct commit *commit)
{}

static struct commit *commit_stack_pop(struct commit_stack *stack)
{}

static void commit_stack_clear(struct commit_stack *stack)
{}

static void mark_one_parent_uninteresting(struct rev_info *revs, struct commit *commit,
					  struct commit_stack *pending)
{}

void mark_parents_uninteresting(struct rev_info *revs, struct commit *commit)
{}

static void add_pending_object_with_path(struct rev_info *revs,
					 struct object *obj,
					 const char *name, unsigned mode,
					 const char *path)
{}

static void add_pending_object_with_mode(struct rev_info *revs,
					 struct object *obj,
					 const char *name, unsigned mode)
{}

void add_pending_object(struct rev_info *revs,
			struct object *obj, const char *name)
{}

void add_head_to_pending(struct rev_info *revs)
{}

static struct object *get_reference(struct rev_info *revs, const char *name,
				    const struct object_id *oid,
				    unsigned int flags)
{}

void add_pending_oid(struct rev_info *revs, const char *name,
		      const struct object_id *oid, unsigned int flags)
{}

static struct commit *handle_commit(struct rev_info *revs,
				    struct object_array_entry *entry)
{}

static int everybody_uninteresting(struct commit_list *orig,
				   struct commit **interesting_cache)
{}

/*
 * A definition of "relevant" commit that we can use to simplify limited graphs
 * by eliminating side branches.
 *
 * A "relevant" commit is one that is !UNINTERESTING (ie we are including it
 * in our list), or that is a specified BOTTOM commit. Then after computing
 * a limited list, during processing we can generally ignore boundary merges
 * coming from outside the graph, (ie from irrelevant parents), and treat
 * those merges as if they were single-parent. TREESAME is defined to consider
 * only relevant parents, if any. If we are TREESAME to our on-graph parents,
 * we don't care if we were !TREESAME to non-graph parents.
 *
 * Treating bottom commits as relevant ensures that a limited graph's
 * connection to the actual bottom commit is not viewed as a side branch, but
 * treated as part of the graph. For example:
 *
 *   ....Z...A---X---o---o---B
 *        .     /
 *         W---Y
 *
 * When computing "A..B", the A-X connection is at least as important as
 * Y-X, despite A being flagged UNINTERESTING.
 *
 * And when computing --ancestry-path "A..B", the A-X connection is more
 * important than Y-X, despite both A and Y being flagged UNINTERESTING.
 */
static inline int relevant_commit(struct commit *commit)
{}

/*
 * Return a single relevant commit from a parent list. If we are a TREESAME
 * commit, and this selects one of our parents, then we can safely simplify to
 * that parent.
 */
static struct commit *one_relevant_parent(const struct rev_info *revs,
					  struct commit_list *orig)
{}

/*
 * The goal is to get REV_TREE_NEW as the result only if the
 * diff consists of all '+' (and no other changes), REV_TREE_OLD
 * if the whole diff is removal of old data, and otherwise
 * REV_TREE_DIFFERENT (of course if the trees are the same we
 * want REV_TREE_SAME).
 *
 * The only time we care about the distinction is when
 * remove_empty_trees is in effect, in which case we care only about
 * whether the whole change is REV_TREE_NEW, or if there's another type
 * of change. Which means we can stop the diff early in either of these
 * cases:
 *
 *   1. We're not using remove_empty_trees at all.
 *
 *   2. We saw anything except REV_TREE_NEW.
 */
#define REV_TREE_SAME
#define REV_TREE_NEW
#define REV_TREE_OLD
#define REV_TREE_DIFFERENT
static int tree_difference =;

static void file_add_remove(struct diff_options *options,
		    int addremove,
		    unsigned mode UNUSED,
		    const struct object_id *oid UNUSED,
		    int oid_valid UNUSED,
		    const char *fullpath UNUSED,
		    unsigned dirty_submodule UNUSED)
{}

static void file_change(struct diff_options *options,
		 unsigned old_mode UNUSED,
		 unsigned new_mode UNUSED,
		 const struct object_id *old_oid UNUSED,
		 const struct object_id *new_oid UNUSED,
		 int old_oid_valid UNUSED,
		 int new_oid_valid UNUSED,
		 const char *fullpath UNUSED,
		 unsigned old_dirty_submodule UNUSED,
		 unsigned new_dirty_submodule UNUSED)
{}

static int bloom_filter_atexit_registered;
static unsigned int count_bloom_filter_maybe;
static unsigned int count_bloom_filter_definitely_not;
static unsigned int count_bloom_filter_false_positive;
static unsigned int count_bloom_filter_not_present;

static void trace2_bloom_filter_statistics_atexit(void)
{}

static int forbid_bloom_filters(struct pathspec *spec)
{}

static void prepare_to_use_bloom_filter(struct rev_info *revs)
{}

static int check_maybe_different_in_bloom_filter(struct rev_info *revs,
						 struct commit *commit)
{}

static int rev_compare_tree(struct rev_info *revs,
			    struct commit *parent, struct commit *commit, int nth_parent)
{}

static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit,
				  int nth_parent)
{}

struct treesame_state {};

static struct treesame_state *initialise_treesame(struct rev_info *revs, struct commit *commit)
{}

/*
 * Must be called immediately after removing the nth_parent from a commit's
 * parent list, if we are maintaining the per-parent treesame[] decoration.
 * This does not recalculate the master TREESAME flag - update_treesame()
 * should be called to update it after a sequence of treesame[] modifications
 * that may have affected it.
 */
static int compact_treesame(struct rev_info *revs, struct commit *commit, unsigned nth_parent)
{}

static unsigned update_treesame(struct rev_info *revs, struct commit *commit)
{}

static inline int limiting_can_increase_treesame(const struct rev_info *revs)
{}

static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
{}

static int process_parents(struct rev_info *revs, struct commit *commit,
			   struct commit_list **list, struct prio_queue *queue)
{}

static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
{}

/* How many extra uninteresting commits we want to see.. */
#define SLOP

static int still_interesting(struct commit_list *src, timestamp_t date, int slop,
			     struct commit **interesting_cache)
{}

/*
 * "rev-list --ancestry-path=C_0 [--ancestry-path=C_1 ...] A..B"
 * computes commits that are ancestors of B but not ancestors of A but
 * further limits the result to those that have any of C in their
 * ancestry path (i.e. are either ancestors of any of C, descendants
 * of any of C, or are any of C). If --ancestry-path is specified with
 * no commit, we use all bottom commits for C.
 *
 * Before this function is called, ancestors of C will have already
 * been marked with ANCESTRY_PATH previously.
 *
 * This takes the list of bottom commits and the result of "A..B"
 * without --ancestry-path, and limits the latter further to the ones
 * that have any of C in their ancestry path. Since the ancestors of C
 * have already been marked (a prerequisite of this function), we just
 * need to mark the descendants, then exclude any commit that does not
 * have any of these marks.
 */
static void limit_to_ancestry(struct commit_list *bottoms, struct commit_list *list)
{}

/*
 * Before walking the history, add the set of "negative" refs the
 * caller has asked to exclude to the bottom list.
 *
 * This is used to compute "rev-list --ancestry-path A..B", as we need
 * to filter the result of "A..B" further to the ones that can actually
 * reach A.
 */
static void collect_bottom_commits(struct commit_list *list,
				   struct commit_list **bottom)
{}

/* Assumes either left_only or right_only is set */
static void limit_left_right(struct commit_list *list, struct rev_info *revs)
{}

static int limit_list(struct rev_info *revs)
{}

/*
 * Add an entry to refs->cmdline with the specified information.
 * *name is copied.
 */
static void add_rev_cmdline(struct rev_info *revs,
			    struct object *item,
			    const char *name,
			    int whence,
			    unsigned flags)
{}

static void add_rev_cmdline_list(struct rev_info *revs,
				 struct commit_list *commit_list,
				 int whence,
				 unsigned flags)
{}

int ref_excluded(const struct ref_exclusions *exclusions, const char *path)
{}

void init_ref_exclusions(struct ref_exclusions *exclusions)
{}

void clear_ref_exclusions(struct ref_exclusions *exclusions)
{}

void add_ref_exclusion(struct ref_exclusions *exclusions, const char *exclude)
{}

struct exclude_hidden_refs_cb {};

static int hide_refs_config(const char *var, const char *value,
			    const struct config_context *ctx UNUSED,
			    void *cb_data)
{}

void exclude_hidden_refs(struct ref_exclusions *exclusions, const char *section)
{}

struct all_refs_cb {};

static int handle_one_ref(const char *path, const char *referent UNUSED, const struct object_id *oid,
			  int flag UNUSED,
			  void *cb_data)
{}

static void init_all_refs_cb(struct all_refs_cb *cb, struct rev_info *revs,
	unsigned flags)
{}

static void handle_refs(struct ref_store *refs,
			struct rev_info *revs, unsigned flags,
			int (*for_each)(struct ref_store *, each_ref_fn, void *))
{}

static void handle_one_reflog_commit(struct object_id *oid, void *cb_data)
{}

static int handle_one_reflog_ent(struct object_id *ooid, struct object_id *noid,
				 const char *email UNUSED,
				 timestamp_t timestamp UNUSED,
				 int tz UNUSED,
				 const char *message UNUSED,
				 void *cb_data)
{}

static int handle_one_reflog(const char *refname_in_wt, void *cb_data)
{}

static void add_other_reflogs_to_pending(struct all_refs_cb *cb)
{}

void add_reflogs_to_pending(struct rev_info *revs, unsigned flags)
{}

static void add_cache_tree(struct cache_tree *it, struct rev_info *revs,
			   struct strbuf *path, unsigned int flags)
{}

static void add_resolve_undo_to_pending(struct index_state *istate, struct rev_info *revs)
{}

static void do_add_index_objects_to_pending(struct rev_info *revs,
					    struct index_state *istate,
					    unsigned int flags)
{}

void add_index_objects_to_pending(struct rev_info *revs, unsigned int flags)
{}

struct add_alternate_refs_data {};

static void add_one_alternate_ref(const struct object_id *oid,
				  void *vdata)
{}

static void add_alternate_refs_to_pending(struct rev_info *revs,
					  unsigned int flags)
{}

static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,
			    int exclude_parent)
{}

void repo_init_revisions(struct repository *r,
			 struct rev_info *revs,
			 const char *prefix)
{}

static void add_pending_commit_list(struct rev_info *revs,
				    struct commit_list *commit_list,
				    unsigned int flags)
{}

static const char *lookup_other_head(struct object_id *oid)
{}

static void prepare_show_merge(struct rev_info *revs)
{}

static int dotdot_missing(const char *arg, char *dotdot,
			  struct rev_info *revs, int symmetric)
{}

static int handle_dotdot_1(const char *arg, char *dotdot,
			   struct rev_info *revs, int flags,
			   int cant_be_filename,
			   struct object_context *a_oc,
			   struct object_context *b_oc)
{}

static int handle_dotdot(const char *arg,
			 struct rev_info *revs, int flags,
			 int cant_be_filename)
{}

static int handle_revision_arg_1(const char *arg_, struct rev_info *revs, int flags, unsigned revarg_opt)
{}

int handle_revision_arg(const char *arg, struct rev_info *revs, int flags, unsigned revarg_opt)
{}

static void read_pathspec_from_stdin(struct strbuf *sb,
				     struct strvec *prune)
{}

static void add_grep(struct rev_info *revs, const char *ptn, enum grep_pat_token what)
{}

static void add_header_grep(struct rev_info *revs, enum grep_header_field field, const char *pattern)
{}

static void add_message_grep(struct rev_info *revs, const char *pattern)
{}

static int parse_count(const char *arg)
{}

static timestamp_t parse_age(const char *arg)
{}

static int handle_revision_opt(struct rev_info *revs, int argc, const char **argv,
			       int *unkc, const char **unkv,
			       const struct setup_revision_opt* opt)
{}

void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
			const struct option *options,
			const char * const usagestr[])
{}

void revision_opts_finish(struct rev_info *revs)
{}

static int for_each_bisect_ref(struct ref_store *refs, each_ref_fn fn,
			       void *cb_data, const char *term)
{}

static int for_each_bad_bisect_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
{}

static int for_each_good_bisect_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
{}

static int handle_revision_pseudo_opt(struct rev_info *revs,
				      const char **argv, int *flags)
{}

static void read_revisions_from_stdin(struct rev_info *revs,
				      struct strvec *prune)
{}

static void NORETURN diagnose_missing_default(const char *def)
{}

/*
 * Parse revision information, filling in the "rev_info" structure,
 * and removing the used arguments from the argument list.
 *
 * Returns the number of arguments left that weren't recognized
 * (which are also moved to the head of the argument list)
 */
int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct setup_revision_opt *opt)
{}

static void release_revisions_cmdline(struct rev_cmdline_info *cmdline)
{}

static void release_revisions_mailmap(struct string_list *mailmap)
{}

static void release_revisions_topo_walk_info(struct topo_walk_info *info);

static void free_void_commit_list(void *list)
{}

void release_revisions(struct rev_info *revs)
{}

static void add_child(struct rev_info *revs, struct commit *parent, struct commit *child)
{}

static int remove_duplicate_parents(struct rev_info *revs, struct commit *commit)
{}

struct merge_simplify_state {};

static struct merge_simplify_state *locate_simplify_state(struct rev_info *revs, struct commit *commit)
{}

static int mark_redundant_parents(struct commit *commit)
{}

static int mark_treesame_root_parents(struct commit *commit)
{}

/*
 * Awkward naming - this means one parent we are TREESAME to.
 * cf mark_treesame_root_parents: root parents that are TREESAME (to an
 * empty tree). Better name suggestions?
 */
static int leave_one_treesame_to_parent(struct rev_info *revs, struct commit *commit)
{}

static int remove_marked_parents(struct rev_info *revs, struct commit *commit)
{}

static struct commit_list **simplify_one(struct rev_info *revs, struct commit *commit, struct commit_list **tail)
{}

static void simplify_merges(struct rev_info *revs)
{}

static void set_children(struct rev_info *revs)
{}

void reset_revision_walk(void)
{}

static int mark_uninteresting(const struct object_id *oid,
			      struct packed_git *pack UNUSED,
			      uint32_t pos UNUSED,
			      void *cb)
{}

define_commit_slab(indegree_slab, int);
define_commit_slab(author_date_slab, timestamp_t);

struct topo_walk_info {};

static int topo_walk_atexit_registered;
static unsigned int count_explore_walked;
static unsigned int count_indegree_walked;
static unsigned int count_topo_walked;

static void trace2_topo_walk_statistics_atexit(void)
{}

static inline void test_flag_and_insert(struct prio_queue *q, struct commit *c, int flag)
{}

static void explore_walk_step(struct rev_info *revs)
{}

static void explore_to_depth(struct rev_info *revs,
			     timestamp_t gen_cutoff)
{}

static void indegree_walk_step(struct rev_info *revs)
{}

static void compute_indegrees_to_depth(struct rev_info *revs,
				       timestamp_t gen_cutoff)
{}

static void release_revisions_topo_walk_info(struct topo_walk_info *info)
{}

static void reset_topo_walk(struct rev_info *revs)
{}

static void init_topo_walk(struct rev_info *revs)
{}

static struct commit *next_topo_commit(struct rev_info *revs)
{}

static void expand_topo_walk(struct rev_info *revs, struct commit *commit)
{}

int prepare_revision_walk(struct rev_info *revs)
{}

static enum rewrite_result rewrite_one_1(struct rev_info *revs,
					 struct commit **pp,
					 struct prio_queue *queue)
{}

static void merge_queue_into_list(struct prio_queue *q, struct commit_list **list)
{}

static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp)
{}

int rewrite_parents(struct rev_info *revs, struct commit *commit,
	rewrite_parent_fn_t rewrite_parent)
{}

static int commit_match(struct commit *commit, struct rev_info *opt)
{}

static inline int want_ancestry(const struct rev_info *revs)
{}

/*
 * Return a timestamp to be used for --since/--until comparisons for this
 * commit, based on the revision options.
 */
static timestamp_t comparison_date(const struct rev_info *revs,
				   struct commit *commit)
{}

enum commit_action get_commit_action(struct rev_info *revs, struct commit *commit)
{}

define_commit_slab(saved_parents, struct commit_list *);

#define EMPTY_PARENT_LIST

/*
 * You may only call save_parents() once per commit (this is checked
 * for non-root commits).
 */
static void save_parents(struct rev_info *revs, struct commit *commit)
{}

static void free_saved_parent(struct commit_list **parents)
{}

static void free_saved_parents(struct rev_info *revs)
{}

struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit)
{}

enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
{}

static void track_linear(struct rev_info *revs, struct commit *commit)
{}

static struct commit *get_revision_1(struct rev_info *revs)
{}

/*
 * Return true for entries that have not yet been shown.  (This is an
 * object_array_each_func_t.)
 */
static int entry_unshown(struct object_array_entry *entry, void *cb_data UNUSED)
{}

/*
 * If array is on the verge of a realloc, garbage-collect any entries
 * that have already been shown to try to free up some space.
 */
static void gc_boundary(struct object_array *array)
{}

static void create_boundary_commit_list(struct rev_info *revs)
{}

static struct commit *get_revision_internal(struct rev_info *revs)
{}

struct commit *get_revision(struct rev_info *revs)
{}

const 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)
{}