aboutsummaryrefslogtreecommitdiffstats
path: root/shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared.c')
-rw-r--r--shared.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/shared.c b/shared.c
index 986f965..be2ae59 100644
--- a/shared.c
+++ b/shared.c
@@ -102,23 +102,15 @@ void *cgit_free_commitinfo(struct commitinfo *info)
102char *trim_end(const char *str, char c) 102char *trim_end(const char *str, char c)
103{ 103{
104 int len; 104 int len;
105 char *s, *t;
106 105
107 if (str == NULL) 106 if (str == NULL)
108 return NULL; 107 return NULL;
109 t = (char *)str; 108 len = strlen(str);
110 len = strlen(t); 109 while(len > 0 && str[len - 1] == c)
111 while(len > 0 && t[len - 1] == c)
112 len--; 110 len--;
113
114 if (len == 0) 111 if (len == 0)
115 return NULL; 112 return NULL;
116 113 return xstrndup(str, len);
117 c = t[len];
118 t[len] = '\0';
119 s = xstrdup(t);
120 t[len] = c;
121 return s;
122} 114}
123 115
124char *strlpart(char *txt, int maxlen) 116char *strlpart(char *txt, int maxlen)
@@ -313,7 +305,6 @@ void cgit_diff_tree(const unsigned char *old_sha1,
313 filepair_fn fn, const char *prefix, int ignorews) 305 filepair_fn fn, const char *prefix, int ignorews)
314{ 306{
315 struct diff_options opt; 307 struct diff_options opt;
316 int ret;
317 int prefixlen; 308 int prefixlen;
318 309
319 diff_setup(&opt); 310 diff_setup(&opt);
@@ -334,9 +325,9 @@ void cgit_diff_tree(const unsigned char *old_sha1,
334 diff_setup_done(&opt); 325 diff_setup_done(&opt);
335 326
336 if (old_sha1 && !is_null_sha1(old_sha1)) 327 if (old_sha1 && !is_null_sha1(old_sha1))
337 ret = diff_tree_sha1(old_sha1, new_sha1, "", &opt); 328 diff_tree_sha1(old_sha1, new_sha1, "", &opt);
338 else 329 else
339 ret = diff_root_tree_sha1(new_sha1, "", &opt); 330 diff_root_tree_sha1(new_sha1, "", &opt);
340 diffcore_std(&opt); 331 diffcore_std(&opt);
341 diff_flush(&opt); 332 diff_flush(&opt);
342} 333}