Git development
 help / color / mirror / Atom feed
* Re: A few more fixups to gitweb
From: Luben Tuikov @ 2006-08-01 20:10 UTC (permalink / raw)
  To: Junio C Hamano, Jakub Narebski; +Cc: git, Martin Langhoff, Matthias Lederhofer
In-Reply-To: <7vzmep2icr.fsf_-_@assigned-by-dhcp.cox.net>

--- Junio C Hamano <junkio@cox.net> wrote:
> One thing to note.  Please make sure that you do not see
> anything in Apache error log after you make your changes.  I do
> not remember the details but kernel.org folks were very unhappy
> earlier when gitweb spewed stuff into the error log, and if I
> recall correctly things that output to the error stream were not
> friendly to the http-server cache for some reason.

I've been meaning to mention this as well.  Gitweb patches,
especially recent ones, need more (thorough) testing, before
posted to the list for inclusion.

    Luben

^ permalink raw reply

* [PATCH] gitweb.cgi: Customization
From: Luben Tuikov @ 2006-08-01 21:19 UTC (permalink / raw)
  To: git

The file "Gitweb_customization.pm" now holds customizable
variables used by "gitweb.cgi".  It is read by "gitweb.cgi"
from @INC, which includes ".", at compile time.

Copy "Gitweb_customization.pm" to where your "gitweb.cgi" or
its link lives.  The values therein are default values,
please change them as per your setup.  From then on, you
only need to update (copy) "gitweb.cgi" in order to upgrade
it, without editing or patching "gitweb.cgi" itself.

Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>
---
 gitweb/Gitweb_customization.pm |   43 ++++++++++++++++++++++++++++++++++++++++
 gitweb/gitweb.cgi              |   31 +----------------------------
 2 files changed, 44 insertions(+), 30 deletions(-)

diff --git a/gitweb/Gitweb_customization.pm b/gitweb/Gitweb_customization.pm
new file mode 100644
index 0000000..8bfa19a
--- /dev/null
+++ b/gitweb/Gitweb_customization.pm
@@ -0,0 +1,43 @@
+package    Gitweb_customization;
+require    Exporter;
+
+our @ISA = qw(Exporter);
+our @EXPORT = qw($GIT $projectroot $projects_list $home_text $site_name
+		 $stylesheet $default_blob_plain_mimetype
+		 $default_text_plain_charset $mimetypes_file);
+
+# core git executable to use
+# this can just be "git" if your webserver has a sensible PATH
+our $GIT = "/usr/bin/git";
+
+# absolute fs-path which will be prepended to the project path
+our $projectroot = "/pub/git";
+
+# source of projects list
+# Directory format:
+#our $projects_list = $projectroot;
+# File (shown below) each line in the file is:
+#        [directory.git]<space>[owner.name]
+# (ignore leading whitespace and perl comment char),
+#   where [owner.name] is a sequence of chars with '+' for a space.
+our $projects_list = "index/index.aux";
+
+# html text to include at home page
+our $home_text = "indextext.html";
+
+# name of your site or organization to appear in page titles
+# replace this with something more descriptive for clearer bookmarks
+our $site_name = $ENV{'SERVER_NAME'} || "Untitled";
+
+# URI of default stylesheet
+our $stylesheet = "gitweb.css";
+
+# default blob_plain mimetype and default charset for text/plain blob
+our $default_blob_plain_mimetype = 'text/plain';
+our $default_text_plain_charset  = undef;
+
+# file to use for guessing MIME types before trying /etc/mime.types
+# (relative to the current git repository)
+our $mimetypes_file = undef;
+
+1;
diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi
index 9448b72..5251fac 100755
--- a/gitweb/gitweb.cgi
+++ b/gitweb/gitweb.cgi
@@ -15,6 +15,7 @@ use CGI::Carp qw(fatalsToBrowser);
 use Encode;
 use Fcntl ':mode';
 use File::Find qw();
+use Gitweb_customization;
 binmode STDOUT, ':utf8';
 
 our $cgi = new CGI;
@@ -23,14 +24,6 @@ our $my_url = $cgi->url();
 our $my_uri = $cgi->url(-absolute => 1);
 our $rss_link = "";
 
-# core git executable to use
-# this can just be "git" if your webserver has a sensible PATH
-our $GIT = "/usr/bin/git";
-
-# absolute fs-path which will be prepended to the project path
-#our $projectroot = "/pub/scm";
-our $projectroot = "/home/kay/public_html/pub/scm";
-
 # version of the core git binary
 our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
 
@@ -43,28 +36,6 @@ if (! -d $git_temp) {
 # target of the home link on top of all pages
 our $home_link = $my_uri;
 
-# name of your site or organization to appear in page titles
-# replace this with something more descriptive for clearer bookmarks
-our $site_name = $ENV{'SERVER_NAME'} || "Untitled";
-
-# html text to include at home page
-our $home_text = "indextext.html";
-
-# URI of default stylesheet
-our $stylesheet = "gitweb.css";
-
-# source of projects list
-#our $projects_list = $projectroot;
-our $projects_list = "index/index.aux";
-
-# default blob_plain mimetype and default charset for text/plain blob
-our $default_blob_plain_mimetype = 'text/plain';
-our $default_text_plain_charset  = undef;
-
-# file to use for guessing MIME types before trying /etc/mime.types
-# (relative to the current git repository)
-our $mimetypes_file = undef;
-
 # input validation and dispatch
 our $action = $cgi->param('a');
 if (defined $action) {
-- 
1.4.2.rc2.gd2da4

^ permalink raw reply related

* Re: [PATCH] gitweb.cgi: Customization
From: Junio C Hamano @ 2006-08-01 22:15 UTC (permalink / raw)
  To: ltuikov; +Cc: git
In-Reply-To: <20060801211948.99497.qmail@web31804.mail.mud.yahoo.com>

Luben Tuikov <ltuikov@yahoo.com> writes:

> Copy "Gitweb_customization.pm" to where your "gitweb.cgi" or
> its link lives.

I do not think this is a good idea -- there may not be any harm
done when http://site/cgi-bin/Gitweb_customization.pm is
accessed, but this _does_ pollute the cgi-bin/ namespace.

^ permalink raw reply

* Re: [PATCH] gitweb.cgi: Customization
From: Luben Tuikov @ 2006-08-01 22:53 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vfygg14sq.fsf@assigned-by-dhcp.cox.net>

--- Junio C Hamano <junkio@cox.net> wrote:
> Luben Tuikov <ltuikov@yahoo.com> writes:
> 
> > Copy "Gitweb_customization.pm" to where your "gitweb.cgi" or
> > its link lives.
> 
> I do not think this is a good idea -- there may not be any harm
> done when http://site/cgi-bin/Gitweb_customization.pm is
> accessed, but this _does_ pollute the cgi-bin/ namespace.

As does "gitweb.css".  Similarly, "gitweb.css"'s contents
used to live in "gitweb.cgi" itself.

"Gitweb_customization.pm" doesn't necessarily need to live
in "http://site/cgi-bin/", but anywhere in any path
in @INC, i.e. such that it wouldn't be accessible from
the outside world.

This method of customization seemed the least intrusive
and easiest from re-deployment point of view.

    Luben

^ permalink raw reply

* What's in git.git
From: Junio C Hamano @ 2006-08-01 23:54 UTC (permalink / raw)
  To: git

* The 'master' branch has these since the last announcement.

  I've merged too many stuff since 1.4.2-rc2, so there will be
  1.4.2-rc3 tonight and hopefully things can be stabilized to
  tag 1.4.2 over the weekend.

  - autoconf stuff by Jakub Narebski
  - portability to GNU/kFreeBSD by Gerrit Pape
  - various cleanups and fixes by Johannes
  - built-in git-mv by Johannes
  - git-apply -R by Johannes
  - setup_git_directory cleanups by Linus
  - gitweb clean-ups and blame improvements by Luben Tuikov
  - commit walker updates by Pasky
  - rebase tweaks by Robert Shearman
  - more tests and documentation updates

* The 'next' branch, in addition, has these.

  - Git.pm by Pasky with help from Pavel Roskin and others.

    I'd like to merge this immediately after 1.4.2, unless there
    still are concerns about its portability (in which case
    please help fixing them up before this hits the "master"
    branch).

  - many gitweb cleanups by Jakub Narebski, Martin Waitz and
    Matthias Lederhofer.

    I think these are low-impact and generally good changes.

  - "merge-recur" by Johannes and Alex with help from others.

    I still see a few TODO here and there in the code, but it
    appears that this operates correctly (I've been using this
    for real work for some time).  Do we have benchmarks?

* The 'pu' branch, in addition, has these.

   Johannes Schindelin:
      Add the --color-words option to the diff options family

   Junio C Hamano:
      upload-pack: minor clean-up in multi-ack logic
      upload-pack: stop the other side when they have more roots than we do.
      read-tree --rename and merge-rename

^ permalink raw reply

* Re: [PATCH] gitweb.cgi: Customization
From: Junio C Hamano @ 2006-08-01 23:54 UTC (permalink / raw)
  To: Luben Tuikov; +Cc: git, Martin Waitz, Matthias Lederhofer
In-Reply-To: <20060801225352.26998.qmail@web31801.mail.mud.yahoo.com>

Luben Tuikov <ltuikov@yahoo.com> writes:

> As does "gitweb.css".  Similarly, "gitweb.css"'s contents
> used to live in "gitweb.cgi" itself.

Not convincing argument.  gitweb.css, and git-logo.png patch I
think I will take, are meant to be fed to the http clients.
They do not compare with the customization.pm which is not.

In any case, I think tweaking gitweb.cgi from Makefile like
Martin Waitz did is as easy and clean for people who want to
customize; it should just be the matter of defining the
necessary params in config.mak.

I do not think there is much difference between any of the
customization proposed so far (yours, Martin's and the one from
Matthias Lederhofer) from functionality and ease-of-use point of
view.  They all try to make customization can be done in one
place, and the difference is mostly of taste, so I'd just pick
one from Martin.

^ permalink raw reply

* Re: What's in git.git
From: Johannes Schindelin @ 2006-08-02  0:34 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7v1ws0xb9y.fsf@assigned-by-dhcp.cox.net>

Hi,

On Tue, 1 Aug 2006, Junio C Hamano wrote:

>   - Git.pm by Pasky with help from Pavel Roskin and others.
> 
>     I'd like to merge this immediately after 1.4.2, unless there
>     still are concerns about its portability (in which case
>     please help fixing them up before this hits the "master"
>     branch).

Although I am admittedly not a big fan of this dependency (it is one thing 
to depend on perl, but another to depend on compiling C modules for perl), 
I have to say that on all machines I tested, it works fine now. The only 
platform I did not test is IRIX, and I'll do that on Friday.

>   - "merge-recur" by Johannes and Alex with help from others.
> 
>     I still see a few TODO here and there in the code, but it
>     appears that this operates correctly (I've been using this
>     for real work for some time).  Do we have benchmarks?

As for the TODOs: they are strictly non-functional. But I think we can 
squash the remaining three until Monday.

As for benchmarks, Alex has a very nasty test-case, where the Python 
script takes ages: 10 minutes as compared to just over 2 minutes with our 
recursive merge.

Unfortunately, resolve beats that easily with less than 3 seconds ;-)

>    Johannes Schindelin:
>       Add the --color-words option to the diff options family

BTW I realized it is not really colouring words, since I erroneously 
selected word boundaries at whitespace. But if the only reaction to this 
is your "soooooooo strange", I guess you'll drop it...

>       read-tree --rename and merge-rename

Do you have any numbers on that? I could imagine that merge-recursive 
could be rewritten as a shell script using this and git-merge-base...

Ciao,
Dscho

^ permalink raw reply

* [PATCH 0/10] LLP - the Legacy Linux Port.
From: Ramsay Jones @ 2006-08-02  1:03 UTC (permalink / raw)
  To: git

Hi all,

For the last few weeks, I have been considering making an active
contribution to the git project (rather than just lurking on the list).
However, I've been putting it off because I need to upgrade my
laptop. My current laptop is somewhat old (7/8 years) and not a very
good development machine. (234MHz mobile Pentium, 64MB RAM, 3GB disk)
In my current configuration, I triple-boot win95, winNT4 and Mandrake
Linux 7.0 (2.2.14-15mdk, Tue Jan 4 22:24:20 CET 2000). As you can
imagine, disk space is always a problem and the dev tools are all
quite out of date. I need win95 to access the internet, since neither
winNT nor Linux can drive the win-modem.

Having said that, I've been trying to upgrade my laptop since before
Christmas ...  So, just for a laugh, and to start to get to know the
code, I instigated the LLP (Legacy Linux Port!). I'm happy to say
that, despite the OS and dev tools being six years old, I have the
core of git (mostly) running.

At first, I did not intend to send patches to the project, since this
was just a bit of fun and a learning experience while waiting for my
new laptop. On reflection, however, most of the patches actually have
little to do with the legacy aspects of the tools/OS and are equally
relevant to more up-to-date setups. Naturally, some of the patches
are a direct result of old tools, and are included simply to document
the complete solution. (someone else may find it useful).

First, some version numbers for my tools:

  - gcc 2.95.2
  - glibc 2.1
  - perl 5.005_03
  - Tcl/Tk 8.0

and my config.mak file:

-- >8 --
MOZILLA_SHA1=1
NO_OPENSSL=1
NO_CURL=1
NO_EXPAT=1
NO_STRLCPY=1
NO_IPV6=1
NO_PYTHON=1
NO_C99_FORMAT=1
ALL_CFLAGS+= -Werror
-- 8< --

As I don't have python installed, this implies no recursive merge.
Also, since I don't have asciidoc, I downloaded the documentation
tar-balls; so thank you for providing them! (If memory serves, asciidoc
is written in python ...).

I started by downloading the version 1.4.1 tarball: git-1_4_1_tar.gz

The first problem I had, was that the zlib headers were not installed.
In order to solve this, I built and installed zlib-1.1.4 from source.
(I had an old Linux From Scratch CD handy). I note that the INSTALL
file did not mention any minimum version numbers, so I can confirm
that version 1.1.4 seems to work fine.

Compiling and building was not too difficult, see the patches (#4-9)
for the details. When running the test suite, however, many of the
tests failed due to the perl scripts failing to "compile".

Indeed, this was the biggest problem and required "downgrading" some
of the perl scripts to work with perl 5.5. I only fixed those scripts
called from the tests or that I called directly. Again, INSTALL does
not mention a minimum version number for perl, but I note that
git-relink.perl has a "use 5.006;". (see patch #10)

Whilst fixing the perl scripts, I noted a problem with git-clone and
with the annotate test script itself. (see patches #1,2). After fixing
these problems, I had a git which passed all the tests.

Installing git, I then noted a problem with the templates install.
(see patch #3 for the fix).

With a working git, I now created a git repository with the original
contents of the git tar-ball. I was now able to re-implement the
changes using git and to produce the patches in this series.

Unfortunately, gitk does not work with Tcl/Tk 8.0. The first problem
was a syntax error caused by the 'ne' operator. I did a global
search/replace of ' ne ' with ' != ' to overcome this problem.
The next problem was caused by invalid command name "encoding" on
line 5557. I deleted the call to encoding, replacing it with an empty
string, just to get past this. It then failed with 'invalid command
name "panedwindow"' (at line 429). At this point, I gave up!

I would have liked to get gitk working, but my Tcl/Tk is a bit rusty.
Again INSTALL does not mention a minimum version for Tcl/Tk, but it
is obviously greater than 8.0!

The patch series is as follows:

[PATCH 1/10] Ensure git-clone exits with error if perl script fails.
[PATCH 2/10] Fix annotate test script; notice when git-annotate fails.
[PATCH 3/10] Fix installation of templates on ancient systems.
[PATCH 4/10] New tests and en-passant modifications to mktag.
[PATCH 5/10] Add NO_C99_FORMAT to support older compilers.
[PATCH 6/10] Fix header breakage with _XOPEN_SOURCE.
[PATCH 7/10] Fix header breakage due to redefining PATH_MAX.
[PATCH 8/10] Fix some minor warnings to allow -Werror.
[PATCH 9/10] Remove cmd_usage() routine and re-organize the help/usage code.
[PATCH 10/10] Fix perl scripts to work with version 5.005_03.

I hope you will consider applying patches 1-9, but patch 10 is only
included for completeness.

Note that patch #5 could be much simpler; I felt the need to provide
a general solution to the problem. However, the simpler solution is
to eliminate the use of the C99 printf size specifiers; it's not
that difficult.

Also, since I have to go via win95 and outlook, the mbox files
produced by git-format-patch have been sent as attachments.
(I renamed them to p0001.txt, p0002.txt, etc. also)

Some other random notes:

  - Since I can't access the internet from Linux, I am unable to
    clone the actual git repository; so the commit/tree IDs in the
    patches bear no relation to commit IDs in the official repo.
  - I don't quite understand the classification scheme used to
    name the tests, so you may want to re-name the new test in
    patch #4 (t3800-mktag.sh) to something more appropriate.
  - I don't know of any established location for html documentation,
    but I used, essentially,  $(prefix)/doc/git-1.4.1/html
  - For some git commands that have more than one "pattern" of
    invocation (e.g. git-am, git-branch) the man pages were correctly
    formatted, each pattern on a separate line, whereas the html page
    shows them all on one line.

I hope you find this useful.

Ramsay

^ permalink raw reply

* [PATCH 1/10] Ensure git-clone exits with error if perl script fails.
From: Ramsay Jones @ 2006-08-02  1:03 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 1078 bytes --]

This helps tests 5400,5600,5700,5710 "fail correctly" rather than
give some false positives.  Also ensure cleanup actions in exit trap
work correctly even if user has alias rm='rm -i'.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 git-clone.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-clone.sh b/git-clone.sh
index 6a14b25..47bd8e7 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -205,7 +205,7 @@ # Try using "humanish" part of source re
 [ -e "$dir" ] && echo "$dir already exists." && usage
 mkdir -p "$dir" &&
 D=$(cd "$dir" && pwd) &&
-trap 'err=$?; cd ..; rm -r "$D"; exit $err' 0
+trap 'err=$?; cd ..; rm -rf "$D"; exit $err' 0
 case "$bare" in
 yes)
 	GIT_DIR="$D" ;;
@@ -324,7 +324,7 @@ test -d "$GIT_DIR/refs/reference-tmp" &&
 if test -f "$GIT_DIR/CLONE_HEAD"
 then
 	# Read git-fetch-pack -k output and store the remote branches.
-	perl -e "$copy_refs" "$GIT_DIR" "$use_separate_remote" "$origin"
+	perl -e "$copy_refs" "$GIT_DIR" "$use_separate_remote" "$origin" || exit 1
 fi

 cd "$D" || exit
--
1.4.1

[-- Attachment #2: P0001.TXT --]
[-- Type: text/plain, Size: 1323 bytes --]

From 08b6502353d6d6191c1ceb1a7095883ffc2b4b4e Mon Sep 17 00:00:00 2001
From: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
Date: Sat, 29 Jul 2006 17:12:34 +0100
Subject: [PATCH 1/10] Ensure git-clone exits with error if perl script fails.

This helps tests 5400,5600,5700,5710 "fail correctly" rather than
give some false positives.  Also ensure cleanup actions in exit trap
work correctly even if user has alias rm='rm -i'.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 git-clone.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-clone.sh b/git-clone.sh
index 6a14b25..47bd8e7 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -205,7 +205,7 @@ # Try using "humanish" part of source re
 [ -e "$dir" ] && echo "$dir already exists." && usage
 mkdir -p "$dir" &&
 D=$(cd "$dir" && pwd) &&
-trap 'err=$?; cd ..; rm -r "$D"; exit $err' 0
+trap 'err=$?; cd ..; rm -rf "$D"; exit $err' 0
 case "$bare" in
 yes)
 	GIT_DIR="$D" ;;
@@ -324,7 +324,7 @@ test -d "$GIT_DIR/refs/reference-tmp" &&
 if test -f "$GIT_DIR/CLONE_HEAD"
 then
 	# Read git-fetch-pack -k output and store the remote branches.
-	perl -e "$copy_refs" "$GIT_DIR" "$use_separate_remote" "$origin"
+	perl -e "$copy_refs" "$GIT_DIR" "$use_separate_remote" "$origin" || exit 1
 fi
 
 cd "$D" || exit
-- 
1.4.1


^ permalink raw reply related

* [PATCH 3/10] Fix installation of templates on ancient systems.
From: Ramsay Jones @ 2006-08-02  1:03 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 1769 bytes --]

Do not use $(call) for 'shell quoting' paths, and pass DESTDIR down
to the templates makefile.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 Makefile           |    2 +-
 templates/Makefile |   12 +++++-------
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index cde619c..180dbd0 100644
--- a/Makefile
+++ b/Makefile
@@ -662,7 +662,7 @@ install: all
 	$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
 	$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
 	$(INSTALL) git$X gitk '$(DESTDIR_SQ)$(bindir_SQ)'
-	$(MAKE) -C templates install
+	$(MAKE) -C templates install DESTDIR=$(DESTDIR)
 	$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
 	$(INSTALL) $(PYMODULES) '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
 	if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
diff --git a/templates/Makefile b/templates/Makefile
index 8f7f4fe..9e1ae1a 100644
--- a/templates/Makefile
+++ b/templates/Makefile
@@ -6,11 +6,9 @@ prefix ?= $(HOME)
 template_dir ?= $(prefix)/share/git-core/templates/
 # DESTDIR=
 
-# Shell quote;
-# Result of this needs to be placed inside ''
-shq = $(subst ','\'',$(1))
-# This has surrounding ''
-shellquote = '$(call shq,$(1))'
+# Shell quote (do not use $(call) to accomodate ancient setups);
+DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
+template_dir_SQ = $(subst ','\'',$(template_dir))
 
 all: boilerplates.made custom
 
@@ -43,6 +41,6 @@ clean:
 	rm -rf blt boilerplates.made
 
 install: all
-	$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(template_dir))
+	$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(template_dir_SQ)'
 	(cd blt && $(TAR) cf - .) | \
-	(cd $(call shellquote,$(DESTDIR)$(template_dir)) && $(TAR) xf -)
+	(cd '$(DESTDIR_SQ)$(template_dir_SQ)' && $(TAR) xf -)
-- 
1.4.1

[-- Attachment #2: P0003.TXT --]
[-- Type: text/plain, Size: 2006 bytes --]

From 4903e542f4361d06361027c10e38750eee7a1208 Mon Sep 17 00:00:00 2001
From: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
Date: Sat, 29 Jul 2006 17:25:03 +0100
Subject: [PATCH 3/10] Fix installation of templates on ancient systems.

Do not use $(call) for 'shell quoting' paths, and pass DESTDIR down
to the templates makefile.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 Makefile           |    2 +-
 templates/Makefile |   12 +++++-------
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index cde619c..180dbd0 100644
--- a/Makefile
+++ b/Makefile
@@ -662,7 +662,7 @@ install: all
 	$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
 	$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
 	$(INSTALL) git$X gitk '$(DESTDIR_SQ)$(bindir_SQ)'
-	$(MAKE) -C templates install
+	$(MAKE) -C templates install DESTDIR=$(DESTDIR)
 	$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
 	$(INSTALL) $(PYMODULES) '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
 	if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
diff --git a/templates/Makefile b/templates/Makefile
index 8f7f4fe..9e1ae1a 100644
--- a/templates/Makefile
+++ b/templates/Makefile
@@ -6,11 +6,9 @@ prefix ?= $(HOME)
 template_dir ?= $(prefix)/share/git-core/templates/
 # DESTDIR=
 
-# Shell quote;
-# Result of this needs to be placed inside ''
-shq = $(subst ','\'',$(1))
-# This has surrounding ''
-shellquote = '$(call shq,$(1))'
+# Shell quote (do not use $(call) to accomodate ancient setups);
+DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
+template_dir_SQ = $(subst ','\'',$(template_dir))
 
 all: boilerplates.made custom
 
@@ -43,6 +41,6 @@ clean:
 	rm -rf blt boilerplates.made
 
 install: all
-	$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(template_dir))
+	$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(template_dir_SQ)'
 	(cd blt && $(TAR) cf - .) | \
-	(cd $(call shellquote,$(DESTDIR)$(template_dir)) && $(TAR) xf -)
+	(cd '$(DESTDIR_SQ)$(template_dir_SQ)' && $(TAR) xf -)
-- 
1.4.1


^ permalink raw reply related

* [PATCH 2/10] Fix annotate test script; notice when git-annotate fails.
From: Ramsay Jones @ 2006-08-02  1:03 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 754 bytes --]

The t8001-annotate.sh test claimed all tests pass, when in fact
the git-annotate perl script failed to run! (prior to fixing the
script to work with perl 5.5).

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 t/annotate-tests.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index 1148b02..077b4a5 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -4,7 +4,8 @@ # sourced from t8001-annotate.sh and t80
 check_count () {
 	head=
 	case "$1" in -h) head="$2"; shift; shift ;; esac
-	$PROG file $head | perl -e '
+	$PROG file $head >.result || return 1
+	cat .result | perl -e '
 		my %expect = (@ARGV);
 		my %count = ();
 		while (<STDIN>) {
-- 
1.4.1

[-- Attachment #2: P0002.TXT --]
[-- Type: text/plain, Size: 999 bytes --]

From b0c4383bf48d10bbd5229b51ad5d9230568add2c Mon Sep 17 00:00:00 2001
From: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
Date: Sat, 29 Jul 2006 17:20:41 +0100
Subject: [PATCH 2/10] Fix annotate test script; notice when git-annotate fails.

The t8001-annotate.sh test claimed all tests pass, when in fact
the git-annotate perl script failed to run! (prior to fixing the
script to work with perl 5.5).

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 t/annotate-tests.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index 1148b02..077b4a5 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -4,7 +4,8 @@ # sourced from t8001-annotate.sh and t80
 check_count () {
 	head=
 	case "$1" in -h) head="$2"; shift; shift ;; esac
-	$PROG file $head | perl -e '
+	$PROG file $head >.result || return 1
+	cat .result | perl -e '
 		my %expect = (@ARGV);
 		my %count = ();
 		while (<STDIN>) {
-- 
1.4.1


^ permalink raw reply related

* [PATCH 4/10] New tests and en-passant modifications to mktag.
From: Ramsay Jones @ 2006-08-02  1:03 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 9481 bytes --]

These changes were originally part of the next patch, but have been
split out since they were peripheral to the main purpose of that patch.

  - update comment describing the signature format to reflect
    the current code.
  - remove trailing \n in calls to error(), since a \n is already
    provided by error().
  - remove redundant call to get_sha1_hex().
  - call sha1_to_hex(sha1) to convert to ascii, rather than attempting
    to print the raw sha1.

The new tests provide a regression suite to support the modifications
to git-mktag in this and the next patch.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 mktag.c          |   35 ++++----
 t/t3800-mktag.sh |  227
++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 245 insertions(+), 17 deletions(-)

diff --git a/mktag.c b/mktag.c
index f0fe528..9bae223 100644
--- a/mktag.c
+++ b/mktag.c
@@ -2,10 +2,11 @@ #include "cache.h"
 #include "tag.h"

 /*
- * A signature file has a very simple fixed format: three lines
- * of "object <sha1>" + "type <typename>" + "tag <tagname>",
- * followed by some free-form signature that git itself doesn't
- * care about, but that can be verified with gpg or similar.
+ * A signature file has a very simple fixed format: four lines
+ * of "object <sha1>" + "type <typename>" + "tag <tagname>" +
+ * "tagger <committer>", followed by a blank line, a free-form tag
+ * message and a signature block that git itself doesn't care about,
+ * but that can be verified with gpg or similar.
  *
  * The first three lines are guaranteed to be at least 63 bytes:
  * "object <sha1>\n" is 48 bytes, "type tag\n" at 9 bytes is the
@@ -46,45 +47,42 @@ static int verify_tag(char *buffer, unsi
 	const char *object, *type_line, *tag_line, *tagger_line;

 	if (size < 64)
-		return error("wanna fool me ? you obviously got the size wrong !\n");
+		return error("wanna fool me ? you obviously got the size wrong !");

 	buffer[size] = 0;

 	/* Verify object line */
 	object = buffer;
 	if (memcmp(object, "object ", 7))
-		return error("char%d: does not start with \"object \"\n", 0);
+		return error("char%d: does not start with \"object \"", 0);

 	if (get_sha1_hex(object + 7, sha1))
-		return error("char%d: could not get SHA1 hash\n", 7);
+		return error("char%d: could not get SHA1 hash", 7);

 	/* Verify type line */
 	type_line = object + 48;
 	if (memcmp(type_line - 1, "\ntype ", 6))
-		return error("char%d: could not find \"\\ntype \"\n", 47);
+		return error("char%d: could not find \"\\ntype \"", 47);

 	/* Verify tag-line */
 	tag_line = strchr(type_line, '\n');
 	if (!tag_line)
-		return error("char%td: could not find next \"\\n\"\n", type_line -
buffer);
+		return error("char%td: could not find next \"\\n\"", type_line - buffer);
 	tag_line++;
 	if (memcmp(tag_line, "tag ", 4) || tag_line[4] == '\n')
-		return error("char%td: no \"tag \" found\n", tag_line - buffer);
+		return error("char%td: no \"tag \" found", tag_line - buffer);

 	/* Get the actual type */
 	typelen = tag_line - type_line - strlen("type \n");
 	if (typelen >= sizeof(type))
-		return error("char%td: type too long\n", type_line+5 - buffer);
+		return error("char%td: type too long", type_line+5 - buffer);

 	memcpy(type, type_line+5, typelen);
 	type[typelen] = 0;

 	/* Verify that the object matches */
-	if (get_sha1_hex(object + 7, sha1))
-		return error("char%d: could not get SHA1 hash but this is really odd
since i got it before !\n", 7);
-
 	if (verify_object(sha1, type))
-		return error("char%d: could not verify object %s\n", 7, sha1);
+		return error("char%d: could not verify object %s", 7, sha1_to_hex(sha1));

 	/* Verify the tag-name: we don't allow control characters or spaces in it
*/
 	tag_line += 4;
@@ -94,14 +92,17 @@ static int verify_tag(char *buffer, unsi
 			break;
 		if (c > ' ')
 			continue;
-		return error("char%td: could not verify tag name\n", tag_line - buffer);
+		return error("char%td: could not verify tag name", tag_line - buffer);
 	}

 	/* Verify the tagger line */
 	tagger_line = tag_line;

 	if (memcmp(tagger_line, "tagger", 6) || (tagger_line[6] == '\n'))
-		return error("char%td: could not find \"tagger\"\n", tagger_line -
buffer);
+		return error("char%td: could not find \"tagger\"", tagger_line - buffer);
+
+	/* TODO: check for committer info + blank line? */
+	/* Also, the minimum length is probably + "tagger .", or 63+8=71 */

 	/* The actual stuff afterwards we don't care about.. */
 	return 0;
diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh
new file mode 100755
index 0000000..b833e19
--- /dev/null
+++ b/t/t3800-mktag.sh
@@ -0,0 +1,227 @@
+#!/bin/sh
+#
+#
+
+test_description='git-mktag: tag object verify test'
+
+. ./test-lib.sh
+
+###########################################################
+# check the tag.sig file, expecting verify_tag() to fail,
+# and checking that the error message matches the pattern
+# given in the expect.pat file.
+
+check_verify_failure () {
+    test_expect_success \
+        "$1" \
+        'git-mktag <tag.sig 2>message ||
+         egrep -q -f expect.pat message'
+}
+
+###########################################################
+# first create a commit, so we have a valid object/type
+# for the tag.
+echo Hello >A
+git-update-index --add A
+git-commit -m "Initial commit"
+head=$(git-rev-parse --verify HEAD)
+
+############################################################
+#  1. length check
+
+cat >tag.sig <<EOF
+too short for a tag
+EOF
+
+cat >expect.pat <<EOF
+^error: .*size wrong.*$
+EOF
+
+check_verify_failure 'Tag object length check'
+
+############################################################
+#  2. object line label check
+
+cat >tag.sig <<EOF
+xxxxxx 139e9b33986b1c2670fff52c5067603117b3e895
+type tag
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char0: .*"object "$
+EOF
+
+check_verify_failure '"object" line label check'
+
+############################################################
+#  3. object line SHA1 check
+
+cat >tag.sig <<EOF
+object zz9e9b33986b1c2670fff52c5067603117b3e895
+type tag
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char7: .*SHA1 hash$
+EOF
+
+check_verify_failure '"object" line SHA1 check'
+
+############################################################
+#  4. type line label check
+
+cat >tag.sig <<EOF
+object 779e9b33986b1c2670fff52c5067603117b3e895
+xxxx tag
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char47: .*"[\]ntype "$
+EOF
+
+check_verify_failure '"type" line label check'
+
+############################################################
+#  5. type line eol check
+
+echo "object 779e9b33986b1c2670fff52c5067603117b3e895" >tag.sig
+echo -n "type tagsssssssssssssssssssssssssssssss" >>tag.sig
+
+cat >expect.pat <<EOF
+^error: char48: .*"[\]n"$
+EOF
+
+check_verify_failure '"type" line eol check'
+
+############################################################
+#  6. tag line label check #1
+
+cat >tag.sig <<EOF
+object 779e9b33986b1c2670fff52c5067603117b3e895
+type tag
+xxx mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char57: no "tag " found$
+EOF
+
+check_verify_failure '"tag" line label check #1'
+
+############################################################
+#  7. tag line label check #2
+
+cat >tag.sig <<EOF
+object 779e9b33986b1c2670fff52c5067603117b3e895
+type taggggggggggggggggggggggggggggggg
+tag
+EOF
+
+cat >expect.pat <<EOF
+^error: char87: no "tag " found$
+EOF
+
+check_verify_failure '"tag" line label check #2'
+
+############################################################
+#  8. type line type-name length check
+
+cat >tag.sig <<EOF
+object 779e9b33986b1c2670fff52c5067603117b3e895
+type taggggggggggggggggggggggggggggggg
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char53: type too long$
+EOF
+
+check_verify_failure '"type" line type-name length check'
+
+############################################################
+#  9. verify object (SHA1/type) check
+
+cat >tag.sig <<EOF
+object 779e9b33986b1c2670fff52c5067603117b3e895
+type tagggg
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char7: could not verify object.*$
+EOF
+
+check_verify_failure 'verify object (SHA1/type) check'
+
+############################################################
+# 10. verify tag-name check
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag my	tag
+EOF
+
+cat >expect.pat <<EOF
+^error: char67: could not verify tag name$
+EOF
+
+check_verify_failure 'verify tag-name check'
+
+############################################################
+# 11. tagger line lable check #1
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char70: could not find "tagger"$
+EOF
+
+check_verify_failure '"tagger" line label check #1'
+
+############################################################
+# 12. tagger line lable check #2
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger
+EOF
+
+cat >expect.pat <<EOF
+^error: char70: could not find "tagger"$
+EOF
+
+check_verify_failure '"tagger" line label check #2'
+
+############################################################
+# 13. create valid tag
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger another@example.com
+EOF
+
+test_expect_success \
+    'create valid tag' \
+    'git-mktag <tag.sig >.git/refs/tags/mytag 2>message'
+
+############################################################
+# 14. check mytag
+
+test_expect_success \
+    'check mytag' \
+    'git-tag -l | grep mytag'
+
+
+test_done
--
1.4.1

[-- Attachment #2: P0004.TXT --]
[-- Type: text/plain, Size: 9732 bytes --]

From 3916b937e735e71b6bc2f22038cc21cbd4a15eb1 Mon Sep 17 00:00:00 2001
From: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
Date: Sat, 29 Jul 2006 18:15:47 +0100
Subject: [PATCH 4/10] New tests and en-passant modifications to mktag.

These changes were originally part of the next patch, but have been
split out since they were peripheral to the main purpose of that patch.

  - update comment describing the signature format to reflect
    the current code.
  - remove trailing \n in calls to error(), since a \n is already
    provided by error().
  - remove redundant call to get_sha1_hex().
  - call sha1_to_hex(sha1) to convert to ascii, rather than attempting
    to print the raw sha1.

The new tests provide a regression suite to support the modifications
to git-mktag in this and the next patch.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 mktag.c          |   35 ++++----
 t/t3800-mktag.sh |  227 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 245 insertions(+), 17 deletions(-)

diff --git a/mktag.c b/mktag.c
index f0fe528..9bae223 100644
--- a/mktag.c
+++ b/mktag.c
@@ -2,10 +2,11 @@ #include "cache.h"
 #include "tag.h"
 
 /*
- * A signature file has a very simple fixed format: three lines
- * of "object <sha1>" + "type <typename>" + "tag <tagname>",
- * followed by some free-form signature that git itself doesn't
- * care about, but that can be verified with gpg or similar.
+ * A signature file has a very simple fixed format: four lines
+ * of "object <sha1>" + "type <typename>" + "tag <tagname>" +
+ * "tagger <committer>", followed by a blank line, a free-form tag
+ * message and a signature block that git itself doesn't care about,
+ * but that can be verified with gpg or similar.
  *
  * The first three lines are guaranteed to be at least 63 bytes:
  * "object <sha1>\n" is 48 bytes, "type tag\n" at 9 bytes is the
@@ -46,45 +47,42 @@ static int verify_tag(char *buffer, unsi
 	const char *object, *type_line, *tag_line, *tagger_line;
 
 	if (size < 64)
-		return error("wanna fool me ? you obviously got the size wrong !\n");
+		return error("wanna fool me ? you obviously got the size wrong !");
 
 	buffer[size] = 0;
 
 	/* Verify object line */
 	object = buffer;
 	if (memcmp(object, "object ", 7))
-		return error("char%d: does not start with \"object \"\n", 0);
+		return error("char%d: does not start with \"object \"", 0);
 
 	if (get_sha1_hex(object + 7, sha1))
-		return error("char%d: could not get SHA1 hash\n", 7);
+		return error("char%d: could not get SHA1 hash", 7);
 
 	/* Verify type line */
 	type_line = object + 48;
 	if (memcmp(type_line - 1, "\ntype ", 6))
-		return error("char%d: could not find \"\\ntype \"\n", 47);
+		return error("char%d: could not find \"\\ntype \"", 47);
 
 	/* Verify tag-line */
 	tag_line = strchr(type_line, '\n');
 	if (!tag_line)
-		return error("char%td: could not find next \"\\n\"\n", type_line - buffer);
+		return error("char%td: could not find next \"\\n\"", type_line - buffer);
 	tag_line++;
 	if (memcmp(tag_line, "tag ", 4) || tag_line[4] == '\n')
-		return error("char%td: no \"tag \" found\n", tag_line - buffer);
+		return error("char%td: no \"tag \" found", tag_line - buffer);
 
 	/* Get the actual type */
 	typelen = tag_line - type_line - strlen("type \n");
 	if (typelen >= sizeof(type))
-		return error("char%td: type too long\n", type_line+5 - buffer);
+		return error("char%td: type too long", type_line+5 - buffer);
 
 	memcpy(type, type_line+5, typelen);
 	type[typelen] = 0;
 
 	/* Verify that the object matches */
-	if (get_sha1_hex(object + 7, sha1))
-		return error("char%d: could not get SHA1 hash but this is really odd since i got it before !\n", 7);
-
 	if (verify_object(sha1, type))
-		return error("char%d: could not verify object %s\n", 7, sha1);
+		return error("char%d: could not verify object %s", 7, sha1_to_hex(sha1));
 
 	/* Verify the tag-name: we don't allow control characters or spaces in it */
 	tag_line += 4;
@@ -94,14 +92,17 @@ static int verify_tag(char *buffer, unsi
 			break;
 		if (c > ' ')
 			continue;
-		return error("char%td: could not verify tag name\n", tag_line - buffer);
+		return error("char%td: could not verify tag name", tag_line - buffer);
 	}
 
 	/* Verify the tagger line */
 	tagger_line = tag_line;
 
 	if (memcmp(tagger_line, "tagger", 6) || (tagger_line[6] == '\n'))
-		return error("char%td: could not find \"tagger\"\n", tagger_line - buffer);
+		return error("char%td: could not find \"tagger\"", tagger_line - buffer);
+
+	/* TODO: check for committer info + blank line? */
+	/* Also, the minimum length is probably + "tagger .", or 63+8=71 */
 
 	/* The actual stuff afterwards we don't care about.. */
 	return 0;
diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh
new file mode 100755
index 0000000..b833e19
--- /dev/null
+++ b/t/t3800-mktag.sh
@@ -0,0 +1,227 @@
+#!/bin/sh
+#
+#
+
+test_description='git-mktag: tag object verify test'
+
+. ./test-lib.sh
+
+###########################################################
+# check the tag.sig file, expecting verify_tag() to fail,
+# and checking that the error message matches the pattern
+# given in the expect.pat file.
+
+check_verify_failure () {
+    test_expect_success \
+        "$1" \
+        'git-mktag <tag.sig 2>message ||
+         egrep -q -f expect.pat message'
+}
+
+###########################################################
+# first create a commit, so we have a valid object/type
+# for the tag.
+echo Hello >A
+git-update-index --add A
+git-commit -m "Initial commit"
+head=$(git-rev-parse --verify HEAD)
+
+############################################################
+#  1. length check
+
+cat >tag.sig <<EOF
+too short for a tag
+EOF
+
+cat >expect.pat <<EOF
+^error: .*size wrong.*$
+EOF
+
+check_verify_failure 'Tag object length check'
+
+############################################################
+#  2. object line label check
+
+cat >tag.sig <<EOF
+xxxxxx 139e9b33986b1c2670fff52c5067603117b3e895
+type tag
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char0: .*"object "$
+EOF
+
+check_verify_failure '"object" line label check'
+
+############################################################
+#  3. object line SHA1 check
+
+cat >tag.sig <<EOF
+object zz9e9b33986b1c2670fff52c5067603117b3e895
+type tag
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char7: .*SHA1 hash$
+EOF
+
+check_verify_failure '"object" line SHA1 check'
+
+############################################################
+#  4. type line label check
+
+cat >tag.sig <<EOF
+object 779e9b33986b1c2670fff52c5067603117b3e895
+xxxx tag
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char47: .*"[\]ntype "$
+EOF
+
+check_verify_failure '"type" line label check'
+
+############################################################
+#  5. type line eol check
+
+echo "object 779e9b33986b1c2670fff52c5067603117b3e895" >tag.sig
+echo -n "type tagsssssssssssssssssssssssssssssss" >>tag.sig
+
+cat >expect.pat <<EOF
+^error: char48: .*"[\]n"$
+EOF
+
+check_verify_failure '"type" line eol check'
+
+############################################################
+#  6. tag line label check #1
+
+cat >tag.sig <<EOF
+object 779e9b33986b1c2670fff52c5067603117b3e895
+type tag
+xxx mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char57: no "tag " found$
+EOF
+
+check_verify_failure '"tag" line label check #1'
+
+############################################################
+#  7. tag line label check #2
+
+cat >tag.sig <<EOF
+object 779e9b33986b1c2670fff52c5067603117b3e895
+type taggggggggggggggggggggggggggggggg
+tag
+EOF
+
+cat >expect.pat <<EOF
+^error: char87: no "tag " found$
+EOF
+
+check_verify_failure '"tag" line label check #2'
+
+############################################################
+#  8. type line type-name length check
+
+cat >tag.sig <<EOF
+object 779e9b33986b1c2670fff52c5067603117b3e895
+type taggggggggggggggggggggggggggggggg
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char53: type too long$
+EOF
+
+check_verify_failure '"type" line type-name length check'
+
+############################################################
+#  9. verify object (SHA1/type) check
+
+cat >tag.sig <<EOF
+object 779e9b33986b1c2670fff52c5067603117b3e895
+type tagggg
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char7: could not verify object.*$
+EOF
+
+check_verify_failure 'verify object (SHA1/type) check'
+
+############################################################
+# 10. verify tag-name check
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag my	tag
+EOF
+
+cat >expect.pat <<EOF
+^error: char67: could not verify tag name$
+EOF
+
+check_verify_failure 'verify tag-name check'
+
+############################################################
+# 11. tagger line lable check #1
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char70: could not find "tagger"$
+EOF
+
+check_verify_failure '"tagger" line label check #1'
+
+############################################################
+# 12. tagger line lable check #2
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger
+EOF
+
+cat >expect.pat <<EOF
+^error: char70: could not find "tagger"$
+EOF
+
+check_verify_failure '"tagger" line label check #2'
+
+############################################################
+# 13. create valid tag
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger another@example.com
+EOF
+
+test_expect_success \
+    'create valid tag' \
+    'git-mktag <tag.sig >.git/refs/tags/mytag 2>message'
+
+############################################################
+# 14. check mytag
+
+test_expect_success \
+    'check mytag' \
+    'git-tag -l | grep mytag'
+
+
+test_done
-- 
1.4.1


^ permalink raw reply related

* [PATCH 5/10] Add NO_C99_FORMAT to support older compilers.
From: Ramsay Jones @ 2006-08-02  1:03 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 3947 bytes --]

The NO_C99_FORMAT macro allows compilers that lack support for the
ll,hh,j,z,t size specifiers (eg. gcc 2.95.2) to adapt the code to avoid
runtime errors in the formatted IO functions.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 Makefile |    8 ++++++++
 alloc.c  |   15 ++++++++++++++-
 mktag.c  |   18 +++++++++++++-----
 3 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 180dbd0..2b72c79 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,11 @@ #
 # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
 # d_type in struct dirent (latest Cygwin -- will be fixed soonish).
 #
+# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
+# do not support the 'size specifiers' introduced by C99, namely ll, hh,
+# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
+# some c compilers supported these specifiers prior to C99 as an extension.
+#
 # Define NO_STRCASESTR if you don't have strcasestr.
 #
 # Define NO_STRLCPY if you don't have strlcpy.
@@ -406,6 +411,9 @@ endif
 ifdef NO_D_INO_IN_DIRENT
 	ALL_CFLAGS += -DNO_D_INO_IN_DIRENT
 endif
+ifdef NO_C99_FORMAT
+	ALL_CFLAGS += -DNO_C99_FORMAT
+endif
 ifdef NO_SYMLINK_HEAD
 	ALL_CFLAGS += -DNO_SYMLINK_HEAD
 endif
diff --git a/alloc.c b/alloc.c
index e3b22f4..460db19 100644
--- a/alloc.c
+++ b/alloc.c
@@ -39,8 +39,21 @@ DEFINE_ALLOCATOR(tree)
 DEFINE_ALLOCATOR(commit)
 DEFINE_ALLOCATOR(tag)

+#ifdef NO_C99_FORMAT
+#define SZ_FMT "%u"
+#else
+#define SZ_FMT "%zu"
+#endif
+
+static void report(const char* name, unsigned int count, size_t size)
+{
+    fprintf(stderr, "%10s: %8u (" SZ_FMT " kB)\n", name, count, size);
+}
+
+#undef SZ_FMT
+
 #define REPORT(name)	\
-	fprintf(stderr, "%10s: %8u (%zu kB)\n", #name, name##_allocs,
name##_allocs*sizeof(struct name) >> 10)
+    report(#name, name##_allocs, name##_allocs*sizeof(struct name) >> 10)

 void alloc_report(void)
 {
diff --git a/mktag.c b/mktag.c
index 9bae223..be41513 100644
--- a/mktag.c
+++ b/mktag.c
@@ -39,6 +39,12 @@ static int verify_object(unsigned char *
 	return ret;
 }

+#ifdef NO_C99_FORMAT
+#define PD_FMT "%d"
+#else
+#define PD_FMT "%td"
+#endif
+
 static int verify_tag(char *buffer, unsigned long size)
 {
 	int typelen;
@@ -67,15 +73,15 @@ static int verify_tag(char *buffer, unsi
 	/* Verify tag-line */
 	tag_line = strchr(type_line, '\n');
 	if (!tag_line)
-		return error("char%td: could not find next \"\\n\"", type_line - buffer);
+		return error("char" PD_FMT ": could not find next \"\\n\"", type_line -
buffer);
 	tag_line++;
 	if (memcmp(tag_line, "tag ", 4) || tag_line[4] == '\n')
-		return error("char%td: no \"tag \" found", tag_line - buffer);
+		return error("char" PD_FMT ": no \"tag \" found", tag_line - buffer);

 	/* Get the actual type */
 	typelen = tag_line - type_line - strlen("type \n");
 	if (typelen >= sizeof(type))
-		return error("char%td: type too long", type_line+5 - buffer);
+		return error("char" PD_FMT ": type too long", type_line+5 - buffer);

 	memcpy(type, type_line+5, typelen);
 	type[typelen] = 0;
@@ -92,14 +98,14 @@ static int verify_tag(char *buffer, unsi
 			break;
 		if (c > ' ')
 			continue;
-		return error("char%td: could not verify tag name", tag_line - buffer);
+		return error("char" PD_FMT ": could not verify tag name", tag_line -
buffer);
 	}

 	/* Verify the tagger line */
 	tagger_line = tag_line;

 	if (memcmp(tagger_line, "tagger", 6) || (tagger_line[6] == '\n'))
-		return error("char%td: could not find \"tagger\"", tagger_line - buffer);
+		return error("char" PD_FMT ": could not find \"tagger\"", tagger_line -
buffer);

 	/* TODO: check for committer info + blank line? */
 	/* Also, the minimum length is probably + "tagger .", or 63+8=71 */
@@ -108,6 +114,8 @@ static int verify_tag(char *buffer, unsi
 	return 0;
 }

+#undef PD_FMT
+
 int main(int argc, char **argv)
 {
 	unsigned long size = 4096;
--
1.4.1

[-- Attachment #2: P0005.TXT --]
[-- Type: text/plain, Size: 4190 bytes --]

From b1456ff7fa2b1a02f3cd71ef596f30df9d634d99 Mon Sep 17 00:00:00 2001
From: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
Date: Sun, 30 Jul 2006 16:38:28 +0100
Subject: [PATCH 5/10] Add NO_C99_FORMAT to support older compilers.

The NO_C99_FORMAT macro allows compilers that lack support for the
ll,hh,j,z,t size specifiers (eg. gcc 2.95.2) to adapt the code to avoid
runtime errors in the formatted IO functions.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 Makefile |    8 ++++++++
 alloc.c  |   15 ++++++++++++++-
 mktag.c  |   18 +++++++++++++-----
 3 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 180dbd0..2b72c79 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,11 @@ #
 # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
 # d_type in struct dirent (latest Cygwin -- will be fixed soonish).
 #
+# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
+# do not support the 'size specifiers' introduced by C99, namely ll, hh,
+# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
+# some c compilers supported these specifiers prior to C99 as an extension.
+#
 # Define NO_STRCASESTR if you don't have strcasestr.
 #
 # Define NO_STRLCPY if you don't have strlcpy.
@@ -406,6 +411,9 @@ endif
 ifdef NO_D_INO_IN_DIRENT
 	ALL_CFLAGS += -DNO_D_INO_IN_DIRENT
 endif
+ifdef NO_C99_FORMAT
+	ALL_CFLAGS += -DNO_C99_FORMAT
+endif
 ifdef NO_SYMLINK_HEAD
 	ALL_CFLAGS += -DNO_SYMLINK_HEAD
 endif
diff --git a/alloc.c b/alloc.c
index e3b22f4..460db19 100644
--- a/alloc.c
+++ b/alloc.c
@@ -39,8 +39,21 @@ DEFINE_ALLOCATOR(tree)
 DEFINE_ALLOCATOR(commit)
 DEFINE_ALLOCATOR(tag)
 
+#ifdef NO_C99_FORMAT
+#define SZ_FMT "%u"
+#else
+#define SZ_FMT "%zu"
+#endif
+
+static void report(const char* name, unsigned int count, size_t size)
+{
+    fprintf(stderr, "%10s: %8u (" SZ_FMT " kB)\n", name, count, size);
+}
+
+#undef SZ_FMT
+
 #define REPORT(name)	\
-	fprintf(stderr, "%10s: %8u (%zu kB)\n", #name, name##_allocs, name##_allocs*sizeof(struct name) >> 10)
+    report(#name, name##_allocs, name##_allocs*sizeof(struct name) >> 10)
 
 void alloc_report(void)
 {
diff --git a/mktag.c b/mktag.c
index 9bae223..be41513 100644
--- a/mktag.c
+++ b/mktag.c
@@ -39,6 +39,12 @@ static int verify_object(unsigned char *
 	return ret;
 }
 
+#ifdef NO_C99_FORMAT
+#define PD_FMT "%d"
+#else
+#define PD_FMT "%td"
+#endif
+
 static int verify_tag(char *buffer, unsigned long size)
 {
 	int typelen;
@@ -67,15 +73,15 @@ static int verify_tag(char *buffer, unsi
 	/* Verify tag-line */
 	tag_line = strchr(type_line, '\n');
 	if (!tag_line)
-		return error("char%td: could not find next \"\\n\"", type_line - buffer);
+		return error("char" PD_FMT ": could not find next \"\\n\"", type_line - buffer);
 	tag_line++;
 	if (memcmp(tag_line, "tag ", 4) || tag_line[4] == '\n')
-		return error("char%td: no \"tag \" found", tag_line - buffer);
+		return error("char" PD_FMT ": no \"tag \" found", tag_line - buffer);
 
 	/* Get the actual type */
 	typelen = tag_line - type_line - strlen("type \n");
 	if (typelen >= sizeof(type))
-		return error("char%td: type too long", type_line+5 - buffer);
+		return error("char" PD_FMT ": type too long", type_line+5 - buffer);
 
 	memcpy(type, type_line+5, typelen);
 	type[typelen] = 0;
@@ -92,14 +98,14 @@ static int verify_tag(char *buffer, unsi
 			break;
 		if (c > ' ')
 			continue;
-		return error("char%td: could not verify tag name", tag_line - buffer);
+		return error("char" PD_FMT ": could not verify tag name", tag_line - buffer);
 	}
 
 	/* Verify the tagger line */
 	tagger_line = tag_line;
 
 	if (memcmp(tagger_line, "tagger", 6) || (tagger_line[6] == '\n'))
-		return error("char%td: could not find \"tagger\"", tagger_line - buffer);
+		return error("char" PD_FMT ": could not find \"tagger\"", tagger_line - buffer);
 
 	/* TODO: check for committer info + blank line? */
 	/* Also, the minimum length is probably + "tagger .", or 63+8=71 */
@@ -108,6 +114,8 @@ static int verify_tag(char *buffer, unsi
 	return 0;
 }
 
+#undef PD_FMT
+
 int main(int argc, char **argv)
 {
 	unsigned long size = 4096;
-- 
1.4.1


^ permalink raw reply related

* [PATCH 7/10] Fix header breakage due to redefining PATH_MAX.
From: Ramsay Jones @ 2006-08-02  1:03 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 765 bytes --]

The header builtin.h was, incorrectly, redefining PATH_MAX which
causes a header order dependency in builtin-write-tree.c.  The fix
is to simply include <limits.h> directly to obtain the correct
definition of PATH_MAX.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
Note that on Linux 2.2.14, PATH_MAX is define to be 4095.
(Solaris, Mac OSX, *BSD define it as 1024)

 builtin.h |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/builtin.h b/builtin.h
index f12d5e6..7bfff11 100644
--- a/builtin.h
+++ b/builtin.h
@@ -2,10 +2,7 @@ #ifndef BUILTIN_H
 #define BUILTIN_H
 
 #include <stdio.h>
-
-#ifndef PATH_MAX
-# define PATH_MAX 4096
-#endif
+#include <limits.h>
 
 extern const char git_version_string[];
 
-- 
1.4.1

[-- Attachment #2: P0007.TXT --]
[-- Type: text/plain, Size: 898 bytes --]

From 14324992ff3a9b43c3ac9c869ef40cf59eeac245 Mon Sep 17 00:00:00 2001
From: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
Date: Sun, 30 Jul 2006 17:00:40 +0100
Subject: [PATCH 7/10] Fix header breakage due to redefining PATH_MAX.

The header builtin.h was, incorrectly, redefining PATH_MAX which
causes a header order dependency in builtin-write-tree.c.  The fix
is to simply include <limits.h> directly to obtain the correct
definition of PATH_MAX.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 builtin.h |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/builtin.h b/builtin.h
index f12d5e6..7bfff11 100644
--- a/builtin.h
+++ b/builtin.h
@@ -2,10 +2,7 @@ #ifndef BUILTIN_H
 #define BUILTIN_H
 
 #include <stdio.h>
-
-#ifndef PATH_MAX
-# define PATH_MAX 4096
-#endif
+#include <limits.h>
 
 extern const char git_version_string[];
 
-- 
1.4.1


^ permalink raw reply related

* [PATCH 8/10] Fix some minor warnings to allow -Werror.
From: Ramsay Jones @ 2006-08-02  1:03 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 958 bytes --]

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 builtin-mailinfo.c |    3 ++-
 diff.c             |    1 +
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index 3e40747..bb5e7b7 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -531,7 +531,8 @@ static int decode_b_segment(char *in, ch
 static void convert_to_utf8(char *line, char *charset)
 {
 #ifndef NO_ICONV
-	char *in, *out;
+	const char *in;
+	char *out;
 	size_t insize, outsize, nrc;
 	char outbuf[4096]; /* cheat */
 	static char latin_one[] = "latin1";
diff --git a/diff.c b/diff.c
index 5a71489..81630c0 100644
--- a/diff.c
+++ b/diff.c
@@ -614,6 +614,7 @@ static void emit_binary_diff(mmfile_t *o
 	 * whichever is smaller.
 	 */
 	delta = NULL;
+	orig_size = 0;
 	deflated = deflate_it(two->ptr, two->size, &deflate_size);
 	if (one->size && two->size) {
 		delta = diff_delta(one->ptr, one->size,
-- 
1.4.1

[-- Attachment #2: P0008.TXT --]
[-- Type: text/plain, Size: 1187 bytes --]

From 262b57917ff01f74c95670ae59f1cd59a9024135 Mon Sep 17 00:00:00 2001
From: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
Date: Sun, 30 Jul 2006 17:06:25 +0100
Subject: [PATCH 8/10] Fix some minor warnings to allow -Werror.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 builtin-mailinfo.c |    3 ++-
 diff.c             |    1 +
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index 3e40747..bb5e7b7 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -531,7 +531,8 @@ static int decode_b_segment(char *in, ch
 static void convert_to_utf8(char *line, char *charset)
 {
 #ifndef NO_ICONV
-	char *in, *out;
+	const char *in;
+	char *out;
 	size_t insize, outsize, nrc;
 	char outbuf[4096]; /* cheat */
 	static char latin_one[] = "latin1";
diff --git a/diff.c b/diff.c
index 5a71489..81630c0 100644
--- a/diff.c
+++ b/diff.c
@@ -614,6 +614,7 @@ static void emit_binary_diff(mmfile_t *o
 	 * whichever is smaller.
 	 */
 	delta = NULL;
+	orig_size = 0;
 	deflated = deflate_it(two->ptr, two->size, &deflate_size);
 	if (one->size && two->size) {
 		delta = diff_delta(one->ptr, one->size,
-- 
1.4.1


^ permalink raw reply related

* [PATCH 6/10] Fix header breakage with _XOPEN_SOURCE.
From: Ramsay Jones @ 2006-08-02  1:03 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 1144 bytes --]

convert-objects.c sets _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED before
including <time.h>, in order to get the declaration of strptime().
This leads to breakage in cache.h, due to S_ISLNK and S_IFLNK no longer
being defined by <sys/stat.h>.  These definitions are protected by the
__USE_BSD symbol, which is not set when _XOPEN_SOURCE is set.  Moving
the #defines and #include <time.h> below all other #includes does not
fix the problem, however, since now _USE_XOPEN, which protects the
declaration of strptime(), is now not defined (don't ask!).

The fix is to #define _GNU_SOURCE, which enables the definition of
practically everything.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 convert-objects.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/convert-objects.c b/convert-objects.c
index 0fabd89..971ad6d 100644
--- a/convert-objects.c
+++ b/convert-objects.c
@@ -1,5 +1,6 @@
 #define _XOPEN_SOURCE 500 /* glibc2 and AIX 5.3L need this */
 #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
+#define _GNU_SOURCE
 #include <time.h>
 #include "cache.h"
 #include "blob.h"
-- 
1.4.1

[-- Attachment #2: P0006.TXT --]
[-- Type: text/plain, Size: 1371 bytes --]

From 72f745c4c1e366a0f1fc75ec8da55a3cfb5457c7 Mon Sep 17 00:00:00 2001
From: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
Date: Sun, 30 Jul 2006 16:52:09 +0100
Subject: [PATCH 6/10] Fix header breakage with _XOPEN_SOURCE.

convert-objects.c sets _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED before
including <time.h>, in order to get the declaration of strptime().
This leads to breakage in cache.h, due to S_ISLNK and S_IFLNK no longer
being defined by <sys/stat.h>.  These definitions are protected by the
__USE_BSD symbol, which is not set when _XOPEN_SOURCE is set.  Moving
the #defines and #include <time.h> below all other #includes does not
fix the problem, however, since now _USE_XOPEN, which protects the
declaration of strptime(), is now not defined (don't ask!).

The fix is to #define _GNU_SOURCE, which enables the definition of
practically everything.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 convert-objects.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/convert-objects.c b/convert-objects.c
index 0fabd89..971ad6d 100644
--- a/convert-objects.c
+++ b/convert-objects.c
@@ -1,5 +1,6 @@
 #define _XOPEN_SOURCE 500 /* glibc2 and AIX 5.3L need this */
 #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
+#define _GNU_SOURCE
 #include <time.h>
 #include "cache.h"
 #include "blob.h"
-- 
1.4.1


^ permalink raw reply related

* [PATCH 9/10] Remove cmd_usage() routine and re-organize the help/usage code.
From: Ramsay Jones @ 2006-08-02  1:03 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 4146 bytes --]

The cmd_usage() routine was causing warning messages due to a NULL
format parameter being passed in three out of four calls. This is a
problem if you want to compile with -Werror. A simple solution is to
simply remove the GNU __attribute__ format pragma from the cmd_usage()
declaration in the header file. The function interface was somewhat
muddled anyway, so re-write the code to finesse the problem.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 builtin-help.c |   54
+++++++++++++++++++++++-------------------------------
 builtin.h      |    7 ++-----
 git.c          |    7 +++++--
 3 files changed, 30 insertions(+), 38 deletions(-)

diff --git a/builtin-help.c b/builtin-help.c
index 7470faa..006da05 100644
--- a/builtin-help.c
+++ b/builtin-help.c
@@ -9,8 +9,6 @@ #include "builtin.h"
 #include "exec_cmd.h"
 #include "common-cmds.h"

-static const char git_usage[] =
-	"Usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND
 ARGS ]";

 /* most gui terms set COLUMNS (although some don't export it) */
 static int term_columns(void)
@@ -178,31 +176,6 @@ static void list_common_cmds_help(void)
 	puts("(use 'git help -a' to get a list of all installed git commands)");
 }

-void cmd_usage(int show_all, const char *exec_path, const char *fmt, ...)
-{
-	if (fmt) {
-		va_list ap;
-
-		va_start(ap, fmt);
-		printf("git: ");
-		vprintf(fmt, ap);
-		va_end(ap);
-		putchar('\n');
-	}
-	else
-		puts(git_usage);
-
-	if (exec_path) {
-		putchar('\n');
-		if (show_all)
-			list_commands(exec_path, "git-*");
-		else
-			list_common_cmds_help();
-        }
-
-	exit(1);
-}
-
 static void show_man_page(const char *git_cmd)
 {
 	const char *page;
@@ -221,6 +194,13 @@ static void show_man_page(const char *gi
 	execlp("man", "man", page, NULL);
 }

+void help_unknown_cmd(const char *cmd)
+{
+	printf("git: '%s' is not a git-command\n\n", cmd);
+	list_common_cmds_help();
+	exit(1);
+}
+
 int cmd_version(int argc, const char **argv, char **envp)
 {
 	printf("git version %s\n", git_version_string);
@@ -230,12 +210,24 @@ int cmd_version(int argc, const char **a
 int cmd_help(int argc, const char **argv, char **envp)
 {
 	const char *help_cmd = argv[1];
-	if (!help_cmd)
-		cmd_usage(0, git_exec_path(), NULL);
-	else if (!strcmp(help_cmd, "--all") || !strcmp(help_cmd, "-a"))
-		cmd_usage(1, git_exec_path(), NULL);
+	const char *exec_path = git_exec_path();
+
+	if (!help_cmd) {
+		printf("usage: %s\n\n", git_usage_string);
+		list_common_cmds_help();
+		exit(1);
+	}
+
+	else if (!strcmp(help_cmd, "--all") || !strcmp(help_cmd, "-a")) {
+		printf("usage: %s\n\n", git_usage_string);
+		if(exec_path)
+			list_commands(exec_path, "git-*");
+		exit(1);
+	}
+
 	else
 		show_man_page(help_cmd);
+
 	return 0;
 }

diff --git a/builtin.h b/builtin.h
index 7bfff11..b6cf5be 100644
--- a/builtin.h
+++ b/builtin.h
@@ -5,12 +5,9 @@ #include <stdio.h>
 #include <limits.h>

 extern const char git_version_string[];
+extern const char git_usage_string[];

-void cmd_usage(int show_all, const char *exec_path, const char *fmt, ...)
-#ifdef __GNUC__
-	__attribute__((__format__(__printf__, 3, 4), __noreturn__))
-#endif
-	;
+extern void help_unknown_cmd(const char *cmd);

 extern int cmd_help(int argc, const char **argv, char **envp);
 extern int cmd_version(int argc, const char **argv, char **envp);
diff --git a/git.c b/git.c
index ca8961f..f414df9 100644
--- a/git.c
+++ b/git.c
@@ -14,6 +14,9 @@ #include "cache.h"

 #include "builtin.h"

+const char git_usage_string[] =
+	"git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]";
+
 static void prepend_to_path(const char *dir, int len)
 {
 	const char *old_path = getenv("PATH");
@@ -279,7 +282,7 @@ int main(int argc, const char **argv, ch
 			puts(git_exec_path());
 			exit(0);
 		}
-		cmd_usage(0, NULL, NULL);
+		usage(git_usage_string);
 	}
 	argv[0] = cmd;

@@ -312,7 +315,7 @@ int main(int argc, const char **argv, ch
 	}

 	if (errno == ENOENT)
-		cmd_usage(0, exec_path, "'%s' is not a git-command", cmd);
+		help_unknown_cmd(cmd);

 	fprintf(stderr, "Failed to run command '%s': %s\n",
 		cmd, strerror(errno));
--
1.4.1

[-- Attachment #2: P0009.TXT --]
[-- Type: text/plain, Size: 4412 bytes --]

From 1ce42e2b5b65b03657b3ca9a3b06dc97cc66573c Mon Sep 17 00:00:00 2001
From: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
Date: Sun, 30 Jul 2006 22:42:25 +0100
Subject: [PATCH 9/10] Remove cmd_usage() routine and re-organize the help/usage code.

The cmd_usage() routine was causing warning messages due to a NULL
format parameter being passed in three out of four calls. This is a
problem if you want to compile with -Werror. A simple solution is to
simply remove the GNU __attribute__ format pragma from the cmd_usage()
declaration in the header file. The function interface was somewhat
muddled anyway, so re-write the code to finesse the problem.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 builtin-help.c |   54 +++++++++++++++++++++++-------------------------------
 builtin.h      |    7 ++-----
 git.c          |    7 +++++--
 3 files changed, 30 insertions(+), 38 deletions(-)

diff --git a/builtin-help.c b/builtin-help.c
index 7470faa..006da05 100644
--- a/builtin-help.c
+++ b/builtin-help.c
@@ -9,8 +9,6 @@ #include "builtin.h"
 #include "exec_cmd.h"
 #include "common-cmds.h"
 
-static const char git_usage[] =
-	"Usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]";
 
 /* most gui terms set COLUMNS (although some don't export it) */
 static int term_columns(void)
@@ -178,31 +176,6 @@ static void list_common_cmds_help(void)
 	puts("(use 'git help -a' to get a list of all installed git commands)");
 }
 
-void cmd_usage(int show_all, const char *exec_path, const char *fmt, ...)
-{
-	if (fmt) {
-		va_list ap;
-
-		va_start(ap, fmt);
-		printf("git: ");
-		vprintf(fmt, ap);
-		va_end(ap);
-		putchar('\n');
-	}
-	else
-		puts(git_usage);
-
-	if (exec_path) {
-		putchar('\n');
-		if (show_all)
-			list_commands(exec_path, "git-*");
-		else
-			list_common_cmds_help();
-        }
-
-	exit(1);
-}
-
 static void show_man_page(const char *git_cmd)
 {
 	const char *page;
@@ -221,6 +194,13 @@ static void show_man_page(const char *gi
 	execlp("man", "man", page, NULL);
 }
 
+void help_unknown_cmd(const char *cmd)
+{
+	printf("git: '%s' is not a git-command\n\n", cmd);
+	list_common_cmds_help();
+	exit(1);
+}
+
 int cmd_version(int argc, const char **argv, char **envp)
 {
 	printf("git version %s\n", git_version_string);
@@ -230,12 +210,24 @@ int cmd_version(int argc, const char **a
 int cmd_help(int argc, const char **argv, char **envp)
 {
 	const char *help_cmd = argv[1];
-	if (!help_cmd)
-		cmd_usage(0, git_exec_path(), NULL);
-	else if (!strcmp(help_cmd, "--all") || !strcmp(help_cmd, "-a"))
-		cmd_usage(1, git_exec_path(), NULL);
+	const char *exec_path = git_exec_path();
+
+	if (!help_cmd) {
+		printf("usage: %s\n\n", git_usage_string);
+		list_common_cmds_help();
+		exit(1);
+	}
+
+	else if (!strcmp(help_cmd, "--all") || !strcmp(help_cmd, "-a")) {
+		printf("usage: %s\n\n", git_usage_string);
+		if(exec_path)
+			list_commands(exec_path, "git-*");
+		exit(1);
+	}
+
 	else
 		show_man_page(help_cmd);
+
 	return 0;
 }
 
diff --git a/builtin.h b/builtin.h
index 7bfff11..b6cf5be 100644
--- a/builtin.h
+++ b/builtin.h
@@ -5,12 +5,9 @@ #include <stdio.h>
 #include <limits.h>
 
 extern const char git_version_string[];
+extern const char git_usage_string[];
 
-void cmd_usage(int show_all, const char *exec_path, const char *fmt, ...)
-#ifdef __GNUC__
-	__attribute__((__format__(__printf__, 3, 4), __noreturn__))
-#endif
-	;
+extern void help_unknown_cmd(const char *cmd);
 
 extern int cmd_help(int argc, const char **argv, char **envp);
 extern int cmd_version(int argc, const char **argv, char **envp);
diff --git a/git.c b/git.c
index ca8961f..f414df9 100644
--- a/git.c
+++ b/git.c
@@ -14,6 +14,9 @@ #include "cache.h"
 
 #include "builtin.h"
 
+const char git_usage_string[] =
+	"git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]";
+
 static void prepend_to_path(const char *dir, int len)
 {
 	const char *old_path = getenv("PATH");
@@ -279,7 +282,7 @@ int main(int argc, const char **argv, ch
 			puts(git_exec_path());
 			exit(0);
 		}
-		cmd_usage(0, NULL, NULL);
+		usage(git_usage_string);
 	}
 	argv[0] = cmd;
 
@@ -312,7 +315,7 @@ int main(int argc, const char **argv, ch
 	}
 
 	if (errno == ENOENT)
-		cmd_usage(0, exec_path, "'%s' is not a git-command", cmd);
+		help_unknown_cmd(cmd);
 
 	fprintf(stderr, "Failed to run command '%s': %s\n",
 		cmd, strerror(errno));
-- 
1.4.1


^ permalink raw reply related

* [PATCH 10/10] Fix perl scripts to work with version 5.005_03.
From: Ramsay Jones @ 2006-08-02  1:03 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 7618 bytes --]

In order to make git work on an ancient Linux (Mandrake 7.0) we
need to make the perl scripts work with verion 5.005_03.

The changes include:

  - comment out the "use warnings" pragma
  - open has only two arguments; eg. `open FH, "<$file"` rather
    than `open FH, '<', $file`
  - replace "our" with "my" in the declaration of global (package)
    variables.
  - replace the use of some indirect file-handles with regular
    file-handles.

Note that only those perl scripts which are exercised by the test
suite or that I have called directly have been modified.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 Documentation/build-docdep.perl |    2 +-
 git-annotate.perl               |   25 ++++++++++++-------------
 git-clone.sh                    |    6 +++---
 git-mv.perl                     |    4 ++--
 git-send-email.perl             |   27 +++++++++++++--------------
 git-shortlog.perl               |    2 +-
 6 files changed, 32 insertions(+), 34 deletions(-)

diff --git a/Documentation/build-docdep.perl
b/Documentation/build-docdep.perl
index 489389c..cd40f56 100755
--- a/Documentation/build-docdep.perl
+++ b/Documentation/build-docdep.perl
@@ -4,7 +4,7 @@ my %include = ();
 my %included = ();

 for my $text (<*.txt>) {
-    open I, '<', $text || die "cannot read: $text";
+    open I, "<$text" || die "cannot read: $text";
     while (<I>) {
 	if (/^include::/) {
 	    chomp;
diff --git a/git-annotate.perl b/git-annotate.perl
index a6a7a48..629f480 100755
--- a/git-annotate.perl
+++ b/git-annotate.perl
@@ -6,7 +6,7 @@ #
 # This file is licensed under the GPL v2, or a later version
 # at the discretion of Linus Torvalds.

-use warnings;
+#use warnings;
 use strict;
 use Getopt::Long;
 use POSIX qw(strftime gmtime);
@@ -29,7 +29,7 @@ sub usage() {
 	exit(1);
 }

-our ($help, $longrev, $rename, $rawtime, $starting_rev, $rev_file) = (0, 0,
1);
+my ($help, $longrev, $rename, $rawtime, $starting_rev, $rev_file) = (0, 0,
1);

 my $rc = GetOptions(	"long|l" => \$longrev,
 			"time|t" => \$rawtime,
@@ -52,12 +52,12 @@ my @stack = (
 	},
 );

-our @filelines = ();
+my @filelines = ();

 if (defined $starting_rev) {
 	@filelines = git_cat_file($starting_rev, $filename);
 } else {
-	open(F,"<",$filename)
+	open(F,"<$filename")
 		or die "Failed to open filename: $!";

 	while(<F>) {
@@ -68,9 +68,9 @@ if (defined $starting_rev) {

 }

-our %revs;
-our @revqueue;
-our $head;
+my %revs;
+my @revqueue;
+my $head;

 my $revsprocessed = 0;
 while (my $bound = pop @stack) {
@@ -436,14 +436,13 @@ sub format_date {
 # Copied from git-send-email.perl - We need a Git.pm module..
 sub gitvar {
     my ($var) = @_;
-    my $fh;
-    my $pid = open($fh, '-|');
+    my $pid = open(FH, '-|');
     die "$!" unless defined $pid;
     if (!$pid) {
 	exec('git-var', $var) or die "$!";
     }
-    my ($val) = <$fh>;
-    close $fh or die "$!";
+    my ($val) = <FH>;
+    close FH or die "$!";
     chomp($val);
     return $val;
 }
@@ -471,7 +470,7 @@ sub open_pipe_activestate {
 sub open_pipe_normal {
 	my (@execlist) = @_;

-	my $pid = open my $kid, "-|";
+	my $pid = open KID, "-|";
 	defined $pid or die "Cannot fork: $!";

 	unless ($pid) {
@@ -479,7 +478,7 @@ sub open_pipe_normal {
 		die "Cannot exec @execlist: $!";
 	}

-	return $kid;
+	return *KID;
 }

 package Git::ActiveStatePipe;
diff --git a/git-clone.sh b/git-clone.sh
index 47bd8e7..430c892 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -71,17 +71,17 @@ sub store {
 	my ($sha1, $name, $top) = @_;
 	$name = "$git_dir/refs/$top/$name";
 	mkpath(dirname($name));
-	open O, ">", "$name";
+	open O, ">$name";
 	print O "$sha1\n";
 	close O;
 }

-open FH, "<", "$git_dir/CLONE_HEAD";
+open FH, "<$git_dir/CLONE_HEAD";
 while (<FH>) {
 	my ($sha1, $name) = /^([0-9a-f]{40})\s(.*)$/;
 	next if ($name =~ /\^\173/);
 	if ($name eq "HEAD") {
-		open O, ">", "$git_dir/REMOTE_HEAD";
+		open O, ">$git_dir/REMOTE_HEAD";
 		print O "$sha1\n";
 		close O;
 		next;
diff --git a/git-mv.perl b/git-mv.perl
index 75aa8fe..7aceeb8 100755
--- a/git-mv.perl
+++ b/git-mv.perl
@@ -7,7 +7,7 @@ # This file is licensed under the GPL v2
 # at the discretion of Linus Torvalds.


-use warnings;
+#use warnings;
 use strict;
 use Getopt::Std;

@@ -19,7 +19,7 @@ EOT
 	exit(1);
 }

-our ($opt_n, $opt_f, $opt_h, $opt_k, $opt_v);
+my ($opt_n, $opt_f, $opt_h, $opt_k, $opt_v);
 getopts("hnfkv") || usage;
 usage() if $opt_h;
 @ARGV >= 1 or usage;
diff --git a/git-send-email.perl b/git-send-email.perl
index c5d9e73..e670f28 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -17,7 +17,7 @@ #    and second line is the subject of t
 #

 use strict;
-use warnings;
+#use warnings;
 use Term::ReadLine;
 use Getopt::Long;
 use Data::Dumper;
@@ -83,14 +83,13 @@ # Now, let's fill any that aren't set in

 sub gitvar {
     my ($var) = @_;
-    my $fh;
-    my $pid = open($fh, '-|');
+    my $pid = open(FH, '-|');
     die "$!" unless defined $pid;
     if (!$pid) {
 	exec('git-var', $var) or die "$!";
     }
-    my ($val) = <$fh>;
-    close $fh or die "$!";
+    my ($val) = <FH>;
+    close FH or die "$!";
     chomp($val);
     return $val;
 }
@@ -134,7 +133,7 @@ my %parse_alias = (

 if (@alias_files && defined $parse_alias{$aliasfiletype}) {
 	foreach my $file (@alias_files) {
-		open my $fh, '<', $file or die "opening $file: $!\n";
+		open my $fh, "<$file" or die "opening $file: $!\n";
 		$parse_alias{$aliasfiletype}->($fh);
 		close $fh;
 	}
@@ -209,7 +208,7 @@ if (!$smtp_server) {
 if ($compose) {
 	# Note that this does not need to be secure, but we will make a small
 	# effort to have it be unique
-	open(C,">",$compose_filename)
+	open(C,">$compose_filename")
 		or die "Failed to open for writing $compose_filename: $!";
 	print C "From $from # This line is ignored.\n";
 	printf C "Subject: %s\n\n", $initial_subject;
@@ -226,10 +225,10 @@ EOT
 	$editor = 'vi' unless defined $editor;
 	system($editor, $compose_filename);

-	open(C2,">",$compose_filename . ".final")
+	open(C2,">$compose_filename" . ".final")
 		or die "Failed to open $compose_filename.final : " . $!;

-	open(C,"<",$compose_filename)
+	open(C,"<$compose_filename")
 		or die "Failed to open $compose_filename : " . $!;

 	while(<C>) {
@@ -322,7 +321,7 @@ EOT
 }

 # Variables we set as part of the loop over files
-our ($message_id, $cc, %mail, $subject, $reply_to, $references, $message);
+my ($message_id, $cc, %mail, $subject, $reply_to, $references, $message);

 sub extract_valid_address {
 	my $address = shift;
@@ -396,15 +395,15 @@ X-Mailer: git-send-email $gitversion
 	}

 	if ($smtp_server =~ m#^/#) {
-		my $pid = open my $sm, '|-';
+		my $pid = open SM, '|-';
 		defined $pid or die $!;
 		if (!$pid) {
 			exec($smtp_server,'-i',
 			     map { extract_valid_address($_) }
 			     @recipients) or die $!;
 		}
-		print $sm "$header\n$message";
-		close $sm or die $?;
+		print SM "$header\n$message";
+		close SM or die $?;
 	} else {
 		require Net::SMTP;
 		$smtp ||= Net::SMTP->new( $smtp_server );
@@ -440,7 +439,7 @@ make_message_id();
 $subject = $initial_subject;

 foreach my $t (@files) {
-	open(F,"<",$t) or die "can't open file $t";
+	open(F,"<$t") or die "can't open file $t";

 	my $author_not_sender = undef;
 	@cc = @initial_cc;
diff --git a/git-shortlog.perl b/git-shortlog.perl
index 0b14f83..57604dd 100755
--- a/git-shortlog.perl
+++ b/git-shortlog.perl
@@ -128,7 +128,7 @@ sub setup_mailmap {
 	read_mailmap(\*DATA, \%mailmap);
 	if (-f '.mailmap') {
 		my $fh = undef;
-		open $fh, '<', '.mailmap';
+		open $fh, '<.mailmap';
 		read_mailmap($fh, \%mailmap);
 		close $fh;
 	}
--
1.4.1

[-- Attachment #2: P0010.TXT --]
[-- Type: text/plain, Size: 7885 bytes --]

From b94dcac94f70cc677d4d26aaab47a3e9eecccba2 Mon Sep 17 00:00:00 2001
From: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
Date: Sun, 30 Jul 2006 23:13:14 +0100
Subject: [PATCH 10/10] Fix perl scripts to work with version 5.005_03.

In order to make git work on an ancient Linux (Mandrake 7.0) we
need to make the perl scripts work with verion 5.005_03.

The changes include:

  - comment out the "use warnings" pragma
  - open has only two arguments; eg. `open FH, "<$file"` rather
    than `open FH, '<', $file`
  - replace "our" with "my" in the declaration of global (package)
    variables.
  - replace the use of some indirect file-handles with regular
    file-handles.

Note that only those perl scripts which are exercised by the test
suite or that I have called directly have been modified.

Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
---
 Documentation/build-docdep.perl |    2 +-
 git-annotate.perl               |   25 ++++++++++++-------------
 git-clone.sh                    |    6 +++---
 git-mv.perl                     |    4 ++--
 git-send-email.perl             |   27 +++++++++++++--------------
 git-shortlog.perl               |    2 +-
 6 files changed, 32 insertions(+), 34 deletions(-)

diff --git a/Documentation/build-docdep.perl b/Documentation/build-docdep.perl
index 489389c..cd40f56 100755
--- a/Documentation/build-docdep.perl
+++ b/Documentation/build-docdep.perl
@@ -4,7 +4,7 @@ my %include = ();
 my %included = ();
 
 for my $text (<*.txt>) {
-    open I, '<', $text || die "cannot read: $text";
+    open I, "<$text" || die "cannot read: $text";
     while (<I>) {
 	if (/^include::/) {
 	    chomp;
diff --git a/git-annotate.perl b/git-annotate.perl
index a6a7a48..629f480 100755
--- a/git-annotate.perl
+++ b/git-annotate.perl
@@ -6,7 +6,7 @@ #
 # This file is licensed under the GPL v2, or a later version
 # at the discretion of Linus Torvalds.
 
-use warnings;
+#use warnings;
 use strict;
 use Getopt::Long;
 use POSIX qw(strftime gmtime);
@@ -29,7 +29,7 @@ sub usage() {
 	exit(1);
 }
 
-our ($help, $longrev, $rename, $rawtime, $starting_rev, $rev_file) = (0, 0, 1);
+my ($help, $longrev, $rename, $rawtime, $starting_rev, $rev_file) = (0, 0, 1);
 
 my $rc = GetOptions(	"long|l" => \$longrev,
 			"time|t" => \$rawtime,
@@ -52,12 +52,12 @@ my @stack = (
 	},
 );
 
-our @filelines = ();
+my @filelines = ();
 
 if (defined $starting_rev) {
 	@filelines = git_cat_file($starting_rev, $filename);
 } else {
-	open(F,"<",$filename)
+	open(F,"<$filename")
 		or die "Failed to open filename: $!";
 
 	while(<F>) {
@@ -68,9 +68,9 @@ if (defined $starting_rev) {
 
 }
 
-our %revs;
-our @revqueue;
-our $head;
+my %revs;
+my @revqueue;
+my $head;
 
 my $revsprocessed = 0;
 while (my $bound = pop @stack) {
@@ -436,14 +436,13 @@ sub format_date {
 # Copied from git-send-email.perl - We need a Git.pm module..
 sub gitvar {
     my ($var) = @_;
-    my $fh;
-    my $pid = open($fh, '-|');
+    my $pid = open(FH, '-|');
     die "$!" unless defined $pid;
     if (!$pid) {
 	exec('git-var', $var) or die "$!";
     }
-    my ($val) = <$fh>;
-    close $fh or die "$!";
+    my ($val) = <FH>;
+    close FH or die "$!";
     chomp($val);
     return $val;
 }
@@ -471,7 +470,7 @@ sub open_pipe_activestate {
 sub open_pipe_normal {
 	my (@execlist) = @_;
 
-	my $pid = open my $kid, "-|";
+	my $pid = open KID, "-|";
 	defined $pid or die "Cannot fork: $!";
 
 	unless ($pid) {
@@ -479,7 +478,7 @@ sub open_pipe_normal {
 		die "Cannot exec @execlist: $!";
 	}
 
-	return $kid;
+	return *KID;
 }
 
 package Git::ActiveStatePipe;
diff --git a/git-clone.sh b/git-clone.sh
index 47bd8e7..430c892 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -71,17 +71,17 @@ sub store {
 	my ($sha1, $name, $top) = @_;
 	$name = "$git_dir/refs/$top/$name";
 	mkpath(dirname($name));
-	open O, ">", "$name";
+	open O, ">$name";
 	print O "$sha1\n";
 	close O;
 }
 
-open FH, "<", "$git_dir/CLONE_HEAD";
+open FH, "<$git_dir/CLONE_HEAD";
 while (<FH>) {
 	my ($sha1, $name) = /^([0-9a-f]{40})\s(.*)$/;
 	next if ($name =~ /\^\173/);
 	if ($name eq "HEAD") {
-		open O, ">", "$git_dir/REMOTE_HEAD";
+		open O, ">$git_dir/REMOTE_HEAD";
 		print O "$sha1\n";
 		close O;
 		next;
diff --git a/git-mv.perl b/git-mv.perl
index 75aa8fe..7aceeb8 100755
--- a/git-mv.perl
+++ b/git-mv.perl
@@ -7,7 +7,7 @@ # This file is licensed under the GPL v2
 # at the discretion of Linus Torvalds.
 
 
-use warnings;
+#use warnings;
 use strict;
 use Getopt::Std;
 
@@ -19,7 +19,7 @@ EOT
 	exit(1);
 }
 
-our ($opt_n, $opt_f, $opt_h, $opt_k, $opt_v);
+my ($opt_n, $opt_f, $opt_h, $opt_k, $opt_v);
 getopts("hnfkv") || usage;
 usage() if $opt_h;
 @ARGV >= 1 or usage;
diff --git a/git-send-email.perl b/git-send-email.perl
index c5d9e73..e670f28 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -17,7 +17,7 @@ #    and second line is the subject of t
 #
 
 use strict;
-use warnings;
+#use warnings;
 use Term::ReadLine;
 use Getopt::Long;
 use Data::Dumper;
@@ -83,14 +83,13 @@ # Now, let's fill any that aren't set in
 
 sub gitvar {
     my ($var) = @_;
-    my $fh;
-    my $pid = open($fh, '-|');
+    my $pid = open(FH, '-|');
     die "$!" unless defined $pid;
     if (!$pid) {
 	exec('git-var', $var) or die "$!";
     }
-    my ($val) = <$fh>;
-    close $fh or die "$!";
+    my ($val) = <FH>;
+    close FH or die "$!";
     chomp($val);
     return $val;
 }
@@ -134,7 +133,7 @@ my %parse_alias = (
 
 if (@alias_files && defined $parse_alias{$aliasfiletype}) {
 	foreach my $file (@alias_files) {
-		open my $fh, '<', $file or die "opening $file: $!\n";
+		open my $fh, "<$file" or die "opening $file: $!\n";
 		$parse_alias{$aliasfiletype}->($fh);
 		close $fh;
 	}
@@ -209,7 +208,7 @@ if (!$smtp_server) {
 if ($compose) {
 	# Note that this does not need to be secure, but we will make a small
 	# effort to have it be unique
-	open(C,">",$compose_filename)
+	open(C,">$compose_filename")
 		or die "Failed to open for writing $compose_filename: $!";
 	print C "From $from # This line is ignored.\n";
 	printf C "Subject: %s\n\n", $initial_subject;
@@ -226,10 +225,10 @@ EOT
 	$editor = 'vi' unless defined $editor;
 	system($editor, $compose_filename);
 
-	open(C2,">",$compose_filename . ".final")
+	open(C2,">$compose_filename" . ".final")
 		or die "Failed to open $compose_filename.final : " . $!;
 
-	open(C,"<",$compose_filename)
+	open(C,"<$compose_filename")
 		or die "Failed to open $compose_filename : " . $!;
 
 	while(<C>) {
@@ -322,7 +321,7 @@ EOT
 }
 
 # Variables we set as part of the loop over files
-our ($message_id, $cc, %mail, $subject, $reply_to, $references, $message);
+my ($message_id, $cc, %mail, $subject, $reply_to, $references, $message);
 
 sub extract_valid_address {
 	my $address = shift;
@@ -396,15 +395,15 @@ X-Mailer: git-send-email $gitversion
 	}
 
 	if ($smtp_server =~ m#^/#) {
-		my $pid = open my $sm, '|-';
+		my $pid = open SM, '|-';
 		defined $pid or die $!;
 		if (!$pid) {
 			exec($smtp_server,'-i',
 			     map { extract_valid_address($_) }
 			     @recipients) or die $!;
 		}
-		print $sm "$header\n$message";
-		close $sm or die $?;
+		print SM "$header\n$message";
+		close SM or die $?;
 	} else {
 		require Net::SMTP;
 		$smtp ||= Net::SMTP->new( $smtp_server );
@@ -440,7 +439,7 @@ make_message_id();
 $subject = $initial_subject;
 
 foreach my $t (@files) {
-	open(F,"<",$t) or die "can't open file $t";
+	open(F,"<$t") or die "can't open file $t";
 
 	my $author_not_sender = undef;
 	@cc = @initial_cc;
diff --git a/git-shortlog.perl b/git-shortlog.perl
index 0b14f83..57604dd 100755
--- a/git-shortlog.perl
+++ b/git-shortlog.perl
@@ -128,7 +128,7 @@ sub setup_mailmap {
 	read_mailmap(\*DATA, \%mailmap);
 	if (-f '.mailmap') {
 		my $fh = undef;
-		open $fh, '<', '.mailmap';
+		open $fh, '<.mailmap';
 		read_mailmap($fh, \%mailmap);
 		close $fh;
 	}
-- 
1.4.1


^ permalink raw reply related

* Re: [PATCH] gitweb.cgi: Customization
From: Luben Tuikov @ 2006-08-02  2:01 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Martin Waitz, Matthias Lederhofer
In-Reply-To: <7v8xm8xbaa.fsf@assigned-by-dhcp.cox.net>

--- Junio C Hamano <junkio@cox.net> wrote:
> I do not think there is much difference between any of the
> customization proposed so far (yours, Martin's and the one from
> Matthias Lederhofer) from functionality and ease-of-use point of
> view.  They all try to make customization can be done in one
> place, and the difference is mostly of taste, so I'd just pick
> one from Martin.

Ok, sounds good.

    Luben

^ permalink raw reply

* Re: [PATCH] gitweb.cgi: Customization
From: Martin Langhoff @ 2006-08-02  2:13 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Luben Tuikov, git, Martin Waitz, Matthias Lederhofer
In-Reply-To: <7v8xm8xbaa.fsf@assigned-by-dhcp.cox.net>

On 8/2/06, Junio C Hamano <junkio@cox.net> wrote:
> I do not think there is much difference between any of the
> customization proposed so far (yours, Martin's and the one from
> Matthias Lederhofer) from functionality and ease-of-use point of
> view.  They all try to make customization can be done in one
> place, and the difference is mostly of taste, so I'd just pick
> one from Martin

I'm a bit lost as to gitweb config. Are we not relying on %ENV for
this stuff? Apache's facilities to configure CGIs via ENV are really
powerful. You can do conditionals in apache config files, lock stuff
down in httpd.conf, override it with files in conf.d, and
allow/disallow overrides in .htaccess ...

cheers,


martin

^ permalink raw reply

* Re: [PATCH] gitweb.cgi: Customization
From: Matthias Lederhofer @ 2006-08-02  7:09 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Martin Waitz, Luben Tuikov
In-Reply-To: <7v8xm8xbaa.fsf@assigned-by-dhcp.cox.net>

Junio C Hamano <junkio@cox.net> wrote:
> In any case, I think tweaking gitweb.cgi from Makefile like
> Martin Waitz did is as easy and clean for people who want to
> customize; it should just be the matter of defining the
> necessary params in config.mak.
Ack.

> I do not think there is much difference between any of the
> customization proposed so far (yours, Martin's and the one from
> Matthias Lederhofer) from functionality and ease-of-use point of
> view.  They all try to make customization can be done in one
> place, and the difference is mostly of taste, so I'd just pick
> one from Martin.
Functionality is a bit different.  If you have a configuration where
perl is used this cannot be done using the make variables.  I would like
to have the option to include a perl file (this does not conflict with
using the Makefile to fill in some values), I've explained this in my
other patch.  The ways I see to specify the file to include are an
environment variable (I don't know if all webservers make it easy to set
one), files after __DATA__ or just $include_file =
@@GITWEB_INCLUDE_FILE@@ which is replaced by the filename or undef if
the user did not set this variable.  For the .pm thing I don't know if
it is not too complicated to change the path I can put the file and just
allowing the user to specify the full path is probably the best.  (I
think the $include_file way is probably the one to use, using __DATA__
is a bit obscur, and not everyone can set environment variables for the
webserver.)

^ permalink raw reply

* Re: What's in git.git
From: Junio C Hamano @ 2006-08-02  7:41 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git
In-Reply-To: <Pine.LNX.4.63.0608020215470.17230@wbgn013.biozentrum.uni-wuerzburg.de>

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Although I am admittedly not a big fan of this dependency (it is one thing 
> to depend on perl, but another to depend on compiling C modules for perl), 
> I have to say that on all machines I tested, it works fine now. The only 
> platform I did not test is IRIX, and I'll do that on Friday.

Thanks.

>>    Johannes Schindelin:
>>       Add the --color-words option to the diff options family
>
> BTW I realized it is not really colouring words, since I erroneously 
> selected word boundaries at whitespace. But if the only reaction to this 
> is your "soooooooo strange", I guess you'll drop it...

Perhaps, I dunno.

>>       read-tree --rename and merge-rename
>
> Do you have any numbers on that? I could imagine that merge-recursive 
> could be rewritten as a shell script using this and git-merge-base...

I think "read-tree --rename" is now becoming into a debuggable
shape.

One bad thing about it is that merge-rename uses the usual
merge-one-file, and it loses a rename merge conflict because of
that.  When our branch renames A to B while their branch renames
A to C, "read-tree --rename" notices it and leaves A, B, and C
in stage #1, #2, and #3, but merge-one-file resolves these paths
following the usual 3-way merge rules, resulting A to be removed
and both B and C created.

^ permalink raw reply

* Re: [PATCH] gitweb.cgi: Customization
From: Junio C Hamano @ 2006-08-02  7:45 UTC (permalink / raw)
  To: Martin Langhoff; +Cc: git
In-Reply-To: <46a038f90608011913t777cf20dh9baaf355b19d18e6@mail.gmail.com>

"Martin Langhoff" <martin.langhoff@gmail.com> writes:

> I'm a bit lost as to gitweb config. Are we not relying on %ENV for
> this stuff?

It is Ok to use %ENV as an alternative way, but I'd rather not
make it the _only_ way for basic configuration.  Not everybody
runs Apache.

^ permalink raw reply

* Re: [PATCH 8/10] Fix some minor warnings to allow -Werror.
From: Junio C Hamano @ 2006-08-02  7:46 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: git
In-Reply-To: <00be01c6b5cf$7f7e9e20$c47eedc1@ramsay1.demon.co.uk>

"Ramsay Jones" <ramsay@ramsay1.demon.co.uk> writes:

> diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
> index 3e40747..bb5e7b7 100644
> --- a/builtin-mailinfo.c
> +++ b/builtin-mailinfo.c
> @@ -531,7 +531,8 @@ static int decode_b_segment(char *in, ch
>  static void convert_to_utf8(char *line, char *charset)
>  {
>  #ifndef NO_ICONV
> -	char *in, *out;
> +	const char *in;
> +	char *out;
>  	size_t insize, outsize, nrc;
>  	char outbuf[4096]; /* cheat */
>  	static char latin_one[] = "latin1";

This kills the compilation with:

gcc -o builtin-mailinfo.o -c -O2 -Werror -ansi -pedantic -std=c99 -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wall -Wdeclaration-after-statement -g -DSHA1_HEADER='<openssl/sha.h>' -DNO_STRLCPY builtin-mailinfo.c
cc1: warnings being treated as errors
builtin-mailinfo.c: In function 'convert_to_utf8':
builtin-mailinfo.c:561: warning: passing argument 2 of 'iconv' from incompatible pointer type

where the line 561 reads:

	nrc = iconv(conv, &in, &insize, &out, &outsize);

> diff --git a/diff.c b/diff.c
> index 5a71489..81630c0 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -614,6 +614,7 @@ static void emit_binary_diff(mmfile_t *o
>  	 * whichever is smaller.
>  	 */
>  	delta = NULL;
> +	orig_size = 0;
>  	deflated = deflate_it(two->ptr, two->size, &deflate_size);
>  	if (one->size && two->size) {
>  		delta = diff_delta(one->ptr, one->size,

This is not wrong per se, but is working around a stupid compiler that
do not understand the dataflow.  orig_size is only used when
delta is non NULL, and when delta is non NULL, the variable is
always set.  Not very happy but is acceptable.

^ permalink raw reply

* Re: [PATCH 6/10] Fix header breakage with _XOPEN_SOURCE.
From: Junio C Hamano @ 2006-08-02  7:46 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: git
In-Reply-To: <00b601c6b5cf$7d54b940$c47eedc1@ramsay1.demon.co.uk>

"Ramsay Jones" <ramsay@ramsay1.demon.co.uk> writes:

> convert-objects.c sets _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED before
> including <time.h>, in order to get the declaration of strptime().
> This leads to breakage in cache.h, due to S_ISLNK and S_IFLNK no longer
> being defined by <sys/stat.h>.  These definitions are protected by the
> __USE_BSD symbol, which is not set when _XOPEN_SOURCE is set.  Moving
> the #defines and #include <time.h> below all other #includes does not
> fix the problem, however, since now _USE_XOPEN, which protects the
> declaration of strptime(), is now not defined (don't ask!).

Wouldn't including "cache.h" and friends first and including
<time.h> last solve the problem, then?

This kind of change tends to fix one system while potentially
breaking another, and we would need to be careful.  Will queue
for post 1.4.2 and have people scream if it breaks somebody, I
guess.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox