aboutsummaryrefslogtreecommitdiffstats
path: root/shared.c
diff options
context:
space:
mode:
authorGravatar Lars Hjemli <hjemli@gmail.com>2011-05-24 06:26:10 (JST)
committerGravatar Lars Hjemli <hjemli@gmail.com>2011-05-24 06:26:10 (JST)
commit652a5a18db3b0409fedfaf8c5720446d87628ba0 (patch)
treecefa386058d968217af24374b93972820a9b43a8 /shared.c
parent4837fddc35bbd8d6f66a40486f75cdee3197172d (diff)
parentec79265f2053e6dc20e0ec486719f5954d2be83d (diff)
downloadcgit-652a5a18db3b0409fedfaf8c5720446d87628ba0.zip
cgit-652a5a18db3b0409fedfaf8c5720446d87628ba0.tar.gz
Merge branch 'stable'
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 7ec2e19..3778a5b 100644
--- a/shared.c
+++ b/shared.c
@@ -100,23 +100,15 @@ void *cgit_free_commitinfo(struct commitinfo *info)
100char *trim_end(const char *str, char c) 100char *trim_end(const char *str, char c)
101{ 101{
102 int len; 102 int len;
103 char *s, *t;
104 103
105 if (str == NULL) 104 if (str == NULL)
106 return NULL; 105 return NULL;
107 t = (char *)str; 106 len = strlen(str);
108 len = strlen(t); 107 while(len > 0 && str[len - 1] == c)
109 while(len > 0 && t[len - 1] == c)
110 len--; 108 len--;
111
112 if (len == 0) 109 if (len == 0)
113 return NULL; 110 return NULL;
114 111 return xstrndup(str, len);
115 c = t[len];
116 t[len] = '\0';
117 s = xstrdup(t);
118 t[len] = c;
119 return s;
120} 112}
121 113
122char *strlpart(char *txt, int maxlen) 114char *strlpart(char *txt, int maxlen)
@@ -311,7 +303,6 @@ void cgit_diff_tree(const unsigned char *old_sha1,
311 filepair_fn fn, const char *prefix, int ignorews) 303 filepair_fn fn, const char *prefix, int ignorews)
312{ 304{
313 struct diff_options opt; 305 struct diff_options opt;
314 int ret;
315 int prefixlen; 306 int prefixlen;
316 307
317 diff_setup(&opt); 308 diff_setup(&opt);
@@ -332,9 +323,9 @@ void cgit_diff_tree(const unsigned char *old_sha1,
332 diff_setup_done(&opt); 323 diff_setup_done(&opt);
333 324
334 if (old_sha1 && !is_null_sha1(old_sha1)) 325 if (old_sha1 && !is_null_sha1(old_sha1))
335 ret = diff_tree_sha1(old_sha1, new_sha1, "", &opt); 326 diff_tree_sha1(old_sha1, new_sha1, "", &opt);
336 else 327 else
337 ret = diff_root_tree_sha1(new_sha1, "", &opt); 328 diff_root_tree_sha1(new_sha1, "", &opt);
338 diffcore_std(&opt); 329 diffcore_std(&opt);
339 diff_flush(&opt); 330 diff_flush(&opt);
340} 331}