git/diffcore-rename.c

/*
 *
 * Copyright (C) 2005 Junio C Hamano
 */

#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "diff.h"
#include "diffcore.h"
#include "object-store-ll.h"
#include "hashmap.h"
#include "mem-pool.h"
#include "oid-array.h"
#include "progress.h"
#include "promisor-remote.h"
#include "string-list.h"
#include "strmap.h"
#include "trace2.h"

/* Table of rename/copy destinations */

static struct diff_rename_dst {} *rename_dst;
static int rename_dst_nr, rename_dst_alloc;
/* Mapping from break source pathname to break destination index */
static struct strintmap *break_idx =;

static struct diff_rename_dst *locate_rename_dst(struct diff_filepair *p)
{}

/*
 * Returns 0 on success, -1 if we found a duplicate.
 */
static int add_rename_dst(struct diff_filepair *p)
{}

/* Table of rename/copy src files */
static struct diff_rename_src {} *rename_src;
static int rename_src_nr, rename_src_alloc;

static void register_rename_src(struct diff_filepair *p)
{}

static int basename_same(struct diff_filespec *src, struct diff_filespec *dst)
{}

struct diff_score {};

struct inexact_prefetch_options {};
static void inexact_prefetch(void *prefetch_options)
{}

static int estimate_similarity(struct repository *r,
			       struct diff_filespec *src,
			       struct diff_filespec *dst,
			       int minimum_score,
			       struct diff_populate_filespec_options *dpf_opt)
{}

static void record_rename_pair(int dst_index, int src_index, int score)
{}

/*
 * We sort the rename similarity matrix with the score, in descending
 * order (the most similar first).
 */
static int score_compare(const void *a_, const void *b_)
{}

struct file_similarity {};

static unsigned int hash_filespec(struct repository *r,
				  struct diff_filespec *filespec)
{}

static int find_identical_files(struct hashmap *srcs,
				int dst_index,
				struct diff_options *options)
{}

static void insert_file_table(struct repository *r,
			      struct mem_pool *pool,
			      struct hashmap *table, int index,
			      struct diff_filespec *filespec)
{}

/*
 * Find exact renames first.
 *
 * The first round matches up the up-to-date entries,
 * and then during the second round we try to match
 * cache-dirty entries as well.
 */
static int find_exact_renames(struct diff_options *options,
			      struct mem_pool *pool)
{}

struct dir_rename_info {};

static char *get_dirname(const char *filename)
{}

static void dirname_munge(char *filename)
{}

static const char *get_highest_rename_path(struct strintmap *counts)
{}

static const char *UNKNOWN_DIR =;  /* placeholder -- short, illegal directory */

static int dir_rename_already_determinable(struct strintmap *counts)
{}

static void increment_count(struct dir_rename_info *info,
			    const char *old_dir,
			    const char *new_dir)
{}

static void update_dir_rename_counts(struct dir_rename_info *info,
				     struct strintmap *dirs_removed,
				     const char *oldname,
				     const char *newname)
{}

static void initialize_dir_rename_info(struct dir_rename_info *info,
				       struct strintmap *relevant_sources,
				       struct strintmap *dirs_removed,
				       struct strmap *dir_rename_count,
				       struct strmap *cached_pairs)
{}

void partial_clear_dir_rename_count(struct strmap *dir_rename_count)
{}

static void cleanup_dir_rename_info(struct dir_rename_info *info,
				    struct strintmap *dirs_removed,
				    int keep_dir_rename_count)
{}

static const char *get_basename(const char *filename)
{}

static int idx_possible_rename(char *filename, struct dir_rename_info *info)
{}

struct basename_prefetch_options {};
static void basename_prefetch(void *prefetch_options)
{}

static int find_basename_matches(struct diff_options *options,
				 int minimum_score,
				 struct dir_rename_info *info,
				 struct strintmap *relevant_sources,
				 struct strintmap *dirs_removed)
{}

#define NUM_CANDIDATE_PER_DST
static void record_if_better(struct diff_score m[], struct diff_score *o)
{}

/*
 * Returns:
 * 0 if we are under the limit;
 * 1 if we need to disable inexact rename detection;
 * 2 if we would be under the limit if we were given -C instead of -C -C.
 */
static int too_many_rename_candidates(int num_destinations, int num_sources,
				      struct diff_options *options)
{}

static int find_renames(struct diff_score *mx,
			int dst_cnt,
			int minimum_score,
			int copies,
			struct dir_rename_info *info,
			struct strintmap *dirs_removed)
{}

static void remove_unneeded_paths_from_src(int detecting_copies,
					   struct strintmap *interesting)
{}

static void handle_early_known_dir_renames(struct dir_rename_info *info,
					   struct strintmap *relevant_sources,
					   struct strintmap *dirs_removed)
{}

static void free_filespec_data(struct diff_filespec *spec)
{}

static void pool_free_filespec(struct mem_pool *pool,
			       struct diff_filespec *spec)
{}

void pool_diff_free_filepair(struct mem_pool *pool,
			     struct diff_filepair *p)
{}

void diffcore_rename_extended(struct diff_options *options,
			      struct mem_pool *pool,
			      struct strintmap *relevant_sources,
			      struct strintmap *dirs_removed,
			      struct strmap *dir_rename_count,
			      struct strmap *cached_pairs)
{}

void diffcore_rename(struct diff_options *options)
{}