List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH 1/1] RFC: git: update to v2.18.0-rc2
@ 2018-06-13 22:52 list
  2018-06-14  1:48 ` [PATCH] ui-shared: typename changed to type_name in git 2.18.0-rc2 andy
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: list @ 2018-06-13 22:52 UTC (permalink / raw)


From: Christian Hesse <mail at eworm.de>

Update to git version v2.18.0-rc2. Required changes follow upstream commits:

* Convert find_unique_abbrev* to struct object_id
  (aab9583f7b5ea5463eb3f653a0b4ecac7539dc94)
* sha1_file: convert read_sha1_file to struct object_id
  (b4f5aca40e6f77cbabcbf4ff003c3cf30a1830c8)
* sha1_file: convert sha1_object_info* to object_id
  (abef9020e3df87c441c9a3a95f592fce5fa49bb9)
* object-store: move packed_git and packed_git_mru to object store
  (a80d72db2a73174b3f22142eb2014b33696fd795)
* treewide: rename tree to maybe_tree
  (891435d55da80ca3654b19834481205be6bdfe33)

The changed data types required some of our own functions to be converted
to struct object_id:

  ls_item
  print_dir
  print_dir_entry
  print_object
  single_tree_cb
  walk_tree
  write_tree_link

And finally we use new upstream functions that were added for
struct object_id:

  hashcpy     -> oidcpy
  sha1_to_hex -> oid_to_hex

Signed-off-by: Christian Hesse <mail at eworm.de>
---
 Makefile    |  4 ++--
 git         |  2 +-
 parsing.c   |  2 +-
 shared.c    |  2 +-
 ui-blame.c  | 20 ++++++++++----------
 ui-blob.c   | 24 ++++++++++++------------
 ui-clone.c  |  5 +++--
 ui-commit.c |  2 +-
 ui-diff.c   |  8 ++++----
 ui-log.c    |  4 ++--
 ui-plain.c  | 28 ++++++++++++++--------------
 ui-tree.c   | 42 +++++++++++++++++++++---------------------
 12 files changed, 72 insertions(+), 71 deletions(-)

diff --git a/Makefile b/Makefile
index 5188980..d7f04be 100644
--- a/Makefile
+++ b/Makefile
@@ -14,8 +14,8 @@ htmldir = $(docdir)
 pdfdir = $(docdir)
 mandir = $(prefix)/share/man
 SHA1_HEADER = <openssl/sha.h>
-GIT_VER = 2.17.1
-GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz
+GIT_VER = 2.18.0-rc2
+GIT_URL = https://www.kernel.org/pub/software/scm/git/testing/git-$(GIT_VER).tar.gz
 INSTALL = install
 COPYTREE = cp -r
 MAN5_TXT = $(wildcard *.5.txt)
diff --git a/git b/git
index fc54c1a..68372c8 160000
--- a/git
+++ b/git
@@ -1 +1 @@
-Subproject commit fc54c1af3ec09bab8b8ea09768c2da4069b7f53e
+Subproject commit 68372c88794aba15f853542008cda39def768372
diff --git a/parsing.c b/parsing.c
index fd1ea99..12453c2 100644
--- a/parsing.c
+++ b/parsing.c
@@ -200,7 +200,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag)
 	const char *p;
 	struct taginfo *ret = NULL;
 
-	data = read_sha1_file(tag->object.oid.hash, &type, &size);
+	data = read_object_file(&tag->object.oid, &type, &size);
 	if (!data || type != OBJ_TAG)
 		goto cleanup;
 
diff --git a/shared.c b/shared.c
index 21ac8f4..ff1dc29 100644
--- a/shared.c
+++ b/shared.c
@@ -239,7 +239,7 @@ static int load_mmfile(mmfile_t *file, const struct object_id *oid)
 		file->ptr = (char *)"";
 		file->size = 0;
 	} else {
-		file->ptr = read_sha1_file(oid->hash, &type,
+		file->ptr = read_object_file(oid, &type,
 		                           (unsigned long *)&file->size);
 	}
 	return 1;
diff --git a/ui-blame.c b/ui-blame.c
index 17e2d60..daa7e2b 100644
--- a/ui-blame.c
+++ b/ui-blame.c
@@ -49,7 +49,7 @@ static void emit_blame_entry_hash(struct blame_entry *ent)
 
 	char *detail = emit_suspect_detail(suspect);
 	html("<span class='sha1'>");
-	cgit_commit_link(find_unique_abbrev(oid->hash, DEFAULT_ABBREV), detail,
+	cgit_commit_link(find_unique_abbrev(oid, DEFAULT_ABBREV), detail,
 			 NULL, ctx.qry.head, oid_to_hex(oid), suspect->path);
 	html("</span>");
 	free(detail);
@@ -98,7 +98,7 @@ struct walk_tree_context {
 	int state;
 };
 
-static void print_object(const unsigned char *sha1, const char *path,
+static void print_object(const struct object_id *oid, const char *path,
 			 const char *basename, const char *rev)
 {
 	enum object_type type;
@@ -110,17 +110,17 @@ static void print_object(const unsigned char *sha1, const char *path,
 	struct blame_origin *o;
 	struct blame_entry *ent = NULL;
 
-	type = sha1_object_info(sha1, &size);
+	type = oid_object_info(the_repository, oid, &size);
 	if (type == OBJ_BAD) {
 		cgit_print_error_page(404, "Not found", "Bad object name: %s",
-				      sha1_to_hex(sha1));
+				      oid_to_hex(oid));
 		return;
 	}
 
-	buf = read_sha1_file(sha1, &type, &size);
+	buf = read_object_file(oid, &type, &size);
 	if (!buf) {
 		cgit_print_error_page(500, "Internal server error",
-			"Error reading object %s", sha1_to_hex(sha1));
+			"Error reading object %s", oid_to_hex(oid));
 		return;
 	}
 
@@ -144,7 +144,7 @@ static void print_object(const unsigned char *sha1, const char *path,
 	cgit_set_title_from_path(path);
 
 	cgit_print_layout_start();
-	htmlf("blob: %s (", sha1_to_hex(sha1));
+	htmlf("blob: %s (", oid_to_hex(oid));
 	cgit_plain_link("plain", NULL, NULL, ctx.qry.head, rev, path);
 	html(") (");
 	cgit_tree_link("tree", NULL, NULL, ctx.qry.head, rev, path);
@@ -215,7 +215,7 @@ static void print_object(const unsigned char *sha1, const char *path,
 	cgit_print_layout_end();
 }
 
-static int walk_tree(const unsigned char *sha1, struct strbuf *base,
+static int walk_tree(const struct object_id *oid, struct strbuf *base,
 		     const char *pathname, unsigned mode, int stage,
 		     void *cbdata)
 {
@@ -226,7 +226,7 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base,
 			struct strbuf buffer = STRBUF_INIT;
 			strbuf_addbuf(&buffer, base);
 			strbuf_addstr(&buffer, pathname);
-			print_object(sha1, buffer.buf, pathname,
+			print_object(oid, buffer.buf, pathname,
 				     walk_tree_ctx->curr_rev);
 			strbuf_release(&buffer);
 			walk_tree_ctx->state = 1;
@@ -286,7 +286,7 @@ void cgit_print_blame(void)
 	walk_tree_ctx.match_baselen = (path_items.match) ?
 				       basedir_len(path_items.match) : -1;
 
-	read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree,
+	read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree,
 		&walk_tree_ctx);
 	if (!walk_tree_ctx.state)
 		cgit_print_error_page(404, "Not found", "Not found");
diff --git a/ui-blob.c b/ui-blob.c
index 761e886..7b6da2a 100644
--- a/ui-blob.c
+++ b/ui-blob.c
@@ -18,7 +18,7 @@ struct walk_tree_context {
 	unsigned int file_only:1;
 };
 
-static int walk_tree(const unsigned char *sha1, struct strbuf *base,
+static int walk_tree(const struct object_id *oid, struct strbuf *base,
 		const char *pathname, unsigned mode, int stage, void *cbdata)
 {
 	struct walk_tree_context *walk_tree_ctx = cbdata;
@@ -28,7 +28,7 @@ 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;
-	hashcpy(walk_tree_ctx->matched_oid->hash, sha1);
+	oidcpy(walk_tree_ctx->matched_oid, oid);
 	walk_tree_ctx->found_path = 1;
 	return 0;
 }
@@ -54,9 +54,9 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only)
 
 	if (get_oid(ref, &oid))
 		goto done;
-	if (sha1_object_info(oid.hash, &size) != OBJ_COMMIT)
+	if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT)
 		goto done;
-	read_tree_recursive(lookup_commit_reference(&oid)->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+	read_tree_recursive(lookup_commit_reference(&oid)->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
 
 done:
 	free(path_items.match);
@@ -87,17 +87,17 @@ int cgit_print_file(char *path, const char *head, int file_only)
 
 	if (get_oid(head, &oid))
 		return -1;
-	type = sha1_object_info(oid.hash, &size);
+	type = oid_object_info(the_repository, &oid, &size);
 	if (type == OBJ_COMMIT) {
 		commit = lookup_commit_reference(&oid);
-		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+		read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
 		if (!walk_tree_ctx.found_path)
 			return -1;
-		type = sha1_object_info(oid.hash, &size);
+		type = oid_object_info(the_repository, &oid, &size);
 	}
 	if (type == OBJ_BAD)
 		return -1;
-	buf = read_sha1_file(oid.hash, &type, &size);
+	buf = read_object_file(&oid, &type, &size);
 	if (!buf)
 		return -1;
 	buf[size] = '\0';
@@ -142,12 +142,12 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
 		}
 	}
 
-	type = sha1_object_info(oid.hash, &size);
+	type = oid_object_info(the_repository, &oid, &size);
 
 	if ((!hex) && type == OBJ_COMMIT && path) {
 		commit = lookup_commit_reference(&oid);
-		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
-		type = sha1_object_info(oid.hash, &size);
+		read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+		type = oid_object_info(the_repository, &oid, &size);
 	}
 
 	if (type == OBJ_BAD) {
@@ -156,7 +156,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
 		return;
 	}
 
-	buf = read_sha1_file(oid.hash, &type, &size);
+	buf = read_object_file(&oid, &type, &size);
 	if (!buf) {
 		cgit_print_error_page(500, "Internal server error",
 				"Error reading object %s", hex);
diff --git a/ui-clone.c b/ui-clone.c
index bc98980..2c1ac3d 100644
--- a/ui-clone.c
+++ b/ui-clone.c
@@ -12,6 +12,7 @@
 #include "html.h"
 #include "ui-shared.h"
 #include "packfile.h"
+#include "object-store.h"
 
 static int print_ref_info(const char *refname, const struct object_id *oid,
                           int flags, void *cb_data)
@@ -38,8 +39,8 @@ static void print_pack_info(void)
 	ctx.page.mimetype = "text/plain";
 	ctx.page.filename = "objects/info/packs";
 	cgit_print_http_headers();
-	prepare_packed_git();
-	for (pack = packed_git; pack; pack = pack->next) {
+	reprepare_packed_git(the_repository);
+	for (pack = get_packed_git(the_repository); pack; pack = pack->next) {
 		if (pack->pack_local) {
 			offset = strrchr(pack->pack_name, '/');
 			if (offset && offset[1] != '\0')
diff --git a/ui-commit.c b/ui-commit.c
index abf58f6..f9b2aad 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -78,7 +78,7 @@ void cgit_print_commit(char *hex, const char *prefix)
 	html(")</td></tr>\n");
 	html("<tr><th>tree</th><td colspan='2' class='sha1'>");
 	tmp = xstrdup(hex);
-	cgit_tree_link(oid_to_hex(&commit->tree->object.oid), NULL, NULL,
+	cgit_tree_link(oid_to_hex(&commit->maybe_tree->object.oid), NULL, NULL,
 		       ctx.qry.head, tmp, NULL);
 	if (prefix) {
 		html(" /");
diff --git a/ui-diff.c b/ui-diff.c
index a10ce8a..e33e9fb 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -258,8 +258,8 @@ static void header(const struct object_id *oid1, char *path1, int mode1,
 		htmlf("<br/>deleted file mode %.6o", mode1);
 
 	if (!subproject) {
-		abbrev1 = xstrdup(find_unique_abbrev(oid1->hash, DEFAULT_ABBREV));
-		abbrev2 = xstrdup(find_unique_abbrev(oid2->hash, DEFAULT_ABBREV));
+		abbrev1 = xstrdup(find_unique_abbrev(oid1, DEFAULT_ABBREV));
+		abbrev2 = xstrdup(find_unique_abbrev(oid2, DEFAULT_ABBREV));
 		htmlf("<br/>index %s..%s", abbrev1, abbrev2);
 		free(abbrev1);
 		free(abbrev2);
@@ -413,7 +413,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
 			"Bad commit: %s", oid_to_hex(new_rev_oid));
 		return;
 	}
-	new_tree_oid = &commit->tree->object.oid;
+	new_tree_oid = &commit->maybe_tree->object.oid;
 
 	if (old_rev) {
 		if (get_oid(old_rev, old_rev_oid)) {
@@ -434,7 +434,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
 				"Bad commit: %s", oid_to_hex(old_rev_oid));
 			return;
 		}
-		old_tree_oid = &commit2->tree->object.oid;
+		old_tree_oid = &commit2->maybe_tree->object.oid;
 	} else {
 		old_tree_oid = NULL;
 	}
diff --git a/ui-log.c b/ui-log.c
index 8e36fba..d9ef05c 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -149,8 +149,8 @@ static int show_commit(struct commit *commit, struct rev_info *revs)
 	rem_lines = 0;
 
 	revs->diffopt.flags.recursive = 1;
-	diff_tree_oid(&parent->tree->object.oid,
-		      &commit->tree->object.oid,
+	diff_tree_oid(&parent->maybe_tree->object.oid,
+		      &commit->maybe_tree->object.oid,
 		      "", &revs->diffopt);
 	diffcore_std(&revs->diffopt);
 
diff --git a/ui-plain.c b/ui-plain.c
index cfdbf73..ddb3e48 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -16,19 +16,19 @@ struct walk_tree_context {
 	int match;
 };
 
-static int print_object(const unsigned char *sha1, const char *path)
+static int print_object(const struct object_id *oid, const char *path)
 {
 	enum object_type type;
 	char *buf, *mimetype;
 	unsigned long size;
 
-	type = sha1_object_info(sha1, &size);
+	type = oid_object_info(the_repository, oid, &size);
 	if (type == OBJ_BAD) {
 		cgit_print_error_page(404, "Not found", "Not found");
 		return 0;
 	}
 
-	buf = read_sha1_file(sha1, &type, &size);
+	buf = read_object_file(oid, &type, &size);
 	if (!buf) {
 		cgit_print_error_page(404, "Not found", "Not found");
 		return 0;
@@ -57,7 +57,7 @@ static int print_object(const unsigned char *sha1, const char *path)
 	}
 	ctx.page.filename = path;
 	ctx.page.size = size;
-	ctx.page.etag = sha1_to_hex(sha1);
+	ctx.page.etag = oid_to_hex(oid);
 	cgit_print_http_headers();
 	html_raw(buf, size);
 	free(mimetype);
@@ -73,7 +73,7 @@ static char *buildpath(const char *base, int baselen, const char *path)
 		return fmtalloc("%.*s/", baselen, base);
 }
 
-static void print_dir(const unsigned char *sha1, const char *base,
+static void print_dir(const struct object_id *oid, const char *base,
 		      int baselen, const char *path)
 {
 	char *fullpath, *slash;
@@ -81,7 +81,7 @@ static void print_dir(const unsigned char *sha1, const char *base,
 
 	fullpath = buildpath(base, baselen, path);
 	slash = (fullpath[0] == '/' ? "" : "/");
-	ctx.page.etag = sha1_to_hex(sha1);
+	ctx.page.etag = oid_to_hex(oid);
 	cgit_print_http_headers();
 	htmlf("<html><head><title>%s", slash);
 	html_txt(fullpath);
@@ -106,7 +106,7 @@ static void print_dir(const unsigned char *sha1, const char *base,
 	free(fullpath);
 }
 
-static void print_dir_entry(const unsigned char *sha1, const char *base,
+static void print_dir_entry(const struct object_id *oid, const char *base,
 			    int baselen, const char *path, unsigned mode)
 {
 	char *fullpath;
@@ -116,7 +116,7 @@ static void print_dir_entry(const unsigned char *sha1, const char *base,
 		fullpath[strlen(fullpath) - 1] = 0;
 	html("  <li>");
 	if (S_ISGITLINK(mode)) {
-		cgit_submodule_link(NULL, fullpath, sha1_to_hex(sha1));
+		cgit_submodule_link(NULL, fullpath, oid_to_hex(oid));
 	} else
 		cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.sha1,
 				fullpath);
@@ -129,22 +129,22 @@ static void print_dir_tail(void)
 	html(" </ul>\n</body></html>\n");
 }
 
-static int walk_tree(const unsigned char *sha1, struct strbuf *base,
+static int walk_tree(const struct object_id *oid, struct strbuf *base,
 		const char *pathname, unsigned mode, int stage, void *cbdata)
 {
 	struct walk_tree_context *walk_tree_ctx = cbdata;
 
 	if (base->len == walk_tree_ctx->match_baselen) {
 		if (S_ISREG(mode) || S_ISLNK(mode)) {
-			if (print_object(sha1, pathname))
+			if (print_object(oid, pathname))
 				walk_tree_ctx->match = 1;
 		} else if (S_ISDIR(mode)) {
-			print_dir(sha1, base->buf, base->len, pathname);
+			print_dir(oid, base->buf, base->len, pathname);
 			walk_tree_ctx->match = 2;
 			return READ_TREE_RECURSIVE;
 		}
 	} else if (base->len < INT_MAX && (int)base->len > walk_tree_ctx->match_baselen) {
-		print_dir_entry(sha1, base->buf, base->len, pathname, mode);
+		print_dir_entry(oid, base->buf, base->len, pathname, mode);
 		walk_tree_ctx->match = 2;
 	} else if (S_ISDIR(mode)) {
 		return READ_TREE_RECURSIVE;
@@ -193,12 +193,12 @@ void cgit_print_plain(void)
 	if (!path_items.match) {
 		path_items.match = "";
 		walk_tree_ctx.match_baselen = -1;
-		print_dir(commit->tree->object.oid.hash, "", 0, "");
+		print_dir(&commit->maybe_tree->object.oid, "", 0, "");
 		walk_tree_ctx.match = 2;
 	}
 	else
 		walk_tree_ctx.match_baselen = basedir_len(path_items.match);
-	read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+	read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
 	if (!walk_tree_ctx.match)
 		cgit_print_error_page(404, "Not found", "Not found");
 	else if (walk_tree_ctx.match == 2)
diff --git a/ui-tree.c b/ui-tree.c
index 67fd1bc..c1864e8 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -84,30 +84,30 @@ static void print_binary_buffer(char *buf, unsigned long size)
 	html("</table>\n");
 }
 
-static void print_object(const unsigned char *sha1, char *path, const char *basename, const char *rev)
+static void print_object(const struct object_id *oid, char *path, const char *basename, const char *rev)
 {
 	enum object_type type;
 	char *buf;
 	unsigned long size;
 
-	type = sha1_object_info(sha1, &size);
+	type = oid_object_info(the_repository, oid, &size);
 	if (type == OBJ_BAD) {
 		cgit_print_error_page(404, "Not found",
-			"Bad object name: %s", sha1_to_hex(sha1));
+			"Bad object name: %s", oid_to_hex(oid));
 		return;
 	}
 
-	buf = read_sha1_file(sha1, &type, &size);
+	buf = read_object_file(oid, &type, &size);
 	if (!buf) {
 		cgit_print_error_page(500, "Internal server error",
-			"Error reading object %s", sha1_to_hex(sha1));
+			"Error reading object %s", oid_to_hex(oid));
 		return;
 	}
 
 	cgit_set_title_from_path(path);
 
 	cgit_print_layout_start();
-	htmlf("blob: %s (", sha1_to_hex(sha1));
+	htmlf("blob: %s (", oid_to_hex(oid));
 	cgit_plain_link("plain", NULL, NULL, ctx.qry.head,
 		        rev, path);
 	if (ctx.cfg.enable_blame) {
@@ -136,7 +136,7 @@ struct single_tree_ctx {
 	size_t count;
 };
 
-static int single_tree_cb(const unsigned char *sha1, struct strbuf *base,
+static int single_tree_cb(const struct object_id *oid, struct strbuf *base,
 			  const char *pathname, unsigned mode, int stage,
 			  void *cbdata)
 {
@@ -151,12 +151,12 @@ static int single_tree_cb(const unsigned char *sha1, struct strbuf *base,
 	}
 
 	ctx->name = xstrdup(pathname);
-	hashcpy(ctx->oid.hash, sha1);
+	oidcpy(&ctx->oid, oid);
 	strbuf_addf(ctx->path, "/%s", pathname);
 	return 0;
 }
 
-static void write_tree_link(const unsigned char *sha1, char *name,
+static void write_tree_link(const struct object_id *oid, char *name,
 			    char *rev, struct strbuf *fullpath)
 {
 	size_t initial_length = fullpath->len;
@@ -169,7 +169,7 @@ static void write_tree_link(const unsigned char *sha1, char *name,
 		.nr = 0
 	};
 
-	hashcpy(tree_ctx.oid.hash, sha1);
+	oidcpy(&tree_ctx.oid, oid);
 
 	while (tree_ctx.count == 1) {
 		cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, rev,
@@ -196,7 +196,7 @@ static void write_tree_link(const unsigned char *sha1, char *name,
 	strbuf_setlen(fullpath, initial_length);
 }
 
-static int ls_item(const unsigned char *sha1, struct strbuf *base,
+static int ls_item(const struct object_id *oid, struct strbuf *base,
 		const char *pathname, unsigned mode, int stage, void *cbdata)
 {
 	struct walk_tree_context *walk_tree_ctx = cbdata;
@@ -211,11 +211,11 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base,
 		    ctx.qry.path ? "/" : "", name);
 
 	if (!S_ISGITLINK(mode)) {
-		type = sha1_object_info(sha1, &size);
+		type = oid_object_info(the_repository, oid, &size);
 		if (type == OBJ_BAD) {
 			htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>",
 			      name,
-			      sha1_to_hex(sha1));
+			      oid_to_hex(oid));
 			free(name);
 			return 0;
 		}
@@ -225,9 +225,9 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base,
 	cgit_print_filemode(mode);
 	html("</td><td>");
 	if (S_ISGITLINK(mode)) {
-		cgit_submodule_link("ls-mod", fullpath.buf, sha1_to_hex(sha1));
+		cgit_submodule_link("ls-mod", fullpath.buf, oid_to_hex(oid));
 	} else if (S_ISDIR(mode)) {
-		write_tree_link(sha1, name, walk_tree_ctx->curr_rev,
+		write_tree_link(oid, name, walk_tree_ctx->curr_rev,
 				&fullpath);
 	} else {
 		char *ext = strrchr(name, '.');
@@ -287,7 +287,7 @@ static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_co
 	tree = parse_tree_indirect(oid);
 	if (!tree) {
 		cgit_print_error_page(404, "Not found",
-			"Not a tree object: %s", sha1_to_hex(oid->hash));
+			"Not a tree object: %s", oid_to_hex(oid));
 		return;
 	}
 
@@ -297,7 +297,7 @@ static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_co
 }
 
 
-static int walk_tree(const unsigned char *sha1, struct strbuf *base,
+static int walk_tree(const struct object_id *oid, struct strbuf *base,
 		const char *pathname, unsigned mode, int stage, void *cbdata)
 {
 	struct walk_tree_context *walk_tree_ctx = cbdata;
@@ -318,12 +318,12 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base,
 			return READ_TREE_RECURSIVE;
 		} else {
 			walk_tree_ctx->state = 2;
-			print_object(sha1, buffer.buf, pathname, walk_tree_ctx->curr_rev);
+			print_object(oid, buffer.buf, pathname, walk_tree_ctx->curr_rev);
 			strbuf_release(&buffer);
 			return 0;
 		}
 	}
-	ls_item(sha1, base, pathname, mode, stage, walk_tree_ctx);
+	ls_item(oid, base, pathname, mode, stage, walk_tree_ctx);
 	return 0;
 }
 
@@ -367,11 +367,11 @@ void cgit_print_tree(const char *rev, char *path)
 	walk_tree_ctx.curr_rev = xstrdup(rev);
 
 	if (path == NULL) {
-		ls_tree(&commit->tree->object.oid, NULL, &walk_tree_ctx);
+		ls_tree(&commit->maybe_tree->object.oid, NULL, &walk_tree_ctx);
 		goto cleanup;
 	}
 
-	read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+	read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
 	if (walk_tree_ctx.state == 1)
 		ls_tail();
 	else if (walk_tree_ctx.state == 2)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] ui-shared: typename changed to type_name in git 2.18.0-rc2
  2018-06-13 22:52 [PATCH 1/1] RFC: git: update to v2.18.0-rc2 list
@ 2018-06-14  1:48 ` andy
  2018-06-16 16:14 ` [PATCH 1/1] RFC: git: update to v2.18.0-rc2 john
  2018-06-18  6:10 ` list
  2 siblings, 0 replies; 7+ messages in thread
From: andy @ 2018-06-14  1:48 UTC (permalink / raw)


Signed-off-by: Andy Green <andy at warmcat.com>
---
 ui-shared.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui-shared.c b/ui-shared.c
index 9d8f66b..ce806f6 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -545,7 +545,7 @@ void cgit_object_link(struct object *obj)
 		page = "tag";
 	else
 		page = "blob";
-	name = fmt("%s %s...", typename(obj->type), shortrev);
+	name = fmt("%s %s...", type_name(obj->type), shortrev);
 	reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL);
 }
 



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/1] RFC: git: update to v2.18.0-rc2
  2018-06-13 22:52 [PATCH 1/1] RFC: git: update to v2.18.0-rc2 list
  2018-06-14  1:48 ` [PATCH] ui-shared: typename changed to type_name in git 2.18.0-rc2 andy
@ 2018-06-16 16:14 ` john
  2018-06-16 16:15   ` Jason
  2018-06-16 20:34   ` list
  2018-06-18  6:10 ` list
  2 siblings, 2 replies; 7+ messages in thread
From: john @ 2018-06-16 16:14 UTC (permalink / raw)


On Thu, Jun 14, 2018 at 12:52:25AM +0200, Christian Hesse wrote:
> From: Christian Hesse <mail at eworm.de>
> 
> Update to git version v2.18.0-rc2. Required changes follow upstream commits:
> 
> * Convert find_unique_abbrev* to struct object_id
>   (aab9583f7b5ea5463eb3f653a0b4ecac7539dc94)
> * sha1_file: convert read_sha1_file to struct object_id
>   (b4f5aca40e6f77cbabcbf4ff003c3cf30a1830c8)
> * sha1_file: convert sha1_object_info* to object_id
>   (abef9020e3df87c441c9a3a95f592fce5fa49bb9)
> * object-store: move packed_git and packed_git_mru to object store
>   (a80d72db2a73174b3f22142eb2014b33696fd795)
> * treewide: rename tree to maybe_tree
>   (891435d55da80ca3654b19834481205be6bdfe33)
> 
> The changed data types required some of our own functions to be converted
> to struct object_id:
> 
>   ls_item
>   print_dir
>   print_dir_entry
>   print_object
>   single_tree_cb
>   walk_tree
>   write_tree_link
> 
> And finally we use new upstream functions that were added for
> struct object_id:
> 
>   hashcpy     -> oidcpy
>   sha1_to_hex -> oid_to_hex
> 
> Signed-off-by: Christian Hesse <mail at eworm.de>

With Andy's fix,

Reviewed-by: John Keeping <john at keeping.me.uk>

It looks like our interface to libgit.a is completely converted to
struct object_id after this update!

But we still have a few mentions of sha1 in our code.  Most of this is
sha1 and sha2 in struct cgit_query, but these aren't actually hashes
most of the time, they can be any object reference that Git understands,
so I think we should rename them to ref1 and ref2 (along with has_sha1
-> has_ref).  What do you think?

(ui-blob does require sha1 to be hex, but it's a bit of a special case
anyway and I think it's fine to impose an extra requirement there.)

After that, I think all that's left is parsing.c and there's no reason
to do anything there until we now how newhash will alter the commit and
tag object encodings.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/1] RFC: git: update to v2.18.0-rc2
  2018-06-16 16:14 ` [PATCH 1/1] RFC: git: update to v2.18.0-rc2 john
@ 2018-06-16 16:15   ` Jason
  2018-06-16 20:34   ` list
  1 sibling, 0 replies; 7+ messages in thread
From: Jason @ 2018-06-16 16:15 UTC (permalink / raw)


On Sat, Jun 16, 2018 at 6:14 PM John Keeping <john at keeping.me.uk> wrote:
> But we still have a few mentions of sha1 in our code.  Most of this is
> sha1 and sha2 in struct cgit_query, but these aren't actually hashes
> most of the time, they can be any object reference that Git understands,
> so I think we should rename them to ref1 and ref2 (along with has_sha1
> -> has_ref).  What do you think?

Yes, please. This is some excellent progress.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/1] RFC: git: update to v2.18.0-rc2
  2018-06-16 16:14 ` [PATCH 1/1] RFC: git: update to v2.18.0-rc2 john
  2018-06-16 16:15   ` Jason
@ 2018-06-16 20:34   ` list
  1 sibling, 0 replies; 7+ messages in thread
From: list @ 2018-06-16 20:34 UTC (permalink / raw)


John Keeping <john at keeping.me.uk> on Sat, 2018/06/16 17:14:
> With Andy's fix,
> 
> Reviewed-by: John Keeping <john at keeping.me.uk>

That is in git 2.17.1 commit already. ;)
-- 
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: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20180616/058ef84c/attachment.asc>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/1] RFC: git: update to v2.18.0-rc2
  2018-06-13 22:52 [PATCH 1/1] RFC: git: update to v2.18.0-rc2 list
  2018-06-14  1:48 ` [PATCH] ui-shared: typename changed to type_name in git 2.18.0-rc2 andy
  2018-06-16 16:14 ` [PATCH 1/1] RFC: git: update to v2.18.0-rc2 john
@ 2018-06-18  6:10 ` list
  2018-06-18  6:42   ` andy
  2 siblings, 1 reply; 7+ messages in thread
From: list @ 2018-06-18  6:10 UTC (permalink / raw)


Christian Hesse <list at eworm.de> on Thu, 2018/06/14 00:52:
> Update to git version v2.18.0-rc2. Required changes follow upstream commits:

I've pushed John's snapshot series to ch/for-jason. Does anybody agree that
we want that? I will rebase the final commit on ch/for-jason then.
-- 
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: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20180618/5f2c5fa4/attachment.asc>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/1] RFC: git: update to v2.18.0-rc2
  2018-06-18  6:10 ` list
@ 2018-06-18  6:42   ` andy
  0 siblings, 0 replies; 7+ messages in thread
From: andy @ 2018-06-18  6:42 UTC (permalink / raw)




On 06/18/2018 02:10 PM, Christian Hesse wrote:
> Christian Hesse <list at eworm.de> on Thu, 2018/06/14 00:52:
>> Update to git version v2.18.0-rc2. Required changes follow upstream commits:
> 
> I've pushed John's snapshot series to ch/for-jason. Does anybody agree that
> we want that? I will rebase the final commit on ch/for-jason then.

FWIW ch/for-jason, with your v2.18.0-rc2 patch on top, and then my stuff 
is here

https://warmcat.com/git/cgit/log/?h=rebase-on-ch

-Andy

> 
> _______________________________________________
> CGit mailing list
> CGit at lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/cgit
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-06-18  6:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-13 22:52 [PATCH 1/1] RFC: git: update to v2.18.0-rc2 list
2018-06-14  1:48 ` [PATCH] ui-shared: typename changed to type_name in git 2.18.0-rc2 andy
2018-06-16 16:14 ` [PATCH 1/1] RFC: git: update to v2.18.0-rc2 john
2018-06-16 16:15   ` Jason
2018-06-16 20:34   ` list
2018-06-18  6:10 ` list
2018-06-18  6:42   ` andy

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).