git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/6] gitweb.perl : added ability to debug requests coming through gitweb interface by adding an option to request URL (also requires server-side envvar "GITWEB_MAY_DEBUG=yes")

From
JKJim Klimov <jim@jimklimov.com>
Date
Mar 11, 2016, 13:24 UTC
Message-ID
<1457702689-9084-2-git-send-email-jim@jimklimov.com>
In-Reply-To
<1457702689-9084-1-git-send-email-jim@jimklimov.com>
---
 gitweb/gitweb.perl | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 030d429..c715472 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -74,6 +74,11 @@ sub evaluate_uri {
 	our $home_link = $my_uri || "/";
 }
 
+# Request parameters
+our ($action, $project, $DEBUG, $file_name, $file_parent, $hash, $hash_parent, $hash_base,
+     $hash_parent_base, @extra_options, $page, $searchtype, $search_use_regexp,
+     $searchtext, $search_regexp, $project_filter);
+
 # core git executable to use
 # this can just be "git" if your webserver has a sensible PATH
 our $GIT = "++GIT_BINDIR++/git";
@@ -803,6 +808,7 @@ our %input_params = ();
 our @cgi_param_mapping = (
 	project => "p",
 	action => "a",
+	debug => "debug",
 	file_name => "f",
 	file_parent => "fp",
 	hash => "h",
@@ -1033,9 +1039,6 @@ sub evaluate_path_info {
 	}
 }
 
-our ($action, $project, $file_name, $file_parent, $hash, $hash_parent, $hash_base,
-     $hash_parent_base, @extra_options, $page, $searchtype, $search_use_regexp,
-     $searchtext, $search_regexp, $project_filter);
 sub evaluate_and_validate_params {
 	our $action = $input_params{'action'};
 	if (defined $action) {
@@ -1053,6 +1056,23 @@ sub evaluate_and_validate_params {
 		}
 	}
 
+	our $DEBUG = $input_params{'debug'};
+	if (defined $DEBUG) {
+		if ( $DEBUG =~ /^([Yy][Ee][Ss]|[Oo][Nn]|1|[Tt][Rr][Uu][Ee])$/ ) {
+			if ( defined($ENV{'GITWEB_MAY_DEBUG'}) && $ENV{'GITWEB_MAY_DEBUG'} eq "yes" ) {
+				$DEBUG = 1; #true
+			} else {
+				printf STDERR "Invalid action parameter: DEBUG=$DEBUG was requested but server-side GITWEB_MAY_DEBUG=yes is not set\n";
+				die_error(403, "Invalid action parameter: DEBUG was requested but server-side GITWEB_MAY_DEBUG=yes is not set");
+				$DEBUG = 0; #false
+			}
+		} else {
+			$DEBUG = 0; #false
+		}
+	} else {
+		$DEBUG = 0;	# false
+	}
+
 	our $project_filter = $input_params{'project_filter'};
 	if (defined $project_filter) {
 		if (!is_valid_pathname($project_filter)) {
-- 
2.1.4
Previous: Jim KlimovNext: Jim Klimov
Message 2 of 6 in “gitweb.perl : added ability to "git archive" just certain paths (files or subdirs, not whole repo) via gitweb interface”
  1. 1/6 gitweb.perl : added ability to "git archive" just certain paths (files or subdirs, not whole repo) via gitweb interfaceJim Klimov, Mar 11, 2016
  2. 2/6 gitweb.perl : added ability to debug requests coming through gitweb interface by adding an option to request URL (also requires server-side envvar "GITWEB_MAY_DEBUG=yes")Jim Klimov, Mar 11, 2016
  3. 3/6 gitweb.perl : added ability to DEBUG progression through "git archive"Jim Klimov, Mar 11, 2016
  4. 4/6 gitweb.perl support for snapshots with lists of specified files is now testedJim Klimov, Mar 11, 2016
  5. 5/6 gitweb.perl changed (and tested) to return HTTP-404 when missing objects are requested via snapshotJim Klimov, Mar 11, 2016
  6. 6/6 gitweb.perl : the optional DEBUG functionality is now unit-testedJim Klimov, Mar 11, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.