diff.h 2.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/*
 * Copyright (C) 2009-2012 the libgit2 contributors
 *
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
 */
#ifndef INCLUDE_diff_h__
#define INCLUDE_diff_h__

#include <stdio.h>
#include "vector.h"
#include "buffer.h"
13 14
#include "iterator.h"
#include "repository.h"
15
#include "pool.h"
16

17 18
#define DIFF_OLD_PREFIX_DEFAULT "a/"
#define DIFF_NEW_PREFIX_DEFAULT "b/"
19

20 21 22
enum {
	GIT_DIFFCAPS_HAS_SYMLINKS     = (1 << 0), /* symlinks on platform? */
	GIT_DIFFCAPS_ASSUME_UNCHANGED = (1 << 1), /* use stat? */
23
	GIT_DIFFCAPS_TRUST_MODE_BITS  = (1 << 2), /* use st_mode? */
24 25 26 27
	GIT_DIFFCAPS_TRUST_CTIME      = (1 << 3), /* use st_ctime? */
	GIT_DIFFCAPS_USE_DEV          = (1 << 4), /* use st_dev? */
};

28 29
#define MAX_DIFF_FILESIZE 0x20000000

30
struct git_diff_list {
Russell Belfer committed
31
	git_refcount     rc;
32 33
	git_repository   *repo;
	git_diff_options opts;
34
	git_vector       pathspec;
35
	git_vector       deltas;    /* vector of git_diff_file_delta */
36
	git_pool pool;
37 38
	git_iterator_type_t old_src;
	git_iterator_type_t new_src;
39
	uint32_t diffcaps;
40 41
};

42 43 44
extern void git_diff__cleanup_modes(
	uint32_t diffcaps, uint32_t *omode, uint32_t *nmode);

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
/**
 * Return the maximum possible number of files in the diff.
 *
 * NOTE: This number has to be treated as an upper bound on the number of
 * files that have changed if the diff is with the working directory.
 *
 * Why?! For efficiency, we defer loading the file contents as long as
 * possible, so if a file has been "touched" in the working directory and
 * then reverted to the original content, it may get stored in the diff list
 * as MODIFIED along with a flag that the status should be reconfirmed when
 * it is actually loaded into memory.  When that load happens, it could get
 * flipped to UNMODIFIED. If unmodified files are being skipped, then the
 * iterator will skip that file and this number may be too high.
 *
 * This behavior is true of `git_diff_foreach` as well, but the only
 * implication there is that the `progress` value would not advance evenly.
 *
 * @param iterator The iterator object
 * @return The maximum number of files to be iterated over
 */
int git_diff_iterator__max_files(git_diff_iterator *iterator);

67 68
#endif