git: update to v2.14

Numerous changes were made to git functions to use an object_id
structure rather than sending sha1 hashes as raw unsigned character
arrays.  The functions that affect cgit are: parse_object,
lookup_commit_reference, lookup_tag, lookup_tree, parse_tree_indirect,
diff_root_tree_sha1, diff_tree_sha1, and format_display_notes.

Commit b2141fc (config: don't include config.h by default) made it
necessary to that config.h be explicitly included when needed.

Commit 07a3d41 (grep: remove regflags from the public grep_opt API)
removed one way of specifying the ignore-case grep option.

Signed-off-by: Jeff Smith <whydoubt@gmail.com>
This commit is contained in:
Jeff Smith 2017-08-09 19:02:56 -05:00 committed by Lukas Fleischer
parent 3d33b46df2
commit d08d6fcb19
14 changed files with 44 additions and 43 deletions

View File

@ -14,7 +14,7 @@ htmldir = $(docdir)
pdfdir = $(docdir) pdfdir = $(docdir)
mandir = $(prefix)/share/man mandir = $(prefix)/share/man
SHA1_HEADER = <openssl/sha.h> SHA1_HEADER = <openssl/sha.h>
GIT_VER = 2.13.4 GIT_VER = 2.14.0
GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz
INSTALL = install INSTALL = install
COPYTREE = cp -r COPYTREE = cp -r

2
git

@ -1 +1 @@
Subproject commit cf8899d285d2648013040ec7196ffd3de0606664 Subproject commit 4384e3cde2ce8ecd194202e171ae16333d241326

View File

@ -10,6 +10,7 @@
#include "scan-tree.h" #include "scan-tree.h"
#include "configfile.h" #include "configfile.h"
#include "html.h" #include "html.h"
#include "config.h"
/* return 1 if path contains a objects/ directory and a HEAD file */ /* return 1 if path contains a objects/ directory and a HEAD file */
static int is_git_dir(const char *path) static int is_git_dir(const char *path)
@ -48,7 +49,7 @@ out:
static struct cgit_repo *repo; static struct cgit_repo *repo;
static repo_config_fn config_fn; static repo_config_fn config_fn;
static void repo_config(const char *name, const char *value) static void scan_tree_repo_config(const char *name, const char *value)
{ {
config_fn(repo, name, value); config_fn(repo, name, value);
} }
@ -178,7 +179,7 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
strbuf_addstr(path, "cgitrc"); strbuf_addstr(path, "cgitrc");
if (!stat(path->buf, &st)) if (!stat(path->buf, &st))
parse_configfile(path->buf, &repo_config); parse_configfile(path->buf, &scan_tree_repo_config);
strbuf_release(&rel); strbuf_release(&rel);
} }

View File

@ -160,7 +160,7 @@ static struct refinfo *cgit_mk_refinfo(const char *refname, const struct object_
ref = xmalloc(sizeof (struct refinfo)); ref = xmalloc(sizeof (struct refinfo));
ref->refname = xstrdup(refname); ref->refname = xstrdup(refname);
ref->object = parse_object(oid->hash); ref->object = parse_object(oid);
switch (ref->object->type) { switch (ref->object->type) {
case OBJ_TAG: case OBJ_TAG:
ref->tag = cgit_parse_tag((struct tag *)ref->object); ref->tag = cgit_parse_tag((struct tag *)ref->object);
@ -360,9 +360,9 @@ void cgit_diff_tree(const struct object_id *old_oid,
diff_setup_done(&opt); diff_setup_done(&opt);
if (old_oid && !is_null_oid(old_oid)) if (old_oid && !is_null_oid(old_oid))
diff_tree_sha1(old_oid->hash, new_oid->hash, "", &opt); diff_tree_oid(old_oid, new_oid, "", &opt);
else else
diff_root_tree_sha1(new_oid->hash, "", &opt); diff_root_tree_oid(new_oid, "", &opt);
diffcore_std(&opt); diffcore_std(&opt);
diff_flush(&opt); diff_flush(&opt);

View File

@ -56,7 +56,7 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only)
goto done; goto done;
if (sha1_object_info(oid.hash, &size) != OBJ_COMMIT) if (sha1_object_info(oid.hash, &size) != OBJ_COMMIT)
goto done; goto done;
read_tree_recursive(lookup_commit_reference(oid.hash)->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); read_tree_recursive(lookup_commit_reference(&oid)->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
done: done:
free(path_items.match); free(path_items.match);
@ -89,7 +89,7 @@ int cgit_print_file(char *path, const char *head, int file_only)
return -1; return -1;
type = sha1_object_info(oid.hash, &size); type = sha1_object_info(oid.hash, &size);
if (type == OBJ_COMMIT) { if (type == OBJ_COMMIT) {
commit = lookup_commit_reference(oid.hash); commit = lookup_commit_reference(&oid);
read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
if (!walk_tree_ctx.found_path) if (!walk_tree_ctx.found_path)
return -1; return -1;
@ -145,7 +145,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
type = sha1_object_info(oid.hash, &size); type = sha1_object_info(oid.hash, &size);
if ((!hex) && type == OBJ_COMMIT && path) { if ((!hex) && type == OBJ_COMMIT && path) {
commit = lookup_commit_reference(oid.hash); commit = lookup_commit_reference(&oid);
read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
type = sha1_object_info(oid.hash, &size); type = sha1_object_info(oid.hash, &size);
} }

View File

@ -17,7 +17,7 @@ static int print_ref_info(const char *refname, const struct object_id *oid,
{ {
struct object *obj; struct object *obj;
if (!(obj = parse_object(oid->hash))) if (!(obj = parse_object(oid)))
return 0; return 0;
htmlf("%s\t%s\n", oid_to_hex(oid), refname); htmlf("%s\t%s\n", oid_to_hex(oid), refname);

View File

@ -31,7 +31,7 @@ void cgit_print_commit(char *hex, const char *prefix)
"Bad object id: %s", hex); "Bad object id: %s", hex);
return; return;
} }
commit = lookup_commit_reference(oid.hash); commit = lookup_commit_reference(&oid);
if (!commit) { if (!commit) {
cgit_print_error_page(404, "Not found", cgit_print_error_page(404, "Not found",
"Bad commit reference: %s", hex); "Bad commit reference: %s", hex);
@ -39,7 +39,7 @@ void cgit_print_commit(char *hex, const char *prefix)
} }
info = cgit_parse_commit(commit); info = cgit_parse_commit(commit);
format_display_notes(oid.hash, &notes, PAGE_ENCODING, 0); format_display_notes(&oid, &notes, PAGE_ENCODING, 0);
load_ref_decorations(DECORATE_FULL_REFS); load_ref_decorations(DECORATE_FULL_REFS);
@ -87,7 +87,7 @@ void cgit_print_commit(char *hex, const char *prefix)
free(tmp); free(tmp);
html("</td></tr>\n"); html("</td></tr>\n");
for (p = commit->parents; p; p = p->next) { for (p = commit->parents; p; p = p->next) {
parent = lookup_commit_reference(p->item->object.oid.hash); parent = lookup_commit_reference(&p->item->object.oid);
if (!parent) { if (!parent) {
html("<tr><td colspan='3'>"); html("<tr><td colspan='3'>");
cgit_print_error("Error reading parent commit"); cgit_print_error("Error reading parent commit");

View File

@ -385,7 +385,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
const char *prefix, int show_ctrls, int raw) const char *prefix, int show_ctrls, int raw)
{ {
struct commit *commit, *commit2; struct commit *commit, *commit2;
const unsigned char *old_tree_sha1, *new_tree_sha1; const struct object_id *old_tree_oid, *new_tree_oid;
diff_type difftype; diff_type difftype;
/* /*
@ -407,13 +407,13 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
"Bad object name: %s", new_rev); "Bad object name: %s", new_rev);
return; return;
} }
commit = lookup_commit_reference(new_rev_oid->hash); commit = lookup_commit_reference(new_rev_oid);
if (!commit || parse_commit(commit)) { if (!commit || parse_commit(commit)) {
cgit_print_error_page(404, "Not found", cgit_print_error_page(404, "Not found",
"Bad commit: %s", oid_to_hex(new_rev_oid)); "Bad commit: %s", oid_to_hex(new_rev_oid));
return; return;
} }
new_tree_sha1 = commit->tree->object.oid.hash; new_tree_oid = &commit->tree->object.oid;
if (old_rev) { if (old_rev) {
if (get_oid(old_rev, old_rev_oid)) { if (get_oid(old_rev, old_rev_oid)) {
@ -428,15 +428,15 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
} }
if (!is_null_oid(old_rev_oid)) { if (!is_null_oid(old_rev_oid)) {
commit2 = lookup_commit_reference(old_rev_oid->hash); commit2 = lookup_commit_reference(old_rev_oid);
if (!commit2 || parse_commit(commit2)) { if (!commit2 || parse_commit(commit2)) {
cgit_print_error_page(404, "Not found", cgit_print_error_page(404, "Not found",
"Bad commit: %s", oid_to_hex(old_rev_oid)); "Bad commit: %s", oid_to_hex(old_rev_oid));
return; return;
} }
old_tree_sha1 = commit2->tree->object.oid.hash; old_tree_oid = &commit2->tree->object.oid;
} else { } else {
old_tree_sha1 = NULL; old_tree_oid = NULL;
} }
if (raw) { if (raw) {
@ -449,11 +449,11 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
ctx.page.mimetype = "text/plain"; ctx.page.mimetype = "text/plain";
cgit_print_http_headers(); cgit_print_http_headers();
if (old_tree_sha1) { if (old_tree_oid) {
diff_tree_sha1(old_tree_sha1, new_tree_sha1, "", diff_tree_oid(old_tree_oid, new_tree_oid, "",
&diffopt); &diffopt);
} else { } else {
diff_root_tree_sha1(new_tree_sha1, "", &diffopt); diff_root_tree_oid(new_tree_oid, "", &diffopt);
} }
diffcore_std(&diffopt); diffcore_std(&diffopt);
diff_flush(&diffopt); diff_flush(&diffopt);

View File

@ -150,8 +150,8 @@ static int show_commit(struct commit *commit, struct rev_info *revs)
rem_lines = 0; rem_lines = 0;
DIFF_OPT_SET(&revs->diffopt, RECURSIVE); DIFF_OPT_SET(&revs->diffopt, RECURSIVE);
diff_tree_sha1(parent->tree->object.oid.hash, diff_tree_oid(&parent->tree->object.oid,
commit->tree->object.oid.hash, &commit->tree->object.oid,
"", &revs->diffopt); "", &revs->diffopt);
diffcore_std(&revs->diffopt); diffcore_std(&revs->diffopt);
@ -273,7 +273,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
strbuf_addstr(&msgbuf, info->msg); strbuf_addstr(&msgbuf, info->msg);
strbuf_addch(&msgbuf, '\n'); strbuf_addch(&msgbuf, '\n');
} }
format_display_notes(commit->object.oid.hash, format_display_notes(&commit->object.oid,
&msgbuf, PAGE_ENCODING, 0); &msgbuf, PAGE_ENCODING, 0);
strbuf_addch(&msgbuf, '\n'); strbuf_addch(&msgbuf, '\n');
strbuf_ltrim(&msgbuf); strbuf_ltrim(&msgbuf);
@ -436,7 +436,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
setup_revisions(rev_argv.argc, rev_argv.argv, &rev, NULL); setup_revisions(rev_argv.argc, rev_argv.argv, &rev, NULL);
load_ref_decorations(DECORATE_FULL_REFS); load_ref_decorations(DECORATE_FULL_REFS);
rev.show_decorations = 1; rev.show_decorations = 1;
rev.grep_filter.regflags |= REG_ICASE; rev.grep_filter.ignore_case = 1;
rev.diffopt.detect_rename = 1; rev.diffopt.detect_rename = 1;
rev.diffopt.rename_limit = ctx.cfg.renamelimit; rev.diffopt.rename_limit = ctx.cfg.renamelimit;

View File

@ -33,7 +33,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
"Bad object id: %s", new_rev); "Bad object id: %s", new_rev);
return; return;
} }
commit = lookup_commit_reference(new_rev_oid.hash); commit = lookup_commit_reference(&new_rev_oid);
if (!commit) { if (!commit) {
cgit_print_error_page(404, "Not found", cgit_print_error_page(404, "Not found",
"Bad commit reference: %s", new_rev); "Bad commit reference: %s", new_rev);
@ -46,7 +46,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
"Bad object id: %s", old_rev); "Bad object id: %s", old_rev);
return; return;
} }
if (!lookup_commit_reference(old_rev_oid.hash)) { if (!lookup_commit_reference(&old_rev_oid)) {
cgit_print_error_page(404, "Not found", cgit_print_error_page(404, "Not found",
"Bad commit reference: %s", old_rev); "Bad commit reference: %s", old_rev);
return; return;

View File

@ -185,7 +185,7 @@ void cgit_print_plain(void)
cgit_print_error_page(404, "Not found", "Not found"); cgit_print_error_page(404, "Not found", "Not found");
return; return;
} }
commit = lookup_commit_reference(oid.hash); commit = lookup_commit_reference(&oid);
if (!commit || parse_commit(commit)) { if (!commit || parse_commit(commit)) {
cgit_print_error_page(404, "Not found", "Not found"); cgit_print_error_page(404, "Not found", "Not found");
return; return;

View File

@ -116,7 +116,7 @@ static int make_snapshot(const struct cgit_snapshot_format *format,
"Bad object id: %s", hex); "Bad object id: %s", hex);
return 1; return 1;
} }
if (!lookup_commit_reference(oid.hash)) { if (!lookup_commit_reference(&oid)) {
cgit_print_error_page(400, "Bad request", cgit_print_error_page(400, "Bad request",
"Not a commit reference: %s", hex); "Not a commit reference: %s", hex);
return 1; return 1;

View File

@ -54,7 +54,7 @@ void cgit_print_tag(char *revname)
"Bad tag reference: %s", revname); "Bad tag reference: %s", revname);
goto cleanup; goto cleanup;
} }
obj = parse_object(oid.hash); obj = parse_object(&oid);
if (!obj) { if (!obj) {
cgit_print_error_page(500, "Internal server error", cgit_print_error_page(500, "Internal server error",
"Bad object id: %s", oid_to_hex(&oid)); "Bad object id: %s", oid_to_hex(&oid));
@ -64,7 +64,7 @@ void cgit_print_tag(char *revname)
struct tag *tag; struct tag *tag;
struct taginfo *info; struct taginfo *info;
tag = lookup_tag(oid.hash); tag = lookup_tag(&oid);
if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) {
cgit_print_error_page(500, "Internal server error", cgit_print_error_page(500, "Internal server error",
"Bad tag object: %s", revname); "Bad tag object: %s", revname);

View File

@ -157,7 +157,7 @@ static void print_object(const unsigned char *sha1, char *path, const char *base
struct single_tree_ctx { struct single_tree_ctx {
struct strbuf *path; struct strbuf *path;
unsigned char sha1[GIT_SHA1_RAWSZ]; struct object_id oid;
char *name; char *name;
size_t count; size_t count;
}; };
@ -177,7 +177,7 @@ static int single_tree_cb(const unsigned char *sha1, struct strbuf *base,
} }
ctx->name = xstrdup(pathname); ctx->name = xstrdup(pathname);
hashcpy(ctx->sha1, sha1); hashcpy(ctx->oid.hash, sha1);
strbuf_addf(ctx->path, "/%s", pathname); strbuf_addf(ctx->path, "/%s", pathname);
return 0; return 0;
} }
@ -195,13 +195,13 @@ static void write_tree_link(const unsigned char *sha1, char *name,
.nr = 0 .nr = 0
}; };
hashcpy(tree_ctx.sha1, sha1); hashcpy(tree_ctx.oid.hash, sha1);
while (tree_ctx.count == 1) { while (tree_ctx.count == 1) {
cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, rev, cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, rev,
fullpath->buf); fullpath->buf);
tree = lookup_tree(tree_ctx.sha1); tree = lookup_tree(&tree_ctx.oid);
if (!tree) if (!tree)
return; return;
@ -300,17 +300,17 @@ static void ls_tail(void)
cgit_print_layout_end(); cgit_print_layout_end();
} }
static void ls_tree(const unsigned char *sha1, char *path, struct walk_tree_context *walk_tree_ctx) static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_context *walk_tree_ctx)
{ {
struct tree *tree; struct tree *tree;
struct pathspec paths = { struct pathspec paths = {
.nr = 0 .nr = 0
}; };
tree = parse_tree_indirect(sha1); tree = parse_tree_indirect(oid);
if (!tree) { if (!tree) {
cgit_print_error_page(404, "Not found", cgit_print_error_page(404, "Not found",
"Not a tree object: %s", sha1_to_hex(sha1)); "Not a tree object: %s", sha1_to_hex(oid->hash));
return; return;
} }
@ -380,7 +380,7 @@ void cgit_print_tree(const char *rev, char *path)
"Invalid revision name: %s", rev); "Invalid revision name: %s", rev);
return; return;
} }
commit = lookup_commit_reference(oid.hash); commit = lookup_commit_reference(&oid);
if (!commit || parse_commit(commit)) { if (!commit || parse_commit(commit)) {
cgit_print_error_page(404, "Not found", cgit_print_error_page(404, "Not found",
"Invalid commit reference: %s", rev); "Invalid commit reference: %s", rev);
@ -390,7 +390,7 @@ void cgit_print_tree(const char *rev, char *path)
walk_tree_ctx.curr_rev = xstrdup(rev); walk_tree_ctx.curr_rev = xstrdup(rev);
if (path == NULL) { if (path == NULL) {
ls_tree(commit->tree->object.oid.hash, NULL, &walk_tree_ctx); ls_tree(&commit->tree->object.oid, NULL, &walk_tree_ctx);
goto cleanup; goto cleanup;
} }