[PATCH] diff: Fix docs and add -O to diff-helper.
[git/dscho.git] / diffcore.h
blob2e613ebe899e8e4b49d489d6c3961a62ba55547d
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 60000
12 #define DEFAULT_RENAME_SCORE 30000 /* rename/copy similarity minimum (50%) */
13 #define DEFAULT_BREAK_SCORE 59400 /* minimum for break to happen (99%)*/
15 struct diff_filespec {
16 unsigned char sha1[20];
17 char *path;
18 void *data;
19 unsigned long size;
20 int xfrm_flags; /* for use by the xfrm */
21 unsigned short mode; /* file mode */
22 unsigned sha1_valid : 1; /* if true, use sha1 and trust mode;
23 * if false, use the name and read from
24 * the filesystem.
26 #define DIFF_FILE_VALID(spec) (((spec)->mode) != 0)
27 unsigned should_free : 1; /* data should be free()'ed */
28 unsigned should_munmap : 1; /* data should be munmap()'ed */
31 extern struct diff_filespec *alloc_filespec(const char *);
32 extern void fill_filespec(struct diff_filespec *, const unsigned char *,
33 unsigned short);
35 extern int diff_populate_filespec(struct diff_filespec *, int);
36 extern void diff_free_filespec_data(struct diff_filespec *);
38 struct diff_filepair {
39 struct diff_filespec *one;
40 struct diff_filespec *two;
41 unsigned short int score;
42 char status; /* M C R N D U (see Documentation/diff-format.txt) */
43 unsigned source_stays : 1; /* all of R/C are copies */
44 unsigned broken_pair : 1;
46 #define DIFF_PAIR_UNMERGED(p) \
47 (!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))
49 #define DIFF_PAIR_RENAME(p) (strcmp((p)->one->path, (p)->two->path))
51 #define DIFF_PAIR_BROKEN(p) \
52 ( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \
53 ((p)->broken_pair != 0) )
55 #define DIFF_PAIR_TYPE_CHANGED(p) \
56 ((S_IFMT & (p)->one->mode) != (S_IFMT & (p)->two->mode))
58 #define DIFF_PAIR_MODE_CHANGED(p) ((p)->one->mode != (p)->two->mode)
60 extern void diff_free_filepair(struct diff_filepair *);
62 extern int diff_unmodified_pair(struct diff_filepair *);
64 struct diff_queue_struct {
65 struct diff_filepair **queue;
66 int alloc;
67 int nr;
70 extern struct diff_queue_struct diff_queued_diff;
71 extern struct diff_filepair *diff_queue(struct diff_queue_struct *,
72 struct diff_filespec *,
73 struct diff_filespec *);
74 extern void diff_q(struct diff_queue_struct *, struct diff_filepair *);
76 extern void diffcore_pathspec(const char **pathspec);
77 extern void diffcore_break(int);
78 extern void diffcore_rename(int rename_copy, int);
79 extern void diffcore_pickaxe(const char *needle, int opts);
80 extern void diffcore_order(const char *orderfile);
82 #define DIFF_DEBUG 0
83 #if DIFF_DEBUG
84 void diff_debug_filespec(struct diff_filespec *, int, const char *);
85 void diff_debug_filepair(const struct diff_filepair *, int);
86 void diff_debug_queue(const char *, struct diff_queue_struct *);
87 #else
88 #define diff_debug_filespec(a,b,c) do {} while(0)
89 #define diff_debug_filepair(a,b) do {} while(0)
90 #define diff_debug_queue(a,b) do {} while(0)
91 #endif
93 #endif