| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 1 | #ifndef CACHE_H |
| 2 | #define CACHE_H |
| 3 | |
| Junio C Hamano | 4050c0d | 2005-12-05 19:54:29 | [diff] [blame] | 4 | #include "git-compat-util.h" |
| Pierre Habouzit | 5ecd293 | 2007-09-16 13:51:04 | [diff] [blame] | 5 | #include "strbuf.h" |
| Linus Torvalds | cf55870 | 2008-01-23 02:41:14 | [diff] [blame] | 6 | #include "hash.h" |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 7 | |
| Linus Torvalds | cef661f | 2005-04-21 19:33:22 | [diff] [blame] | 8 | #include SHA1_HEADER |
| Nicolas Pitre | 9126f00 | 2008-10-01 18:05:20 | [diff] [blame] | 9 | #ifndef git_SHA_CTX |
| 10 | #define git_SHA_CTX SHA_CTX |
| 11 | #define git_SHA1_Init SHA1_Init |
| 12 | #define git_SHA1_Update SHA1_Update |
| 13 | #define git_SHA1_Final SHA1_Final |
| 14 | #endif |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 15 | |
| Nicolas Pitre | 9126f00 | 2008-10-01 18:05:20 | [diff] [blame] | 16 | #include <zlib.h> |
| David Symonds | 609a228 | 2007-11-07 03:24:28 | [diff] [blame] | 17 | #if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200 |
| Edgar Toernig | 9da3acf | 2005-04-30 16:51:03 | [diff] [blame] | 18 | #define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11) |
| 19 | #endif |
| 20 | |
| Linus Torvalds | 39c6854 | 2009-01-08 03:54:47 | [diff] [blame] | 21 | void git_inflate_init(z_streamp strm); |
| 22 | void git_inflate_end(z_streamp strm); |
| 23 | int git_inflate(z_streamp strm, int flush); |
| 24 | |
| Timo Hirvonen | 962554c | 2006-02-26 15:13:46 | [diff] [blame] | 25 | #if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT) |
| Edgar Toernig | b682969 | 2005-04-30 16:51:03 | [diff] [blame] | 26 | #define DTYPE(de) ((de)->d_type) |
| 27 | #else |
| Junio C Hamano | 0bdd79a | 2006-01-20 21:33:20 | [diff] [blame] | 28 | #undef DT_UNKNOWN |
| 29 | #undef DT_DIR |
| 30 | #undef DT_REG |
| 31 | #undef DT_LNK |
| Edgar Toernig | b682969 | 2005-04-30 16:51:03 | [diff] [blame] | 32 | #define DT_UNKNOWN 0 |
| 33 | #define DT_DIR 1 |
| 34 | #define DT_REG 2 |
| Junio C Hamano | a15c1c6 | 2005-05-13 00:16:04 | [diff] [blame] | 35 | #define DT_LNK 3 |
| Edgar Toernig | b682969 | 2005-04-30 16:51:03 | [diff] [blame] | 36 | #define DTYPE(de) DT_UNKNOWN |
| 37 | #endif |
| 38 | |
| Martin Koegler | 40689ae | 2007-04-22 16:43:56 | [diff] [blame] | 39 | /* unknown mode (impossible combination S_IFIFO|S_IFCHR) */ |
| 40 | #define S_IFINVALID 0030000 |
| 41 | |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 42 | /* |
| Linus Torvalds | 9eec479 | 2007-04-10 04:14:58 | [diff] [blame] | 43 | * A "directory link" is a link to another git directory. |
| 44 | * |
| 45 | * The value 0160000 is not normally a valid mode, and |
| 46 | * also just happens to be S_IFDIR + S_IFLNK |
| 47 | * |
| 48 | * NOTE! We *really* shouldn't depend on the S_IFxxx macros |
| 49 | * always having the same values everywhere. We should use |
| 50 | * our internal git values for these things, and then we can |
| 51 | * translate that to the OS-specific value. It just so |
| 52 | * happens that everybody shares the same bit representation |
| 53 | * in the UNIX world (and apparently wider too..) |
| 54 | */ |
| Martin Waitz | 302b928 | 2007-05-21 20:08:28 | [diff] [blame] | 55 | #define S_IFGITLINK 0160000 |
| 56 | #define S_ISGITLINK(m) (((m) & S_IFMT) == S_IFGITLINK) |
| Linus Torvalds | 9eec479 | 2007-04-10 04:14:58 | [diff] [blame] | 57 | |
| 58 | /* |
| Linus Torvalds | 2386d65 | 2005-07-14 01:46:20 | [diff] [blame] | 59 | * Intensive research over the course of many years has shown that |
| 60 | * port 9418 is totally unused by anything else. Or |
| 61 | * |
| 62 | * Your search - "port 9418" - did not match any documents. |
| 63 | * |
| 64 | * as www.google.com puts it. |
| Linus Torvalds | ba8a497 | 2005-09-12 18:23:00 | [diff] [blame] | 65 | * |
| 66 | * This port has been properly assigned for git use by IANA: |
| 67 | * git (Assigned-9418) [I06-050728-0001]. |
| 68 | * |
| 69 | * git 9418/tcp git pack transfer service |
| 70 | * git 9418/udp git pack transfer service |
| 71 | * |
| 72 | * with Linus Torvalds <torvalds@osdl.org> as the point of |
| 73 | * contact. September 2005. |
| 74 | * |
| 75 | * See http://www.iana.org/assignments/port-numbers |
| Linus Torvalds | 2386d65 | 2005-07-14 01:46:20 | [diff] [blame] | 76 | */ |
| 77 | #define DEFAULT_GIT_PORT 9418 |
| 78 | |
| 79 | /* |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 80 | * Basic data structures for the directory cache |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 81 | */ |
| 82 | |
| 83 | #define CACHE_SIGNATURE 0x44495243 /* "DIRC" */ |
| 84 | struct cache_header { |
| Linus Torvalds | ccc4feb | 2005-04-15 17:44:27 | [diff] [blame] | 85 | unsigned int hdr_signature; |
| 86 | unsigned int hdr_version; |
| 87 | unsigned int hdr_entries; |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | /* |
| 91 | * The "cache_time" is just the low 32 bits of the |
| 92 | * time. It doesn't matter if it overflows - we only |
| 93 | * check it for equality in the 32 bits we save. |
| 94 | */ |
| 95 | struct cache_time { |
| 96 | unsigned int sec; |
| 97 | unsigned int nsec; |
| 98 | }; |
| 99 | |
| 100 | /* |
| 101 | * dev/ino/uid/gid/size are also just tracked to the low 32 bits |
| 102 | * Again - this is just a (very strong in practice) heuristic that |
| 103 | * the inode hasn't changed. |
| Linus Torvalds | ccc4feb | 2005-04-15 17:44:27 | [diff] [blame] | 104 | * |
| 105 | * We save the fields in big-endian order to allow using the |
| 106 | * index file over NFS transparently. |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 107 | */ |
| Linus Torvalds | 7a51ed6 | 2008-01-15 00:03:17 | [diff] [blame] | 108 | struct ondisk_cache_entry { |
| 109 | struct cache_time ctime; |
| 110 | struct cache_time mtime; |
| 111 | unsigned int dev; |
| 112 | unsigned int ino; |
| 113 | unsigned int mode; |
| 114 | unsigned int uid; |
| 115 | unsigned int gid; |
| 116 | unsigned int size; |
| 117 | unsigned char sha1[20]; |
| 118 | unsigned short flags; |
| 119 | char name[FLEX_ARRAY]; /* more */ |
| 120 | }; |
| 121 | |
| Nguyễn Thái Ngọc Duy | 06aaaa0 | 2008-10-01 04:04:01 | [diff] [blame] | 122 | /* |
| 123 | * This struct is used when CE_EXTENDED bit is 1 |
| 124 | * The struct must match ondisk_cache_entry exactly from |
| 125 | * ctime till flags |
| 126 | */ |
| 127 | struct ondisk_cache_entry_extended { |
| 128 | struct cache_time ctime; |
| 129 | struct cache_time mtime; |
| 130 | unsigned int dev; |
| 131 | unsigned int ino; |
| 132 | unsigned int mode; |
| 133 | unsigned int uid; |
| 134 | unsigned int gid; |
| 135 | unsigned int size; |
| 136 | unsigned char sha1[20]; |
| 137 | unsigned short flags; |
| 138 | unsigned short flags2; |
| 139 | char name[FLEX_ARRAY]; /* more */ |
| 140 | }; |
| 141 | |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 142 | struct cache_entry { |
| Kjetil Barvik | fba2f38 | 2009-02-19 20:08:29 | [diff] [blame] | 143 | struct cache_time ce_ctime; |
| 144 | struct cache_time ce_mtime; |
| Linus Torvalds | ccc4feb | 2005-04-15 17:44:27 | [diff] [blame] | 145 | unsigned int ce_dev; |
| 146 | unsigned int ce_ino; |
| 147 | unsigned int ce_mode; |
| 148 | unsigned int ce_uid; |
| 149 | unsigned int ce_gid; |
| 150 | unsigned int ce_size; |
| Linus Torvalds | 7a51ed6 | 2008-01-15 00:03:17 | [diff] [blame] | 151 | unsigned int ce_flags; |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 152 | unsigned char sha1[20]; |
| Linus Torvalds | eb7a2f1 | 2008-02-23 04:41:17 | [diff] [blame] | 153 | struct cache_entry *next; |
| Junio C Hamano | 8f1d2e6 | 2006-01-07 09:33:54 | [diff] [blame] | 154 | char name[FLEX_ARRAY]; /* more */ |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 155 | }; |
| 156 | |
| Linus Torvalds | 95fd5bf | 2005-04-16 05:51:44 | [diff] [blame] | 157 | #define CE_NAMEMASK (0x0fff) |
| 158 | #define CE_STAGEMASK (0x3000) |
| Junio C Hamano | 16ce2e4c | 2008-08-17 06:02:08 | [diff] [blame] | 159 | #define CE_EXTENDED (0x4000) |
| Junio C Hamano | 5f73076 | 2006-02-09 05:15:24 | [diff] [blame] | 160 | #define CE_VALID (0x8000) |
| Junio C Hamano | aee4619 | 2005-04-16 15:33:23 | [diff] [blame] | 161 | #define CE_STAGESHIFT 12 |
| Linus Torvalds | 95fd5bf | 2005-04-16 05:51:44 | [diff] [blame] | 162 | |
| Nguyễn Thái Ngọc Duy | 06aaaa0 | 2008-10-01 04:04:01 | [diff] [blame] | 163 | /* |
| 164 | * Range 0xFFFF0000 in ce_flags is divided into |
| 165 | * two parts: in-memory flags and on-disk ones. |
| 166 | * Flags in CE_EXTENDED_FLAGS will get saved on-disk |
| 167 | * if you want to save a new flag, add it in |
| 168 | * CE_EXTENDED_FLAGS |
| 169 | * |
| 170 | * In-memory only flags |
| 171 | */ |
| Linus Torvalds | 7a51ed6 | 2008-01-15 00:03:17 | [diff] [blame] | 172 | #define CE_UPDATE (0x10000) |
| 173 | #define CE_REMOVE (0x20000) |
| Junio C Hamano | eadb583 | 2008-01-19 07:45:24 | [diff] [blame] | 174 | #define CE_UPTODATE (0x40000) |
| Linus Torvalds | 1102952 | 2008-03-22 21:22:44 | [diff] [blame] | 175 | #define CE_ADDED (0x80000) |
| Linus Torvalds | a22c637 | 2008-02-23 04:37:40 | [diff] [blame] | 176 | |
| 177 | #define CE_HASHED (0x100000) |
| 178 | #define CE_UNHASHED (0x200000) |
| Linus Torvalds | 7a51ed6 | 2008-01-15 00:03:17 | [diff] [blame] | 179 | |
| Linus Torvalds | d070e3a | 2008-02-23 04:39:21 | [diff] [blame] | 180 | /* |
| Nguyễn Thái Ngọc Duy | 06aaaa0 | 2008-10-01 04:04:01 | [diff] [blame] | 181 | * Extended on-disk flags |
| 182 | */ |
| Junio C Hamano | 388b2ac | 2008-11-29 03:55:25 | [diff] [blame] | 183 | #define CE_INTENT_TO_ADD 0x20000000 |
| Nguyễn Thái Ngọc Duy | 06aaaa0 | 2008-10-01 04:04:01 | [diff] [blame] | 184 | /* CE_EXTENDED2 is for future extension */ |
| 185 | #define CE_EXTENDED2 0x80000000 |
| 186 | |
| Junio C Hamano | 388b2ac | 2008-11-29 03:55:25 | [diff] [blame] | 187 | #define CE_EXTENDED_FLAGS (CE_INTENT_TO_ADD) |
| Nguyễn Thái Ngọc Duy | 06aaaa0 | 2008-10-01 04:04:01 | [diff] [blame] | 188 | |
| 189 | /* |
| 190 | * Safeguard to avoid saving wrong flags: |
| 191 | * - CE_EXTENDED2 won't get saved until its semantic is known |
| 192 | * - Bits in 0x0000FFFF have been saved in ce_flags already |
| 193 | * - Bits in 0x003F0000 are currently in-memory flags |
| 194 | */ |
| 195 | #if CE_EXTENDED_FLAGS & 0x803FFFFF |
| 196 | #error "CE_EXTENDED_FLAGS out of range" |
| 197 | #endif |
| 198 | |
| 199 | /* |
| Linus Torvalds | eb7a2f1 | 2008-02-23 04:41:17 | [diff] [blame] | 200 | * Copy the sha1 and stat state of a cache entry from one to |
| 201 | * another. But we never change the name, or the hash state! |
| 202 | */ |
| 203 | #define CE_STATE_MASK (CE_HASHED | CE_UNHASHED) |
| 204 | static inline void copy_cache_entry(struct cache_entry *dst, struct cache_entry *src) |
| 205 | { |
| 206 | unsigned int state = dst->ce_flags & CE_STATE_MASK; |
| 207 | |
| 208 | /* Don't copy hash chain and name */ |
| 209 | memcpy(dst, src, offsetof(struct cache_entry, next)); |
| 210 | |
| 211 | /* Restore the hash state */ |
| 212 | dst->ce_flags = (dst->ce_flags & ~CE_STATE_MASK) | state; |
| 213 | } |
| 214 | |
| Junio C Hamano | 7fec10b | 2008-01-19 07:42:00 | [diff] [blame] | 215 | static inline unsigned create_ce_flags(size_t len, unsigned stage) |
| 216 | { |
| 217 | if (len >= CE_NAMEMASK) |
| 218 | len = CE_NAMEMASK; |
| 219 | return (len | (stage << CE_STAGESHIFT)); |
| 220 | } |
| 221 | |
| 222 | static inline size_t ce_namelen(const struct cache_entry *ce) |
| 223 | { |
| 224 | size_t len = ce->ce_flags & CE_NAMEMASK; |
| 225 | if (len < CE_NAMEMASK) |
| 226 | return len; |
| 227 | return strlen(ce->name + CE_NAMEMASK) + CE_NAMEMASK; |
| 228 | } |
| 229 | |
| Junio C Hamano | aee4619 | 2005-04-16 15:33:23 | [diff] [blame] | 230 | #define ce_size(ce) cache_entry_size(ce_namelen(ce)) |
| Nguyễn Thái Ngọc Duy | 06aaaa0 | 2008-10-01 04:04:01 | [diff] [blame] | 231 | #define ondisk_ce_size(ce) (((ce)->ce_flags & CE_EXTENDED) ? \ |
| 232 | ondisk_cache_entry_extended_size(ce_namelen(ce)) : \ |
| 233 | ondisk_cache_entry_size(ce_namelen(ce))) |
| Linus Torvalds | 7a51ed6 | 2008-01-15 00:03:17 | [diff] [blame] | 234 | #define ce_stage(ce) ((CE_STAGEMASK & (ce)->ce_flags) >> CE_STAGESHIFT) |
| Junio C Hamano | eadb583 | 2008-01-19 07:45:24 | [diff] [blame] | 235 | #define ce_uptodate(ce) ((ce)->ce_flags & CE_UPTODATE) |
| 236 | #define ce_mark_uptodate(ce) ((ce)->ce_flags |= CE_UPTODATE) |
| Junio C Hamano | aee4619 | 2005-04-16 15:33:23 | [diff] [blame] | 237 | |
| Linus Torvalds | e447947 | 2005-04-17 05:26:31 | [diff] [blame] | 238 | #define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644) |
| Kay Sievers | 8ae0a8c | 2005-05-05 12:38:25 | [diff] [blame] | 239 | static inline unsigned int create_ce_mode(unsigned int mode) |
| 240 | { |
| Kay Sievers | 8ae0a8c | 2005-05-05 12:38:25 | [diff] [blame] | 241 | if (S_ISLNK(mode)) |
| Linus Torvalds | 7a51ed6 | 2008-01-15 00:03:17 | [diff] [blame] | 242 | return S_IFLNK; |
| Martin Waitz | 302b928 | 2007-05-21 20:08:28 | [diff] [blame] | 243 | if (S_ISDIR(mode) || S_ISGITLINK(mode)) |
| Linus Torvalds | 7a51ed6 | 2008-01-15 00:03:17 | [diff] [blame] | 244 | return S_IFGITLINK; |
| 245 | return S_IFREG | ce_permissions(mode); |
| Kay Sievers | 8ae0a8c | 2005-05-05 12:38:25 | [diff] [blame] | 246 | } |
| Junio C Hamano | 185c975 | 2007-02-17 06:43:48 | [diff] [blame] | 247 | static inline unsigned int ce_mode_from_stat(struct cache_entry *ce, unsigned int mode) |
| 248 | { |
| Johannes Sixt | 78a8d64 | 2007-03-02 21:11:30 | [diff] [blame] | 249 | extern int trust_executable_bit, has_symlinks; |
| 250 | if (!has_symlinks && S_ISREG(mode) && |
| Linus Torvalds | 7a51ed6 | 2008-01-15 00:03:17 | [diff] [blame] | 251 | ce && S_ISLNK(ce->ce_mode)) |
| Johannes Sixt | 78a8d64 | 2007-03-02 21:11:30 | [diff] [blame] | 252 | return ce->ce_mode; |
| Junio C Hamano | 185c975 | 2007-02-17 06:43:48 | [diff] [blame] | 253 | if (!trust_executable_bit && S_ISREG(mode)) { |
| Linus Torvalds | 7a51ed6 | 2008-01-15 00:03:17 | [diff] [blame] | 254 | if (ce && S_ISREG(ce->ce_mode)) |
| Junio C Hamano | 185c975 | 2007-02-17 06:43:48 | [diff] [blame] | 255 | return ce->ce_mode; |
| 256 | return create_ce_mode(0666); |
| 257 | } |
| 258 | return create_ce_mode(mode); |
| 259 | } |
| Junio C Hamano | d6b8fc3 | 2008-01-31 09:17:48 | [diff] [blame] | 260 | static inline int ce_to_dtype(const struct cache_entry *ce) |
| 261 | { |
| 262 | unsigned ce_mode = ntohl(ce->ce_mode); |
| 263 | if (S_ISREG(ce_mode)) |
| 264 | return DT_REG; |
| 265 | else if (S_ISDIR(ce_mode) || S_ISGITLINK(ce_mode)) |
| 266 | return DT_DIR; |
| 267 | else if (S_ISLNK(ce_mode)) |
| 268 | return DT_LNK; |
| 269 | else |
| 270 | return DT_UNKNOWN; |
| 271 | } |
| Junio C Hamano | 1b0c717 | 2006-03-30 06:55:43 | [diff] [blame] | 272 | #define canon_mode(mode) \ |
| 273 | (S_ISREG(mode) ? (S_IFREG | ce_permissions(mode)) : \ |
| Martin Waitz | 302b928 | 2007-05-21 20:08:28 | [diff] [blame] | 274 | S_ISLNK(mode) ? S_IFLNK : S_ISDIR(mode) ? S_IFDIR : S_IFGITLINK) |
| Linus Torvalds | e447947 | 2005-04-17 05:26:31 | [diff] [blame] | 275 | |
| Nguyễn Thái Ngọc Duy | 06aaaa0 | 2008-10-01 04:04:01 | [diff] [blame] | 276 | #define flexible_size(STRUCT,len) ((offsetof(struct STRUCT,name) + (len) + 8) & ~7) |
| 277 | #define cache_entry_size(len) flexible_size(cache_entry,len) |
| 278 | #define ondisk_cache_entry_size(len) flexible_size(ondisk_cache_entry,len) |
| 279 | #define ondisk_cache_entry_extended_size(len) flexible_size(ondisk_cache_entry_extended,len) |
| Linus Torvalds | f5cabd1 | 2005-04-16 04:45:38 | [diff] [blame] | 280 | |
| Junio C Hamano | 228e94f | 2007-04-02 01:14:06 | [diff] [blame] | 281 | struct index_state { |
| 282 | struct cache_entry **cache; |
| 283 | unsigned int cache_nr, cache_alloc, cache_changed; |
| 284 | struct cache_tree *cache_tree; |
| Kjetil Barvik | fba2f38 | 2009-02-19 20:08:29 | [diff] [blame] | 285 | struct cache_time timestamp; |
| Linus Torvalds | 7a51ed6 | 2008-01-15 00:03:17 | [diff] [blame] | 286 | void *alloc; |
| Junio C Hamano | 913e0e9 | 2008-08-23 19:57:30 | [diff] [blame] | 287 | unsigned name_hash_initialized : 1, |
| 288 | initialized : 1; |
| Linus Torvalds | cf55870 | 2008-01-23 02:41:14 | [diff] [blame] | 289 | struct hash_table name_hash; |
| Junio C Hamano | 228e94f | 2007-04-02 01:14:06 | [diff] [blame] | 290 | }; |
| 291 | |
| 292 | extern struct index_state the_index; |
| 293 | |
| Linus Torvalds | 96872bc | 2008-03-21 20:16:24 | [diff] [blame] | 294 | /* Name hashing */ |
| 295 | extern void add_name_hash(struct index_state *istate, struct cache_entry *ce); |
| 296 | /* |
| 297 | * We don't actually *remove* it, we can just mark it invalid so that |
| 298 | * we won't find it in lookups. |
| 299 | * |
| 300 | * Not only would we have to search the lists (simple enough), but |
| 301 | * we'd also have to rehash other hash buckets in case this makes the |
| 302 | * hash bucket empty (common). So it's much better to just mark |
| 303 | * it. |
| 304 | */ |
| 305 | static inline void remove_name_hash(struct cache_entry *ce) |
| 306 | { |
| 307 | ce->ce_flags |= CE_UNHASHED; |
| 308 | } |
| 309 | |
| 310 | |
| Junio C Hamano | 4aab5b4 | 2007-04-02 06:26:07 | [diff] [blame] | 311 | #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS |
| Junio C Hamano | 228e94f | 2007-04-02 01:14:06 | [diff] [blame] | 312 | #define active_cache (the_index.cache) |
| 313 | #define active_nr (the_index.cache_nr) |
| 314 | #define active_alloc (the_index.cache_alloc) |
| 315 | #define active_cache_changed (the_index.cache_changed) |
| 316 | #define active_cache_tree (the_index.cache_tree) |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 317 | |
| Junio C Hamano | 4aab5b4 | 2007-04-02 06:26:07 | [diff] [blame] | 318 | #define read_cache() read_index(&the_index) |
| 319 | #define read_cache_from(path) read_index_from(&the_index, (path)) |
| Linus Torvalds | 671c9b7 | 2008-11-14 00:36:30 | [diff] [blame] | 320 | #define read_cache_preload(pathspec) read_index_preload(&the_index, (pathspec)) |
| Junio C Hamano | fa7b3c2 | 2008-11-12 19:52:35 | [diff] [blame] | 321 | #define is_cache_unborn() is_index_unborn(&the_index) |
| Miklos Vajna | e46bbcf | 2008-06-27 16:21:58 | [diff] [blame] | 322 | #define read_cache_unmerged() read_index_unmerged(&the_index) |
| Junio C Hamano | 4aab5b4 | 2007-04-02 06:26:07 | [diff] [blame] | 323 | #define write_cache(newfd, cache, entries) write_index(&the_index, (newfd)) |
| 324 | #define discard_cache() discard_index(&the_index) |
| Daniel Barkalow | 94a5728 | 2008-02-07 16:40:13 | [diff] [blame] | 325 | #define unmerged_cache() unmerged_index(&the_index) |
| Junio C Hamano | 4aab5b4 | 2007-04-02 06:26:07 | [diff] [blame] | 326 | #define cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen)) |
| 327 | #define add_cache_entry(ce, option) add_index_entry(&the_index, (ce), (option)) |
| Petr Baudis | 81dc230 | 2008-07-21 00:25:56 | [diff] [blame] | 328 | #define rename_cache_entry_at(pos, new_name) rename_index_entry_at(&the_index, (pos), (new_name)) |
| Junio C Hamano | 4aab5b4 | 2007-04-02 06:26:07 | [diff] [blame] | 329 | #define remove_cache_entry_at(pos) remove_index_entry_at(&the_index, (pos)) |
| 330 | #define remove_file_from_cache(path) remove_file_from_index(&the_index, (path)) |
| Junio C Hamano | 38ed1d8 | 2008-05-21 19:04:34 | [diff] [blame] | 331 | #define add_to_cache(path, st, flags) add_to_index(&the_index, (path), (st), (flags)) |
| 332 | #define add_file_to_cache(path, flags) add_file_to_index(&the_index, (path), (flags)) |
| Alexandre Julliard | d616813 | 2007-08-11 21:59:01 | [diff] [blame] | 333 | #define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL) |
| Junio C Hamano | 4bd5b7d | 2007-11-10 08:15:03 | [diff] [blame] | 334 | #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options)) |
| 335 | #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options)) |
| Linus Torvalds | cd2fef5 | 2008-03-21 22:55:19 | [diff] [blame] | 336 | #define cache_name_exists(name, namelen, igncase) index_name_exists(&the_index, (name), (namelen), (igncase)) |
| Jeff King | 98fa473 | 2008-10-16 15:07:26 | [diff] [blame] | 337 | #define cache_name_is_other(name, namelen) index_name_is_other(&the_index, (name), (namelen)) |
| Junio C Hamano | 4aab5b4 | 2007-04-02 06:26:07 | [diff] [blame] | 338 | #endif |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 339 | |
| Junio C Hamano | edaec3f | 2007-02-28 19:45:56 | [diff] [blame] | 340 | enum object_type { |
| 341 | OBJ_BAD = -1, |
| 342 | OBJ_NONE = 0, |
| 343 | OBJ_COMMIT = 1, |
| 344 | OBJ_TREE = 2, |
| 345 | OBJ_BLOB = 3, |
| 346 | OBJ_TAG = 4, |
| 347 | /* 5 for future expansion */ |
| 348 | OBJ_OFS_DELTA = 6, |
| 349 | OBJ_REF_DELTA = 7, |
| Martin Koegler | 355885d | 2008-02-25 21:46:04 | [diff] [blame] | 350 | OBJ_ANY, |
| Junio C Hamano | edaec3f | 2007-02-28 19:45:56 | [diff] [blame] | 351 | OBJ_MAX, |
| 352 | }; |
| 353 | |
| Junio C Hamano | b45563a | 2007-12-01 06:22:38 | [diff] [blame] | 354 | static inline enum object_type object_type(unsigned int mode) |
| 355 | { |
| 356 | return S_ISDIR(mode) ? OBJ_TREE : |
| 357 | S_ISGITLINK(mode) ? OBJ_COMMIT : |
| 358 | OBJ_BLOB; |
| 359 | } |
| 360 | |
| Junio C Hamano | 8ac069a | 2005-05-10 05:57:58 | [diff] [blame] | 361 | #define GIT_DIR_ENVIRONMENT "GIT_DIR" |
| Matthias Lederhofer | 892c41b | 2007-06-06 07:10:42 | [diff] [blame] | 362 | #define GIT_WORK_TREE_ENVIRONMENT "GIT_WORK_TREE" |
| Junio C Hamano | 8ac069a | 2005-05-10 05:57:58 | [diff] [blame] | 363 | #define DEFAULT_GIT_DIR_ENVIRONMENT ".git" |
| Junio C Hamano | d19938a | 2005-05-10 00:57:56 | [diff] [blame] | 364 | #define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY" |
| Linus Torvalds | bb233d6 | 2005-04-21 17:55:18 | [diff] [blame] | 365 | #define INDEX_ENVIRONMENT "GIT_INDEX_FILE" |
| Junio C Hamano | 5da5c8f | 2005-07-30 07:58:28 | [diff] [blame] | 366 | #define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE" |
| Junio C Hamano | d4ebc36 | 2006-12-19 09:28:15 | [diff] [blame] | 367 | #define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR" |
| 368 | #define CONFIG_ENVIRONMENT "GIT_CONFIG" |
| Junio C Hamano | d4ebc36 | 2006-12-19 09:28:15 | [diff] [blame] | 369 | #define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH" |
| David Reiss | 0454dd9 | 2008-05-20 06:49:26 | [diff] [blame] | 370 | #define CEILING_DIRECTORIES_ENVIRONMENT "GIT_CEILING_DIRECTORIES" |
| Junio C Hamano | d0bfd02 | 2007-04-12 08:07:32 | [diff] [blame] | 371 | #define GITATTRIBUTES_FILE ".gitattributes" |
| 372 | #define INFOATTRIBUTES_FILE "info/attributes" |
| Junio C Hamano | f48fd68 | 2007-04-14 15:54:37 | [diff] [blame] | 373 | #define ATTRIBUTE_MACRO_PREFIX "[attr]" |
| Linus Torvalds | bb233d6 | 2005-04-21 17:55:18 | [diff] [blame] | 374 | |
| Junio C Hamano | 7d1864c | 2007-01-07 10:00:28 | [diff] [blame] | 375 | extern int is_bare_repository_cfg; |
| 376 | extern int is_bare_repository(void); |
| Johannes Schindelin | 6802563 | 2007-01-20 02:09:34 | [diff] [blame] | 377 | extern int is_inside_git_dir(void); |
| Johannes Schindelin | e90fdc3 | 2007-08-01 00:30:14 | [diff] [blame] | 378 | extern char *git_work_tree_cfg; |
| Matthias Lederhofer | 892c41b | 2007-06-06 07:10:42 | [diff] [blame] | 379 | extern int is_inside_work_tree(void); |
| Dmitry Potapov | d2b0708 | 2008-09-27 08:41:50 | [diff] [blame] | 380 | extern int have_git_dir(void); |
| Pierre Habouzit | c5fba16 | 2006-08-23 10:39:11 | [diff] [blame] | 381 | extern const char *get_git_dir(void); |
| Junio C Hamano | 8ac069a | 2005-05-10 05:57:58 | [diff] [blame] | 382 | extern char *get_object_directory(void); |
| Junio C Hamano | 8ac069a | 2005-05-10 05:57:58 | [diff] [blame] | 383 | extern char *get_index_file(void); |
| Junio C Hamano | 5da5c8f | 2005-07-30 07:58:28 | [diff] [blame] | 384 | extern char *get_graft_file(void); |
| Johannes Schindelin | d7ac12b | 2007-08-01 00:29:38 | [diff] [blame] | 385 | extern int set_git_dir(const char *path); |
| Johannes Schindelin | e90fdc3 | 2007-08-01 00:30:14 | [diff] [blame] | 386 | extern const char *get_git_work_tree(void); |
| Lars Hjemli | b44ebb1 | 2008-02-20 22:13:13 | [diff] [blame] | 387 | extern const char *read_gitfile_gently(const char *path); |
| Daniel Barkalow | 19757d8 | 2008-04-27 17:39:21 | [diff] [blame] | 388 | extern void set_git_work_tree(const char *tree); |
| Junio C Hamano | 8ac069a | 2005-05-10 05:57:58 | [diff] [blame] | 389 | |
| 390 | #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES" |
| Linus Torvalds | bb233d6 | 2005-04-21 17:55:18 | [diff] [blame] | 391 | |
| Junio C Hamano | 6b5ee13 | 2005-09-21 07:00:47 | [diff] [blame] | 392 | extern const char **get_pathspec(const char *prefix, const char **pathspec); |
| Mike Hommey | 59f0f2f | 2007-11-03 11:23:11 | [diff] [blame] | 393 | extern void setup_work_tree(void); |
| Junio C Hamano | 4ca0660 | 2005-11-26 07:14:15 | [diff] [blame] | 394 | extern const char *setup_git_directory_gently(int *); |
| Linus Torvalds | d288a70 | 2005-08-17 01:06:34 | [diff] [blame] | 395 | extern const char *setup_git_directory(void); |
| Junio C Hamano | 6b5ee13 | 2005-09-21 07:00:47 | [diff] [blame] | 396 | extern const char *prefix_path(const char *prefix, int len, const char *path); |
| Junio C Hamano | 4ca0660 | 2005-11-26 07:14:15 | [diff] [blame] | 397 | extern const char *prefix_filename(const char *prefix, int len, const char *path); |
| Linus Torvalds | e23d0b4 | 2006-04-26 17:15:54 | [diff] [blame] | 398 | extern void verify_filename(const char *prefix, const char *name); |
| Junio C Hamano | ea92f41 | 2006-04-26 22:09:27 | [diff] [blame] | 399 | extern void verify_non_filename(const char *prefix, const char *name); |
| Linus Torvalds | d288a70 | 2005-08-17 01:06:34 | [diff] [blame] | 400 | |
| Daniel Barkalow | f225aeb | 2008-04-27 17:39:27 | [diff] [blame] | 401 | #define INIT_DB_QUIET 0x0001 |
| 402 | |
| 403 | extern int init_db(const char *template_dir, unsigned int flags); |
| 404 | |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 405 | #define alloc_nr(x) (((x)+16)*3/2) |
| 406 | |
| Jeff King | 6815e56 | 2007-06-11 13:39:44 | [diff] [blame] | 407 | /* |
| 408 | * Realloc the buffer pointed at by variable 'x' so that it can hold |
| 409 | * at least 'nr' entries; the number of entries currently allocated |
| 410 | * is 'alloc', using the standard growing factor alloc_nr() macro. |
| 411 | * |
| 412 | * DO NOT USE any expression with side-effect for 'x' or 'alloc'. |
| 413 | */ |
| 414 | #define ALLOC_GROW(x, nr, alloc) \ |
| 415 | do { \ |
| Jeff King | c927e6c | 2007-06-16 22:37:39 | [diff] [blame] | 416 | if ((nr) > alloc) { \ |
| Junio C Hamano | 4234a76 | 2007-06-12 05:10:55 | [diff] [blame] | 417 | if (alloc_nr(alloc) < (nr)) \ |
| 418 | alloc = (nr); \ |
| 419 | else \ |
| 420 | alloc = alloc_nr(alloc); \ |
| Jeff King | 6815e56 | 2007-06-11 13:39:44 | [diff] [blame] | 421 | x = xrealloc((x), alloc * sizeof(*(x))); \ |
| 422 | } \ |
| 423 | } while(0) |
| 424 | |
| Linus Torvalds | 734aab7 | 2005-04-09 16:48:20 | [diff] [blame] | 425 | /* Initialize and use the cache information */ |
| Junio C Hamano | 4aab5b4 | 2007-04-02 06:26:07 | [diff] [blame] | 426 | extern int read_index(struct index_state *); |
| Linus Torvalds | 671c9b7 | 2008-11-14 00:36:30 | [diff] [blame] | 427 | extern int read_index_preload(struct index_state *, const char **pathspec); |
| Junio C Hamano | 4aab5b4 | 2007-04-02 06:26:07 | [diff] [blame] | 428 | extern int read_index_from(struct index_state *, const char *path); |
| Junio C Hamano | fa7b3c2 | 2008-11-12 19:52:35 | [diff] [blame] | 429 | extern int is_index_unborn(struct index_state *); |
| Miklos Vajna | e46bbcf | 2008-06-27 16:21:58 | [diff] [blame] | 430 | extern int read_index_unmerged(struct index_state *); |
| Kjetil Barvik | e1afca4 | 2009-02-23 18:02:57 | [diff] [blame] | 431 | extern int write_index(struct index_state *, int newfd); |
| Junio C Hamano | 4aab5b4 | 2007-04-02 06:26:07 | [diff] [blame] | 432 | extern int discard_index(struct index_state *); |
| Linus Torvalds | d1f128b | 2008-03-06 20:46:09 | [diff] [blame] | 433 | extern int unmerged_index(const struct index_state *); |
| Linus Torvalds | 8dcf39c | 2006-05-18 19:07:31 | [diff] [blame] | 434 | extern int verify_path(const char *path); |
| Linus Torvalds | cd2fef5 | 2008-03-21 22:55:19 | [diff] [blame] | 435 | extern struct cache_entry *index_name_exists(struct index_state *istate, const char *name, int namelen, int igncase); |
| Linus Torvalds | d1f128b | 2008-03-06 20:46:09 | [diff] [blame] | 436 | extern int index_name_pos(const struct index_state *, const char *name, int namelen); |
| Junio C Hamano | 192268c | 2005-05-08 04:55:21 | [diff] [blame] | 437 | #define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */ |
| 438 | #define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */ |
| Junio C Hamano | b155725 | 2005-06-25 09:25:29 | [diff] [blame] | 439 | #define ADD_CACHE_SKIP_DFCHECK 4 /* Ok to skip DF conflict checks */ |
| Junio C Hamano | af3785d | 2007-08-09 20:42:50 | [diff] [blame] | 440 | #define ADD_CACHE_JUST_APPEND 8 /* Append only; tree.c::read_tree() */ |
| Junio C Hamano | 3942581 | 2008-08-21 08:44:53 | [diff] [blame] | 441 | #define ADD_CACHE_NEW_ONLY 16 /* Do not replace existing ones */ |
| Junio C Hamano | 4aab5b4 | 2007-04-02 06:26:07 | [diff] [blame] | 442 | extern int add_index_entry(struct index_state *, struct cache_entry *ce, int option); |
| Johannes Schindelin | 8fd2cb4 | 2006-07-26 04:32:18 | [diff] [blame] | 443 | extern struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really); |
| Petr Baudis | 81dc230 | 2008-07-21 00:25:56 | [diff] [blame] | 444 | extern void rename_index_entry_at(struct index_state *, int pos, const char *new_name); |
| Junio C Hamano | 4aab5b4 | 2007-04-02 06:26:07 | [diff] [blame] | 445 | extern int remove_index_entry_at(struct index_state *, int pos); |
| Kjetil Barvik | 36419c8 | 2009-02-18 22:18:03 | [diff] [blame] | 446 | extern void remove_marked_cache_entries(struct index_state *istate); |
| Junio C Hamano | 4aab5b4 | 2007-04-02 06:26:07 | [diff] [blame] | 447 | extern int remove_file_from_index(struct index_state *, const char *path); |
| Junio C Hamano | 38ed1d8 | 2008-05-21 19:04:34 | [diff] [blame] | 448 | #define ADD_CACHE_VERBOSE 1 |
| 449 | #define ADD_CACHE_PRETEND 2 |
| Junio C Hamano | 0166592 | 2008-05-25 21:03:50 | [diff] [blame] | 450 | #define ADD_CACHE_IGNORE_ERRORS 4 |
| Junio C Hamano | 041aee3 | 2008-07-21 08:24:17 | [diff] [blame] | 451 | #define ADD_CACHE_IGNORE_REMOVAL 8 |
| Junio C Hamano | 3942581 | 2008-08-21 08:44:53 | [diff] [blame] | 452 | #define ADD_CACHE_INTENT 16 |
| Junio C Hamano | 38ed1d8 | 2008-05-21 19:04:34 | [diff] [blame] | 453 | extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags); |
| 454 | extern int add_file_to_index(struct index_state *, const char *path, int flags); |
| Carlos Rica | 6640f88 | 2007-09-11 03:17:28 | [diff] [blame] | 455 | extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, int refresh); |
| Brad Roberts | dbbce55 | 2005-05-15 02:04:25 | [diff] [blame] | 456 | extern int ce_same_name(struct cache_entry *a, struct cache_entry *b); |
| Jeff King | 98fa473 | 2008-10-16 15:07:26 | [diff] [blame] | 457 | extern int index_name_is_other(const struct index_state *, const char *, int); |
| Junio C Hamano | 4bd5b7d | 2007-11-10 08:15:03 | [diff] [blame] | 458 | |
| 459 | /* do stat comparison even if CE_VALID is true */ |
| 460 | #define CE_MATCH_IGNORE_VALID 01 |
| 461 | /* do not check the contents but report dirty on racily-clean entries */ |
| 462 | #define CE_MATCH_RACY_IS_DIRTY 02 |
| Linus Torvalds | d1f128b | 2008-03-06 20:46:09 | [diff] [blame] | 463 | extern int ie_match_stat(const struct index_state *, struct cache_entry *, struct stat *, unsigned int); |
| 464 | extern int ie_modified(const struct index_state *, struct cache_entry *, struct stat *, unsigned int); |
| Junio C Hamano | 4bd5b7d | 2007-11-10 08:15:03 | [diff] [blame] | 465 | |
| Linus Torvalds | c0fd1f5 | 2005-07-14 23:55:06 | [diff] [blame] | 466 | extern int ce_path_match(const struct cache_entry *ce, const char **pathspec); |
| Junio C Hamano | 53bca91 | 2007-02-28 19:52:04 | [diff] [blame] | 467 | extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path); |
| Junio C Hamano | ec1fcc1 | 2005-10-07 10:42:00 | [diff] [blame] | 468 | extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object); |
| Junio C Hamano | 415e96c | 2005-05-15 21:23:12 | [diff] [blame] | 469 | extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st); |
| 470 | |
| Linus Torvalds | 405e5b2 | 2006-05-19 16:56:35 | [diff] [blame] | 471 | #define REFRESH_REALLY 0x0001 /* ignore_valid */ |
| 472 | #define REFRESH_UNMERGED 0x0002 /* allow unmerged */ |
| 473 | #define REFRESH_QUIET 0x0004 /* be quiet about it */ |
| 474 | #define REFRESH_IGNORE_MISSING 0x0008 /* ignore non-existent */ |
| Junio C Hamano | 3f1b7b6 | 2008-07-20 06:25:00 | [diff] [blame] | 475 | #define REFRESH_IGNORE_SUBMODULES 0x0010 /* ignore submodules */ |
| Junio C Hamano | d14e740 | 2008-07-20 07:21:38 | [diff] [blame] | 476 | #define REFRESH_SAY_CHANGED 0x0020 /* say "changed" not "needs update" */ |
| Alexandre Julliard | d616813 | 2007-08-11 21:59:01 | [diff] [blame] | 477 | extern int refresh_index(struct index_state *, unsigned int flags, const char **pathspec, char *seen); |
| Linus Torvalds | 405e5b2 | 2006-05-19 16:56:35 | [diff] [blame] | 478 | |
| Junio C Hamano | 021b6e4 | 2006-06-06 19:51:49 | [diff] [blame] | 479 | struct lock_file { |
| 480 | struct lock_file *next; |
| Johannes Schindelin | 4723ee9 | 2007-11-13 20:05:03 | [diff] [blame] | 481 | int fd; |
| Junio C Hamano | 5e635e3 | 2007-04-21 10:11:10 | [diff] [blame] | 482 | pid_t owner; |
| Junio C Hamano | 1084b84 | 2007-01-02 19:19:05 | [diff] [blame] | 483 | char on_list; |
| Junio C Hamano | 021b6e4 | 2006-06-06 19:51:49 | [diff] [blame] | 484 | char filename[PATH_MAX]; |
| Junio C Hamano | 415e96c | 2005-05-15 21:23:12 | [diff] [blame] | 485 | }; |
| Junio C Hamano | acd3b9e | 2008-10-17 22:44:39 | [diff] [blame] | 486 | #define LOCK_DIE_ON_ERROR 1 |
| 487 | #define LOCK_NODEREF 2 |
| Matthieu Moy | e43a6fd | 2009-02-19 12:54:18 | [diff] [blame] | 488 | extern NORETURN void unable_to_lock_index_die(const char *path, int err); |
| Junio C Hamano | 40aaae8 | 2006-08-12 08:03:47 | [diff] [blame] | 489 | extern int hold_lock_file_for_update(struct lock_file *, const char *path, int); |
| Daniel Barkalow | ea3cd5c | 2008-04-17 23:32:26 | [diff] [blame] | 490 | extern int hold_lock_file_for_append(struct lock_file *, const char *path, int); |
| Junio C Hamano | 021b6e4 | 2006-06-06 19:51:49 | [diff] [blame] | 491 | extern int commit_lock_file(struct lock_file *); |
| Junio C Hamano | 30ca07a | 2007-04-01 06:09:02 | [diff] [blame] | 492 | |
| 493 | extern int hold_locked_index(struct lock_file *, int); |
| 494 | extern int commit_locked_index(struct lock_file *); |
| Junio C Hamano | 5e7f56a | 2007-04-01 06:27:41 | [diff] [blame] | 495 | extern void set_alternate_index_output(const char *); |
| Brandon Casey | d6cf61b | 2008-01-16 19:05:32 | [diff] [blame] | 496 | extern int close_lock_file(struct lock_file *); |
| Junio C Hamano | 021b6e4 | 2006-06-06 19:51:49 | [diff] [blame] | 497 | extern void rollback_lock_file(struct lock_file *); |
| Miklos Vajna | eca35a2 | 2008-10-26 02:33:56 | [diff] [blame] | 498 | extern int delete_ref(const char *, const unsigned char *sha1, int delopt); |
| Linus Torvalds | 734aab7 | 2005-04-09 16:48:20 | [diff] [blame] | 499 | |
| Junio C Hamano | 2ae1c53 | 2006-02-27 22:47:45 | [diff] [blame] | 500 | /* Environment bits from configuration mechanism */ |
| Linus Torvalds | 1771299 | 2005-10-10 23:31:08 | [diff] [blame] | 501 | extern int trust_executable_bit; |
| Alex Riesen | 1ce4790 | 2008-07-28 06:31:28 | [diff] [blame] | 502 | extern int trust_ctime; |
| Junio C Hamano | 9378c16 | 2007-06-24 22:11:24 | [diff] [blame] | 503 | extern int quote_path_fully; |
| Johannes Sixt | 78a8d64 | 2007-03-02 21:11:30 | [diff] [blame] | 504 | extern int has_symlinks; |
| Linus Torvalds | 0a9b88b | 2008-03-21 23:52:46 | [diff] [blame] | 505 | extern int ignore_case; |
| Junio C Hamano | 5f73076 | 2006-02-09 05:15:24 | [diff] [blame] | 506 | extern int assume_unchanged; |
| Junio C Hamano | 9f0bb90 | 2006-05-02 07:40:24 | [diff] [blame] | 507 | extern int prefer_symlink_refs; |
| Shawn Pearce | 6de08ae | 2006-05-17 09:55:40 | [diff] [blame] | 508 | extern int log_all_ref_updates; |
| Junio C Hamano | 2f8acdb | 2006-03-21 02:45:47 | [diff] [blame] | 509 | extern int warn_ambiguous_refs; |
| Johannes Schindelin | 457f06d | 2005-12-22 22:13:56 | [diff] [blame] | 510 | extern int shared_repository; |
| Junio C Hamano | 2ae1c53 | 2006-02-27 22:47:45 | [diff] [blame] | 511 | extern const char *apply_default_whitespace; |
| Joachim B Haga | 12f6c30 | 2006-07-03 20:11:47 | [diff] [blame] | 512 | extern int zlib_compression_level; |
| Dana How | 960ccca | 2007-05-09 20:56:50 | [diff] [blame] | 513 | extern int core_compression_level; |
| 514 | extern int core_compression_seen; |
| Shawn O. Pearce | 60bb8b1 | 2006-12-23 07:34:28 | [diff] [blame] | 515 | extern size_t packed_git_window_size; |
| Shawn O. Pearce | 77ccc5b | 2006-12-23 07:33:35 | [diff] [blame] | 516 | extern size_t packed_git_limit; |
| Shawn O. Pearce | 18bdec1 | 2007-03-19 05:14:37 | [diff] [blame] | 517 | extern size_t delta_base_cache_limit; |
| Linus Torvalds | 6c510be | 2007-02-13 19:07:23 | [diff] [blame] | 518 | extern int auto_crlf; |
| Linus Torvalds | aafe9fb | 2008-06-18 22:18:44 | [diff] [blame] | 519 | extern int fsync_object_files; |
| Linus Torvalds | 671c9b7 | 2008-11-14 00:36:30 | [diff] [blame] | 520 | extern int core_preload_index; |
| Linus Torvalds | 1771299 | 2005-10-10 23:31:08 | [diff] [blame] | 521 | |
| Steffen Prohaska | 21e5ad5 | 2008-02-06 11:25:58 | [diff] [blame] | 522 | enum safe_crlf { |
| 523 | SAFE_CRLF_FALSE = 0, |
| 524 | SAFE_CRLF_FAIL = 1, |
| 525 | SAFE_CRLF_WARN = 2, |
| 526 | }; |
| 527 | |
| 528 | extern enum safe_crlf safe_crlf; |
| 529 | |
| Jay Soffian | 9ed36cf | 2008-02-19 16:24:37 | [diff] [blame] | 530 | enum branch_track { |
| Alex Riesen | 9188ed8 | 2008-08-21 17:23:20 | [diff] [blame] | 531 | BRANCH_TRACK_UNSPECIFIED = -1, |
| Jay Soffian | 9ed36cf | 2008-02-19 16:24:37 | [diff] [blame] | 532 | BRANCH_TRACK_NEVER = 0, |
| 533 | BRANCH_TRACK_REMOTE, |
| 534 | BRANCH_TRACK_ALWAYS, |
| 535 | BRANCH_TRACK_EXPLICIT, |
| 536 | }; |
| 537 | |
| Dustin Sallings | c998ae9 | 2008-05-10 22:36:29 | [diff] [blame] | 538 | enum rebase_setup_type { |
| 539 | AUTOREBASE_NEVER = 0, |
| 540 | AUTOREBASE_LOCAL, |
| 541 | AUTOREBASE_REMOTE, |
| 542 | AUTOREBASE_ALWAYS, |
| 543 | }; |
| 544 | |
| Finn Arne Gangstad | 5215374 | 2009-03-16 15:42:51 | [diff] [blame] | 545 | enum push_default_type { |
| 546 | PUSH_DEFAULT_UNSPECIFIED = -1, |
| 547 | PUSH_DEFAULT_NOTHING = 0, |
| 548 | PUSH_DEFAULT_MATCHING, |
| 549 | PUSH_DEFAULT_TRACKING, |
| 550 | PUSH_DEFAULT_CURRENT, |
| 551 | }; |
| 552 | |
| Jay Soffian | 9ed36cf | 2008-02-19 16:24:37 | [diff] [blame] | 553 | extern enum branch_track git_branch_track; |
| Dustin Sallings | c998ae9 | 2008-05-10 22:36:29 | [diff] [blame] | 554 | extern enum rebase_setup_type autorebase; |
| Finn Arne Gangstad | 5215374 | 2009-03-16 15:42:51 | [diff] [blame] | 555 | extern enum push_default_type push_default; |
| Jay Soffian | 9ed36cf | 2008-02-19 16:24:37 | [diff] [blame] | 556 | |
| Johannes Schindelin | 348df16 | 2009-04-27 22:32:25 | [diff] [blame] | 557 | enum object_creation_mode { |
| 558 | OBJECT_CREATION_USES_HARDLINKS = 0, |
| 559 | OBJECT_CREATION_USES_RENAMES = 1, |
| 560 | }; |
| 561 | |
| 562 | extern enum object_creation_mode object_creation_mode; |
| Johannes Schindelin | be66a6c | 2009-04-25 09:57:14 | [diff] [blame] | 563 | |
| Junio C Hamano | ab9cb76 | 2005-11-25 23:59:09 | [diff] [blame] | 564 | #define GIT_REPO_VERSION 0 |
| 565 | extern int repository_format_version; |
| 566 | extern int check_repository_format(void); |
| 567 | |
| Linus Torvalds | 734aab7 | 2005-04-09 16:48:20 | [diff] [blame] | 568 | #define MTIME_CHANGED 0x0001 |
| 569 | #define CTIME_CHANGED 0x0002 |
| 570 | #define OWNER_CHANGED 0x0004 |
| 571 | #define MODE_CHANGED 0x0008 |
| 572 | #define INODE_CHANGED 0x0010 |
| 573 | #define DATA_CHANGED 0x0020 |
| Kay Sievers | 8ae0a8c | 2005-05-05 12:38:25 | [diff] [blame] | 574 | #define TYPE_CHANGED 0x0040 |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 575 | |
| Alex Riesen | 108bebe | 2008-10-26 21:59:13 | [diff] [blame] | 576 | extern char *mksnpath(char *buf, size_t n, const char *fmt, ...) |
| 577 | __attribute__((format (printf, 3, 4))); |
| Alex Riesen | fe2d777 | 2008-10-27 09:22:21 | [diff] [blame] | 578 | extern char *git_snpath(char *buf, size_t n, const char *fmt, ...) |
| 579 | __attribute__((format (printf, 3, 4))); |
| Alex Riesen | aba13e7 | 2008-10-27 10:17:51 | [diff] [blame] | 580 | extern char *git_pathdup(const char *fmt, ...) |
| 581 | __attribute__((format (printf, 1, 2))); |
| Alex Riesen | 108bebe | 2008-10-26 21:59:13 | [diff] [blame] | 582 | |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 583 | /* Return a statically allocated filename matching the sha1 signature */ |
| Timo Sirainen | 4ec99bf | 2005-08-09 15:30:22 | [diff] [blame] | 584 | extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2))); |
| 585 | extern char *git_path(const char *fmt, ...) __attribute__((format (printf, 1, 2))); |
| Linus Torvalds | 73134b6 | 2005-04-10 21:03:58 | [diff] [blame] | 586 | extern char *sha1_file_name(const unsigned char *sha1); |
| barkalow@iabervon.org | bf592c5 | 2005-08-01 00:53:44 | [diff] [blame] | 587 | extern char *sha1_pack_name(const unsigned char *sha1); |
| 588 | extern char *sha1_pack_index_name(const unsigned char *sha1); |
| Junio C Hamano | 013f276 | 2005-10-11 22:22:48 | [diff] [blame] | 589 | extern const char *find_unique_abbrev(const unsigned char *sha1, int); |
| Junio C Hamano | 88cd621 | 2005-09-30 21:02:47 | [diff] [blame] | 590 | extern const unsigned char null_sha1[20]; |
| David Rientjes | 0bef57e | 2006-08-15 20:37:19 | [diff] [blame] | 591 | static inline int is_null_sha1(const unsigned char *sha1) |
| 592 | { |
| 593 | return !memcmp(sha1, null_sha1, 20); |
| 594 | } |
| David Rientjes | a89fccd | 2006-08-17 18:54:57 | [diff] [blame] | 595 | static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2) |
| 596 | { |
| 597 | return memcmp(sha1, sha2, 20); |
| 598 | } |
| Shawn Pearce | e702496 | 2006-08-23 06:49:00 | [diff] [blame] | 599 | static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src) |
| 600 | { |
| 601 | memcpy(sha_dst, sha_src, 20); |
| 602 | } |
| Junio C Hamano | a8e0d16 | 2006-08-23 20:57:23 | [diff] [blame] | 603 | static inline void hashclr(unsigned char *hash) |
| 604 | { |
| 605 | memset(hash, 0, 20); |
| 606 | } |
| Jeff King | f55527f | 2008-10-21 13:54:19 | [diff] [blame] | 607 | extern int is_empty_blob_sha1(const unsigned char *sha1); |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 608 | |
| Jeff King | 14d9c57 | 2008-11-12 08:17:52 | [diff] [blame] | 609 | #define EMPTY_TREE_SHA1_HEX \ |
| 610 | "4b825dc642cb6eb9a060e54bf8d69288fbee4904" |
| 611 | #define EMPTY_TREE_SHA1_BIN \ |
| 612 | "\x4b\x82\x5d\xc6\x42\xcb\x6e\xb9\xa0\x60" \ |
| 613 | "\xe5\x4b\xf8\xd6\x92\x88\xfb\xee\x49\x04" |
| 614 | |
| Holger Eitzenberger | f2db68e | 2005-08-04 20:43:03 | [diff] [blame] | 615 | int git_mkstemp(char *path, size_t n, const char *template); |
| 616 | |
| David Aguilar | 003b33a | 2009-05-31 08:35:52 | [diff] [blame] | 617 | int git_mkstemps(char *path, size_t n, const char *template, int suffix_len); |
| 618 | |
| Heikki Orsila | 06cbe85 | 2008-04-16 08:34:24 | [diff] [blame] | 619 | /* |
| 620 | * NOTE NOTE NOTE!! |
| 621 | * |
| 622 | * PERM_UMASK, OLD_PERM_GROUP and OLD_PERM_EVERYBODY enumerations must |
| 623 | * not be changed. Old repositories have core.sharedrepository written in |
| 624 | * numeric format, and therefore these values are preserved for compatibility |
| 625 | * reasons. |
| 626 | */ |
| Junio C Hamano | 94df250 | 2006-06-10 06:09:49 | [diff] [blame] | 627 | enum sharedrepo { |
| Heikki Orsila | 06cbe85 | 2008-04-16 08:34:24 | [diff] [blame] | 628 | PERM_UMASK = 0, |
| 629 | OLD_PERM_GROUP = 1, |
| 630 | OLD_PERM_EVERYBODY = 2, |
| 631 | PERM_GROUP = 0660, |
| 632 | PERM_EVERYBODY = 0664, |
| Junio C Hamano | 94df250 | 2006-06-10 06:09:49 | [diff] [blame] | 633 | }; |
| 634 | int git_config_perm(const char *var, const char *value); |
| Junio C Hamano | 17e61b8 | 2009-03-28 06:21:00 | [diff] [blame] | 635 | int set_shared_perm(const char *path, int mode); |
| 636 | #define adjust_shared_perm(path) set_shared_perm((path), 0) |
| Junio C Hamano | b2cb942 | 2005-07-06 08:11:52 | [diff] [blame] | 637 | int safe_create_leading_directories(char *path); |
| Jeff King | 8e21d63 | 2008-06-25 05:41:34 | [diff] [blame] | 638 | int safe_create_leading_directories_const(const char *path); |
| Timo Hirvonen | bd22c90 | 2005-11-21 00:52:52 | [diff] [blame] | 639 | char *enter_repo(char *path, int strict); |
| Johannes Schindelin | e5392c5 | 2007-08-01 00:28:59 | [diff] [blame] | 640 | static inline int is_absolute_path(const char *path) |
| 641 | { |
| Johannes Sixt | 25fe217 | 2008-03-05 20:51:27 | [diff] [blame] | 642 | return path[0] == '/' || has_dos_drive_prefix(path); |
| Johannes Schindelin | e5392c5 | 2007-08-01 00:28:59 | [diff] [blame] | 643 | } |
| Junio C Hamano | 90b4a71 | 2008-09-09 08:27:07 | [diff] [blame] | 644 | int is_directory(const char *); |
| Johannes Schindelin | e5392c5 | 2007-08-01 00:28:59 | [diff] [blame] | 645 | const char *make_absolute_path(const char *path); |
| Daniel Barkalow | 1b9a946 | 2008-06-06 03:15:19 | [diff] [blame] | 646 | const char *make_nonrelative_path(const char *path); |
| Linus Torvalds | 044bbbc | 2008-06-19 19:34:06 | [diff] [blame] | 647 | const char *make_relative_path(const char *abs, const char *base); |
| Johannes Sixt | f3cad0a | 2009-02-07 15:08:28 | [diff] [blame] | 648 | int normalize_path_copy(char *dst, const char *src); |
| David Reiss | 0454dd9 | 2008-05-20 06:49:26 | [diff] [blame] | 649 | int longest_ancestor_length(const char *path, const char *prefix_list); |
| Johannes Schindelin | 4fcc86b | 2009-02-19 19:10:49 | [diff] [blame] | 650 | char *strip_path_suffix(const char *path, const char *suffix); |
| Junio C Hamano | b2cb942 | 2005-07-06 08:11:52 | [diff] [blame] | 651 | |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 652 | /* Read and unpack a sha1 file into memory, write memory to a sha1 file */ |
| Nicolas Pitre | 21666f1 | 2007-02-26 19:55:59 | [diff] [blame] | 653 | extern int sha1_object_info(const unsigned char *, unsigned long *); |
| Nicolas Pitre | 21666f1 | 2007-02-26 19:55:59 | [diff] [blame] | 654 | extern void * read_sha1_file(const unsigned char *sha1, enum object_type *type, unsigned long *size); |
| Nicolas Pitre | ce9fbf1 | 2007-03-20 20:02:09 | [diff] [blame] | 655 | extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1); |
| Brian Gerst | bf0f910 | 2005-05-18 12:14:09 | [diff] [blame] | 656 | extern int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *return_sha1); |
| Nicolas Pitre | 21666f1 | 2007-02-26 19:55:59 | [diff] [blame] | 657 | extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *); |
| Nicolas Pitre | bbac731 | 2008-05-14 05:32:48 | [diff] [blame] | 658 | extern int force_object_loose(const unsigned char *sha1, time_t mtime); |
| Daniel Barkalow | 8237b18 | 2005-04-24 01:47:23 | [diff] [blame] | 659 | |
| Nicolas Pitre | 0e8189e | 2008-10-31 15:31:08 | [diff] [blame] | 660 | /* global flag to enable extra checks when accessing packed objects */ |
| 661 | extern int do_check_packed_object_crc; |
| 662 | |
| Jason McMullan | 5d6ccf5 | 2005-06-03 15:05:39 | [diff] [blame] | 663 | extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type); |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 664 | |
| Junio C Hamano | 839837b | 2006-09-01 07:17:47 | [diff] [blame] | 665 | extern int move_temp_to_file(const char *tmpfile, const char *filename); |
| Daniel Barkalow | 8237b18 | 2005-04-24 01:47:23 | [diff] [blame] | 666 | |
| Junio C Hamano | cd673c1 | 2009-02-28 07:15:53 | [diff] [blame] | 667 | extern int has_sha1_pack(const unsigned char *sha1); |
| Daniel Barkalow | 8237b18 | 2005-04-24 01:47:23 | [diff] [blame] | 668 | extern int has_sha1_file(const unsigned char *sha1); |
| Brandon Casey | 0f4dc14 | 2008-11-10 05:59:57 | [diff] [blame] | 669 | extern int has_loose_object_nonlocal(const unsigned char *sha1); |
| Daniel Barkalow | 8237b18 | 2005-04-24 01:47:23 | [diff] [blame] | 670 | |
| barkalow@iabervon.org | bf592c5 | 2005-08-01 00:53:44 | [diff] [blame] | 671 | extern int has_pack_file(const unsigned char *sha1); |
| 672 | extern int has_pack_index(const unsigned char *sha1); |
| 673 | |
| Linus Torvalds | 192a6be | 2007-05-30 17:32:19 | [diff] [blame] | 674 | extern const signed char hexval_table[256]; |
| 675 | static inline unsigned int hexval(unsigned char c) |
| Junio C Hamano | e49521b | 2006-09-20 23:04:46 | [diff] [blame] | 676 | { |
| 677 | return hexval_table[c]; |
| 678 | } |
| 679 | |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 680 | /* Convert to/from hex/sha1 representation */ |
| Junio C Hamano | 46a6c26 | 2006-01-25 09:03:18 | [diff] [blame] | 681 | #define MINIMUM_ABBREV 4 |
| 682 | #define DEFAULT_ABBREV 7 |
| 683 | |
| Linus Torvalds | 3c249c9 | 2005-05-01 23:36:56 | [diff] [blame] | 684 | extern int get_sha1(const char *str, unsigned char *sha1); |
| Martin Koegler | a0cd87a | 2007-04-23 20:55:05 | [diff] [blame] | 685 | extern int get_sha1_with_mode(const char *str, unsigned char *sha1, unsigned *mode); |
| Linus Torvalds | 197ee8c | 2005-04-09 19:09:27 | [diff] [blame] | 686 | extern int get_sha1_hex(const char *hex, unsigned char *sha1); |
| 687 | extern char *sha1_to_hex(const unsigned char *sha1); /* static buffer result! */ |
| Linus Torvalds | ca8db14 | 2005-09-25 16:59:37 | [diff] [blame] | 688 | extern int read_ref(const char *filename, unsigned char *sha1); |
| Junio C Hamano | 8da1977 | 2006-09-21 05:02:01 | [diff] [blame] | 689 | extern const char *resolve_ref(const char *path, unsigned char *sha1, int, int *); |
| Junio C Hamano | e86eb66 | 2007-01-19 09:15:15 | [diff] [blame] | 690 | extern int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref); |
| Johannes Schindelin | eb3a482 | 2007-02-09 00:28:23 | [diff] [blame] | 691 | extern int dwim_log(const char *str, int len, unsigned char *sha1, char **ref); |
| Junio C Hamano | 431b196 | 2009-03-21 19:51:34 | [diff] [blame] | 692 | extern int interpret_branch_name(const char *str, struct strbuf *); |
| Junio C Hamano | e86eb66 | 2007-01-19 09:15:15 | [diff] [blame] | 693 | |
| Steffen Prohaska | 7980332 | 2007-11-11 14:01:46 | [diff] [blame] | 694 | extern int refname_match(const char *abbrev_name, const char *full_name, const char **rules); |
| 695 | extern const char *ref_rev_parse_rules[]; |
| Steffen Prohaska | 605b497 | 2007-11-11 14:01:48 | [diff] [blame] | 696 | extern const char *ref_fetch_rules[]; |
| Steffen Prohaska | 7980332 | 2007-11-11 14:01:46 | [diff] [blame] | 697 | |
| Nicolas Pitre | 8b5157e | 2007-01-26 22:26:10 | [diff] [blame] | 698 | extern int create_symref(const char *ref, const char *refs_heads_master, const char *logmsg); |
| Junio C Hamano | c847f53 | 2007-01-02 07:31:08 | [diff] [blame] | 699 | extern int validate_headref(const char *ref); |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 700 | |
| Linus Torvalds | 958ba6c | 2005-05-20 16:09:18 | [diff] [blame] | 701 | extern int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2); |
| Linus Torvalds | 0ab9e1e | 2008-03-06 02:25:10 | [diff] [blame] | 702 | extern int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2); |
| Linus Torvalds | 79517a0 | 2005-04-09 19:59:11 | [diff] [blame] | 703 | extern int cache_name_compare(const char *name1, int len1, const char *name2, int len2); |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 704 | |
| Junio C Hamano | 40469ee | 2005-04-28 23:42:27 | [diff] [blame] | 705 | extern void *read_object_with_reference(const unsigned char *sha1, |
| Brian Gerst | bf0f910 | 2005-05-18 12:14:09 | [diff] [blame] | 706 | const char *required_type, |
| Junio C Hamano | 40469ee | 2005-04-28 23:42:27 | [diff] [blame] | 707 | unsigned long *size, |
| 708 | unsigned char *sha1_ret); |
| Junio C Hamano | f4913f9 | 2005-04-21 01:06:49 | [diff] [blame] | 709 | |
| Junio C Hamano | 8177631 | 2007-12-24 08:51:01 | [diff] [blame] | 710 | extern struct object *peel_to_type(const char *name, int namelen, |
| 711 | struct object *o, enum object_type); |
| 712 | |
| Junio C Hamano | 73013af | 2007-07-14 06:14:52 | [diff] [blame] | 713 | enum date_mode { |
| 714 | DATE_NORMAL = 0, |
| 715 | DATE_RELATIVE, |
| 716 | DATE_SHORT, |
| 717 | DATE_LOCAL, |
| 718 | DATE_ISO8601, |
| Linus Torvalds | 7dff9b3 | 2009-02-20 22:15:22 | [diff] [blame] | 719 | DATE_RFC2822, |
| 720 | DATE_RAW |
| Junio C Hamano | 73013af | 2007-07-14 06:14:52 | [diff] [blame] | 721 | }; |
| 722 | |
| Johannes Schindelin | f8493ec | 2007-02-27 15:21:04 | [diff] [blame] | 723 | const char *show_date(unsigned long time, int timezone, enum date_mode mode); |
| Linus Torvalds | 2a39064 | 2005-09-19 22:53:50 | [diff] [blame] | 724 | int parse_date(const char *date, char *buf, int bufsize); |
| Edgar Toernig | ecee9d9 | 2005-04-30 16:46:49 | [diff] [blame] | 725 | void datestamp(char *buf, int bufsize); |
| Linus Torvalds | 3c07b1d | 2005-11-15 03:29:06 | [diff] [blame] | 726 | unsigned long approxidate(const char *); |
| Andy Parkins | 856665f | 2007-09-28 14:17:31 | [diff] [blame] | 727 | enum date_mode parse_date_format(const char *format); |
| Edgar Toernig | ecee9d9 | 2005-04-30 16:46:49 | [diff] [blame] | 728 | |
| Junio C Hamano | 774751a | 2007-12-09 01:32:08 | [diff] [blame] | 729 | #define IDENT_WARN_ON_NO_NAME 1 |
| 730 | #define IDENT_ERROR_ON_NO_NAME 2 |
| 731 | #define IDENT_NO_DATE 4 |
| Junio C Hamano | 749be72 | 2006-02-19 04:31:05 | [diff] [blame] | 732 | extern const char *git_author_info(int); |
| 733 | extern const char *git_committer_info(int); |
| Junio C Hamano | 798123a | 2007-02-05 01:50:14 | [diff] [blame] | 734 | extern const char *fmt_ident(const char *name, const char *email, const char *date_str, int); |
| Junio C Hamano | d9ccfe7 | 2007-12-02 21:43:34 | [diff] [blame] | 735 | extern const char *fmt_name(const char *name, const char *email); |
| Linus Torvalds | 6aa33f4 | 2005-07-12 18:49:27 | [diff] [blame] | 736 | |
| Linus Torvalds | 12dccc1 | 2005-06-06 04:59:54 | [diff] [blame] | 737 | struct checkout { |
| 738 | const char *base_dir; |
| 739 | int base_dir_len; |
| 740 | unsigned force:1, |
| 741 | quiet:1, |
| 742 | not_new:1, |
| 743 | refresh_cache:1; |
| 744 | }; |
| 745 | |
| Luiz Fernando N. Capitulino | efbc583 | 2007-04-25 14:18:08 | [diff] [blame] | 746 | extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath); |
| Linus Torvalds | b9fd284 | 2009-07-09 20:35:31 | [diff] [blame] | 747 | |
| 748 | struct cache_def { |
| 749 | char path[PATH_MAX + 1]; |
| 750 | int len; |
| 751 | int flags; |
| 752 | int track_flags; |
| 753 | int prefix_len_stat_func; |
| 754 | }; |
| 755 | |
| Kjetil Barvik | 5719989 | 2009-02-09 20:54:06 | [diff] [blame] | 756 | extern int has_symlink_leading_path(const char *name, int len); |
| Linus Torvalds | b9fd284 | 2009-07-09 20:35:31 | [diff] [blame] | 757 | extern int threaded_has_symlink_leading_path(struct cache_def *, const char *, int); |
| Kjetil Barvik | 5719989 | 2009-02-09 20:54:06 | [diff] [blame] | 758 | extern int has_symlink_or_noent_leading_path(const char *name, int len); |
| 759 | extern int has_dirs_only_path(const char *name, int len, int prefix_len); |
| 760 | extern void invalidate_lstat_cache(const char *name, int len); |
| Kjetil Barvik | bda6eb0 | 2009-01-18 15:14:54 | [diff] [blame] | 761 | extern void clear_lstat_cache(void); |
| Kjetil Barvik | 7847892 | 2009-02-09 20:54:07 | [diff] [blame] | 762 | extern void schedule_dir_for_removal(const char *name, int len); |
| 763 | extern void remove_scheduled_dirs(void); |
| Linus Torvalds | 12dccc1 | 2005-06-06 04:59:54 | [diff] [blame] | 764 | |
| Junio C Hamano | 9a217f2 | 2005-06-28 21:56:57 | [diff] [blame] | 765 | extern struct alternate_object_database { |
| Junio C Hamano | d5a63b9 | 2005-08-15 00:25:57 | [diff] [blame] | 766 | struct alternate_object_database *next; |
| Junio C Hamano | 9a217f2 | 2005-06-28 21:56:57 | [diff] [blame] | 767 | char *name; |
| Junio C Hamano | 8f1d2e6 | 2006-01-07 09:33:54 | [diff] [blame] | 768 | char base[FLEX_ARRAY]; /* more */ |
| Junio C Hamano | d5a63b9 | 2005-08-15 00:25:57 | [diff] [blame] | 769 | } *alt_odb_list; |
| Junio C Hamano | 9a217f2 | 2005-06-28 21:56:57 | [diff] [blame] | 770 | extern void prepare_alt_odb(void); |
| Daniel Barkalow | bef70b2 | 2008-04-17 23:32:30 | [diff] [blame] | 771 | extern void add_to_alternates_file(const char *reference); |
| Junio C Hamano | d79796b | 2008-09-09 08:27:10 | [diff] [blame] | 772 | typedef int alt_odb_fn(struct alternate_object_database *, void *); |
| 773 | extern void foreach_alt_odb(alt_odb_fn, void*); |
| Junio C Hamano | 9a217f2 | 2005-06-28 21:56:57 | [diff] [blame] | 774 | |
| Shawn O. Pearce | c41ee58 | 2006-12-23 07:33:44 | [diff] [blame] | 775 | struct pack_window { |
| 776 | struct pack_window *next; |
| 777 | unsigned char *base; |
| 778 | off_t offset; |
| 779 | size_t len; |
| 780 | unsigned int last_used; |
| 781 | unsigned int inuse_cnt; |
| 782 | }; |
| 783 | |
| Junio C Hamano | 9a217f2 | 2005-06-28 21:56:57 | [diff] [blame] | 784 | extern struct packed_git { |
| 785 | struct packed_git *next; |
| Shawn O. Pearce | c41ee58 | 2006-12-23 07:33:44 | [diff] [blame] | 786 | struct pack_window *windows; |
| Shawn O. Pearce | 2dc3a23 | 2006-12-23 07:33:47 | [diff] [blame] | 787 | off_t pack_size; |
| Nicolas Pitre | 5705909 | 2007-04-09 05:06:28 | [diff] [blame] | 788 | const void *index_data; |
| 789 | size_t index_size; |
| 790 | uint32_t num_objects; |
| Nicolas Pitre | 8eca0b4 | 2008-06-24 01:23:39 | [diff] [blame] | 791 | uint32_t num_bad_objects; |
| 792 | unsigned char *bad_object_sha1; |
| Nicolas Pitre | 4287307 | 2007-03-16 20:42:50 | [diff] [blame] | 793 | int index_version; |
| Nicolas Pitre | 5705909 | 2007-04-09 05:06:28 | [diff] [blame] | 794 | time_t mtime; |
| Shawn O. Pearce | 9bc879c | 2006-12-23 07:34:01 | [diff] [blame] | 795 | int pack_fd; |
| Brandon Casey | 8d25931 | 2008-11-12 17:59:03 | [diff] [blame] | 796 | unsigned pack_local:1, |
| 797 | pack_keep:1; |
| barkalow@iabervon.org | bf592c5 | 2005-08-01 00:53:44 | [diff] [blame] | 798 | unsigned char sha1[20]; |
| Junio C Hamano | 8f1d2e6 | 2006-01-07 09:33:54 | [diff] [blame] | 799 | /* something like ".git/objects/pack/xxxxx.pack" */ |
| 800 | char pack_name[FLEX_ARRAY]; /* more */ |
| Junio C Hamano | 9a217f2 | 2005-06-28 21:56:57 | [diff] [blame] | 801 | } *packed_git; |
| Junio C Hamano | f3bf922 | 2005-07-01 00:15:39 | [diff] [blame] | 802 | |
| 803 | struct pack_entry { |
| Shawn O. Pearce | c4001d9 | 2007-03-07 01:44:30 | [diff] [blame] | 804 | off_t offset; |
| Junio C Hamano | f3bf922 | 2005-07-01 00:15:39 | [diff] [blame] | 805 | unsigned char sha1[20]; |
| 806 | struct packed_git *p; |
| 807 | }; |
| 808 | |
| Linus Torvalds | d1c133f | 2005-07-16 20:55:50 | [diff] [blame] | 809 | struct ref { |
| 810 | struct ref *next; |
| 811 | unsigned char old_sha1[20]; |
| 812 | unsigned char new_sha1[20]; |
| Daniel Barkalow | be885d9 | 2008-04-26 19:53:12 | [diff] [blame] | 813 | char *symref; |
| Shawn O. Pearce | 9f8a15c | 2007-11-18 09:31:37 | [diff] [blame] | 814 | unsigned int force:1, |
| 815 | merge:1, |
| 816 | nonfastforward:1, |
| 817 | deletion:1; |
| Jeff King | 8736a84 | 2007-11-17 12:54:27 | [diff] [blame] | 818 | enum { |
| 819 | REF_STATUS_NONE = 0, |
| 820 | REF_STATUS_OK, |
| 821 | REF_STATUS_REJECT_NONFASTFORWARD, |
| 822 | REF_STATUS_REJECT_NODELETE, |
| 823 | REF_STATUS_UPTODATE, |
| Jeff King | ca74c45 | 2007-11-17 12:56:03 | [diff] [blame] | 824 | REF_STATUS_REMOTE_REJECT, |
| Jeff King | 2a0fe89 | 2007-11-18 07:16:52 | [diff] [blame] | 825 | REF_STATUS_EXPECTING_REPORT, |
| Jeff King | 8736a84 | 2007-11-17 12:54:27 | [diff] [blame] | 826 | } status; |
| Jeff King | 2a0fe89 | 2007-11-18 07:16:52 | [diff] [blame] | 827 | char *remote_status; |
| Junio C Hamano | f88395a | 2005-08-03 23:35:29 | [diff] [blame] | 828 | struct ref *peer_ref; /* when renaming */ |
| Junio C Hamano | 8f1d2e6 | 2006-01-07 09:33:54 | [diff] [blame] | 829 | char name[FLEX_ARRAY]; /* more */ |
| Linus Torvalds | d1c133f | 2005-07-16 20:55:50 | [diff] [blame] | 830 | }; |
| 831 | |
| Linus Torvalds | 2718ff0 | 2006-07-04 19:29:10 | [diff] [blame] | 832 | #define REF_NORMAL (1u << 0) |
| 833 | #define REF_HEADS (1u << 1) |
| 834 | #define REF_TAGS (1u << 2) |
| 835 | |
| Jeff King | 5483f79 | 2009-02-25 08:32:10 | [diff] [blame] | 836 | extern struct ref *find_ref_by_name(const struct ref *list, const char *name); |
| Jeff King | cda69f4 | 2007-11-18 07:13:10 | [diff] [blame] | 837 | |
| Michael S. Tsirkin | 7841ce7 | 2007-05-16 17:09:41 | [diff] [blame] | 838 | #define CONNECT_VERBOSE (1u << 0) |
| Daniel Barkalow | 4577370 | 2007-10-30 01:05:40 | [diff] [blame] | 839 | extern struct child_process *git_connect(int fd[2], const char *url, const char *prog, int flags); |
| Johannes Sixt | 98158e9 | 2007-10-19 19:47:53 | [diff] [blame] | 840 | extern int finish_connect(struct child_process *conn); |
| Linus Torvalds | 013e7c7 | 2005-07-04 20:24:30 | [diff] [blame] | 841 | extern int path_match(const char *path, int nr, char **match); |
| Linus Torvalds | 41cb748 | 2005-07-05 22:44:09 | [diff] [blame] | 842 | extern int get_ack(int fd, unsigned char *result_sha1); |
| Junio C Hamano | 40c155f | 2008-09-09 08:27:09 | [diff] [blame] | 843 | struct extra_have_objects { |
| 844 | int nr, alloc; |
| 845 | unsigned char (*array)[20]; |
| 846 | }; |
| 847 | extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match, unsigned int flags, struct extra_have_objects *); |
| Johannes Schindelin | 211b5f9 | 2005-10-28 02:48:54 | [diff] [blame] | 848 | extern int server_supports(const char *feature); |
| Linus Torvalds | f719259 | 2005-07-04 18:57:58 | [diff] [blame] | 849 | |
| barkalow@iabervon.org | bf592c5 | 2005-08-01 00:53:44 | [diff] [blame] | 850 | extern struct packed_git *parse_pack_index(unsigned char *sha1); |
| barkalow@iabervon.org | bf592c5 | 2005-08-01 00:53:44 | [diff] [blame] | 851 | |
| Junio C Hamano | 9a217f2 | 2005-06-28 21:56:57 | [diff] [blame] | 852 | extern void prepare_packed_git(void); |
| Shawn Pearce | fc04c41 | 2006-11-01 22:06:21 | [diff] [blame] | 853 | extern void reprepare_packed_git(void); |
| barkalow@iabervon.org | bf592c5 | 2005-08-01 00:53:44 | [diff] [blame] | 854 | extern void install_packed_git(struct packed_git *pack); |
| 855 | |
| Junio C Hamano | a6080a0 | 2007-06-07 07:04:01 | [diff] [blame] | 856 | extern struct packed_git *find_sha1_pack(const unsigned char *sha1, |
| barkalow@iabervon.org | bf592c5 | 2005-08-01 00:53:44 | [diff] [blame] | 857 | struct packed_git *packs); |
| 858 | |
| Chris Wedgwood | 276bc2c | 2007-01-17 06:28:02 | [diff] [blame] | 859 | extern void pack_report(void); |
| Shawn O. Pearce | d079837 | 2007-05-26 05:24:19 | [diff] [blame] | 860 | extern int open_pack_index(struct packed_git *); |
| Felipe Contreras | 4b25d09 | 2009-05-01 09:06:36 | [diff] [blame] | 861 | extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned int *); |
| Shawn O. Pearce | c9ced05 | 2008-01-18 03:57:00 | [diff] [blame] | 862 | extern void close_pack_windows(struct packed_git *); |
| Shawn O. Pearce | 03e79c8 | 2006-12-23 07:34:08 | [diff] [blame] | 863 | extern void unuse_pack(struct pack_window **); |
| Nicolas Pitre | c74faea | 2008-12-09 19:26:52 | [diff] [blame] | 864 | extern void free_pack_by_name(const char *); |
| Shawn O. Pearce | 3d20c63 | 2009-02-10 21:36:12 | [diff] [blame] | 865 | extern void clear_delta_base_cache(void); |
| Nicolas Pitre | 4287307 | 2007-03-16 20:42:50 | [diff] [blame] | 866 | extern struct packed_git *add_packed_git(const char *, int, int); |
| Shawn O. Pearce | d079837 | 2007-05-26 05:24:19 | [diff] [blame] | 867 | extern const unsigned char *nth_packed_object_sha1(struct packed_git *, uint32_t); |
| Nicolas Pitre | 9909323 | 2008-06-25 03:17:12 | [diff] [blame] | 868 | extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t); |
| Shawn O. Pearce | c4001d9 | 2007-03-07 01:44:30 | [diff] [blame] | 869 | extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *); |
| 870 | extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *); |
| Nicolas Pitre | 09ded04 | 2008-10-29 23:02:46 | [diff] [blame] | 871 | extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep); |
| Nicolas Pitre | 54dab52 | 2007-04-16 16:31:56 | [diff] [blame] | 872 | extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t); |
| Shawn O. Pearce | c4001d9 | 2007-03-07 01:44:30 | [diff] [blame] | 873 | extern const char *packed_object_info_detail(struct packed_git *, off_t, unsigned long *, unsigned long *, unsigned int *, unsigned char *); |
| Junio C Hamano | 9a217f2 | 2005-06-28 21:56:57 | [diff] [blame] | 874 | |
| Junio C Hamano | 8f3f9b0 | 2005-07-24 00:54:41 | [diff] [blame] | 875 | /* Dumb servers support */ |
| 876 | extern int update_server_info(int); |
| 877 | |
| Johannes Schindelin | ef90d6d | 2008-05-14 17:46:53 | [diff] [blame] | 878 | typedef int (*config_fn_t)(const char *, const char *, void *); |
| 879 | extern int git_default_config(const char *, const char *, void *); |
| 880 | extern int git_config_from_file(config_fn_t fn, const char *, void *); |
| 881 | extern int git_config(config_fn_t fn, void *); |
| Brian Downing | 0b87b6e | 2007-07-12 13:32:26 | [diff] [blame] | 882 | extern int git_parse_ulong(const char *, unsigned long *); |
| Linus Torvalds | 1771299 | 2005-10-10 23:31:08 | [diff] [blame] | 883 | extern int git_config_int(const char *, const char *); |
| Brian Downing | 0b87b6e | 2007-07-12 13:32:26 | [diff] [blame] | 884 | extern unsigned long git_config_ulong(const char *, const char *); |
| Junio C Hamano | a53f2ec | 2008-04-13 01:33:31 | [diff] [blame] | 885 | extern int git_config_bool_or_int(const char *, const char *, int *); |
| Linus Torvalds | 1771299 | 2005-10-10 23:31:08 | [diff] [blame] | 886 | extern int git_config_bool(const char *, const char *); |
| Christian Couder | ea5105a | 2008-02-16 05:00:24 | [diff] [blame] | 887 | extern int git_config_string(const char **, const char *, const char *); |
| Johannes Schindelin | 10bea15 | 2005-11-17 21:32:36 | [diff] [blame] | 888 | extern int git_config_set(const char *, const char *); |
| Johannes Schindelin | 4ddba79 | 2005-11-20 05:52:22 | [diff] [blame] | 889 | extern int git_config_set_multivar(const char *, const char *, const char *, int); |
| Johannes Schindelin | 0667fcf | 2006-12-16 14:14:14 | [diff] [blame] | 890 | extern int git_config_rename_section(const char *, const char *); |
| Johannes Sixt | 506b17b | 2007-11-13 20:05:05 | [diff] [blame] | 891 | extern const char *git_etc_gitconfig(void); |
| Johannes Schindelin | ef90d6d | 2008-05-14 17:46:53 | [diff] [blame] | 892 | extern int check_repository_format_version(const char *var, const char *value, void *cb); |
| Jeff King | ab88c36 | 2008-02-06 10:11:18 | [diff] [blame] | 893 | extern int git_config_system(void); |
| 894 | extern int git_config_global(void); |
| Junio C Hamano | 40ea4ed | 2008-02-11 18:41:18 | [diff] [blame] | 895 | extern int config_error_nonbool(const char *); |
| Daniel Barkalow | dc87183 | 2008-06-30 07:37:47 | [diff] [blame] | 896 | extern const char *config_exclusive_filename; |
| Linus Torvalds | 1771299 | 2005-10-10 23:31:08 | [diff] [blame] | 897 | |
| Linus Torvalds | e1b1039 | 2005-10-12 01:47:34 | [diff] [blame] | 898 | #define MAX_GITNAME (1000) |
| 899 | extern char git_default_email[MAX_GITNAME]; |
| 900 | extern char git_default_name[MAX_GITNAME]; |
| Santi Béjar | bb1ae3f | 2008-05-04 16:04:51 | [diff] [blame] | 901 | extern int user_ident_explicitly_given; |
| Linus Torvalds | e1b1039 | 2005-10-12 01:47:34 | [diff] [blame] | 902 | |
| Shawn O. Pearce | 1a8f274 | 2007-03-12 19:33:18 | [diff] [blame] | 903 | extern const char *git_commit_encoding; |
| Shawn O. Pearce | 3a55602 | 2007-03-07 01:44:17 | [diff] [blame] | 904 | extern const char *git_log_output_encoding; |
| Marius Storm-Olsen | d551a48 | 2009-02-08 14:34:27 | [diff] [blame] | 905 | extern const char *git_mailmap_file; |
| Junio C Hamano | 4e72dce | 2005-11-28 00:09:40 | [diff] [blame] | 906 | |
| Theodore Ts'o | 06f59e9 | 2007-06-29 17:40:46 | [diff] [blame] | 907 | /* IO helper functions */ |
| 908 | extern void maybe_flush_or_die(FILE *, const char *); |
| Junio C Hamano | f3123c4 | 2005-10-22 08:28:13 | [diff] [blame] | 909 | extern int copy_fd(int ifd, int ofd); |
| Daniel Barkalow | 1468bd4 | 2008-02-25 19:24:48 | [diff] [blame] | 910 | extern int copy_file(const char *dst, const char *src, int mode); |
| Heikki Orsila | 0104ca0 | 2008-04-27 18:21:58 | [diff] [blame] | 911 | extern ssize_t read_in_full(int fd, void *buf, size_t count); |
| 912 | extern ssize_t write_in_full(int fd, const void *buf, size_t count); |
| Rene Scharfe | 7230e6d | 2006-08-21 18:43:43 | [diff] [blame] | 913 | extern void write_or_die(int fd, const void *buf, size_t count); |
| Christian Couder | 6ce4e61 | 2006-09-02 16:23:48 | [diff] [blame] | 914 | extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg); |
| Andy Whitcroft | e081405 | 2007-01-08 15:57:52 | [diff] [blame] | 915 | extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg); |
| Linus Torvalds | 4c81b03 | 2008-05-30 15:42:16 | [diff] [blame] | 916 | extern void fsync_or_die(int fd, const char *); |
| Junio C Hamano | ad89721 | 2005-12-15 06:17:38 | [diff] [blame] | 917 | |
| Linus Torvalds | f67b45f | 2006-02-28 19:26:21 | [diff] [blame] | 918 | /* pager.c */ |
| 919 | extern void setup_pager(void); |
| Christian Couder | 872da32 | 2008-02-16 05:01:11 | [diff] [blame] | 920 | extern const char *pager_program; |
| Jeff King | 6e9af86 | 2007-12-11 06:27:33 | [diff] [blame] | 921 | extern int pager_in_use(void); |
| Matthias Lederhofer | aa086eb | 2006-07-29 22:27:43 | [diff] [blame] | 922 | extern int pager_use_color; |
| Linus Torvalds | f67b45f | 2006-02-28 19:26:21 | [diff] [blame] | 923 | |
| Christian Couder | ee9601e | 2008-02-16 05:01:41 | [diff] [blame] | 924 | extern const char *editor_program; |
| Christian Couder | dfb068b | 2008-02-16 05:01:59 | [diff] [blame] | 925 | extern const char *excludes_file; |
| Johannes Schindelin | 4d87b9c | 2007-07-20 12:06:09 | [diff] [blame] | 926 | |
| Junio C Hamano | 051308f | 2006-05-04 23:51:44 | [diff] [blame] | 927 | /* base85 */ |
| Jim Meyering | f981577 | 2007-04-09 22:56:33 | [diff] [blame] | 928 | int decode_85(char *dst, const char *line, int linelen); |
| 929 | void encode_85(char *buf, const unsigned char *data, int bytes); |
| Junio C Hamano | 051308f | 2006-05-04 23:51:44 | [diff] [blame] | 930 | |
| Linus Torvalds | 855419f | 2006-06-19 17:44:15 | [diff] [blame] | 931 | /* alloc.c */ |
| Linus Torvalds | 100c5f3 | 2007-04-17 05:11:43 | [diff] [blame] | 932 | extern void *alloc_blob_node(void); |
| 933 | extern void *alloc_tree_node(void); |
| 934 | extern void *alloc_commit_node(void); |
| 935 | extern void *alloc_tag_node(void); |
| 936 | extern void *alloc_object_node(void); |
| Linus Torvalds | 855419f | 2006-06-19 17:44:15 | [diff] [blame] | 937 | extern void alloc_report(void); |
| 938 | |
| Christian Couder | 6ce4e61 | 2006-09-02 16:23:48 | [diff] [blame] | 939 | /* trace.c */ |
| Christian Couder | 6ce4e61 | 2006-09-02 16:23:48 | [diff] [blame] | 940 | extern void trace_printf(const char *format, ...); |
| Christian Couder | b319ce4 | 2007-12-03 04:51:50 | [diff] [blame] | 941 | extern void trace_argv_printf(const char **argv, const char *format, ...); |
| Christian Couder | 6ce4e61 | 2006-09-02 16:23:48 | [diff] [blame] | 942 | |
| Linus Torvalds | 6c510be | 2007-02-13 19:07:23 | [diff] [blame] | 943 | /* convert.c */ |
| Pierre Habouzit | 5ecd293 | 2007-09-16 13:51:04 | [diff] [blame] | 944 | /* returns 1 if *dst was used */ |
| Steffen Prohaska | 21e5ad5 | 2008-02-06 11:25:58 | [diff] [blame] | 945 | extern int convert_to_git(const char *path, const char *src, size_t len, |
| 946 | struct strbuf *dst, enum safe_crlf checksafe); |
| Pierre Habouzit | 5ecd293 | 2007-09-16 13:51:04 | [diff] [blame] | 947 | extern int convert_to_working_tree(const char *path, const char *src, size_t len, struct strbuf *dst); |
| Linus Torvalds | 6c510be | 2007-02-13 19:07:23 | [diff] [blame] | 948 | |
| Junio C Hamano | b6ec1d6 | 2007-11-18 09:12:04 | [diff] [blame] | 949 | /* add */ |
| Alex Riesen | 7ae02a3 | 2008-05-12 17:58:10 | [diff] [blame] | 950 | /* |
| 951 | * return 0 if success, 1 - if addition of a file failed and |
| 952 | * ADD_FILES_IGNORE_ERRORS was specified in flags |
| 953 | */ |
| 954 | int add_files_to_cache(const char *prefix, const char **pathspec, int flags); |
| Junio C Hamano | b6ec1d6 | 2007-11-18 09:12:04 | [diff] [blame] | 955 | |
| Junio C Hamano | aecbf91 | 2007-08-31 20:13:42 | [diff] [blame] | 956 | /* diff.c */ |
| 957 | extern int diff_auto_refresh_index; |
| 958 | |
| Junio C Hamano | 68faf68 | 2007-02-16 00:32:45 | [diff] [blame] | 959 | /* match-trees.c */ |
| 960 | void shift_tree(const unsigned char *, const unsigned char *, unsigned char *, int); |
| 961 | |
| Junio C Hamano | a9cc857 | 2007-11-02 07:24:27 | [diff] [blame] | 962 | /* |
| 963 | * whitespace rules. |
| 964 | * used by both diff and apply |
| 965 | */ |
| 966 | #define WS_TRAILING_SPACE 01 |
| 967 | #define WS_SPACE_BEFORE_TAB 02 |
| Junio C Hamano | 459fa6d | 2007-10-03 01:00:27 | [diff] [blame] | 968 | #define WS_INDENT_WITH_NON_TAB 04 |
| Junio C Hamano | b2979ff | 2008-01-15 08:59:05 | [diff] [blame] | 969 | #define WS_CR_AT_EOL 010 |
| Junio C Hamano | a9cc857 | 2007-11-02 07:24:27 | [diff] [blame] | 970 | #define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB) |
| Junio C Hamano | cf1b786 | 2007-12-06 08:14:14 | [diff] [blame] | 971 | extern unsigned whitespace_rule_cfg; |
| 972 | extern unsigned whitespace_rule(const char *); |
| 973 | extern unsigned parse_whitespace_rule(const char *); |
| Junio C Hamano | 8f8841e | 2008-06-26 22:35:21 | [diff] [blame] | 974 | extern unsigned ws_check(const char *line, int len, unsigned ws_rule); |
| 975 | extern void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws); |
| Wincent Colaiuta | c1795bb | 2007-12-13 13:32:29 | [diff] [blame] | 976 | extern char *whitespace_error_string(unsigned ws); |
| Junio C Hamano | fe3403c | 2008-02-24 00:59:16 | [diff] [blame] | 977 | extern int ws_fix_copy(char *, const char *, int, unsigned, int *); |
| Junio C Hamano | 877f23c | 2008-06-26 22:36:59 | [diff] [blame] | 978 | extern int ws_blank_line(const char *line, int len, unsigned ws_rule); |
| Junio C Hamano | a9cc857 | 2007-11-02 07:24:27 | [diff] [blame] | 979 | |
| Junio C Hamano | ee425e4 | 2007-11-18 09:13:32 | [diff] [blame] | 980 | /* ls-files */ |
| Junio C Hamano | ee425e4 | 2007-11-18 09:13:32 | [diff] [blame] | 981 | int report_path_error(const char *ps_matched, const char **pathspec, int prefix_offset); |
| 982 | void overlay_tree_on_cache(const char *tree_name, const char *prefix); |
| 983 | |
| Jeff King | 9435111 | 2008-02-24 22:17:14 | [diff] [blame] | 984 | char *alias_lookup(const char *alias); |
| Miklos Vajna | 0989fe9 | 2008-06-27 16:21:54 | [diff] [blame] | 985 | int split_cmdline(char *cmdline, const char ***argv); |
| Jeff King | 9435111 | 2008-02-24 22:17:14 | [diff] [blame] | 986 | |
| Linus Torvalds | e83c516 | 2005-04-07 22:13:13 | [diff] [blame] | 987 | #endif /* CACHE_H */ |