List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH 1/1] git: preview for v2.3.0-rc0
@ 2015-01-13  8:56 list
  2015-01-13  9:43 ` john
  0 siblings, 1 reply; 7+ messages in thread
From: list @ 2015-01-13  8:56 UTC (permalink / raw)


From: Christian Hesse <mail at eworm.de>

* sort_string_list(): rename to string_list_sort() (upstream commit 3383e199)
* update read_tree_recursive callback to pass strbuf as base (upstream
  commit 6a0b0b6d)

Signed-off-by: Christian Hesse <mail at eworm.de>
---
 Makefile   |  4 ++--
 cgit.c     |  2 +-
 git        |  2 +-
 ui-blob.c  | 14 +++++++++++---
 ui-plain.c | 10 +++++++++-
 ui-tree.c  | 21 +++++++++++++++++++--
 6 files changed, 43 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index 38bf595..36c30a8 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.2.1
-GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz
+GIT_VER = 2.3.0.rc0
+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/cgit.c b/cgit.c
index 79019c2..df301ea 100644
--- a/cgit.c
+++ b/cgit.c
@@ -599,7 +599,7 @@ static int prepare_repo_cmd(void)
 		free(tmp);
 		return 1;
 	}
-	sort_string_list(&ctx.repo->submodules);
+	string_list_sort(&ctx.repo->submodules);
 	cgit_prepare_repo_env(ctx.repo);
 	choose_readme(ctx.repo);
 	return 0;
diff --git a/git b/git
index 9b7cbb3..addfb21 160000
--- a/git
+++ b/git
@@ -1 +1 @@
-Subproject commit 9b7cbb315923e61bb0c4297c701089f30e116750
+Subproject commit addfb21a94fb4e6b9d07b270f7bb3748767a8f38
diff --git a/ui-blob.c b/ui-blob.c
index c2de8d6..90fcf81 100644
--- a/ui-blob.c
+++ b/ui-blob.c
@@ -33,6 +33,14 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
 	return 0;
 }
 
+static int walk_tree_buf(const unsigned char *sha1, struct strbuf *base,
+	const char *filename, unsigned mode, int stage,
+	void *context)
+{
+	return walk_tree(sha1, base->buf, base->len,
+		filename, mode, stage, context);
+}
+
 int cgit_ref_path_exists(const char *path, const char *ref, int file_only)
 {
 	unsigned char sha1[20];
@@ -56,7 +64,7 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only)
 		return 0;
 	if (sha1_object_info(sha1, &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(sha1)->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
 	return walk_tree_ctx.found_path;
 }
 
@@ -87,7 +95,7 @@ int cgit_print_file(char *path, const char *head, int file_only)
 	type = sha1_object_info(sha1, &size);
 	if (type == OBJ_COMMIT && path) {
 		commit = lookup_commit_reference(sha1);
-		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
 		if (!walk_tree_ctx.found_path)
 			return -1;
 		type = sha1_object_info(sha1, &size);
@@ -140,7 +148,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
 
 	if ((!hex) && type == OBJ_COMMIT && path) {
 		commit = lookup_commit_reference(sha1);
-		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
 		type = sha1_object_info(sha1,&size);
 	}
 
diff --git a/ui-plain.c b/ui-plain.c
index 30fff89..891e9f7 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -198,6 +198,14 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
 	return 0;
 }
 
+static int walk_tree_buf(const unsigned char *sha1, struct strbuf *base,
+	const char *filename, unsigned mode, int stage,
+	void *context)
+{
+	return walk_tree(sha1, base->buf, base->len,
+		filename, mode, stage, context);
+}
+
 static int basedir_len(const char *path)
 {
 	char *p = strrchr(path, '/');
@@ -243,7 +251,7 @@ void cgit_print_plain(void)
 	}
 	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->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
 	if (!walk_tree_ctx.match)
 		html_status(404, "Not found", 0);
 	else if (walk_tree_ctx.match == 2)
diff --git a/ui-tree.c b/ui-tree.c
index e4c3d22..7cc45e9 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -181,6 +181,15 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
 	return 0;
 }
 
+static int ls_item_buf(const unsigned char *sha1, struct strbuf *base,
+	const char *filename, unsigned mode, int stage,
+	void *context)
+{
+	return ls_item(sha1, base->buf, base->len,
+		filename, mode, stage, context);
+}
+
+
 static void ls_head()
 {
 	html("<table summary='tree listing' class='list'>\n");
@@ -211,7 +220,7 @@ static void ls_tree(const unsigned char *sha1, char *path, struct walk_tree_cont
 	}
 
 	ls_head();
-	read_tree_recursive(tree, "", 0, 1, &paths, ls_item, walk_tree_ctx);
+	read_tree_recursive(tree, "", 0, 1, &paths, ls_item_buf, walk_tree_ctx);
 	ls_tail();
 }
 
@@ -242,6 +251,14 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
 	return 0;
 }
 
+static int walk_tree_buf(const unsigned char *sha1, struct strbuf *base,
+	const char *filename, unsigned mode, int stage,
+	void *context)
+{
+	return walk_tree(sha1, base->buf, base->len,
+		filename, mode, stage, context);
+}
+
 
 /*
  * Show a tree or a blob
@@ -285,7 +302,7 @@ void cgit_print_tree(const char *rev, char *path)
 		goto cleanup;
 	}
 
-	read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+	read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
 	if (walk_tree_ctx.state == 1)
 		ls_tail();
 
-- 
2.2.1



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

* [PATCH 1/1] git: preview for v2.3.0-rc0
  2015-01-13  8:56 [PATCH 1/1] git: preview for v2.3.0-rc0 list
@ 2015-01-13  9:43 ` john
  2015-01-13  9:57   ` list
  0 siblings, 1 reply; 7+ messages in thread
From: john @ 2015-01-13  9:43 UTC (permalink / raw)


On Tue, Jan 13, 2015 at 09:56:47AM +0100, list at eworm.de wrote:
> From: Christian Hesse <mail at eworm.de>
> 
> * sort_string_list(): rename to string_list_sort() (upstream commit 3383e199)
> * update read_tree_recursive callback to pass strbuf as base (upstream
>   commit 6a0b0b6d)
> 
> Signed-off-by: Christian Hesse <mail at eworm.de>
> ---
>  Makefile   |  4 ++--
>  cgit.c     |  2 +-
>  git        |  2 +-
>  ui-blob.c  | 14 +++++++++++---
>  ui-plain.c | 10 +++++++++-
>  ui-tree.c  | 21 +++++++++++++++++++--
>  6 files changed, 43 insertions(+), 10 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 38bf595..36c30a8 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.2.1
> -GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz
> +GIT_VER = 2.3.0.rc0
> +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/cgit.c b/cgit.c
> index 79019c2..df301ea 100644
> --- a/cgit.c
> +++ b/cgit.c
> @@ -599,7 +599,7 @@ static int prepare_repo_cmd(void)
>  		free(tmp);
>  		return 1;
>  	}
> -	sort_string_list(&ctx.repo->submodules);
> +	string_list_sort(&ctx.repo->submodules);
>  	cgit_prepare_repo_env(ctx.repo);
>  	choose_readme(ctx.repo);
>  	return 0;
> diff --git a/git b/git
> index 9b7cbb3..addfb21 160000
> --- a/git
> +++ b/git
> @@ -1 +1 @@
> -Subproject commit 9b7cbb315923e61bb0c4297c701089f30e116750
> +Subproject commit addfb21a94fb4e6b9d07b270f7bb3748767a8f38
> diff --git a/ui-blob.c b/ui-blob.c
> index c2de8d6..90fcf81 100644
> --- a/ui-blob.c
> +++ b/ui-blob.c
> @@ -33,6 +33,14 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
>  	return 0;
>  }
>  
> +static int walk_tree_buf(const unsigned char *sha1, struct strbuf *base,
> +	const char *filename, unsigned mode, int stage,
> +	void *context)
> +{
> +	return walk_tree(sha1, base->buf, base->len,
> +		filename, mode, stage, context);
> +}
> +

Is there any benefit to introducing a new function here?  In other
words, is walk_tree() used anywhere else?  If not, wouldn't it be
simpler to update the signature of the existing function?

(The same comment applies to several other places below.)

>  int cgit_ref_path_exists(const char *path, const char *ref, int file_only)
>  {
>  	unsigned char sha1[20];
> @@ -56,7 +64,7 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only)
>  		return 0;
>  	if (sha1_object_info(sha1, &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(sha1)->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
>  	return walk_tree_ctx.found_path;
>  }
>  
> @@ -87,7 +95,7 @@ int cgit_print_file(char *path, const char *head, int file_only)
>  	type = sha1_object_info(sha1, &size);
>  	if (type == OBJ_COMMIT && path) {
>  		commit = lookup_commit_reference(sha1);
> -		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
> +		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
>  		if (!walk_tree_ctx.found_path)
>  			return -1;
>  		type = sha1_object_info(sha1, &size);
> @@ -140,7 +148,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
>  
>  	if ((!hex) && type == OBJ_COMMIT && path) {
>  		commit = lookup_commit_reference(sha1);
> -		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
> +		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
>  		type = sha1_object_info(sha1,&size);
>  	}
>  
> diff --git a/ui-plain.c b/ui-plain.c
> index 30fff89..891e9f7 100644
> --- a/ui-plain.c
> +++ b/ui-plain.c
> @@ -198,6 +198,14 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
>  	return 0;
>  }
>  
> +static int walk_tree_buf(const unsigned char *sha1, struct strbuf *base,
> +	const char *filename, unsigned mode, int stage,
> +	void *context)
> +{
> +	return walk_tree(sha1, base->buf, base->len,
> +		filename, mode, stage, context);
> +}
> +
>  static int basedir_len(const char *path)
>  {
>  	char *p = strrchr(path, '/');
> @@ -243,7 +251,7 @@ void cgit_print_plain(void)
>  	}
>  	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->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
>  	if (!walk_tree_ctx.match)
>  		html_status(404, "Not found", 0);
>  	else if (walk_tree_ctx.match == 2)
> diff --git a/ui-tree.c b/ui-tree.c
> index e4c3d22..7cc45e9 100644
> --- a/ui-tree.c
> +++ b/ui-tree.c
> @@ -181,6 +181,15 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
>  	return 0;
>  }
>  
> +static int ls_item_buf(const unsigned char *sha1, struct strbuf *base,
> +	const char *filename, unsigned mode, int stage,
> +	void *context)
> +{
> +	return ls_item(sha1, base->buf, base->len,
> +		filename, mode, stage, context);
> +}
> +
> +
>  static void ls_head()
>  {
>  	html("<table summary='tree listing' class='list'>\n");
> @@ -211,7 +220,7 @@ static void ls_tree(const unsigned char *sha1, char *path, struct walk_tree_cont
>  	}
>  
>  	ls_head();
> -	read_tree_recursive(tree, "", 0, 1, &paths, ls_item, walk_tree_ctx);
> +	read_tree_recursive(tree, "", 0, 1, &paths, ls_item_buf, walk_tree_ctx);
>  	ls_tail();
>  }
>  
> @@ -242,6 +251,14 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
>  	return 0;
>  }
>  
> +static int walk_tree_buf(const unsigned char *sha1, struct strbuf *base,
> +	const char *filename, unsigned mode, int stage,
> +	void *context)
> +{
> +	return walk_tree(sha1, base->buf, base->len,
> +		filename, mode, stage, context);
> +}
> +
>  
>  /*
>   * Show a tree or a blob
> @@ -285,7 +302,7 @@ void cgit_print_tree(const char *rev, char *path)
>  		goto cleanup;
>  	}
>  
> -	read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
> +	read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
>  	if (walk_tree_ctx.state == 1)
>  		ls_tail();
>  
> -- 
> 2.2.1
> 
> _______________________________________________
> CGit mailing list
> CGit at lists.zx2c4.com
> http://lists.zx2c4.com/mailman/listinfo/cgit


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

* [PATCH 1/1] git: preview for v2.3.0-rc0
  2015-01-13  9:43 ` john
@ 2015-01-13  9:57   ` list
  2015-01-13 10:09     ` john
  2015-01-14 15:34     ` [PATCH v2 " list
  0 siblings, 2 replies; 7+ messages in thread
From: list @ 2015-01-13  9:57 UTC (permalink / raw)


John Keeping <john at keeping.me.uk> on Tue, 2015/01/13 09:43:
> On Tue, Jan 13, 2015 at 09:56:47AM +0100, list at eworm.de wrote:
> > From: Christian Hesse <mail at eworm.de>
> > 
> > * sort_string_list(): rename to string_list_sort() (upstream commit
> > 3383e199)
> > * update read_tree_recursive callback to pass strbuf as base (upstream
> >   commit 6a0b0b6d)
> > 
> > Signed-off-by: Christian Hesse <mail at eworm.de>
> > ---
> > [...]
> 
> Is there any benefit to introducing a new function here?  In other
> words, is walk_tree() used anywhere else?  If not, wouldn't it be
> simpler to update the signature of the existing function?
> 
> (The same comment applies to several other places below.)

I just adopted the changes from git upstream to make things work. This is not
intended for merge... And I will take a closer look for final patch when
git v2.3.0 arrives. ;)

Our code include three functions called 'walk_tree()' in ui-plain.c,
ui-blob.c and ui-tree.c. Can this bring any trouble?
-- 
main(a){char*c=/*    Schoene Gruesse                         */"B?IJj;MEH"
"CX:;",b;for(a/*    Chris           get my mail address:    */=0;b=c[a++];)
putchar(b-1/(/*               gcc -o sig sig.c && ./sig    */b/42*2-3)*42);}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20150113/2a68cb7a/attachment.asc>


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

* [PATCH 1/1] git: preview for v2.3.0-rc0
  2015-01-13  9:57   ` list
@ 2015-01-13 10:09     ` john
  2015-01-14 15:34     ` [PATCH v2 " list
  1 sibling, 0 replies; 7+ messages in thread
From: john @ 2015-01-13 10:09 UTC (permalink / raw)


On Tue, Jan 13, 2015 at 10:57:39AM +0100, Christian Hesse wrote:
> John Keeping <john at keeping.me.uk> on Tue, 2015/01/13 09:43:
> > On Tue, Jan 13, 2015 at 09:56:47AM +0100, list at eworm.de wrote:
> > > From: Christian Hesse <mail at eworm.de>
> > > 
> > > * sort_string_list(): rename to string_list_sort() (upstream commit
> > > 3383e199)
> > > * update read_tree_recursive callback to pass strbuf as base (upstream
> > >   commit 6a0b0b6d)
> > > 
> > > Signed-off-by: Christian Hesse <mail at eworm.de>
> > > ---
> > > [...]
> > 
> > Is there any benefit to introducing a new function here?  In other
> > words, is walk_tree() used anywhere else?  If not, wouldn't it be
> > simpler to update the signature of the existing function?
> > 
> > (The same comment applies to several other places below.)
> 
> I just adopted the changes from git upstream to make things work. This is not
> intended for merge... And I will take a closer look for final patch when
> git v2.3.0 arrives. ;)
> 
> Our code include three functions called 'walk_tree()' in ui-plain.c,
> ui-blob.c and ui-tree.c. Can this bring any trouble?

They're all static so they're limited to the files in which they're
declared.  The names won't appear in the final binary at all (except in
debug annotations).


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

* [PATCH v2 1/1] git: preview for v2.3.0-rc0
  2015-01-13  9:57   ` list
  2015-01-13 10:09     ` john
@ 2015-01-14 15:34     ` list
  2015-01-15 22:01       ` john
  1 sibling, 1 reply; 7+ messages in thread
From: list @ 2015-01-14 15:34 UTC (permalink / raw)


From: Christian Hesse <mail at eworm.de>

* sort_string_list(): rename to string_list_sort() (upstream commit
* 3383e199)
* update read_tree_recursive callback to pass strbuf as base (upstream
  commit 6a0b0b6d)

Signed-off-by: Christian Hesse <mail at eworm.de>
---
 Makefile   |  4 ++--
 cgit.c     |  2 +-
 git        |  2 +-
 ui-blob.c  | 15 ++++++++-------
 ui-plain.c | 16 ++++++++--------
 ui-tree.c  | 23 +++++++++++------------
 6 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/Makefile b/Makefile
index 38bf595..36c30a8 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.2.1
-GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz
+GIT_VER = 2.3.0.rc0
+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/cgit.c b/cgit.c
index 79019c2..df301ea 100644
--- a/cgit.c
+++ b/cgit.c
@@ -599,7 +599,7 @@ static int prepare_repo_cmd(void)
 		free(tmp);
 		return 1;
 	}
-	sort_string_list(&ctx.repo->submodules);
+	string_list_sort(&ctx.repo->submodules);
 	cgit_prepare_repo_env(ctx.repo);
 	choose_readme(ctx.repo);
 	return 0;
diff --git a/git b/git
index 9b7cbb3..addfb21 160000
--- a/git
+++ b/git
@@ -1 +1 @@
-Subproject commit 9b7cbb315923e61bb0c4297c701089f30e116750
+Subproject commit addfb21a94fb4e6b9d07b270f7bb3748767a8f38
diff --git a/ui-blob.c b/ui-blob.c
index c2de8d6..4e29223 100644
--- a/ui-blob.c
+++ b/ui-blob.c
@@ -18,15 +18,16 @@ struct walk_tree_context {
 	int file_only:1;
 };
 
-static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
-	const char *pathname, unsigned mode, int stage, void *cbdata)
+static int walk_tree_buf(const unsigned char *sha1, struct strbuf *base,
+	const char *pathname, unsigned mode, int stage,
+	void *cbdata)
 {
 	struct walk_tree_context *walk_tree_ctx = cbdata;
 
 	if (walk_tree_ctx->file_only && !S_ISREG(mode))
 		return READ_TREE_RECURSIVE;
-	if (strncmp(base, walk_tree_ctx->match_path, baselen)
-		|| strcmp(walk_tree_ctx->match_path + baselen, pathname))
+	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);
 	walk_tree_ctx->found_path = 1;
@@ -56,7 +57,7 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only)
 		return 0;
 	if (sha1_object_info(sha1, &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(sha1)->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
 	return walk_tree_ctx.found_path;
 }
 
@@ -87,7 +88,7 @@ int cgit_print_file(char *path, const char *head, int file_only)
 	type = sha1_object_info(sha1, &size);
 	if (type == OBJ_COMMIT && path) {
 		commit = lookup_commit_reference(sha1);
-		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
 		if (!walk_tree_ctx.found_path)
 			return -1;
 		type = sha1_object_info(sha1, &size);
@@ -140,7 +141,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
 
 	if ((!hex) && type == OBJ_COMMIT && path) {
 		commit = lookup_commit_reference(sha1);
-		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
 		type = sha1_object_info(sha1,&size);
 	}
 
diff --git a/ui-plain.c b/ui-plain.c
index 30fff89..061180d 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -173,23 +173,23 @@ static void print_dir_tail(void)
 	html(" </ul>\n</body></html>\n");
 }
 
-static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
-		     const char *pathname, unsigned mode, int stage,
-		     void *cbdata)
+static int walk_tree_buf(const unsigned char *sha1, struct strbuf *base,
+	const char *pathname, unsigned mode, int stage,
+	void *cbdata)
 {
 	struct walk_tree_context *walk_tree_ctx = cbdata;
 
-	if (baselen == walk_tree_ctx->match_baselen) {
+	if (base->len == walk_tree_ctx->match_baselen) {
 		if (S_ISREG(mode)) {
 			if (print_object(sha1, pathname))
 				walk_tree_ctx->match = 1;
 		} else if (S_ISDIR(mode)) {
-			print_dir(sha1, base, baselen, pathname);
+			print_dir(sha1, base->buf, base->len, pathname);
 			walk_tree_ctx->match = 2;
 			return READ_TREE_RECURSIVE;
 		}
-	} else if (baselen > walk_tree_ctx->match_baselen) {
-		print_dir_entry(sha1, base, baselen, pathname, mode);
+	} else if (base->len > walk_tree_ctx->match_baselen) {
+		print_dir_entry(sha1, base->buf, base->len, pathname, mode);
 		walk_tree_ctx->match = 2;
 	} else if (S_ISDIR(mode)) {
 		return READ_TREE_RECURSIVE;
@@ -243,7 +243,7 @@ void cgit_print_plain(void)
 	}
 	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->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
 	if (!walk_tree_ctx.match)
 		html_status(404, "Not found", 0);
 	else if (walk_tree_ctx.match == 2)
diff --git a/ui-tree.c b/ui-tree.c
index e4c3d22..f30f0e3 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -121,9 +121,9 @@ static void print_object(const unsigned char *sha1, char *path, const char *base
 }
 
 
-static int ls_item(const unsigned char *sha1, const char *base, int baselen,
-		   const char *pathname, unsigned int mode, int stage,
-		   void *cbdata)
+static int ls_item_buf(const unsigned char *sha1, struct strbuf *base,
+	const char *pathname, unsigned mode, int stage,
+	void *cbdata)
 {
 	struct walk_tree_context *walk_tree_ctx = cbdata;
 	char *name;
@@ -211,21 +211,21 @@ static void ls_tree(const unsigned char *sha1, char *path, struct walk_tree_cont
 	}
 
 	ls_head();
-	read_tree_recursive(tree, "", 0, 1, &paths, ls_item, walk_tree_ctx);
+	read_tree_recursive(tree, "", 0, 1, &paths, ls_item_buf, walk_tree_ctx);
 	ls_tail();
 }
 
 
-static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
-		     const char *pathname, unsigned mode, int stage,
-		     void *cbdata)
+static int walk_tree_buf(const unsigned char *sha1, struct strbuf *base,
+	const char *pathname, unsigned mode, int stage,
+	void *cbdata)
 {
 	struct walk_tree_context *walk_tree_ctx = cbdata;
 	static char buffer[PATH_MAX];
 
 	if (walk_tree_ctx->state == 0) {
-		memcpy(buffer, base, baselen);
-		strcpy(buffer + baselen, pathname);
+		memcpy(buffer, base->buf, base->len);
+		strcpy(buffer + base->len, pathname);
 		if (strcmp(walk_tree_ctx->match_path, buffer))
 			return READ_TREE_RECURSIVE;
 
@@ -238,11 +238,10 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
 			return 0;
 		}
 	}
-	ls_item(sha1, base, baselen, pathname, mode, stage, walk_tree_ctx);
+	ls_item_buf(sha1, base, pathname, mode, stage, walk_tree_ctx);
 	return 0;
 }
 
-
 /*
  * Show a tree or a blob
  *   rev:  the commit pointing at the root tree object
@@ -285,7 +284,7 @@ void cgit_print_tree(const char *rev, char *path)
 		goto cleanup;
 	}
 
-	read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+	read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
 	if (walk_tree_ctx.state == 1)
 		ls_tail();
 
-- 
2.2.2



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

* [PATCH v2 1/1] git: preview for v2.3.0-rc0
  2015-01-14 15:34     ` [PATCH v2 " list
@ 2015-01-15 22:01       ` john
  2015-01-16  8:33         ` list
  0 siblings, 1 reply; 7+ messages in thread
From: john @ 2015-01-15 22:01 UTC (permalink / raw)


On Wed, Jan 14, 2015 at 04:34:20PM +0100, list at eworm.de wrote:
> From: Christian Hesse <mail at eworm.de>
> 
> * sort_string_list(): rename to string_list_sort() (upstream commit
> * 3383e199)
> * update read_tree_recursive callback to pass strbuf as base (upstream
>   commit 6a0b0b6d)
> 
> Signed-off-by: Christian Hesse <mail at eworm.de>
> ---
>  Makefile   |  4 ++--
>  cgit.c     |  2 +-
>  git        |  2 +-
>  ui-blob.c  | 15 ++++++++-------
>  ui-plain.c | 16 ++++++++--------
>  ui-tree.c  | 23 +++++++++++------------
>  6 files changed, 31 insertions(+), 31 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 38bf595..36c30a8 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.2.1
> -GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz
> +GIT_VER = 2.3.0.rc0
> +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/cgit.c b/cgit.c
> index 79019c2..df301ea 100644
> --- a/cgit.c
> +++ b/cgit.c
> @@ -599,7 +599,7 @@ static int prepare_repo_cmd(void)
>  		free(tmp);
>  		return 1;
>  	}
> -	sort_string_list(&ctx.repo->submodules);
> +	string_list_sort(&ctx.repo->submodules);
>  	cgit_prepare_repo_env(ctx.repo);
>  	choose_readme(ctx.repo);
>  	return 0;
> diff --git a/git b/git
> index 9b7cbb3..addfb21 160000
> --- a/git
> +++ b/git
> @@ -1 +1 @@
> -Subproject commit 9b7cbb315923e61bb0c4297c701089f30e116750
> +Subproject commit addfb21a94fb4e6b9d07b270f7bb3748767a8f38
> diff --git a/ui-blob.c b/ui-blob.c
> index c2de8d6..4e29223 100644
> --- a/ui-blob.c
> +++ b/ui-blob.c
> @@ -18,15 +18,16 @@ struct walk_tree_context {
>  	int file_only:1;
>  };
>  
> -static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
> -	const char *pathname, unsigned mode, int stage, void *cbdata)
> +static int walk_tree_buf(const unsigned char *sha1, struct strbuf *base,
> +	const char *pathname, unsigned mode, int stage,
> +	void *cbdata)

This seems unnecessarily noisy.  The patch would be easier to read if
the function name stays the same and you avoid re-wrapping the
parameters.  It would also remove several of the hunks below because the
call sites won't need to change.

>  {
>  	struct walk_tree_context *walk_tree_ctx = cbdata;
>  
>  	if (walk_tree_ctx->file_only && !S_ISREG(mode))
>  		return READ_TREE_RECURSIVE;
> -	if (strncmp(base, walk_tree_ctx->match_path, baselen)
> -		|| strcmp(walk_tree_ctx->match_path + baselen, pathname))
> +	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);
>  	walk_tree_ctx->found_path = 1;
> @@ -56,7 +57,7 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only)
>  		return 0;
>  	if (sha1_object_info(sha1, &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(sha1)->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
>  	return walk_tree_ctx.found_path;
>  }
>  
> @@ -87,7 +88,7 @@ int cgit_print_file(char *path, const char *head, int file_only)
>  	type = sha1_object_info(sha1, &size);
>  	if (type == OBJ_COMMIT && path) {
>  		commit = lookup_commit_reference(sha1);
> -		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
> +		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
>  		if (!walk_tree_ctx.found_path)
>  			return -1;
>  		type = sha1_object_info(sha1, &size);
> @@ -140,7 +141,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
>  
>  	if ((!hex) && type == OBJ_COMMIT && path) {
>  		commit = lookup_commit_reference(sha1);
> -		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
> +		read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
>  		type = sha1_object_info(sha1,&size);
>  	}
>  
> diff --git a/ui-plain.c b/ui-plain.c
> index 30fff89..061180d 100644
> --- a/ui-plain.c
> +++ b/ui-plain.c
> @@ -173,23 +173,23 @@ static void print_dir_tail(void)
>  	html(" </ul>\n</body></html>\n");
>  }
>  
> -static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
> -		     const char *pathname, unsigned mode, int stage,
> -		     void *cbdata)
> +static int walk_tree_buf(const unsigned char *sha1, struct strbuf *base,
> +	const char *pathname, unsigned mode, int stage,
> +	void *cbdata)
>  {
>  	struct walk_tree_context *walk_tree_ctx = cbdata;
>  
> -	if (baselen == walk_tree_ctx->match_baselen) {
> +	if (base->len == walk_tree_ctx->match_baselen) {
>  		if (S_ISREG(mode)) {
>  			if (print_object(sha1, pathname))
>  				walk_tree_ctx->match = 1;
>  		} else if (S_ISDIR(mode)) {
> -			print_dir(sha1, base, baselen, pathname);
> +			print_dir(sha1, base->buf, base->len, pathname);
>  			walk_tree_ctx->match = 2;
>  			return READ_TREE_RECURSIVE;
>  		}
> -	} else if (baselen > walk_tree_ctx->match_baselen) {
> -		print_dir_entry(sha1, base, baselen, pathname, mode);
> +	} else if (base->len > walk_tree_ctx->match_baselen) {
> +		print_dir_entry(sha1, base->buf, base->len, pathname, mode);
>  		walk_tree_ctx->match = 2;
>  	} else if (S_ISDIR(mode)) {
>  		return READ_TREE_RECURSIVE;
> @@ -243,7 +243,7 @@ void cgit_print_plain(void)
>  	}
>  	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->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
>  	if (!walk_tree_ctx.match)
>  		html_status(404, "Not found", 0);
>  	else if (walk_tree_ctx.match == 2)
> diff --git a/ui-tree.c b/ui-tree.c
> index e4c3d22..f30f0e3 100644
> --- a/ui-tree.c
> +++ b/ui-tree.c
> @@ -121,9 +121,9 @@ static void print_object(const unsigned char *sha1, char *path, const char *base
>  }
>  
>  
> -static int ls_item(const unsigned char *sha1, const char *base, int baselen,
> -		   const char *pathname, unsigned int mode, int stage,
> -		   void *cbdata)
> +static int ls_item_buf(const unsigned char *sha1, struct strbuf *base,
> +	const char *pathname, unsigned mode, int stage,
> +	void *cbdata)
>  {
>  	struct walk_tree_context *walk_tree_ctx = cbdata;
>  	char *name;
> @@ -211,21 +211,21 @@ static void ls_tree(const unsigned char *sha1, char *path, struct walk_tree_cont
>  	}
>  
>  	ls_head();
> -	read_tree_recursive(tree, "", 0, 1, &paths, ls_item, walk_tree_ctx);
> +	read_tree_recursive(tree, "", 0, 1, &paths, ls_item_buf, walk_tree_ctx);
>  	ls_tail();
>  }
>  
>  
> -static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
> -		     const char *pathname, unsigned mode, int stage,
> -		     void *cbdata)
> +static int walk_tree_buf(const unsigned char *sha1, struct strbuf *base,
> +	const char *pathname, unsigned mode, int stage,
> +	void *cbdata)
>  {
>  	struct walk_tree_context *walk_tree_ctx = cbdata;
>  	static char buffer[PATH_MAX];
>  
>  	if (walk_tree_ctx->state == 0) {
> -		memcpy(buffer, base, baselen);
> -		strcpy(buffer + baselen, pathname);
> +		memcpy(buffer, base->buf, base->len);
> +		strcpy(buffer + base->len, pathname);
>  		if (strcmp(walk_tree_ctx->match_path, buffer))
>  			return READ_TREE_RECURSIVE;
>  
> @@ -238,11 +238,10 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
>  			return 0;
>  		}
>  	}
> -	ls_item(sha1, base, baselen, pathname, mode, stage, walk_tree_ctx);
> +	ls_item_buf(sha1, base, pathname, mode, stage, walk_tree_ctx);
>  	return 0;
>  }
>  
> -
>  /*
>   * Show a tree or a blob
>   *   rev:  the commit pointing at the root tree object
> @@ -285,7 +284,7 @@ void cgit_print_tree(const char *rev, char *path)
>  		goto cleanup;
>  	}
>  
> -	read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
> +	read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree_buf, &walk_tree_ctx);
>  	if (walk_tree_ctx.state == 1)
>  		ls_tail();


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

* [PATCH v2 1/1] git: preview for v2.3.0-rc0
  2015-01-15 22:01       ` john
@ 2015-01-16  8:33         ` list
  0 siblings, 0 replies; 7+ messages in thread
From: list @ 2015-01-16  8:33 UTC (permalink / raw)


John Keeping <john at keeping.me.uk> on Thu, 2015/01/15 22:01:
> On Wed, Jan 14, 2015 at 04:34:20PM +0100, list at eworm.de wrote:
> > From: Christian Hesse <mail at eworm.de>
> > 
> > * sort_string_list(): rename to string_list_sort() (upstream commit
> > * 3383e199)
> > * update read_tree_recursive callback to pass strbuf as base (upstream
> >   commit 6a0b0b6d)
> > 
> > Signed-off-by: Christian Hesse <mail at eworm.de>
> > ---
> >  Makefile   |  4 ++--
> >  cgit.c     |  2 +-
> >  git        |  2 +-
> >  ui-blob.c  | 15 ++++++++-------
> >  ui-plain.c | 16 ++++++++--------
> >  ui-tree.c  | 23 +++++++++++------------
> >  6 files changed, 31 insertions(+), 31 deletions(-)
> > 
> > diff --git a/Makefile b/Makefile
> > index 38bf595..36c30a8 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.2.1
> > -GIT_URL =
> > https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz
> > +GIT_VER = 2.3.0.rc0 +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/cgit.c b/cgit.c
> > index 79019c2..df301ea 100644
> > --- a/cgit.c
> > +++ b/cgit.c
> > @@ -599,7 +599,7 @@ static int prepare_repo_cmd(void)
> >  		free(tmp);
> >  		return 1;
> >  	}
> > -	sort_string_list(&ctx.repo->submodules);
> > +	string_list_sort(&ctx.repo->submodules);
> >  	cgit_prepare_repo_env(ctx.repo);
> >  	choose_readme(ctx.repo);
> >  	return 0;
> > diff --git a/git b/git
> > index 9b7cbb3..addfb21 160000
> > --- a/git
> > +++ b/git
> > @@ -1 +1 @@
> > -Subproject commit 9b7cbb315923e61bb0c4297c701089f30e116750
> > +Subproject commit addfb21a94fb4e6b9d07b270f7bb3748767a8f38
> > diff --git a/ui-blob.c b/ui-blob.c
> > index c2de8d6..4e29223 100644
> > --- a/ui-blob.c
> > +++ b/ui-blob.c
> > @@ -18,15 +18,16 @@ struct walk_tree_context {
> >  	int file_only:1;
> >  };
> >  
> > -static int walk_tree(const unsigned char *sha1, const char *base, int
> > baselen,
> > -	const char *pathname, unsigned mode, int stage, void *cbdata)
> > +static int walk_tree_buf(const unsigned char *sha1, struct strbuf *base,
> > +	const char *pathname, unsigned mode, int stage,
> > +	void *cbdata)
> 
> This seems unnecessarily noisy.  The patch would be easier to read if
> the function name stays the same and you avoid re-wrapping the
> parameters.  It would also remove several of the hunks below because the
> call sites won't need to change.

Already changed that in my local repository. ;)
-- 
main(a){char*c=/*    Schoene Gruesse                         */"B?IJj;MEH"
"CX:;",b;for(a/*    Chris           get my mail address:    */=0;b=c[a++];)
putchar(b-1/(/*               gcc -o sig sig.c && ./sig    */b/42*2-3)*42);}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20150116/62c92d9f/attachment.asc>


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

end of thread, other threads:[~2015-01-16  8:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-13  8:56 [PATCH 1/1] git: preview for v2.3.0-rc0 list
2015-01-13  9:43 ` john
2015-01-13  9:57   ` list
2015-01-13 10:09     ` john
2015-01-14 15:34     ` [PATCH v2 " list
2015-01-15 22:01       ` john
2015-01-16  8:33         ` 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).