about summary refs log tree commit diff
path: root/shared.c
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2007-10-01 11:42:19 +0200
committerLars Hjemli <hjemli@gmail.com>2007-10-01 11:42:19 +0200
commitf527a57c8a55f5fd315e1bc1cb338f5f4a9b20ae (patch)
tree086e1afad5762c5b6bb09672b58f2c491ffbbc20 /shared.c
parentAdd support for a renamelimit option in cgitrc (diff)
downloadcgit-pink-f527a57c8a55f5fd315e1bc1cb338f5f4a9b20ae.tar.gz
cgit-pink-f527a57c8a55f5fd315e1bc1cb338f5f4a9b20ae.zip
Add prefix parameter to cgit_diff_tree()
This paramter can be used to restrict a diff to the specified path prefix.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'shared.c')
-rw-r--r--shared.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/shared.c b/shared.c
index 0a6a5ed..3d4feea 100644
--- a/shared.c
+++ b/shared.c
@@ -386,10 +386,11 @@ int cgit_diff_files(const unsigned char *old_sha1,
 
 void cgit_diff_tree(const unsigned char *old_sha1,
 		    const unsigned char *new_sha1,
-		    filepair_fn fn)
+		    filepair_fn fn, const char *prefix)
 {
 	struct diff_options opt;
 	int ret;
+	int prefixlen;
 
 	diff_setup(&opt);
 	opt.output_format = DIFF_FORMAT_CALLBACK;
@@ -398,6 +399,12 @@ void cgit_diff_tree(const unsigned char *old_sha1,
 	opt.recursive = 1;
 	opt.format_callback = cgit_diff_tree_cb;
 	opt.format_callback_data = fn;
+	if (prefix) {
+		opt.nr_paths = 1;
+		opt.paths = &prefix;
+		prefixlen = strlen(prefix);
+		opt.pathlens = &prefixlen;
+	}
 	diff_setup_done(&opt);
 
 	if (old_sha1 && !is_null_sha1(old_sha1))
@@ -414,5 +421,5 @@ void cgit_diff_commit(struct commit *commit, filepair_fn fn)
 
 	if (commit->parents)
 		old_sha1 = commit->parents->item->object.sha1;
-	cgit_diff_tree(old_sha1, commit->object.sha1, fn);
+	cgit_diff_tree(old_sha1, commit->object.sha1, fn, NULL);
 }
ef='/cgit-pink/commit/README?id=72f8991c8a5aef2d37192429a0365dee838d12ed&follow=1'>New mailing list.Jason A. Donenfeld 2013-04-30ui-snapshot: do not access $HOMEJason A. Donenfeld 2013-04-27t0001: validate Git -rcN version numbers correctlyJohn Keeping 2013-04-27git: update to 1.8.2.2John Keeping 2013-04-17scan-tree: fix regression in section-from-path=-1John Keeping 2013-04-15t0001: ignore ".dirty" suffix on Git versionJohn Keeping 2013-04-15tests: set TEST_OUTPUT_DIRECTORY to the CGit test directoryJohn Keeping 2013-04-15t0109: test more URLsJohn Keeping 2013-04-10cgitrc.5.txt: Specify when scan-path must be defined before.Jason A. Donenfeld 2013-04-10ui-snapshot.c: Prepend "V" when guessing ref namesLukas Fleischer 2013-04-10t0107: Skip ZIP tests if unzip(1) isn't availableLukas Fleischer 2013-04-10tests/: Do not use `sed -i`Lukas Fleischer 2013-04-10Add branch-sort and repo.branch-sort options.Jason A. Donenfeld 2013-04-10t0109: chain operations with &&John Keeping 2013-04-10cgit.c: Do not restore unset environment variablesLukas Fleischer 2013-04-09t0107: Use `tar -z` for gzip'ed archivesLukas Fleischer