[PATCH] diff-raw format update take #2.
[git/dscho.git] / diffcore.h
blobc709cddc42d565fa4e68de87ffff4cf3842fa8b1
1 /*
2 * Copyright (C) 2005 Junio C Hamano
3 */
4 #ifndef _DIFFCORE_H_
5 #define _DIFFCORE_H_
7 /* This header file is internal between diff.c and its diff transformers
8 * (e.g. diffcore-rename, diffcore-pickaxe). Never include this header
9 * in anything else.
11 #define MAX_SCORE 10000
12 #define DEFAULT_MINIMUM_SCORE 5000
14 #define RENAME_DST_MATCHED 01
15 #define RENAME_SRC_GONE 02
16 #define RENAME_SCORE_SHIFT 8
18 struct diff_filespec {
19 unsigned char sha1[20];
20 char *path;
21 void *data;
22 unsigned long size;
23 int xfrm_flags; /* for use by the xfrm */
24 unsigned short mode; /* file mode */
25 unsigned sha1_valid : 1; /* if true, use sha1 and trust mode;
26 * if false, use the name and read from
27 * the filesystem.
29 #define DIFF_FILE_VALID(spec) (((spec)->mode) != 0)
30 unsigned should_free : 1; /* data should be free()'ed */
31 unsigned should_munmap : 1; /* data should be munmap()'ed */
34 extern struct diff_filespec *alloc_filespec(const char *);
35 extern void fill_filespec(struct diff_filespec *, const unsigned char *,
36 unsigned short);
38 extern int diff_populate_filespec(struct diff_filespec *);
39 extern void diff_free_filespec_data(struct diff_filespec *);
41 struct diff_filepair {
42 struct diff_filespec *one;
43 struct diff_filespec *two;
44 int score; /* only valid when one and two are different paths */
45 int orig_order; /* the original order of insertion into the queue */
46 int rename_rank; /* rename/copy dependency needs to enforce
47 * certain ordering of patches that later
48 * diffcore transformations should not break.
50 int status; /* M C R N D U (see Documentation/diff-format.txt) */
52 #define DIFF_PAIR_UNMERGED(p) \
53 (!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))
55 extern int diff_unmodified_pair(struct diff_filepair *);
57 struct diff_queue_struct {
58 struct diff_filepair **queue;
59 int alloc;
60 int nr;
63 extern struct diff_queue_struct diff_queued_diff;
64 extern struct diff_filepair *diff_queue(struct diff_queue_struct *,
65 struct diff_filespec *,
66 struct diff_filespec *);
67 extern void diff_q(struct diff_queue_struct *, struct diff_filepair *);
69 extern int diff_needs_to_stay(struct diff_queue_struct *, int,
70 struct diff_filespec *);
72 #endif