]> git.ipfire.org Git - thirdparty/git.git/blame - diffcore.h
tutorial.txt: start describing how to copy repositories
[thirdparty/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 */
f345b0a0
JH
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%)*/
427dcb4b
JH
14
15#define RENAME_DST_MATCHED 01
427dcb4b
JH
16
17struct diff_filespec {
18 unsigned char sha1[20];
19 char *path;
20 void *data;
21 unsigned long size;
22 int xfrm_flags; /* for use by the xfrm */
23 unsigned short mode; /* file mode */
24 unsigned sha1_valid : 1; /* if true, use sha1 and trust mode;
25 * if false, use the name and read from
26 * the filesystem.
27 */
81e50eab 28#define DIFF_FILE_VALID(spec) (((spec)->mode) != 0)
427dcb4b
JH
29 unsigned should_free : 1; /* data should be free()'ed */
30 unsigned should_munmap : 1; /* data should be munmap()'ed */
31};
32
33extern struct diff_filespec *alloc_filespec(const char *);
34extern void fill_filespec(struct diff_filespec *, const unsigned char *,
35 unsigned short);
36
f0c6b2a2 37extern int diff_populate_filespec(struct diff_filespec *, int);
427dcb4b
JH
38extern void diff_free_filespec_data(struct diff_filespec *);
39
52e95789 40struct diff_filepair {
427dcb4b
JH
41 struct diff_filespec *one;
42 struct diff_filespec *two;
01c4e70f 43 unsigned short int score;
15d061b4 44 char status; /* M C R N D U (see Documentation/diff-format.txt) */
f345b0a0
JH
45 unsigned source_stays : 1; /* all of R/C are copies */
46 unsigned broken_pair : 1;
427dcb4b 47};
6b14d7fa
JH
48#define DIFF_PAIR_UNMERGED(p) \
49 (!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))
427dcb4b 50
01c4e70f
JH
51#define DIFF_PAIR_RENAME(p) (strcmp((p)->one->path, (p)->two->path))
52
f345b0a0
JH
53#define DIFF_PAIR_BROKEN(p) \
54 ( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \
55 ((p)->broken_pair != 0) )
56
96716a19
JH
57#define DIFF_PAIR_TYPE_CHANGED(p) \
58 ((S_IFMT & (p)->one->mode) != (S_IFMT & (p)->two->mode))
59
4130b995
JH
60#define DIFF_PAIR_MODE_CHANGED(p) ((p)->one->mode != (p)->two->mode)
61
226406f6
JH
62extern void diff_free_filepair(struct diff_filepair *);
63
f7c1512a
JH
64extern int diff_unmodified_pair(struct diff_filepair *);
65
427dcb4b 66struct diff_queue_struct {
52e95789 67 struct diff_filepair **queue;
427dcb4b
JH
68 int alloc;
69 int nr;
70};
71
38c6f780 72extern struct diff_queue_struct diff_queued_diff;
52e95789
JH
73extern struct diff_filepair *diff_queue(struct diff_queue_struct *,
74 struct diff_filespec *,
75 struct diff_filespec *);
6b14d7fa 76extern void diff_q(struct diff_queue_struct *, struct diff_filepair *);
f7c1512a 77
25d5ea41
JH
78#define DIFF_DEBUG 0
79#if DIFF_DEBUG
80void diff_debug_filespec(struct diff_filespec *, int, const char *);
81void diff_debug_filepair(const struct diff_filepair *, int);
82void diff_debug_queue(const char *, struct diff_queue_struct *);
83#else
84#define diff_debug_filespec(a,b,c) do {} while(0)
85#define diff_debug_filepair(a,b) do {} while(0)
86#define diff_debug_queue(a,b) do {} while(0)
87#endif
88
427dcb4b 89#endif