[PATCH] Add --pickaxe-all to diff-* brothers.
[git/git.git] / diffcore.h
CommitLineData
427dcb4b
JH
1/*
2 * Copyright (C) 2005 Junio C Hamano
3 */
4#ifndef _DIFFCORE_H_
5#define _DIFFCORE_H_
6
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.
10 */
11#define MAX_SCORE 10000
12#define DEFAULT_MINIMUM_SCORE 5000
13
14#define RENAME_DST_MATCHED 01
427dcb4b
JH
15
16struct diff_filespec {
17 unsigned char sha1[20];
18 char *path;
19 void *data;
20 unsigned long size;
21 int xfrm_flags; /* for use by the xfrm */
22 unsigned short mode; /* file mode */
23 unsigned sha1_valid : 1; /* if true, use sha1 and trust mode;
24 * if false, use the name and read from
25 * the filesystem.
26 */
81e50eab 27#define DIFF_FILE_VALID(spec) (((spec)->mode) != 0)
427dcb4b
JH
28 unsigned should_free : 1; /* data should be free()'ed */
29 unsigned should_munmap : 1; /* data should be munmap()'ed */
30};
31
32extern struct diff_filespec *alloc_filespec(const char *);
33extern void fill_filespec(struct diff_filespec *, const unsigned char *,
34 unsigned short);
35
36extern int diff_populate_filespec(struct diff_filespec *);
37extern void diff_free_filespec_data(struct diff_filespec *);
38
52e95789 39struct diff_filepair {
427dcb4b
JH
40 struct diff_filespec *one;
41 struct diff_filespec *two;
f7c1512a 42 int score; /* only valid when one and two are different paths */
b6d8f309 43 int status; /* M C R N D U (see Documentation/diff-format.txt) */
427dcb4b 44};
6b14d7fa
JH
45#define DIFF_PAIR_UNMERGED(p) \
46 (!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))
427dcb4b 47
96716a19
JH
48#define DIFF_PAIR_TYPE_CHANGED(p) \
49 ((S_IFMT & (p)->one->mode) != (S_IFMT & (p)->two->mode))
50
4130b995
JH
51#define DIFF_PAIR_MODE_CHANGED(p) ((p)->one->mode != (p)->two->mode)
52
53#define DIFF_FILE_CANON_MODE(mode) \
54 (S_ISREG(mode) ? (S_IFREG | ce_permissions(mode)) : \
55 S_ISLNK(mode) ? S_IFLNK : S_IFDIR)
56
226406f6
JH
57extern void diff_free_filepair(struct diff_filepair *);
58
f7c1512a
JH
59extern int diff_unmodified_pair(struct diff_filepair *);
60
427dcb4b 61struct diff_queue_struct {
52e95789 62 struct diff_filepair **queue;
427dcb4b
JH
63 int alloc;
64 int nr;
65};
66
38c6f780 67extern struct diff_queue_struct diff_queued_diff;
52e95789
JH
68extern struct diff_filepair *diff_queue(struct diff_queue_struct *,
69 struct diff_filespec *,
70 struct diff_filespec *);
6b14d7fa 71extern void diff_q(struct diff_queue_struct *, struct diff_filepair *);
f7c1512a 72
25d5ea41
JH
73#define DIFF_DEBUG 0
74#if DIFF_DEBUG
75void diff_debug_filespec(struct diff_filespec *, int, const char *);
76void diff_debug_filepair(const struct diff_filepair *, int);
77void diff_debug_queue(const char *, struct diff_queue_struct *);
78#else
79#define diff_debug_filespec(a,b,c) do {} while(0)
80#define diff_debug_filepair(a,b) do {} while(0)
81#define diff_debug_queue(a,b) do {} while(0)
82#endif
83
427dcb4b 84#endif