diff --git a/src/tools/version_stamp.pl b/src/tools/version_stamp.pl
new file mode 100755
index 6be1ac0..b0a5af0
*** a/src/tools/version_stamp.pl
--- b/src/tools/version_stamp.pl
***************
*** 17,23 ****
  # Usage: cd to top of source tree and issue
  #	src/tools/version_stamp.pl MINORVERSION
  # where MINORVERSION can be a minor release number (0, 1, etc), or
! # "devel", "alphaN", "betaN", "rcN".
  #
  
  # Major version is hard-wired into the script.  We update it when we branch
--- 17,23 ----
  # Usage: cd to top of source tree and issue
  #	src/tools/version_stamp.pl MINORVERSION
  # where MINORVERSION can be a minor release number (0, 1, etc), or
! # "devel", "git", "alphaN", "betaN", "rcN".
  #
  
  # Major version is hard-wired into the script.  We update it when we branch
*************** elsif ($minor eq "devel")
*** 39,44 ****
--- 39,68 ----
  	$dotneeded    = 0;
  	$numericminor = 0;
  }
+ elsif ($minor eq "git")
+ {
+ 	# Add Git commit info to the end of the current version string
+ 	$currminor = get_minor_version(get_current_version());
+ 	if ($currminor =~ /^\./) # Does the minor version start with a dot?
+ 	{
+ 		$dotneeded = 1;
+ 		$currminor =~ s/^\.//;
+ 	}
+ 	else
+ 	{
+ 		$dotneeded = 0;
+ 	}
+ 	if ($currminor =~ /^(\d+)$/) # Does the minor version contain digits only?
+ 	{
+ 		$numericminor = $1;
+ 	}
+ 	else
+ 	{
+ 		$numericminor = 0;
+ 	}
+ 	$minor = $currminor;
+ 	$add_git_info = 1;
+ }
  elsif ($minor =~ m/^alpha\d+$/)
  {
  	$dotneeded    = 0;
*************** elsif ($minor =~ m/^rc\d+$/)
*** 56,62 ****
  }
  else
  {
! 	die "$0: minor-version must be N, devel, alphaN, betaN, or rcN\n";
  }
  
  # Create various required forms of the version number
--- 80,86 ----
  }
  else
  {
! 	die "$0: minor-version must be N, devel, git, alphaN, betaN, or rcN\n";
  }
  
  # Create various required forms of the version number
*************** $aconfver ne ""
*** 94,99 ****
--- 118,132 ----
  
  $fixedfiles = "";
  
+ # If 'git' is specified on the command line, add Git commit information
+ # to the end of the current version string
+ 
+ if (defined($add_git_info))
+ {
+ 	$fullversion .= '+' . `git describe --tags --long`;
+ 	$fullversion =~ s/\s+$//;
+ }
+ 
  sed_file("configure.in",
  "-e 's/AC_INIT(\\[PostgreSQL\\], \\[[0-9a-z.]*\\]/AC_INIT([PostgreSQL], [$fullversion]/'"
  );
*************** sub sed_file
*** 138,140 ****
--- 171,201 ----
  
  	$fixedfiles .= "\t$filename\n";
  }
+ 
+ # Extract current version from configure.in
+ sub get_current_version
+ {
+ 	my $retval = '';
+ 	open(my $fh, "configure.in")
+ 	  or die("could not open configure.in: $!\n");
+ 	while (<$fh>) {
+ 		if (/AC_INIT\(\[PostgreSQL\], \[(\S+?)\]/)
+ 		{
+ 			$retval = $1;
+ 			last;
+ 		}
+ 	}
+ 	close($fh);
+ 	if (!length($retval)) {
+ 		die("could not extract version information from configure.in\n");
+ 	}
+ 	return($retval);
+ }
+ 
+ # Extract minor version from version string
+ sub get_minor_version
+ {
+ 	my $currversion = shift;
+ 	$currversion =~ s/^\d+\.\d+//;
+ 	return($currversion);
+ }
