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

Re: [PATCH] gitweb: Fix "Use of uninitialized value" warning in git_tags_body

From
Junio C Hamano <junkio@cox.net>
Date
Jan 4, 2007, 20:51 UTC
Message-ID
<7vsleqjz1u.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<enh9h8$7l0$2@sea.gmane.org>
Jakub Narebski <jnareb@gmail.com> writes:
Show 7 quoted lines
>> Fix "Use of uninitialized value" warning in git_tags_body generated
>> for lightweight tags of tree and blob object; those don't have age
>> ($tag{'age'}) defined.
>
> By the way, the latest "Fix warnings" patches for gitweb were result
> of working on bare bones test suite for gitweb. For now I'm only
> checking if there was anything written to STDERR.

I think this is a useful thing to have in-tree at this point, with perhaps minor tweaks I'd suggest later. That way other people can write more tests to catch regressions.

> BTW how in portable way to check that given file matches given patterns
> in specified order, or matches given patterns in any order?

This depends on how different the same page is rendered at different times; I suspect the outputs for the same request from two runs of the test are expected to be different in age, commit and tag object ID and nothing else?

If so, I think using test_tick() to force the stable commit object ID while your test is building a test repository would be a useful thing to do. Also I think replacing call to "time" (you seem to call it from multiple places, all to compute "age") with a call to a subroutine "git_time" and then defining:

	sub git_time {
        	if (exists $::ENV{GIT_TEST_TIME}) {
                	return $::ENV{GIT_TEST_TIME};
                }
                return time;
        }

to help testing would be sensible. Set and export GIT_TEST_TIME to a fixed time (say, midnight GMT December 28th, 2006) in gitweb_init and you will get stable agestring if you have already made the commit and author timestamps stable with test_tick().

Previous: Jakub NarebskiNext: Jakub Narebski
Message 3 of 4 in “gitweb: Fix "Use of uninitialized value" warning in git_tags_body”
  1. gitweb: Fix "Use of uninitialized value" warning in git_tags_bodyJakub Narebski, Jan 3, 2007
  2. Jakub NarebskiJan 3, 2007
  3. Junio C HamanoJan 4, 2007
  4. Jakub NarebskiJan 7, 2007

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.