Skip to content

Commit 779631c

Browse files
committed
global: replace references to 'sha1' with 'oid'
For some time now sha1 is considered broken and upstream is working to replace it with sha256. Replace all references to 'sha1' with 'oid', just as upstream does. Signed-off-by: Christian Hesse <[email protected]>
1 parent 629659d commit 779631c

File tree

13 files changed

+66
-66
lines changed

13 files changed

+66
-66
lines changed

cgit.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,11 @@ static void querystring_cb(const char *name, const char *value)
324324
ctx.qry.head = xstrdup(value);
325325
ctx.qry.has_symref = 1;
326326
} else if (!strcmp(name, "id")) {
327-
ctx.qry.sha1 = xstrdup(value);
328-
ctx.qry.has_sha1 = 1;
327+
ctx.qry.oid = xstrdup(value);
328+
ctx.qry.has_oid = 1;
329329
} else if (!strcmp(name, "id2")) {
330-
ctx.qry.sha2 = xstrdup(value);
331-
ctx.qry.has_sha1 = 1;
330+
ctx.qry.oid2 = xstrdup(value);
331+
ctx.qry.has_oid = 1;
332332
} else if (!strcmp(name, "ofs")) {
333333
ctx.qry.ofs = atoi(value);
334334
} else if (!strcmp(name, "path")) {
@@ -992,9 +992,9 @@ static void cgit_parse_args(int argc, const char **argv)
992992
} else if (skip_prefix(argv[i], "--head=", &arg)) {
993993
ctx.qry.head = xstrdup(arg);
994994
ctx.qry.has_symref = 1;
995-
} else if (skip_prefix(argv[i], "--sha1=", &arg)) {
996-
ctx.qry.sha1 = xstrdup(arg);
997-
ctx.qry.has_sha1 = 1;
995+
} else if (skip_prefix(argv[i], "--oid=", &arg)) {
996+
ctx.qry.oid = xstrdup(arg);
997+
ctx.qry.has_oid = 1;
998998
} else if (skip_prefix(argv[i], "--ofs=", &arg)) {
999999
ctx.qry.ofs = atoi(arg);
10001000
} else if (skip_prefix(argv[i], "--scan-tree=", &arg) ||
@@ -1037,7 +1037,7 @@ static int calc_ttl(void)
10371037
if (!strcmp(ctx.qry.page, "snapshot"))
10381038
return ctx.cfg.cache_snapshot_ttl;
10391039

1040-
if (ctx.qry.has_sha1)
1040+
if (ctx.qry.has_oid)
10411041
return ctx.cfg.cache_static_ttl;
10421042

10431043
if (ctx.qry.has_symref)

cgit.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ div#cgit table.diff td div.del {
561561
color: red;
562562
}
563563

564-
div#cgit .sha1 {
564+
div#cgit .oid {
565565
font-family: monospace;
566566
font-size: 90%;
567567
}

cgit.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,16 @@ struct reflist {
164164

165165
struct cgit_query {
166166
int has_symref;
167-
int has_sha1;
167+
int has_oid;
168168
int has_difftype;
169169
char *raw;
170170
char *repo;
171171
char *page;
172172
char *search;
173173
char *grep;
174174
char *head;
175-
char *sha1;
176-
char *sha2;
175+
char *oid;
176+
char *oid2;
177177
char *path;
178178
char *name;
179179
char *url;

cmd.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,22 @@ static void blame_fn(void)
7474

7575
static void blob_fn(void)
7676
{
77-
cgit_print_blob(ctx.qry.sha1, ctx.qry.path, ctx.qry.head, 0);
77+
cgit_print_blob(ctx.qry.oid, ctx.qry.path, ctx.qry.head, 0);
7878
}
7979

8080
static void commit_fn(void)
8181
{
82-
cgit_print_commit(ctx.qry.sha1, ctx.qry.path);
82+
cgit_print_commit(ctx.qry.oid, ctx.qry.path);
8383
}
8484

8585
static void diff_fn(void)
8686
{
87-
cgit_print_diff(ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1, 0);
87+
cgit_print_diff(ctx.qry.oid, ctx.qry.oid2, ctx.qry.path, 1, 0);
8888
}
8989

9090
static void rawdiff_fn(void)
9191
{
92-
cgit_print_diff(ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1, 1);
92+
cgit_print_diff(ctx.qry.oid, ctx.qry.oid2, ctx.qry.path, 1, 1);
9393
}
9494

9595
static void info_fn(void)
@@ -99,7 +99,7 @@ static void info_fn(void)
9999

100100
static void log_fn(void)
101101
{
102-
cgit_print_log(ctx.qry.sha1, ctx.qry.ofs, ctx.cfg.max_commit_count,
102+
cgit_print_log(ctx.qry.oid, ctx.qry.ofs, ctx.cfg.max_commit_count,
103103
ctx.qry.grep, ctx.qry.search, ctx.qry.path, 1,
104104
ctx.repo->enable_commit_graph,
105105
ctx.repo->commit_sort);
@@ -125,7 +125,7 @@ static void repolist_fn(void)
125125

126126
static void patch_fn(void)
127127
{
128-
cgit_print_patch(ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path);
128+
cgit_print_patch(ctx.qry.oid, ctx.qry.oid2, ctx.qry.path);
129129
}
130130

131131
static void plain_fn(void)
@@ -140,7 +140,7 @@ static void refs_fn(void)
140140

141141
static void snapshot_fn(void)
142142
{
143-
cgit_print_snapshot(ctx.qry.head, ctx.qry.sha1, ctx.qry.path,
143+
cgit_print_snapshot(ctx.qry.head, ctx.qry.oid, ctx.qry.path,
144144
ctx.qry.nohead);
145145
}
146146

@@ -156,12 +156,12 @@ static void summary_fn(void)
156156

157157
static void tag_fn(void)
158158
{
159-
cgit_print_tag(ctx.qry.sha1);
159+
cgit_print_tag(ctx.qry.oid);
160160
}
161161

162162
static void tree_fn(void)
163163
{
164-
cgit_print_tree(ctx.qry.sha1, ctx.qry.path);
164+
cgit_print_tree(ctx.qry.oid, ctx.qry.path);
165165
}
166166

167167
#define def_cmd(name, want_repo, want_vpath, is_clone) \

parsing.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static int end_of_header(const char *p)
127127

128128
struct commitinfo *cgit_parse_commit(struct commit *commit)
129129
{
130-
const int sha1hex_len = 40;
130+
const int oid_hex_len = 40;
131131
struct commitinfo *ret;
132132
const char *p = repo_get_commit_buffer(the_repository, commit, NULL);
133133
const char *t;
@@ -140,10 +140,10 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
140140

141141
if (!skip_prefix(p, "tree ", &p))
142142
die("Bad commit: %s", oid_to_hex(&commit->object.oid));
143-
p += sha1hex_len + 1;
143+
p += oid_hex_len + 1;
144144

145145
while (skip_prefix(p, "parent ", &p))
146-
p += sha1hex_len + 1;
146+
p += oid_hex_len + 1;
147147

148148
if (p && skip_prefix(p, "author ", &p)) {
149149
parse_user(p, &ret->author, &ret->author_email,

tests/t0001-validate-git-versions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ test_expect_success 'test submodule version matches Makefile' '
3333
else
3434
(
3535
cd ../.. &&
36-
sm_sha1=$(git ls-files --stage -- git |
36+
sm_oid=$(git ls-files --stage -- git |
3737
sed -e "s/^[0-9]* \\([0-9a-f]*\\) [0-9] .*$/\\1/") &&
3838
cd git &&
39-
git describe --match "v[0-9]*" $sm_sha1
39+
git describe --match "v[0-9]*" $sm_oid
4040
) | sed -e "s/^v//" -e "s/-/./" >sm_version &&
4141
test_cmp sm_version makefile_version
4242
fi

ui-blame.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void emit_blame_entry_hash(struct blame_entry *ent)
4848
unsigned long line = 0;
4949

5050
char *detail = emit_suspect_detail(suspect);
51-
html("<span class='sha1'>");
51+
html("<span class='oid'>");
5252
cgit_commit_link(find_unique_abbrev(oid, DEFAULT_ABBREV), detail,
5353
NULL, ctx.qry.head, oid_to_hex(oid), suspect->path);
5454
html("</span>");
@@ -256,7 +256,7 @@ static int basedir_len(const char *path)
256256

257257
void cgit_print_blame(void)
258258
{
259-
const char *rev = ctx.qry.sha1;
259+
const char *rev = ctx.qry.oid;
260260
struct object_id oid;
261261
struct commit *commit;
262262
struct pathspec_item path_items = {

ui-commit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ void cgit_print_commit(char *hex, const char *prefix)
7070
html_txt(show_date(info->committer_date, info->committer_tz,
7171
cgit_date_mode(DATE_ISO8601)));
7272
html("</td></tr>\n");
73-
html("<tr><th>commit</th><td colspan='2' class='sha1'>");
73+
html("<tr><th>commit</th><td colspan='2' class='oid'>");
7474
tmp = oid_to_hex(&commit->object.oid);
7575
cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix);
7676
html(" (");
7777
cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix);
7878
html(")</td></tr>\n");
79-
html("<tr><th>tree</th><td colspan='2' class='sha1'>");
79+
html("<tr><th>tree</th><td colspan='2' class='oid'>");
8080
tmp = xstrdup(hex);
8181
cgit_tree_link(oid_to_hex(get_commit_tree_oid(commit)), NULL, NULL,
8282
ctx.qry.head, tmp, NULL);
@@ -95,7 +95,7 @@ void cgit_print_commit(char *hex, const char *prefix)
9595
continue;
9696
}
9797
html("<tr><th>parent</th>"
98-
"<td colspan='2' class='sha1'>");
98+
"<td colspan='2' class='oid'>");
9999
tmp = tmp2 = oid_to_hex(&p->item->object.oid);
100100
if (ctx.repo->enable_subject_links) {
101101
parent_info = cgit_parse_commit(parent);
@@ -109,7 +109,7 @@ void cgit_print_commit(char *hex, const char *prefix)
109109
parents++;
110110
}
111111
if (ctx.repo->snapshots) {
112-
html("<tr><th>download</th><td colspan='2' class='sha1'>");
112+
html("<tr><th>download</th><td colspan='2' class='oid'>");
113113
cgit_print_snapshot_links(ctx.repo, hex, "<br/>");
114114
html("</td></tr>");
115115
}
@@ -139,7 +139,7 @@ void cgit_print_commit(char *hex, const char *prefix)
139139
tmp = oid_to_hex(&commit->parents->item->object.oid);
140140
else
141141
tmp = NULL;
142-
cgit_print_diff(ctx.qry.sha1, tmp, prefix, 0, 0);
142+
cgit_print_diff(ctx.qry.oid, tmp, prefix, 0, 0);
143143
}
144144
strbuf_release(&notes);
145145
cgit_free_commitinfo(info);

ui-diff.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ static void print_fileinfo(struct fileinfo *info)
9797
html("]</span>");
9898
}
9999
htmlf("</td><td class='%s'>", class);
100-
cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, ctx.qry.sha1,
101-
ctx.qry.sha2, info->new_path);
100+
cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, ctx.qry.oid,
101+
ctx.qry.oid2, info->new_path);
102102
if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) {
103103
htmlf(" (%s from ",
104104
info->status == DIFF_STATUS_COPIED ? "copied" : "renamed");
@@ -194,8 +194,8 @@ static void cgit_print_diffstat(const struct object_id *old_oid,
194194
int i;
195195

196196
html("<div class='diffstat-header'>");
197-
cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
198-
ctx.qry.sha2, NULL);
197+
cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.oid,
198+
ctx.qry.oid2, NULL);
199199
if (prefix) {
200200
html(" (limited to '");
201201
html_txt(prefix);

ui-log.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
463463
if (pager) {
464464
html(" (");
465465
cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL,
466-
NULL, ctx.qry.head, ctx.qry.sha1,
466+
NULL, ctx.qry.head, ctx.qry.oid,
467467
ctx.qry.vpath, ctx.qry.ofs, ctx.qry.grep,
468468
ctx.qry.search, ctx.qry.showmsg ? 0 : 1,
469469
ctx.qry.follow);
@@ -519,7 +519,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
519519
if (ofs > 0) {
520520
html("<li>");
521521
cgit_log_link("[prev]", NULL, NULL, ctx.qry.head,
522-
ctx.qry.sha1, ctx.qry.vpath,
522+
ctx.qry.oid, ctx.qry.vpath,
523523
ofs - cnt, ctx.qry.grep,
524524
ctx.qry.search, ctx.qry.showmsg,
525525
ctx.qry.follow);
@@ -528,7 +528,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
528528
if ((commit = get_revision(&rev)) != NULL) {
529529
html("<li>");
530530
cgit_log_link("[next]", NULL, NULL, ctx.qry.head,
531-
ctx.qry.sha1, ctx.qry.vpath,
531+
ctx.qry.oid, ctx.qry.vpath,
532532
ofs + cnt, ctx.qry.grep,
533533
ctx.qry.search, ctx.qry.showmsg,
534534
ctx.qry.follow);

ui-plain.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static void print_dir(const struct object_id *oid, const char *base,
9999
fullpath = NULL;
100100
}
101101
html("<li>");
102-
cgit_plain_link("../", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
102+
cgit_plain_link("../", NULL, NULL, ctx.qry.head, ctx.qry.oid,
103103
fullpath);
104104
html("</li>\n");
105105
}
@@ -118,7 +118,7 @@ static void print_dir_entry(const struct object_id *oid, const char *base,
118118
if (S_ISGITLINK(mode)) {
119119
cgit_submodule_link(NULL, fullpath, oid_to_hex(oid));
120120
} else
121-
cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.sha1,
121+
cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.oid,
122122
fullpath);
123123
html("</li>\n");
124124
free(fullpath);
@@ -163,7 +163,7 @@ static int basedir_len(const char *path)
163163

164164
void cgit_print_plain(void)
165165
{
166-
const char *rev = ctx.qry.sha1;
166+
const char *rev = ctx.qry.oid;
167167
struct object_id oid;
168168
struct commit *commit;
169169
struct pathspec_item path_items = {

0 commit comments

Comments
 (0)