- commit
- c2d6e06ab15c5e36bf0338f44d7429a20782efa0
- parent
- 2001bd104b6cd3a130d7a56184b9bb87b82afbc7
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-03-26 16:08
rm refs
Diffstat
M | Makefile | 2 | -- |
M | compat.h | 2 | -- |
D | reallocarray.c | 39 | --------------------------------------- |
M | stagit.c | 124 | +------------------------------------------------------------ |
4 files changed, 1 insertions, 166 deletions
diff --git a/Makefile b/Makefile
@@ -23,7 +23,6 @@ SRC = \ 23 23 stagit.c\ 24 24 stagit-index.c 25 25 COMPATSRC = \26 -1 reallocarray.c\27 26 strlcat.c\ 28 27 strlcpy.c 29 28 BIN = \ @@ -38,7 +37,6 @@ DOC = \ 38 37 HDR = compat.h 39 38 40 39 COMPATOBJ = \41 -1 reallocarray.o\42 40 strlcat.o\ 43 41 strlcpy.o 44 42
diff --git a/compat.h b/compat.h
@@ -2,5 +2,3 @@ 2 2 size_t strlcat(char *, const char *, size_t); 3 3 #undef strlcpy 4 4 size_t strlcpy(char *, const char *, size_t);5 -1 #undef reallocarray6 -1 void *reallocarray(void *, size_t, size_t);
diff --git a/reallocarray.c b/reallocarray.c
@@ -1,39 +0,0 @@1 -1 /*2 -1 * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>3 -1 *4 -1 * Permission to use, copy, modify, and distribute this software for any5 -1 * purpose with or without fee is hereby granted, provided that the above6 -1 * copyright notice and this permission notice appear in all copies.7 -1 *8 -1 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES9 -1 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF10 -1 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR11 -1 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES12 -1 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN13 -1 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF14 -1 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.15 -1 */16 -117 -1 #include <sys/types.h>18 -1 #include <errno.h>19 -1 #include <stdint.h>20 -1 #include <stdlib.h>21 -122 -1 #include "compat.h"23 -124 -1 /*25 -1 * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX26 -1 * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW27 -1 */28 -1 #define MUL_NO_OVERFLOW (1UL << (sizeof(size_t) * 4))29 -130 -1 void *31 -1 reallocarray(void *optr, size_t nmemb, size_t size)32 -1 {33 -1 if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&34 -1 nmemb > 0 && SIZE_MAX / nmemb < size) {35 -1 errno = ENOMEM;36 -1 return NULL;37 -1 }38 -1 return realloc(optr, size * nmemb);39 -1 }
diff --git a/stagit.c b/stagit.c
@@ -375,8 +375,7 @@ writeheader(FILE *fp, const char *title) 375 375 } 376 376 fputs("<tr><td></td><td>\n", fp); 377 377 fprintf(fp, "<a href=\"%sfiles.html\">Files</a> | ", relpath);378 -1 fprintf(fp, "<a href=\"%slog.html\">Log</a> | ", relpath);379 -1 fprintf(fp, "<a href=\"%srefs.html\">Refs</a>", relpath);-1 378 fprintf(fp, "<a href=\"%slog.html\">Log</a>", relpath); 380 379 if (submodules) 381 380 fprintf(fp, " | <a href=\"%sfile/%s.html\">Submodules</a>", 382 381 relpath, submodules); @@ -953,120 +952,6 @@ writefiles(FILE *fp, const git_oid *id) 953 952 return ret; 954 953 } 955 954956 -1 int957 -1 refs_cmp(const void *v1, const void *v2)958 -1 {959 -1 git_reference *r1 = (*(git_reference **)v1);960 -1 git_reference *r2 = (*(git_reference **)v2);961 -1 int r;962 -1963 -1 if ((r = git_reference_is_branch(r1) - git_reference_is_branch(r2)))964 -1 return r;965 -1966 -1 return strcmp(git_reference_shorthand(r1),967 -1 git_reference_shorthand(r2));968 -1 }969 -1970 -1 int971 -1 writerefs(FILE *fp)972 -1 {973 -1 struct commitinfo *ci;974 -1 const git_oid *id = NULL;975 -1 git_object *obj = NULL;976 -1 git_reference *dref = NULL, *r, *ref = NULL;977 -1 git_reference_iterator *it = NULL;978 -1 git_reference **refs = NULL;979 -1 size_t count, i, j, refcount;980 -1 const char *titles[] = { "Branches", "Tags" };981 -1 const char *ids[] = { "branches", "tags" };982 -1 const char *name;983 -1984 -1 if (git_reference_iterator_new(&it, repo))985 -1 return -1;986 -1987 -1 for (refcount = 0; !git_reference_next(&ref, it); refcount++) {988 -1 if (!(refs = reallocarray(refs, refcount + 1, sizeof(git_reference *))))989 -1 err(1, "realloc");990 -1 refs[refcount] = ref;991 -1 }992 -1 git_reference_iterator_free(it);993 -1994 -1 /* sort by type then shorthand name */995 -1 qsort(refs, refcount, sizeof(git_reference *), refs_cmp);996 -1997 -1 for (j = 0; j < 2; j++) {998 -1 for (i = 0, count = 0; i < refcount; i++) {999 -1 if (!(git_reference_is_branch(refs[i]) && j == 0) &&1000 -1 !(git_reference_is_tag(refs[i]) && j == 1))1001 -1 continue;1002 -11003 -1 switch (git_reference_type(refs[i])) {1004 -1 case GIT_REF_SYMBOLIC:1005 -1 if (git_reference_resolve(&dref, refs[i]))1006 -1 goto err;1007 -1 r = dref;1008 -1 break;1009 -1 case GIT_REF_OID:1010 -1 r = refs[i];1011 -1 break;1012 -1 default:1013 -1 continue;1014 -1 }1015 -1 if (!git_reference_target(r) ||1016 -1 git_reference_peel(&obj, r, GIT_OBJ_ANY))1017 -1 goto err;1018 -1 if (!(id = git_object_id(obj)))1019 -1 goto err;1020 -1 if (!(ci = commitinfo_getbyoid(id)))1021 -1 break;1022 -11023 -1 /* print header if it has an entry (first). */1024 -1 if (++count == 1) {1025 -1 fprintf(fp, "<h2>%s</h2><table id=\"%s\">"1026 -1 "<thead>\n<tr><td><b>Name</b></td>"1027 -1 "<td><b>Last commit date</b></td>"1028 -1 "<td><b>Author</b></td>\n</tr>\n"1029 -1 "</thead><tbody>\n",1030 -1 titles[j], ids[j]);1031 -1 }1032 -11033 -1 relpath = "";1034 -1 name = git_reference_shorthand(r);1035 -11036 -1 fputs("<tr><td>", fp);1037 -1 xmlencode(fp, name, strlen(name));1038 -1 fputs("</td><td>", fp);1039 -1 if (ci->author)1040 -1 printtimeshort(fp, &(ci->author->when));1041 -1 fputs("</td><td>", fp);1042 -1 if (ci->author)1043 -1 xmlencode(fp, ci->author->name, strlen(ci->author->name));1044 -1 fputs("</td></tr>\n", fp);1045 -11046 -1 relpath = "../";1047 -11048 -1 commitinfo_free(ci);1049 -1 git_object_free(obj);1050 -1 obj = NULL;1051 -1 git_reference_free(dref);1052 -1 dref = NULL;1053 -1 }1054 -1 /* table footer */1055 -1 if (count)1056 -1 fputs("</tbody></table><br/>", fp);1057 -1 }1058 -11059 -1 err:1060 -1 git_object_free(obj);1061 -1 git_reference_free(dref);1062 -11063 -1 for (i = 0; i < refcount; i++)1064 -1 git_reference_free(refs[i]);1065 -1 free(refs);1066 -11067 -1 return 0;1068 -1 }1069 -11070 955 void 1071 956 usage(char *argv0) 1072 957 { @@ -1261,13 +1146,6 @@ main(int argc, char *argv[]) 1261 1146 writefooter(fp); 1262 1147 fclose(fp); 1263 11481264 -1 /* summary page with branches and tags */1265 -1 fp = efopen("refs.html", "w");1266 -1 writeheader(fp, "Refs");1267 -1 writerefs(fp);1268 -1 writefooter(fp);1269 -1 fclose(fp);1270 -11271 1149 /* Atom feed */ 1272 1150 fp = efopen("atom.xml", "w"); 1273 1151 writeatom(fp);