* [PATCH 01/10] cgit: replace 'unsigned char sha1[20]' with 'struct object_id oid'
[not found] <20161004095050.29c7859b@leda.localdomain>
@ 2016-10-04 7:51 ` list
2016-10-04 7:51 ` [PATCH 02/10] ui-blob: " list
` (8 more replies)
0 siblings, 9 replies; 15+ messages in thread
From: list @ 2016-10-04 7:51 UTC (permalink / raw)
From: Christian Hesse <mail at eworm.de>
Upstream git is replacing 'unsigned char sha1[20]' with 'struct object_id
oid'. We have some code that can be changed independent from upstream. So
here we go...
Signed-off-by: Christian Hesse <mail at eworm.de>
---
cgit.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/cgit.c b/cgit.c
index 2f29aa6..9f5a80f 100644
--- a/cgit.c
+++ b/cgit.c
@@ -471,13 +471,14 @@ static char *find_default_branch(struct cgit_repo *repo)
static char *guess_defbranch(void)
{
const char *ref;
- unsigned char sha1[20];
+ struct object_id oid;
- ref = resolve_ref_unsafe("HEAD", 0, sha1, NULL);
+ ref = resolve_ref_unsafe("HEAD", 0, oid.hash, NULL);
if (!ref || !starts_with(ref, "refs/heads/"))
return "master";
return xstrdup(ref + 11);
}
+
/* The caller must free filename and ref after calling this. */
static inline void parse_readme(const char *readme, char **filename, char **ref, struct cgit_repo *repo)
{
@@ -557,7 +558,7 @@ static void print_no_repo_clone_urls(const char *url)
static int prepare_repo_cmd(void)
{
- unsigned char sha1[20];
+ struct object_id oid;
int nongit = 0;
int rc;
@@ -615,7 +616,7 @@ static int prepare_repo_cmd(void)
return 1;
}
- if (get_sha1(ctx.qry.head, sha1)) {
+ if (get_oid(ctx.qry.head, &oid)) {
char *old_head = ctx.qry.head;
ctx.qry.head = xstrdup(ctx.repo->defbranch);
cgit_print_error_page(404, "Not found",
--
2.10.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 02/10] ui-blob: replace 'unsigned char sha1[20]' with 'struct object_id oid'
2016-10-04 7:51 ` [PATCH 01/10] cgit: replace 'unsigned char sha1[20]' with 'struct object_id oid' list
@ 2016-10-04 7:51 ` list
2016-10-04 8:07 ` Jason
2016-10-04 7:51 ` [PATCH 03/10] ui-commit: " list
` (7 subsequent siblings)
8 siblings, 1 reply; 15+ messages in thread
From: list @ 2016-10-04 7:51 UTC (permalink / raw)
From: Christian Hesse <mail at eworm.de>
Upstream git is replacing 'unsigned char sha1[20]' with 'struct object_id
oid'. We have some code that can be changed independent from upstream. So
here we go...
In addition replace memmove() with hashcpy().
Signed-off-by: Christian Hesse <mail at eworm.de>
---
ui-blob.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/ui-blob.c b/ui-blob.c
index d388489..2f8bb7a 100644
--- a/ui-blob.c
+++ b/ui-blob.c
@@ -13,7 +13,7 @@
struct walk_tree_context {
const char *match_path;
- unsigned char *matched_sha1;
+ struct object_id matched_oid;
unsigned int found_path:1;
unsigned int file_only:1;
};
@@ -28,14 +28,14 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base,
if (strncmp(base->buf, walk_tree_ctx->match_path, base->len)
|| strcmp(walk_tree_ctx->match_path + base->len, pathname))
return READ_TREE_RECURSIVE;
- memmove(walk_tree_ctx->matched_sha1, sha1, 20);
+ hashcpy(walk_tree_ctx->matched_oid.hash, sha1);
walk_tree_ctx->found_path = 1;
return 0;
}
int cgit_ref_path_exists(const char *path, const char *ref, int file_only)
{
- unsigned char sha1[20];
+ struct object_id oid;
unsigned long size;
struct pathspec_item path_items = {
.match = path,
@@ -47,22 +47,22 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only)
};
struct walk_tree_context walk_tree_ctx = {
.match_path = path,
- .matched_sha1 = sha1,
+ .matched_oid = oid,
.found_path = 0,
.file_only = file_only
};
- if (get_sha1(ref, sha1))
+ if (get_oid(ref, &oid))
return 0;
- if (sha1_object_info(sha1, &size) != OBJ_COMMIT)
+ if (sha1_object_info(oid.hash, &size) != OBJ_COMMIT)
return 0;
- read_tree_recursive(lookup_commit_reference(sha1)->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+ read_tree_recursive(lookup_commit_reference(oid.hash)->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
return walk_tree_ctx.found_path;
}
int cgit_print_file(char *path, const char *head, int file_only)
{
- unsigned char sha1[20];
+ struct object_id oid;
enum object_type type;
char *buf;
unsigned long size;
@@ -77,24 +77,24 @@ int cgit_print_file(char *path, const char *head, int file_only)
};
struct walk_tree_context walk_tree_ctx = {
.match_path = path,
- .matched_sha1 = sha1,
+ .matched_oid = oid,
.found_path = 0,
.file_only = file_only
};
- if (get_sha1(head, sha1))
+ if (get_oid(head, &oid))
return -1;
- type = sha1_object_info(sha1, &size);
+ type = sha1_object_info(oid.hash, &size);
if (type == OBJ_COMMIT) {
- commit = lookup_commit_reference(sha1);
+ commit = lookup_commit_reference(oid.hash);
read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
if (!walk_tree_ctx.found_path)
return -1;
- type = sha1_object_info(sha1, &size);
+ type = sha1_object_info(oid.hash, &size);
}
if (type == OBJ_BAD)
return -1;
- buf = read_sha1_file(sha1, &type, &size);
+ buf = read_sha1_file(oid.hash, &type, &size);
if (!buf)
return -1;
buf[size] = '\0';
@@ -105,7 +105,7 @@ int cgit_print_file(char *path, const char *head, int file_only)
void cgit_print_blob(const char *hex, char *path, const char *head, int file_only)
{
- unsigned char sha1[20];
+ struct object_id oid;
enum object_type type;
char *buf;
unsigned long size;
@@ -120,31 +120,31 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
};
struct walk_tree_context walk_tree_ctx = {
.match_path = path,
- .matched_sha1 = sha1,
+ .matched_oid = oid,
.found_path = 0,
.file_only = file_only
};
if (hex) {
- if (get_sha1_hex(hex, sha1)) {
+ if (get_oid_hex(hex, &oid)) {
cgit_print_error_page(400, "Bad request",
"Bad hex value: %s", hex);
return;
}
} else {
- if (get_sha1(head, sha1)) {
+ if (get_oid(head, &oid)) {
cgit_print_error_page(404, "Not found",
"Bad ref: %s", head);
return;
}
}
- type = sha1_object_info(sha1, &size);
+ type = sha1_object_info(oid.hash, &size);
if ((!hex) && type == OBJ_COMMIT && path) {
- commit = lookup_commit_reference(sha1);
+ commit = lookup_commit_reference(oid.hash);
read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
- type = sha1_object_info(sha1,&size);
+ type = sha1_object_info(oid.hash, &size);
}
if (type == OBJ_BAD) {
@@ -153,7 +153,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
return;
}
- buf = read_sha1_file(sha1, &type, &size);
+ buf = read_sha1_file(oid.hash, &type, &size);
if (!buf) {
cgit_print_error_page(500, "Internal server error",
"Error reading object %s", hex);
--
2.10.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 03/10] ui-commit: replace 'unsigned char sha1[20]' with 'struct object_id oid'
2016-10-04 7:51 ` [PATCH 01/10] cgit: replace 'unsigned char sha1[20]' with 'struct object_id oid' list
2016-10-04 7:51 ` [PATCH 02/10] ui-blob: " list
@ 2016-10-04 7:51 ` list
2016-10-04 7:51 ` [PATCH 04/10] ui-log: replace get_sha1() with get_oid() list
` (6 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: list @ 2016-10-04 7:51 UTC (permalink / raw)
From: Christian Hesse <mail at eworm.de>
Upstream git is replacing 'unsigned char sha1[20]' with 'struct object_id
oid'. We have some code that can be changed independent from upstream. So
here we go...
Signed-off-by: Christian Hesse <mail at eworm.de>
---
ui-commit.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/ui-commit.c b/ui-commit.c
index 099d294..db69d54 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -19,19 +19,19 @@ void cgit_print_commit(char *hex, const char *prefix)
struct commitinfo *info, *parent_info;
struct commit_list *p;
struct strbuf notes = STRBUF_INIT;
- unsigned char sha1[20];
+ struct object_id oid;
char *tmp, *tmp2;
int parents = 0;
if (!hex)
hex = ctx.qry.head;
- if (get_sha1(hex, sha1)) {
+ if (get_oid(hex, &oid)) {
cgit_print_error_page(400, "Bad request",
"Bad object id: %s", hex);
return;
}
- commit = lookup_commit_reference(sha1);
+ commit = lookup_commit_reference(oid.hash);
if (!commit) {
cgit_print_error_page(404, "Not found",
"Bad commit reference: %s", hex);
@@ -39,7 +39,7 @@ void cgit_print_commit(char *hex, const char *prefix)
}
info = cgit_parse_commit(commit);
- format_display_notes(sha1, ¬es, PAGE_ENCODING, 0);
+ format_display_notes(oid.hash, ¬es, PAGE_ENCODING, 0);
load_ref_decorations(DECORATE_FULL_REFS);
--
2.10.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 04/10] ui-log: replace get_sha1() with get_oid()
2016-10-04 7:51 ` [PATCH 01/10] cgit: replace 'unsigned char sha1[20]' with 'struct object_id oid' list
2016-10-04 7:51 ` [PATCH 02/10] ui-blob: " list
2016-10-04 7:51 ` [PATCH 03/10] ui-commit: " list
@ 2016-10-04 7:51 ` list
2016-10-04 7:51 ` [PATCH 05/10] ui-patch: replace 'unsigned char sha1[20]' with 'struct object_id oid' list
` (5 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: list @ 2016-10-04 7:51 UTC (permalink / raw)
From: Christian Hesse <mail at eworm.de>
Data structures have been replaced already, so use correct function calls.
Signed-off-by: Christian Hesse <mail at eworm.de>
---
ui-log.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui-log.c b/ui-log.c
index a31ff7c..6cc81a3 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -325,7 +325,7 @@ static const char *disambiguate_ref(const char *ref, int *must_free_result)
struct strbuf longref = STRBUF_INIT;
strbuf_addf(&longref, "refs/heads/%s", ref);
- if (get_sha1(longref.buf, oid.hash) == 0) {
+ if (get_oid(longref.buf, &oid) == 0) {
*must_free_result = 1;
return strbuf_detach(&longref, NULL);
}
--
2.10.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 05/10] ui-patch: replace 'unsigned char sha1[20]' with 'struct object_id oid'
2016-10-04 7:51 ` [PATCH 01/10] cgit: replace 'unsigned char sha1[20]' with 'struct object_id oid' list
` (2 preceding siblings ...)
2016-10-04 7:51 ` [PATCH 04/10] ui-log: replace get_sha1() with get_oid() list
@ 2016-10-04 7:51 ` list
2016-10-04 7:51 ` [PATCH 06/10] ui-plain: " list
` (4 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: list @ 2016-10-04 7:51 UTC (permalink / raw)
From: Christian Hesse <mail at eworm.de>
Upstream git is replacing 'unsigned char sha1[20]' with 'struct object_id
oid'. We have some code that can be changed independent from upstream. So
here we go...
Signed-off-by: Christian Hesse <mail at eworm.de>
---
ui-patch.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/ui-patch.c b/ui-patch.c
index 4c051e8..fd6316b 100644
--- a/ui-patch.c
+++ b/ui-patch.c
@@ -16,7 +16,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
{
struct rev_info rev;
struct commit *commit;
- unsigned char new_rev_sha1[20], old_rev_sha1[20];
+ struct object_id new_rev_oid, old_rev_oid;
char rev_range[2 * 40 + 3];
char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range };
char *patchname;
@@ -24,12 +24,12 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
if (!new_rev)
new_rev = ctx.qry.head;
- if (get_sha1(new_rev, new_rev_sha1)) {
+ if (get_oid(new_rev, &new_rev_oid)) {
cgit_print_error_page(404, "Not found",
"Bad object id: %s", new_rev);
return;
}
- commit = lookup_commit_reference(new_rev_sha1);
+ commit = lookup_commit_reference(new_rev_oid.hash);
if (!commit) {
cgit_print_error_page(404, "Not found",
"Bad commit reference: %s", new_rev);
@@ -37,27 +37,27 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
}
if (old_rev) {
- if (get_sha1(old_rev, old_rev_sha1)) {
+ if (get_oid(old_rev, &old_rev_oid)) {
cgit_print_error_page(404, "Not found",
"Bad object id: %s", old_rev);
return;
}
- if (!lookup_commit_reference(old_rev_sha1)) {
+ if (!lookup_commit_reference(old_rev_oid.hash)) {
cgit_print_error_page(404, "Not found",
"Bad commit reference: %s", old_rev);
return;
}
} else if (commit->parents && commit->parents->item) {
- hashcpy(old_rev_sha1, commit->parents->item->object.oid.hash);
+ oidcpy(&old_rev_oid, &commit->parents->item->object.oid);
} else {
- hashclr(old_rev_sha1);
+ oidclr(&old_rev_oid);
}
- if (is_null_sha1(old_rev_sha1)) {
- memcpy(rev_range, sha1_to_hex(new_rev_sha1), 41);
+ if (is_null_oid(&old_rev_oid)) {
+ memcpy(rev_range, oid_to_hex(&new_rev_oid), GIT_SHA1_HEXSZ + 1);
} else {
- sprintf(rev_range, "%s..%s", sha1_to_hex(old_rev_sha1),
- sha1_to_hex(new_rev_sha1));
+ sprintf(rev_range, "%s..%s", oid_to_hex(&old_rev_oid),
+ oid_to_hex(&new_rev_oid));
}
patchname = fmt("%s.patch", rev_range);
--
2.10.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 06/10] ui-plain: replace 'unsigned char sha1[20]' with 'struct object_id oid'
2016-10-04 7:51 ` [PATCH 01/10] cgit: replace 'unsigned char sha1[20]' with 'struct object_id oid' list
` (3 preceding siblings ...)
2016-10-04 7:51 ` [PATCH 05/10] ui-patch: replace 'unsigned char sha1[20]' with 'struct object_id oid' list
@ 2016-10-04 7:51 ` list
2016-10-04 7:52 ` [PATCH 07/10] ui-shared: " list
` (3 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: list @ 2016-10-04 7:51 UTC (permalink / raw)
From: Christian Hesse <mail at eworm.de>
Upstream git is replacing 'unsigned char sha1[20]' with 'struct object_id
oid'. We have some code that can be changed independent from upstream. So
here we go...
Signed-off-by: Christian Hesse <mail at eworm.de>
---
ui-plain.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/ui-plain.c b/ui-plain.c
index 97cf639..8d541e3 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -164,7 +164,7 @@ static int basedir_len(const char *path)
void cgit_print_plain(void)
{
const char *rev = ctx.qry.sha1;
- unsigned char sha1[20];
+ struct object_id oid;
struct commit *commit;
struct pathspec_item path_items = {
.match = ctx.qry.path,
@@ -181,11 +181,11 @@ void cgit_print_plain(void)
if (!rev)
rev = ctx.qry.head;
- if (get_sha1(rev, sha1)) {
+ if (get_oid(rev, &oid)) {
cgit_print_error_page(404, "Not found", "Not found");
return;
}
- commit = lookup_commit_reference(sha1);
+ commit = lookup_commit_reference(oid.hash);
if (!commit || parse_commit(commit)) {
cgit_print_error_page(404, "Not found", "Not found");
return;
--
2.10.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 07/10] ui-shared: replace 'unsigned char sha1[20]' with 'struct object_id oid'
2016-10-04 7:51 ` [PATCH 01/10] cgit: replace 'unsigned char sha1[20]' with 'struct object_id oid' list
` (4 preceding siblings ...)
2016-10-04 7:51 ` [PATCH 06/10] ui-plain: " list
@ 2016-10-04 7:52 ` list
2016-10-04 7:52 ` [PATCH 08/10] ui-snapshot: " list
` (2 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: list @ 2016-10-04 7:52 UTC (permalink / raw)
From: Christian Hesse <mail at eworm.de>
Upstream git is replacing 'unsigned char sha1[20]' with 'struct object_id
oid'. We have some code that can be changed independent from upstream. So
here we go...
Signed-off-by: Christian Hesse <mail at eworm.de>
---
ui-shared.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/ui-shared.c b/ui-shared.c
index 3fa36d6..2e4fcd9 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -1074,18 +1074,18 @@ void cgit_print_filemode(unsigned short mode)
void cgit_compose_snapshot_prefix(struct strbuf *filename, const char *base,
const char *ref)
{
- unsigned char sha1[20];
+ struct object_id oid;
/*
* Prettify snapshot names by stripping leading "v" or "V" if the tag
* name starts with {v,V}[0-9] and the prettify mapping is injective,
* i.e. each stripped tag can be inverted without ambiguities.
*/
- if (get_sha1(fmt("refs/tags/%s", ref), sha1) == 0 &&
+ if (get_oid(fmt("refs/tags/%s", ref), &oid) == 0 &&
(ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1]) &&
- ((get_sha1(fmt("refs/tags/%s", ref + 1), sha1) == 0) +
- (get_sha1(fmt("refs/tags/v%s", ref + 1), sha1) == 0) +
- (get_sha1(fmt("refs/tags/V%s", ref + 1), sha1) == 0) == 1))
+ ((get_oid(fmt("refs/tags/%s", ref + 1), &oid) == 0) +
+ (get_oid(fmt("refs/tags/v%s", ref + 1), &oid) == 0) +
+ (get_oid(fmt("refs/tags/V%s", ref + 1), &oid) == 0) == 1))
ref++;
strbuf_addf(filename, "%s-%s", base, ref);
--
2.10.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 08/10] ui-snapshot: replace 'unsigned char sha1[20]' with 'struct object_id oid'
2016-10-04 7:51 ` [PATCH 01/10] cgit: replace 'unsigned char sha1[20]' with 'struct object_id oid' list
` (5 preceding siblings ...)
2016-10-04 7:52 ` [PATCH 07/10] ui-shared: " list
@ 2016-10-04 7:52 ` list
2016-10-04 7:52 ` [PATCH 09/10] ui-tag: " list
2016-10-04 7:52 ` [PATCH 10/10] ui-tree: " list
8 siblings, 0 replies; 15+ messages in thread
From: list @ 2016-10-04 7:52 UTC (permalink / raw)
From: Christian Hesse <mail at eworm.de>
Upstream git is replacing 'unsigned char sha1[20]' with 'struct object_id
oid'. We have some code that can be changed independent from upstream. So
here we go...
Signed-off-by: Christian Hesse <mail at eworm.de>
---
ui-snapshot.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/ui-snapshot.c b/ui-snapshot.c
index f68e877..08c6e80 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -109,19 +109,19 @@ static int make_snapshot(const struct cgit_snapshot_format *format,
const char *hex, const char *prefix,
const char *filename)
{
- unsigned char sha1[20];
+ struct object_id oid;
- if (get_sha1(hex, sha1)) {
+ if (get_oid(hex, &oid)) {
cgit_print_error_page(404, "Not found",
"Bad object id: %s", hex);
return 1;
}
- if (!lookup_commit_reference(sha1)) {
+ if (!lookup_commit_reference(oid.hash)) {
cgit_print_error_page(400, "Bad request",
"Not a commit reference: %s", hex);
return 1;
}
- ctx.page.etag = sha1_to_hex(sha1);
+ ctx.page.etag = oid_to_hex(&oid);
ctx.page.mimetype = xstrdup(format->mimetype);
ctx.page.filename = xstrdup(filename);
cgit_print_http_headers();
@@ -143,14 +143,14 @@ static const char *get_ref_from_filename(const char *url, const char *filename,
const struct cgit_snapshot_format *format)
{
const char *reponame;
- unsigned char sha1[20];
+ struct object_id oid;
struct strbuf snapshot = STRBUF_INIT;
int result = 1;
strbuf_addstr(&snapshot, filename);
strbuf_setlen(&snapshot, snapshot.len - strlen(format->suffix));
- if (get_sha1(snapshot.buf, sha1) == 0)
+ if (get_oid(snapshot.buf, &oid) == 0)
goto out;
reponame = cgit_repobasename(url);
@@ -162,15 +162,15 @@ static const char *get_ref_from_filename(const char *url, const char *filename,
strbuf_splice(&snapshot, 0, new_start - snapshot.buf, "", 0);
}
- if (get_sha1(snapshot.buf, sha1) == 0)
+ if (get_oid(snapshot.buf, &oid) == 0)
goto out;
strbuf_insert(&snapshot, 0, "v", 1);
- if (get_sha1(snapshot.buf, sha1) == 0)
+ if (get_oid(snapshot.buf, &oid) == 0)
goto out;
strbuf_splice(&snapshot, 0, 1, "V", 1);
- if (get_sha1(snapshot.buf, sha1) == 0)
+ if (get_oid(snapshot.buf, &oid) == 0)
goto out;
result = 0;
--
2.10.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 09/10] ui-tag: replace 'unsigned char sha1[20]' with 'struct object_id oid'
2016-10-04 7:51 ` [PATCH 01/10] cgit: replace 'unsigned char sha1[20]' with 'struct object_id oid' list
` (6 preceding siblings ...)
2016-10-04 7:52 ` [PATCH 08/10] ui-snapshot: " list
@ 2016-10-04 7:52 ` list
2016-10-04 7:52 ` [PATCH 10/10] ui-tree: " list
8 siblings, 0 replies; 15+ messages in thread
From: list @ 2016-10-04 7:52 UTC (permalink / raw)
From: Christian Hesse <mail at eworm.de>
Upstream git is replacing 'unsigned char sha1[20]' with 'struct object_id
oid'. We have some code that can be changed independent from upstream. So
here we go...
Signed-off-by: Christian Hesse <mail at eworm.de>
---
ui-tag.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/ui-tag.c b/ui-tag.c
index 3fa63b3..afd7d61 100644
--- a/ui-tag.c
+++ b/ui-tag.c
@@ -42,29 +42,29 @@ static void print_download_links(char *revname)
void cgit_print_tag(char *revname)
{
struct strbuf fullref = STRBUF_INIT;
- unsigned char sha1[20];
+ struct object_id oid;
struct object *obj;
if (!revname)
revname = ctx.qry.head;
strbuf_addf(&fullref, "refs/tags/%s", revname);
- if (get_sha1(fullref.buf, sha1)) {
+ if (get_oid(fullref.buf, &oid)) {
cgit_print_error_page(404, "Not found",
"Bad tag reference: %s", revname);
goto cleanup;
}
- obj = parse_object(sha1);
+ obj = parse_object(oid.hash);
if (!obj) {
cgit_print_error_page(500, "Internal server error",
- "Bad object id: %s", sha1_to_hex(sha1));
+ "Bad object id: %s", oid_to_hex(&oid));
goto cleanup;
}
if (obj->type == OBJ_TAG) {
struct tag *tag;
struct taginfo *info;
- tag = lookup_tag(sha1);
+ tag = lookup_tag(oid.hash);
if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) {
cgit_print_error_page(500, "Internal server error",
"Bad tag object: %s", revname);
@@ -74,7 +74,7 @@ void cgit_print_tag(char *revname)
html("<table class='commit-info'>\n");
htmlf("<tr><td>tag name</td><td>");
html_txt(revname);
- htmlf(" (%s)</td></tr>\n", sha1_to_hex(sha1));
+ htmlf(" (%s)</td></tr>\n", oid_to_hex(&oid));
if (info->tagger_date > 0) {
html("<tr><td>tag date</td><td>");
html_txt(show_date(info->tagger_date, info->tagger_tz,
--
2.10.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 10/10] ui-tree: replace 'unsigned char sha1[20]' with 'struct object_id oid'
2016-10-04 7:51 ` [PATCH 01/10] cgit: replace 'unsigned char sha1[20]' with 'struct object_id oid' list
` (7 preceding siblings ...)
2016-10-04 7:52 ` [PATCH 09/10] ui-tag: " list
@ 2016-10-04 7:52 ` list
8 siblings, 0 replies; 15+ messages in thread
From: list @ 2016-10-04 7:52 UTC (permalink / raw)
From: Christian Hesse <mail at eworm.de>
Upstream git is replacing 'unsigned char sha1[20]' with 'struct object_id
oid'. We have some code that can be changed independent from upstream. So
here we go...
Signed-off-by: Christian Hesse <mail at eworm.de>
---
ui-tree.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/ui-tree.c b/ui-tree.c
index b98a7f0..b310242 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -357,7 +357,7 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base,
*/
void cgit_print_tree(const char *rev, char *path)
{
- unsigned char sha1[20];
+ struct object_id oid;
struct commit *commit;
struct pathspec_item path_items = {
.match = path,
@@ -375,12 +375,12 @@ void cgit_print_tree(const char *rev, char *path)
if (!rev)
rev = ctx.qry.head;
- if (get_sha1(rev, sha1)) {
+ if (get_oid(rev, &oid)) {
cgit_print_error_page(404, "Not found",
"Invalid revision name: %s", rev);
return;
}
- commit = lookup_commit_reference(sha1);
+ commit = lookup_commit_reference(oid.hash);
if (!commit || parse_commit(commit)) {
cgit_print_error_page(404, "Not found",
"Invalid commit reference: %s", rev);
--
2.10.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 02/10] ui-blob: replace 'unsigned char sha1[20]' with 'struct object_id oid'
2016-10-04 7:51 ` [PATCH 02/10] ui-blob: " list
@ 2016-10-04 8:07 ` Jason
2016-10-04 8:19 ` list
0 siblings, 1 reply; 15+ messages in thread
From: Jason @ 2016-10-04 8:07 UTC (permalink / raw)
On Tue, Oct 4, 2016 at 9:51 AM, Christian Hesse <list at eworm.de> wrote:
> + hashcpy(walk_tree_ctx->matched_oid.hash, sha1);
> + if (sha1_object_info(oid.hash, &size) != OBJ_COMMIT)
> + type = sha1_object_info(oid.hash, &size);
> + type = sha1_object_info(oid.hash, &size);
> + buf = read_sha1_file(oid.hash, &type, &size);
> + type = sha1_object_info(oid.hash, &size);
> + buf = read_sha1_file(oid.hash, &type, &size);
Presumably upstream git doesn't have an oid family of functions for these yet?
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 02/10] ui-blob: replace 'unsigned char sha1[20]' with 'struct object_id oid'
2016-10-04 8:07 ` Jason
@ 2016-10-04 8:19 ` list
2016-10-04 18:34 ` john
0 siblings, 1 reply; 15+ messages in thread
From: list @ 2016-10-04 8:19 UTC (permalink / raw)
"Jason A. Donenfeld" <Jason at zx2c4.com> on Tue, 2016/10/04 10:07:
> On Tue, Oct 4, 2016 at 9:51 AM, Christian Hesse <list at eworm.de> wrote:
> > + hashcpy(walk_tree_ctx->matched_oid.hash, sha1);
> > + if (sha1_object_info(oid.hash, &size) != OBJ_COMMIT)
> > + type = sha1_object_info(oid.hash, &size);
> > + type = sha1_object_info(oid.hash, &size);
> > + buf = read_sha1_file(oid.hash, &type, &size);
> > + type = sha1_object_info(oid.hash, &size);
> > + buf = read_sha1_file(oid.hash, &type, &size);
>
> Presumably upstream git doesn't have an oid family of functions for these
> yet?
No. I think I have replaced everything possible.
John wrote a comment about changing format_notes(), but that is an upstream
function as well.
--
main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH"
"CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];)
putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 455 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20161004/99d208ae/attachment.asc>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 02/10] ui-blob: replace 'unsigned char sha1[20]' with 'struct object_id oid'
2016-10-04 8:19 ` list
@ 2016-10-04 18:34 ` john
2016-10-04 19:24 ` Jason
0 siblings, 1 reply; 15+ messages in thread
From: john @ 2016-10-04 18:34 UTC (permalink / raw)
On Tue, Oct 04, 2016 at 10:19:20AM +0200, Christian Hesse wrote:
> "Jason A. Donenfeld" <Jason at zx2c4.com> on Tue, 2016/10/04 10:07:
> > On Tue, Oct 4, 2016 at 9:51 AM, Christian Hesse <list at eworm.de> wrote:
> > > + hashcpy(walk_tree_ctx->matched_oid.hash, sha1);
> > > + if (sha1_object_info(oid.hash, &size) != OBJ_COMMIT)
> > > + type = sha1_object_info(oid.hash, &size);
> > > + type = sha1_object_info(oid.hash, &size);
> > > + buf = read_sha1_file(oid.hash, &type, &size);
> > > + type = sha1_object_info(oid.hash, &size);
> > > + buf = read_sha1_file(oid.hash, &type, &size);
> >
> > Presumably upstream git doesn't have an oid family of functions for these
> > yet?
>
> No. I think I have replaced everything possible.
>
> John wrote a comment about changing format_notes(), but that is an upstream
> function as well.
Yeah, I wasn't paying enough attention to where that functions was.
This series looks good to me, so:
Reviewed-by: John Keeping <john at keeping.me.uk>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 02/10] ui-blob: replace 'unsigned char sha1[20]' with 'struct object_id oid'
2016-10-04 18:34 ` john
@ 2016-10-04 19:24 ` Jason
2016-10-04 19:48 ` list
0 siblings, 1 reply; 15+ messages in thread
From: Jason @ 2016-10-04 19:24 UTC (permalink / raw)
Ack'd. Pop em in a for-jason branch.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 02/10] ui-blob: replace 'unsigned char sha1[20]' with 'struct object_id oid'
2016-10-04 19:24 ` Jason
@ 2016-10-04 19:48 ` list
0 siblings, 0 replies; 15+ messages in thread
From: list @ 2016-10-04 19:48 UTC (permalink / raw)
"Jason A. Donenfeld" <Jason at zx2c4.com> on Tue, 2016/10/04 21:24:
> Ack'd. Pop em in a for-jason branch.
Done. Please merge.
--
main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH"
"CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];)
putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 455 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20161004/37f8d606/attachment.asc>
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2016-10-04 19:48 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20161004095050.29c7859b@leda.localdomain>
2016-10-04 7:51 ` [PATCH 01/10] cgit: replace 'unsigned char sha1[20]' with 'struct object_id oid' list
2016-10-04 7:51 ` [PATCH 02/10] ui-blob: " list
2016-10-04 8:07 ` Jason
2016-10-04 8:19 ` list
2016-10-04 18:34 ` john
2016-10-04 19:24 ` Jason
2016-10-04 19:48 ` list
2016-10-04 7:51 ` [PATCH 03/10] ui-commit: " list
2016-10-04 7:51 ` [PATCH 04/10] ui-log: replace get_sha1() with get_oid() list
2016-10-04 7:51 ` [PATCH 05/10] ui-patch: replace 'unsigned char sha1[20]' with 'struct object_id oid' list
2016-10-04 7:51 ` [PATCH 06/10] ui-plain: " list
2016-10-04 7:52 ` [PATCH 07/10] ui-shared: " list
2016-10-04 7:52 ` [PATCH 08/10] ui-snapshot: " list
2016-10-04 7:52 ` [PATCH 09/10] ui-tag: " list
2016-10-04 7:52 ` [PATCH 10/10] ui-tree: " list
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).