summaryrefslogtreecommitdiffabout
path: root/git.h
authorLars Hjemli <hjemli@gmail.com>2006-12-17 22:07:28 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2006-12-17 22:07:28 (UTC)
commit6cb326c83b3c0b35d472305294afee3105b3088d (patch) (unidiff)
treefcceeec36ae6f1b3b8e9f861064e2d6ba962a6e0 /git.h
parent9c5229ea394808f90433ee84439503bee124e1de (diff)
downloadcgit-6cb326c83b3c0b35d472305294afee3105b3088d.zip
cgit-6cb326c83b3c0b35d472305294afee3105b3088d.tar.gz
cgit-6cb326c83b3c0b35d472305294afee3105b3088d.tar.bz2
Show list of modified files in ui-commit.c
Compare current commit with 1.parent, and for each affected file display current filemode, old filemode if changed, current filename and source filename if it was a copy/rename. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'git.h') (more/less context) (ignore whitespace changes)
-rw-r--r--git.h106
1 files changed, 106 insertions, 0 deletions
diff --git a/git.h b/git.h
index a3f977c..922a167 100644
--- a/git.h
+++ b/git.h
@@ -107,56 +107,76 @@ static inline ssize_t xread(int fd, void *buf, size_t len)
107 107
108static inline ssize_t xwrite(int fd, const void *buf, size_t len) 108static inline ssize_t xwrite(int fd, const void *buf, size_t len)
109{ 109{
110 ssize_t nr; 110 ssize_t nr;
111 while (1) { 111 while (1) {
112 nr = write(fd, buf, len); 112 nr = write(fd, buf, len);
113 if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) 113 if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
114 continue; 114 continue;
115 return nr; 115 return nr;
116 } 116 }
117} 117}
118 118
119 119
120 120
121 121
122/* 122/*
123 * from git:cache.h 123 * from git:cache.h
124 */ 124 */
125 125
126 126
127/* Convert to/from hex/sha1 representation */ 127/* Convert to/from hex/sha1 representation */
128#define MINIMUM_ABBREV 4 128#define MINIMUM_ABBREV 4
129#define DEFAULT_ABBREV 7 129#define DEFAULT_ABBREV 7
130 130
131extern const unsigned char null_sha1[20];
132
131extern int sha1_object_info(const unsigned char *, char *, unsigned long *); 133extern int sha1_object_info(const unsigned char *, char *, unsigned long *);
132 134
133extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size); 135extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size);
134 136
135extern int get_sha1(const char *str, unsigned char *sha1); 137extern int get_sha1(const char *str, unsigned char *sha1);
136extern int get_sha1_hex(const char *hex, unsigned char *sha1); 138extern int get_sha1_hex(const char *hex, unsigned char *sha1);
137 extern char *sha1_to_hex(const unsigned char *sha1);/* static buffer result! */ 139 extern char *sha1_to_hex(const unsigned char *sha1);/* static buffer result! */
138 140
141static inline int is_null_sha1(const unsigned char *sha1)
142{
143 return !memcmp(sha1, null_sha1, 20);
144}
145static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
146{
147 return memcmp(sha1, sha2, 20);
148}
149static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
150{
151 memcpy(sha_dst, sha_src, 20);
152}
153static inline void hashclr(unsigned char *hash)
154{
155 memset(hash, 0, 20);
156}
157
158
139 159
140 160
141/* 161/*
142 * from git:object.h 162 * from git:object.h
143 */ 163 */
144 164
145struct object_list { 165struct object_list {
146 struct object *item; 166 struct object *item;
147 struct object_list *next; 167 struct object_list *next;
148}; 168};
149 169
150struct object_refs { 170struct object_refs {
151 unsigned count; 171 unsigned count;
152 struct object *base; 172 struct object *base;
153 struct object *ref[FLEX_ARRAY]; /* more */ 173 struct object *ref[FLEX_ARRAY]; /* more */
154}; 174};
155 175
156struct object_array { 176struct object_array {
157 unsigned int nr; 177 unsigned int nr;
158 unsigned int alloc; 178 unsigned int alloc;
159 struct object_array_entry { 179 struct object_array_entry {
160 struct object *item; 180 struct object *item;
161 const char *name; 181 const char *name;
162 } *objects; 182 } *objects;
@@ -236,48 +256,103 @@ void free_commit_list(struct commit_list *list);
236void sort_by_date(struct commit_list **list); 256void sort_by_date(struct commit_list **list);
237 257
238/* Commit formats */ 258/* Commit formats */
239enum cmit_fmt { 259enum cmit_fmt {
240 CMIT_FMT_RAW, 260 CMIT_FMT_RAW,
241 CMIT_FMT_MEDIUM, 261 CMIT_FMT_MEDIUM,
242 CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM, 262 CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,
243 CMIT_FMT_SHORT, 263 CMIT_FMT_SHORT,
244 CMIT_FMT_FULL, 264 CMIT_FMT_FULL,
245 CMIT_FMT_FULLER, 265 CMIT_FMT_FULLER,
246 CMIT_FMT_ONELINE, 266 CMIT_FMT_ONELINE,
247 CMIT_FMT_EMAIL, 267 CMIT_FMT_EMAIL,
248 268
249 CMIT_FMT_UNSPECIFIED, 269 CMIT_FMT_UNSPECIFIED,
250}; 270};
251 271
252extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char *buf, unsigned long space, int abbrev, const char *subject, const char *after_subject, int relative_date); 272extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char *buf, unsigned long space, int abbrev, const char *subject, const char *after_subject, int relative_date);
253 273
254 274
255typedef void (*topo_sort_set_fn_t)(struct commit*, void *data); 275typedef void (*topo_sort_set_fn_t)(struct commit*, void *data);
256typedef void* (*topo_sort_get_fn_t)(struct commit*); 276typedef void* (*topo_sort_get_fn_t)(struct commit*);
257 277
258 278
259 279
280/*
281 * from git:diffcore.h
282 */
283
284struct diff_filespec {
285 unsigned char sha1[20];
286 char *path;
287 void *data;
288 void *cnt_data;
289 unsigned long size;
290 int xfrm_flags; /* for use by the xfrm */
291 unsigned short mode; /* file mode */
292 unsigned sha1_valid : 1; /* if true, use sha1 and trust mode;
293 * if false, use the name and read from
294 * the filesystem.
295 */
296#define DIFF_FILE_VALID(spec) (((spec)->mode) != 0)
297 unsigned should_free : 1; /* data should be free()'ed */
298 unsigned should_munmap : 1; /* data should be munmap()'ed */
299};
300
301struct diff_filepair {
302 struct diff_filespec *one;
303 struct diff_filespec *two;
304 unsigned short int score;
305 char status; /* M C R N D U (see Documentation/diff-format.txt) */
306 unsigned source_stays : 1; /* all of R/C are copies */
307 unsigned broken_pair : 1;
308 unsigned renamed_pair : 1;
309};
310
311#define DIFF_PAIR_UNMERGED(p) \
312 (!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))
313
314#define DIFF_PAIR_RENAME(p) ((p)->renamed_pair)
315
316#define DIFF_PAIR_BROKEN(p) \
317 ( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \
318 ((p)->broken_pair != 0) )
319
320#define DIFF_PAIR_TYPE_CHANGED(p) \
321 ((S_IFMT & (p)->one->mode) != (S_IFMT & (p)->two->mode))
322
323#define DIFF_PAIR_MODE_CHANGED(p) ((p)->one->mode != (p)->two->mode)
324
325extern void diff_free_filepair(struct diff_filepair *);
326
327extern int diff_unmodified_pair(struct diff_filepair *);
328
329struct diff_queue_struct {
330 struct diff_filepair **queue;
331 int alloc;
332 int nr;
333};
334
260 335
261/* 336/*
262 * from git:diff.h 337 * from git:diff.h
263 */ 338 */
264 339
265 340
266struct rev_info; 341struct rev_info;
267struct diff_options; 342struct diff_options;
268struct diff_queue_struct; 343struct diff_queue_struct;
269 344
270typedef void (*change_fn_t)(struct diff_options *options, 345typedef void (*change_fn_t)(struct diff_options *options,
271 unsigned old_mode, unsigned new_mode, 346 unsigned old_mode, unsigned new_mode,
272 const unsigned char *old_sha1, 347 const unsigned char *old_sha1,
273 const unsigned char *new_sha1, 348 const unsigned char *new_sha1,
274 const char *base, const char *path); 349 const char *base, const char *path);
275 350
276typedef void (*add_remove_fn_t)(struct diff_options *options, 351typedef void (*add_remove_fn_t)(struct diff_options *options,
277 int addremove, unsigned mode, 352 int addremove, unsigned mode,
278 const unsigned char *sha1, 353 const unsigned char *sha1,
279 const char *base, const char *path); 354 const char *base, const char *path);
280 355
281typedef void (*diff_format_fn_t)(struct diff_queue_struct *q, 356typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
282 struct diff_options *options, void *data); 357 struct diff_options *options, void *data);
283 358
@@ -331,48 +406,74 @@ struct diff_options {
331 int stat_width; 406 int stat_width;
332 int stat_name_width; 407 int stat_name_width;
333 408
334 int nr_paths; 409 int nr_paths;
335 const char **paths; 410 const char **paths;
336 int *pathlens; 411 int *pathlens;
337 change_fn_t change; 412 change_fn_t change;
338 add_remove_fn_t add_remove; 413 add_remove_fn_t add_remove;
339 diff_format_fn_t format_callback; 414 diff_format_fn_t format_callback;
340 void *format_callback_data; 415 void *format_callback_data;
341}; 416};
342 417
343enum color_diff { 418enum color_diff {
344 DIFF_RESET = 0, 419 DIFF_RESET = 0,
345 DIFF_PLAIN = 1, 420 DIFF_PLAIN = 1,
346 DIFF_METAINFO = 2, 421 DIFF_METAINFO = 2,
347 DIFF_FRAGINFO = 3, 422 DIFF_FRAGINFO = 3,
348 DIFF_FILE_OLD = 4, 423 DIFF_FILE_OLD = 4,
349 DIFF_FILE_NEW = 5, 424 DIFF_FILE_NEW = 5,
350 DIFF_COMMIT = 6, 425 DIFF_COMMIT = 6,
351 DIFF_WHITESPACE = 7, 426 DIFF_WHITESPACE = 7,
352}; 427};
353 428
354 429
430extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
431 const char *base, struct diff_options *opt);
432
433extern int diff_root_tree_sha1(const unsigned char *new, const char *base,
434 struct diff_options *opt);
435
436extern int git_diff_ui_config(const char *var, const char *value);
437extern void diff_setup(struct diff_options *);
438extern int diff_opt_parse(struct diff_options *, const char **, int);
439extern int diff_setup_done(struct diff_options *);
440
441
442extern void diffcore_std(struct diff_options *);
443extern void diff_flush(struct diff_options*);
444
445
446/* diff-raw status letters */
447 #define DIFF_STATUS_ADDED 'A'
448 #define DIFF_STATUS_COPIED 'C'
449 #define DIFF_STATUS_DELETED 'D'
450 #define DIFF_STATUS_MODIFIED 'M'
451 #define DIFF_STATUS_RENAMED 'R'
452 #define DIFF_STATUS_TYPE_CHANGED'T'
453 #define DIFF_STATUS_UNKNOWN 'X'
454 #define DIFF_STATUS_UNMERGED 'U'
455
355 456
356 457
357/* 458/*
358 * from git:refs.g 459 * from git:refs.g
359 */ 460 */
360 461
361typedef int each_ref_fn(const char *refname, const unsigned char *sha1, int flags, void *cb_data); 462typedef int each_ref_fn(const char *refname, const unsigned char *sha1, int flags, void *cb_data);
362extern int head_ref(each_ref_fn, void *); 463extern int head_ref(each_ref_fn, void *);
363extern int for_each_ref(each_ref_fn, void *); 464extern int for_each_ref(each_ref_fn, void *);
364extern int for_each_tag_ref(each_ref_fn, void *); 465extern int for_each_tag_ref(each_ref_fn, void *);
365extern int for_each_branch_ref(each_ref_fn, void *); 466extern int for_each_branch_ref(each_ref_fn, void *);
366extern int for_each_remote_ref(each_ref_fn, void *); 467extern int for_each_remote_ref(each_ref_fn, void *);
367 468
368 469
369 470
370/* 471/*
371 * from git:revision.h 472 * from git:revision.h
372 */ 473 */
373 474
374struct rev_info; 475struct rev_info;
375struct log_info; 476struct log_info;
376 477
377typedef void (prune_fn_t)(struct rev_info *revs, struct commit *commit); 478typedef void (prune_fn_t)(struct rev_info *revs, struct commit *commit);
378 479
@@ -437,26 +538,31 @@ struct rev_info {
437 538
438 /* special limits */ 539 /* special limits */
439 int max_count; 540 int max_count;
440 unsigned long max_age; 541 unsigned long max_age;
441 unsigned long min_age; 542 unsigned long min_age;
442 543
443 /* diff info for patches and for paths limiting */ 544 /* diff info for patches and for paths limiting */
444 struct diff_options diffopt; 545 struct diff_options diffopt;
445 struct diff_options pruning; 546 struct diff_options pruning;
446 547
447 topo_sort_set_fn_t topo_setter; 548 topo_sort_set_fn_t topo_setter;
448 topo_sort_get_fn_t topo_getter; 549 topo_sort_get_fn_t topo_getter;
449}; 550};
450 551
451 552
452extern void init_revisions(struct rev_info *revs, const char *prefix); 553extern void init_revisions(struct rev_info *revs, const char *prefix);
453extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def); 554extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def);
454extern int handle_revision_arg(const char *arg, struct rev_info *revs,int flags,int cant_be_filename); 555extern int handle_revision_arg(const char *arg, struct rev_info *revs,int flags,int cant_be_filename);
455 556
456extern void prepare_revision_walk(struct rev_info *revs); 557extern void prepare_revision_walk(struct rev_info *revs);
457extern struct commit *get_revision(struct rev_info *revs); 558extern struct commit *get_revision(struct rev_info *revs);
458 559
459 560
460 561
562/* from git:log-tree.h */
563
564int log_tree_commit(struct rev_info *, struct commit *);
565
566
461 567
462#endif /* GIT_H */ 568#endif /* GIT_H */