Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Show a renamed file's diff as the rename
A diff limited to the new name cannot see the old one, so the
diffstat's link for a renamed file, the commit page reached from that
file's log, and the file's rawdiff and patch all showed every line as
added. A path the old tree lacks is now diffed across the whole commit
with rename detection aimed at it alone, the way git blame looks for a
rename, so it is compared with the commit's deleted files and nothing
else. Doing it in cgit_diff_tree keeps the log's counts for that commit
in step with the page they link to.
The rawdiff and patch pages leave the diff to git's own output, so for
them that search finds the old name, and both names go into the limit
with rename detection on.
Diffstat (limited to 'source/shared.h')
| -rw-r--r-- | source/shared.h | 24 |
1 file changed, 22 insertions, 2 deletions
diff --git a/source/shared.h b/source/shared.h index f182962..b24c690 100644 --- a/source/shared.h +++ b/source/shared.h @@ -25,8 +25,9 @@ extern struct cgit_repo *cgit_get_repoinfo(const char *url); /* * A diff format callback that hands each filepair to the filepair_fn data - * points at. ISO C has no conversion between a function pointer and void *, - * so the function travels by address. + * points at, or only the pair landing on single_follow when that is set. ISO + * C has no conversion between a function pointer and void *, so the function + * travels by address. */ extern void cgit_diff_tree_cb(struct diff_queue_struct *q, struct diff_options *options, void *data); @@ -45,6 +46,25 @@ extern int cgit_diff_files(const struct object_id *old_oid, const struct object_ */ extern void cgit_diff_limit_path(struct diff_options *opt, const char *prefix); +/* + * Limit a diff to path and to source, the name it was renamed from, both + * taken literally, with rename detection on so that git pairs the two. + */ +extern void cgit_diff_limit_rename(struct diff_options *opt, const char *path, const char *source); + +/* + * The name path had in the old tree when the change between the two trees + * renamed it, or NULL when path is no renamed file's new name. The result is + * the caller's to free. + */ +extern char *cgit_rename_source(const struct object_id *old_oid, const struct object_id *new_oid, + const char *path); + +/* + * Hand fn each filepair between the two trees, limited to the paths below + * prefix when one is given. A prefix naming a file the old tree lacks still + * comes back as the rename that produced it. + */ extern void cgit_diff_tree(const struct object_id *old_oid, const struct object_id *new_oid, filepair_fn fn, const char *prefix, int ignorews); extern void cgit_diff_commit(struct commit *commit, filepair_fn fn, const char *prefix); |
