Git development
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix handling of merges in git-annotate
From: Ryan Anderson @ 2006-07-04  1:30 UTC (permalink / raw)
  To: junkio; +Cc: git

This 2-patch series is a major overhaul to the way git-annotate calculates the blame for each line.

Instead of parsing each diff in reverse, this uses the output from "git
diff-tree --combined", so that merges can be handled sanely.

Ryan Anderson:
      annotate: Support annotation of files on other revisions.
      annotate: Correct most merge following to annotate correctly.

 git-annotate.perl   |  197 ++++++++++++++++++++++++++++++++++++---------------
 t/t8001-annotate.sh |    6 ++
 2 files changed, 145 insertions(+), 58 deletions(-)

^ permalink raw reply

* [PATCH 2/2] annotate: Correct most merge following to annotate correctly.
From: Ryan Anderson @ 2006-07-04  1:30 UTC (permalink / raw)
  To: junkio; +Cc: git, Ryan Anderson
In-Reply-To: <11519766033852-git-send-email-ryan@michonline.com>

There is still a bug involving octopus merges, somewhere, but this gets normal
merges correct, so it's still an improvement over the existing version.

Signed-off-by: Ryan Anderson <ryan@michonline.com>
---
 git-annotate.perl |  197 +++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 139 insertions(+), 58 deletions(-)

diff --git a/git-annotate.perl b/git-annotate.perl
index a6a7a48..9a7b022 100755
--- a/git-annotate.perl
+++ b/git-annotate.perl
@@ -102,10 +102,10 @@ while (my $bound = pop @stack) {
 push @revqueue, $head;
 init_claim( defined $starting_rev ? $head : 'dirty');
 unless (defined $starting_rev) {
-	my $diff = open_pipe("git","diff","-R", "HEAD", "--",$filename)
+	my $diff = open_pipe("git","diff","HEAD", "--",$filename)
 		or die "Failed to call git diff to check for dirty state: $!";
 
-	_git_diff_parse($diff, $head, "dirty", (
+	_git_diff_parse($diff, [$head], "dirty", (
 				'author' => gitvar_name("GIT_AUTHOR_IDENT"),
 				'author_date' => sprintf("%s +0000",time()),
 				)
@@ -154,14 +154,13 @@ sub handle_rev {
 
 		my %revinfo = git_commit_info($rev);
 
-		foreach my $p (@{$revs{$rev}{'parents'}}) {
-
-			git_diff_parse($p, $rev, %revinfo);
-			push @revqueue, $p;
-		}
+		if (exists $revs{$rev}{parents} &&
+		    scalar @{$revs{$rev}{parents}} != 0) {
 
+			git_diff_parse($revs{$rev}{'parents'}, $rev, %revinfo);
+			push @revqueue, @{$revs{$rev}{'parents'}};
 
-		if (scalar @{$revs{$rev}{parents}} == 0) {
+ 		} else {
 			# We must be at the initial rev here, so claim everything that is left.
 			for (my $i = 0; $i < @{$revs{$rev}{lines}}; $i++) {
 				if (ref ${$revs{$rev}{lines}}[$i] eq '' || ${$revs{$rev}{lines}}[$i][1] eq '') {
@@ -252,89 +251,171 @@ sub git_find_parent {
 # Get a diff between the current revision and a parent.
 # Record the commit information that results.
 sub git_diff_parse {
-	my ($parent, $rev, %revinfo) = @_;
+	my ($parents, $rev, %revinfo) = @_;
+
+	my @filenames = ( $revs{$rev}{'filename'} );
+	foreach my $parent (@$parents) {
+		push @filenames, $revs{$parent}{'filename'};
+	}
 
-	my $diff = open_pipe("git-diff-tree","-M","-p",$rev,$parent,"--",
-			$revs{$rev}{'filename'}, $revs{$parent}{'filename'})
+	my $diff = open_pipe("git-diff-tree","-M","-p","-c",$rev,"--",
+				@filenames )
 		or die "Failed to call git-diff for annotation: $!";
 
-	_git_diff_parse($diff, $parent, $rev, %revinfo);
+	_git_diff_parse($diff, $parents, $rev, %revinfo);
 
 	close($diff);
 }
 
 sub _git_diff_parse {
-	my ($diff, $parent, $rev, %revinfo) = @_;
+	my ($diff, $parents, $rev, %revinfo) = @_;
+
+	my $ri = 0;
 
-	my ($ri, $pi) = (0,0);
 	my $slines = $revs{$rev}{'lines'};
-	my @plines;
+	my (%plines, %pi);
 
 	my $gotheader = 0;
 	my ($remstart);
-	my ($hunk_start, $hunk_index);
+	my $parent_count = @$parents;
+
+	my $diff_header_regexp = "^@";
+	$diff_header_regexp .= "@" x @$parents;
+	$diff_header_regexp .= ' -\d+,\d+' x @$parents;
+	$diff_header_regexp .= ' \+(\d+),\d+';
+
+	my %claim_regexps;
+	my $allparentplus = '^' . '\\+' x @$parents . '(.*)$';
+
+	{
+		my $i = 0;
+		foreach my $parent (@$parents) {
+
+			$pi{$parent} = 0;
+			my $r = '^' . '.' x @$parents . '(.*)$';
+			my $p = $r;		     
+			substr($p,$i+1, 1) = '\\+';
+
+			my $m = $r;
+			substr($m,$i+1, 1) = '-';
+
+			$claim_regexps{$parent}{plus} = $p;
+			$claim_regexps{$parent}{minus} = $m;
+
+			$plines{$parent} = [];
+
+			$i++;
+		}
+	}
+
+	DIFF:
 	while(<$diff>) {
 		chomp;
-		if (m/^@@ -(\d+),(\d+) \+(\d+),(\d+)/) {
-			$remstart = $1;
-			# Adjust for 0-based arrays
-			$remstart--;
-			# Reinit hunk tracking.
-			$hunk_start = $remstart;
-			$hunk_index = 0;
+		if (m/$diff_header_regexp/) {
+			$remstart = $1 - 1;
+			# (0-based arrays)
+
 			$gotheader = 1;
 
-			for (my $i = $ri; $i < $remstart; $i++) {
-				$plines[$pi++] = $slines->[$i];
-				$ri++;
+			printf("Copying from %d to %d\n", $ri, $remstart);
+			foreach my $parent (@$parents) {
+				for (my $i = $ri; $i < $remstart; $i++) {
+					$plines{$parent}[$pi{$parent}++] = $slines->[$i];
+				}
 			}
-			next;
-		} elsif (!$gotheader) {
-			next;
-		}
+			$ri = $remstart;
 
-		if (m/^\+(.*)$/) {
-			my $line = $1;
-			$plines[$pi++] = [ $line, '', '', '', 0 ];
-			next;
+			next DIFF;
 
-		} elsif (m/^-(.*)$/) {
-			my $line = $1;
-			if (get_line($slines, $ri) eq $line) {
-				# Found a match, claim
-				claim_line($ri, $rev, $slines, %revinfo);
-			} else {
-				die sprintf("Sync error: %d/%d\n|%s\n|%s\n%s => %s\n",
-						$ri, $hunk_start + $hunk_index,
-						$line,
-						get_line($slines, $ri),
-						$rev, $parent);
-			}
-			$ri++;
+		} elsif (!$gotheader) {
+			# Skip over the leadin.
+			next DIFF;
+		}
 
-		} elsif (m/^\\/) {
+		if (m/^\\/) {
 			;
 			# Skip \No newline at end of file.
 			# But this can be internationalized, so only look
 			# for an initial \
 
 		} else {
-			if (substr($_,1) ne get_line($slines,$ri) ) {
-				die sprintf("Line %d (%d) does not match:\n|%s\n|%s\n%s => %s\n",
-						$hunk_start + $hunk_index, $ri,
-						substr($_,1),
-						get_line($slines,$ri),
-						$rev, $parent);
+			my %claims = ();
+			my $negclaim = 0;
+			my $allclaimed = 0;
+			my $line;
+
+			if (m/$allparentplus/) {
+				claim_line($ri, $rev, $slines, %revinfo);
+				$allclaimed = 1;
+
+			}
+
+			PARENT:
+			foreach my $parent (keys %claim_regexps) {
+				my $m = $claim_regexps{$parent}{minus};
+				my $p = $claim_regexps{$parent}{plus};
+
+				if (m/$m/) {
+					$line = $1;
+					$plines{$parent}[$pi{$parent}++] = [ $line, '', '', '', 0 ];
+					$negclaim++;
+
+				} elsif (m/$p/) {
+					$line = $1;
+					if (get_line($slines, $ri) eq $line) {
+						# Found a match, claim
+					       	$claims{$parent}++;
+
+					} else {
+						die sprintf("Sync error: %d\n|%s\n|%s\n%s => %s\n",
+								$ri, $line,
+								get_line($slines, $ri),
+								$rev, $parent);
+					}
+				}
+			}
+
+			if (%claims) {
+				foreach my $parent (@$parents) {
+					next if $claims{$parent} || $allclaimed;
+					$plines{$parent}[$pi{$parent}++] = $slines->[$ri];
+					    #[ $line, '', '', '', 0 ];
+				}
+				$ri++;
+
+			} elsif ($negclaim) {
+				next DIFF;
+
+			} else {
+				if (substr($_,scalar @$parents) ne get_line($slines,$ri) ) {
+				        foreach my $parent (@$parents) {
+						printf("parent %s is on line %d\n", $parent, $pi{$parent});
+					}
+
+					die sprintf("Line %d, does not match:\n|%s|\n|%s|\n%s\n",
+						    $ri,
+						substr($_,scalar @$parents),
+						get_line($slines,$ri), $rev);
+				}
+				foreach my $parent (@$parents) {
+					$plines{$parent}[$pi{$parent}++] = $slines->[$ri];
+				}
+				$ri++;
 			}
-			$plines[$pi++] = $slines->[$ri++];
 		}
-		$hunk_index++;
 	}
+
 	for (my $i = $ri; $i < @{$slines} ; $i++) {
-		push @plines, $slines->[$ri++];
+		foreach my $parent (@$parents) {
+			push @{$plines{$parent}}, $slines->[$ri];
+		}
+		$ri++;
+	}
+
+	foreach my $parent (@$parents) {
+		$revs{$parent}{lines} = $plines{$parent};
 	}
 
-	$revs{$parent}{lines} = \@plines;
 	return;
 }
 
-- 
1.4.1.g8fced

^ permalink raw reply related

* [PATCH 1/2] annotate: Support annotation of files on other revisions.
From: Ryan Anderson @ 2006-07-04  1:30 UTC (permalink / raw)
  To: junkio; +Cc: git, Ryan Anderson
In-Reply-To: <11519766021208-git-send-email-ryan@michonline.com>

This is a bug fix, and cleans up one or two other things spotted during the
course of tracking down the main bug here.

Also, the test-suite is updated to reflect this case.

Signed-off-by: Ryan Anderson <ryan@michonline.com>
(cherry picked from 2f7554b4db3ab2c2d3866b160245c91c9236fc9a commit)
---
 t/t8001-annotate.sh |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/t/t8001-annotate.sh b/t/t8001-annotate.sh
index 2496397..70e2ad2 100755
--- a/t/t8001-annotate.sh
+++ b/t/t8001-annotate.sh
@@ -6,4 +6,10 @@ test_description='git-annotate'
 PROG='git annotate'
 . ../annotate-tests.sh
 
+test_expect_success \
+    'Annotating an old revision works' \
+    '[ $(git annotate file master | awk "{print \$3}" | grep -c "^A$") == 2 ] && \
+     [ $(git annotate file master | awk "{print \$3}" | grep -c "^B$") == 2 ]'
+
+
 test_done
-- 
1.4.1.g8fced

^ permalink raw reply related

* Re: git-fetch per-repository speed issues
From: Ryan Anderson @ 2006-07-04  1:22 UTC (permalink / raw)
  To: Jeff King; +Cc: Linus Torvalds, Keith Packard, Git Mailing List
In-Reply-To: <20060704002138.GB5716@coredump.intra.peff.net>

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

Jeff King wrote:
> On Mon, Jul 03, 2006 at 04:14:10PM -0700, Linus Torvalds wrote:
>
>   
>> Well, you could use multiple branches in the same repository, even if they 
>> are totally unrealated. That would allow you to fetch them all in one go.
>>     
>
> One annoying thing about this is that you may want to have several of
> the branches checked out at a time (i.e., you want the actual directory
> structure of libXrandr/, Xorg/, etc). You could pull everything down
> into one repo and point small pseudo-repos at it with alternates, but I
> would think that would become a mess with pushes. You can do some magic
> with read-tree --prefix, but again, I'm not sure how you'd make commits
> on the correct branch.  Is there an easier way to do this?
>   
You can have multiple source trees, one per 'branch' (which is a bit of
a bad term here), and have completely unrelated things in the branches.

See, for an example, the main Git repo, which has the "man", "html", and
"todo" branches, logically distinct and (somewhat) unrelated to the main
branch tucked away in "master".

-- 

Ryan Anderson
  sometimes Pug Majere



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply

* [PATCH] Add a custom ./configure script
From: Petr Baudis @ 2006-07-04  0:40 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

This patch adds a custom hand-made and supposedly easy to debug ./configure
script. It is originally based on mplayer's ./configure script but heavily
modified and of course stripped of all the mplayer-specific tests, as well
as many other tests we won't probably need (but we might reintroduce some
of them later). I kept the CPU checks since they might come handy to decide
which assembler SHA1 implementation to choose.

Also, I'm an autogeneration freak so compared to the mplayer's script
this one has a bit different design wrt. the configuration variables; instead
of adding random bits of code at various places you just insert one function
call near the top and your test near the bottom, everything else is taken
care of automagically. Also, the heavy machinery is split to a separate library
config-lib.sh.

It's a shame that we have to carry something like this around. Wouldn't the
world be much happier place if there would be something like autoconf but
instead of mucking with M4 you would just write a shell script while calling
various predefined functions? :/

The patch is on top of pu, that is Jakub Narebski's autoconf patch, because
it reuses most of its infrastructure and just replaces the configure script.

Signed-off-by: Petr Baudis <pasky@suse.cz>
---

 .gitignore    |    6 -
 INSTALL       |    1 
 config-lib.sh |  449 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 config.mak.in |   18 --
 configure     |   78 ++++++++++
 configure.ac  |   14 --
 6 files changed, 528 insertions(+), 38 deletions(-)

diff --git a/.gitignore b/.gitignore
index 616aa98..8950a9e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -136,10 +136,6 @@ git-core.spec
 *.[ao]
 *.py[co]
 config.mak
-autom4te.cache
-config.log
-config.status
-config.mak.in
 config.mak.autogen
-configure
+config.log
 git-blame
diff --git a/INSTALL b/INSTALL
index 6c8fd09..bff6aa6 100644
--- a/INSTALL
+++ b/INSTALL
@@ -16,7 +16,6 @@ install" would not work.
 Alternatively you can use autoconf generated ./configure script to
 set up install paths (via config.mak.autogen), so you can write instead
 
-	$ autoconf ;# as yourself if ./configure doesn't exist yet
 	$ ./configure --prefix=/usr ;# as yourself
 	$ make all doc ;# as yourself
 	# make install install-doc ;# as root
diff --git a/config-lib.sh b/config-lib.sh
new file mode 100755
index 0000000..68fecc5
--- /dev/null
+++ b/config-lib.sh
@@ -0,0 +1,449 @@
+# This script provides a wannabe-generic library for compile-time package
+# autoconfiguration
+# Copyright (c) Petr Baudis, 2006
+#
+#
+# Some design traits and large chunks of this script come from mplayer:
+#
+# Original version (C) 2000 Pontscho/fresh!mindworkz
+#                      pontscho@makacs.poliod.hu
+#
+# History / Contributors: check the cvs log !
+#
+# Cleanups all over the place (c) 2001 pl
+#
+#
+# This configure script is *not* autoconf-based and has different semantics.
+# It attempts to autodetect all settings and options where possible. It is
+# possible to override autodetection with the --enable-option/--disable-option
+# command line parameters.  --enable-option forces the option on skipping
+# autodetection. Yes, this means that compilation may fail and yes, this is not
+# how autoconf-based configure scripts behave.
+#
+# configure generates config.mak.autogen, then included in the Makefile.
+#
+#############################################################################
+
+# Prevent locale nonsense from breaking basic text processing utils
+LC_ALL=C
+export LC_ALL
+
+# These macros only return an error code - NO display is done
+
+compile_check() {
+{
+	echo
+	cat "$1"
+	echo
+	echo "$_cc $CFLAGS $_inc_extra $_ld_static $_ld_extra -o $TMPO $@"
+	rm -f "$TMPO"
+	$_cc $CFLAGS $_inc_extra $_ld_static $_ld_extra -o "$TMPO" "$@" || return $?
+	echo
+	echo "ldd $TMPO"
+	$_ldd "$TMPO" || return $?
+	echo
+} >>"$TMPLOG" 2>&1
+}
+
+cc_check() {
+	compile_check $TMPC $@
+}
+
+# Try to run the compiled file
+tmp_run() {
+	"$TMPO" >> "$TMPLOG" 2>&1
+}
+
+# Display error message, flushes tempfile, exit
+die () {
+	echo
+	echo "Error: $@" >&2
+	echo >&2
+	rm -f "$TMPO" "$TMPC" "$TMPS" "$TMPCPP"
+	echo "Check \"$TMPLOG\" if you do not understand why it failed." >&2
+	exit 1
+}
+
+# OS test booleans functions
+issystem() {
+	test "`echo $system_name | tr A-Z a-z`" = "`echo $1 | tr A-Z a-z`"
+}
+linux()   { issystem "Linux"   ; return "$?" ; }
+sunos()   { issystem "SunOS"   ; return "$?" ; }
+hpux()    { issystem "HP-UX"   ; return "$?" ; }
+irix()    { issystem "IRIX"    ; return "$?" ; }
+aix()     { issystem "AIX"     ; return "$?" ; }
+cygwin()  { issystem "CYGWIN"  ; return "$?" ; }
+freebsd() { issystem "FreeBSD" ; return "$?" ; }
+netbsd()  { issystem "NetBSD"  ; return "$?" ; }
+bsdos()   { issystem "BSD/OS"  ; return "$?" ; }
+openbsd() { issystem "OpenBSD" ; return "$?" ; }
+bsd()     { freebsd || netbsd || bsdos || openbsd ; return "$?" ; }
+qnx()     { issystem "QNX"     ; return "$?" ; }
+darwin()  { issystem "Darwin"  ; return "$?" ; }
+gnu()     { issystem "GNU"     ; return "$?" ; }
+mingw32() { issystem "MINGW32" ; return "$?" ; }
+morphos() { issystem "MorphOS" ; return "$?" ; }
+win32()   { cygwin || mingw32  ; return "$?" ; }
+beos()    { issystem "BEOS"    ; return "$?" ; }
+
+# arch test boolean functions
+# x86/x86pc is used by QNX
+x86() {
+	case "$host_arch" in
+		i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686) return 0 ;;
+		*) return 1 ;;
+	esac
+}
+
+x86_64() {
+	case "$host_arch" in
+		x86_64|amd64) return 0 ;;
+		*) return 1 ;;
+	esac
+}
+
+ppc() {
+	case "$host_arch" in
+		ppc) return 0;;
+		*) return 1;;
+	esac
+}
+
+alpha() {
+	case "$host_arch" in
+		alpha) return 0;;
+		*) return 1;;
+	esac
+}
+
+# not boolean test: implement the posix shell "!" operator for a
+# non-posix /bin/sh.
+#   usage:  not {command}
+# returns exit status "success" when the execution of "command"
+# fails.
+not() {
+	eval "$@"
+	test $? -ne 0
+}
+
+# Use this before starting a check
+# The second optional parameter is name of the feature variable;
+# it is preset to an empty string so that it can be dropped into
+# config.mak.autogen seamlessly; use echores_yesno() for reporting.
+echocheck() {
+	echo "============ Checking $@ ============" >> "$TMPLOG"
+	echo ${_echo_n} "Checking $@... ${_echo_c}"
+}
+
+# Use this to echo the results of a check
+echores() {
+	if test "$_res_comment" ; then
+		_res_comment="($_res_comment)"
+	fi
+	echo "Result is: $@ $_res_comment" >> "$TMPLOG"
+	echo "##########################################" >> "$TMPLOG"
+	echo "" >> "$TMPLOG"
+	echo "$@ $_res_comment"
+	_res_comment=""
+}
+
+# Use this to introduce a regular feature with a commandline switch
+# @name is the variable name
+# @switch is the commandline switch
+# @mkvar is the Makefile variable name; prefix with a space to say that it's negated (ow)
+# @desc is a line to insert to the --help output
+# @default is the default value (yes/no/auto)
+add_library() { # --with
+	name="$1"; shift; switch="$1"; shift; mkvar="$1"; shift; default="$1"; shift; desc="$1"; shift
+	case $default in
+		yes) hdefault=with;;
+		no) hdefault=without;;
+		auto) hdefault=autodetect;;
+	esac
+
+	lib_help="$lib_help
+$desc [$hdefault]"
+	switches="$switches switch_lib \"$name\" \"$switch\" \"\$ac_option\" || "
+	mkvars="$mkvars mkvar \"\$$name\" \"$mkvar\";"
+	eval "$name=$default"
+}
+
+add_feature() { # --enable
+	name="$1"; shift; switch="$1"; shift; mkvar="$1"; shift; default="$1"; shift; desc="$1"; shift
+	case $default in
+		yes) hdefault=enable;;
+		no) hdefault=disable;;
+		auto) hdefault=autodetect;;
+	esac
+
+	feature_help="$feature_help
+$desc [$hdefault]"
+	switches="$switches switch_feature \"$name\" \"$switch\" \"\$ac_option\" || "
+	mkvars="$mkvars mkvar \"\$$name\" \"$mkvar\";"
+	eval "$name=$default"
+}
+
+lib_help=
+feature_help=
+switches=
+mkvars=
+
+
+switch_lib() {
+	name="$1"; shift; switch="$1"; shift; option="$1"; shift
+	case $option in
+		--with-$switch) eval "$name=yes";;
+		--without-$switch) eval "$name=no";;
+		*) return 1
+	esac
+	return 0
+}
+
+switch_feature() {
+	name="$1"; shift; switch="$1"; shift; option="$1"; shift
+	case $option in
+		--enable-$switch) eval "$name=yes";;
+		--disable-$switch) eval "$name=no";;
+		*) return 1
+	esac
+	return 0
+}
+
+mkvar() {
+	value="$1"; shift; mkvar="$1"; shift
+	noval=""; yesval="ConfigureYesPlease"
+	case $mkvar in
+		\ *) swap="$noval"; noval="$yesval"; yesval="$swap";;
+	esac
+	case $value in
+		auto) die "$mkvar autodetection failed";;
+		no) echo "$mkvar = $noval";;
+		yes) echo "$mkvar = $yesval";;
+		*) die "$mkvar got invalid value ''$value''";;
+	esac
+}
+
+
+#############################################################################
+
+
+# Check how echo works in this /bin/sh
+case `echo -n` in
+	-n)	_echo_n=	_echo_c='\c'	;;	# SysV echo
+	*)	_echo_n='-n '	_echo_c=	;;	# BSD echo
+esac
+
+
+process_params() {
+	_install=install
+	_cc=cc
+	test "$CC" && _cc="$CC"
+
+	for ac_option do
+		case "$ac_option" in
+		--help|-help|-h)
+			cat << EOF
+Usage: $0 [OPTIONS]...
+
+Configuration:
+  -h, --help             display this help and exit
+
+Installation directories:
+  --prefix=DIR           use this prefix for installing git [HOME]
+  --bindir=DIR           use this prefix for installing git binary
+                         [PREFIX/bin]
+  --gitexecdir=DIR       use this prefix for installing individual git command
+                         binaries [BINDIR]
+  --mandir=DIR           use this prefix for installing manpages [PREFIX/man]
+  --templatedir=DIR      use this prefix for installing configuration file
+                         templates [PREFIX/share/git-core/templates]
+  --gitpythondir=DIR     use this prefix for python libraries [PREFIX/share/git-core/python]
+
+Miscellaneous options:
+  --cc=COMPILER          use this C compiler to build MPlayer [gcc]
+  --target=PLATFORM      target platform (i386-linux, arm-linux, etc)
+  --with-install=PATH    use a custom install program (useful if your OS uses
+                         a GNU-incompatible install utility by default and
+                         you want to use GNU version)
+
+For the options below, see the top of the Makefile for more detailed
+description.
+
+Optional features:$feature_help
+
+Optional libraries:$lib_help
+
+This configure script is NOT autoconf-based, even though its output is similar.
+It will try to autodetect all configuration options. If you --enable an option
+it will be forcefully turned on, skipping autodetection. This can break
+compilation, so you need to know what you are doing.
+EOF
+			exit 0 ;;
+
+		--prefix=*)
+			_prefix=`echo $ac_option | cut -d '=' -f 2` ;;
+		--bindir=*)
+			_bindir=`echo $ac_option | cut -d '=' -f 2` ;;
+		--gitexecdir=*)
+			_gitexecdir=`echo $ac_option | cut -d '=' -f 2` ;;
+		--mandir=*)
+			_mandir=`echo $ac_option | cut -d '=' -f 2` ;;
+		--templatedir=*)
+			_templatedir=`echo $ac_option | cut -d '=' -f 2` ;;
+		--gitpythondir=*)
+			_gitpythondir=`echo $ac_option | cut -d '=' -f 2` ;;
+
+		--cc=*)
+			_cc=`echo $ac_option | cut -d '=' -f 2` ;;
+		--target=*)
+			_target=`echo $ac_option | cut -d '=' -f 2` ;;
+		--with-install=*)
+			_install=`echo $ac_option | cut -d '=' -f 2 ` ;;
+
+		*)
+			# $switches is the real bulk
+			eval "$switches { echo \"Unknown parameter: $ac_option\"; exit 1; }" || exit 1 ;;
+		esac
+	done
+
+	# Determine our OS name and CPU architecture
+	if test -z "$_target" ; then
+		# OS name
+		system_name=`uname -s 2>&1`
+		case "$system_name" in
+		Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin|GNU|BeOS|MorphOS|AIX)
+			;;
+		IRIX*)
+			system_name=IRIX ;;
+		HP-UX*)
+			system_name=HP-UX ;;
+		[cC][yY][gG][wW][iI][nN]*)
+			system_name=CYGWIN ;;
+		MINGW32*)
+			system_name=MINGW32 ;;
+		*)
+			system_name="$system_name-UNKNOWN" ;;
+		esac
+
+
+		# host's CPU/instruction set
+		host_arch=`uname -p 2>&1`
+		case "$host_arch" in
+		i386|sparc|ppc|alpha|arm|mips|vax)
+			;;
+		powerpc) # Darwin returns 'powerpc'
+			host_arch=ppc ;;
+		*)	# uname -p on Linux returns 'unknown' for the processor type,
+			# OpenBSD returns 'Intel Pentium/MMX ("Genuine Intel" 586-class)'
+
+			# Maybe uname -m (machine hardware name) returns something we
+			# recognize.
+
+			# x86/x86pc is used by QNX
+			case "`uname -m 2>&1`" in
+				i[3-9]86*|x86|x86pc|k5|k6|k6_2|k6_3|k6-2|k6-3|pentium*|athlon*|i586_i686|i586-i686|BePC) host_arch=i386 ;;
+				ia64) host_arch=ia64 ;;
+				x86_64|amd64)
+				if [ -n "`$_cc -dumpmachine | sed -n '/^x86_64-/p;/^amd64-/p'`" -a \
+					-z "`echo $CFLAGS | grep -- -m32`"  ]; then
+					host_arch=x86_64
+				else
+					host_arch=i386
+				fi
+				;;
+				macppc|ppc|ppc64) host_arch=ppc ;;
+				alpha) host_arch=alpha ;;
+				sparc) host_arch=sparc ;;
+				sparc64) host_arch=sparc64 ;;
+				parisc*|hppa*|9000*) host_arch=hppa ;;
+				arm*|zaurus|cats) host_arch=arm ;;
+				s390) host_arch=s390 ;;
+				s390x) host_arch=s390x ;;
+				mips*) host_arch=mips ;;
+				vax) host_arch=vax ;;
+				*) host_arch=UNKNOWN ;;
+			esac
+			;;
+		esac
+	else # if test -z "$_target"
+		system_name=`echo $_target | cut -d '-' -f 2`
+		case "`echo $system_name | tr A-Z a-z`" in
+			linux) system_name=Linux ;;
+			freebsd) system_name=FreeBSD ;;
+			netbsd) system_name=NetBSD ;;
+			bsd/os) system_name=BSD/OS ;;
+			openbsd) system_name=OpenBSD ;;
+			sunos) system_name=SunOS ;;
+			qnx) system_name=QNX ;;
+			morphos) system_name=MorphOS ;;
+			mingw32msvc) system_name=MINGW32 ;;
+		esac
+		# We need to convert underscores so that values like k6-2 and pentium-mmx can be passed
+		host_arch=`echo $_target | cut -d '-' -f 1 | tr '_' '-'`
+	fi
+
+	echo "Detected operating system: $system_name"
+	echo "Detected host architecture: $host_arch"
+}
+
+
+test_setup() {
+	# LGB: temporary files
+	# FIXME: Use mktemp -d?
+	for I in "$TMPDIR" "$TEMPDIR" "/tmp" ; do
+		test "$I" && break
+	done
+
+	TMPLOG="config.log"
+	rm -f "$TMPLOG"
+	TMPC="$I/git-conf-$RANDOM-$$.c"
+	TMPO="$I/git-conf-$RANDOM-$$.o"
+	TMPS="$I/git-conf-$RANDOM-$$.S"
+}
+
+basic_tests() {
+	echocheck "if your build environment is sane"
+	cat > $TMPC <<EOF
+int main(void) { return 0; }
+EOF
+	{ cc_check && tmp_run; } || die "unusable compiler or produced binary"
+	echores yes
+}
+
+
+write_config() {
+	echo "Creating config.mak.autogen"
+
+	{
+		cat << EOF
+# -------- Generated by configure -----------
+
+CC = $_cc
+INSTALL = $_install
+
+EOF
+		test -z $_prefix || echo "prefix = $_prefix"
+		test -z $_bindir || echo "bindir = $_bindir"
+		test -z $_gitexecdir || echo "gitexecdir = $_gitexecdir"
+		test -z $_mandir || ( echo "mandir = $_mandir" && echo "export mandir" )
+		test -z $_templatedir || echo "template_dir = $_templatedir"
+		test -z $_gitpythondir || echo "GIT_PYTHON_DIR = $_gitpythondir"
+		echo
+		eval "$mkvars"
+	} > config.mak.autogen
+
+	cat << EOF
+
+Config files successfully generated by ./configure.
+You can inspect the results in \`\`./config.mak.autogen''.
+EOF
+}
+
+
+finish() {
+	# Last move:
+	rm -f "$TMPO" "$TMPC" "$TMPS" "$TMPCPP"
+}
+
+trap finish 0
diff --git a/config.mak.in b/config.mak.in
deleted file mode 100644
index 82c9781..0000000
--- a/config.mak.in
+++ /dev/null
@@ -1,18 +0,0 @@
-# git Makefile configuration, included in main Makefile
-# @configure_input@
-
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-bindir = @bindir@
-#gitexecdir = @libexecdir@/git-core/
-template_dir = @datadir@/git-core/templates/
-GIT_PYTHON_DIR = @datadir@/git-core/python
-
-mandir=@mandir@
-
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-export exec_prefix mandir
-export srcdir VPATH
-
diff --git a/configure b/configure
new file mode 100755
index 0000000..2604aa3
--- /dev/null
+++ b/configure
@@ -0,0 +1,78 @@
+#! /bin/sh
+#
+# This configure script is *not* autoconf-based and has different semantics.
+# It attempts to autodetect all settings and options where possible. It is
+# possible to override autodetection with the --enable-option/--disable-option
+# command line parameters.  --enable-option forces the option on skipping
+# autodetection. Yes, this means that compilation may fail and yes, this is not
+# how autoconf-based configure scripts behave.
+#
+# configure generates config.mak.autogen, then included in the Makefile.
+#
+# If you want to add a new check for $feature, add it at two places - to the
+# variable list and to the checks section. You will find both below.
+#
+#############################################################################
+
+[ -f ./config-lib.sh ] || {
+	echo "config-lib.sh not found; please run ./configure from the source tree" >&2
+	exit 1
+}
+. ./config-lib.sh
+
+
+
+#############################################################################
+
+# List variables for features and libraries here:
+
+add_feature "_no_symlink_head" "no-symlink-head" "NO_SYMLINK_HEAD" "auto" \
+"  --enable-no-symlink-head  Never have .git/HEAD as a symbolic link"
+
+add_feature "_nsec" "nsec" "USE_NSEC" "no" \
+"  --enable-nsec          Use sub-second resolution when checking mtimes"
+
+add_library "_expat" "expat" " NO_EXPAT" "auto" \
+"  --without-expat        Disable libexpat support (disables git-http-push)"
+
+
+#############################################################################
+
+
+process_params "$@"
+test_setup
+basic_tests
+
+
+#############################################################################
+
+
+echocheck "whether to prohibit usage of symlinked HEAD"
+if test "$_no_symlink_head" = auto ; then
+	if win32; then
+		_no_symlink_head=yes
+	else
+		_no_symlink_head=no
+	fi
+fi
+echores "$_no_symlink_head"
+
+
+echocheck "for expat"
+if test "$_expat" = auto ; then
+	cat > $TMPC <<EOF
+#include <expat.h>
+int main(void) { return 0; }
+EOF
+	_expat=no
+	cc_check -lexpat && _expat=yes
+fi
+echores "$_expat"
+
+
+# Insert tests for features and libraries here.
+
+#############################################################################
+
+
+write_config
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index a0374d4..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,14 +0,0 @@
-#                                               -*- Autoconf -*-
-# Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.59)
-AC_INIT([git], [1.4.1], [git@vger.kernel.org])
-
-AC_CONFIG_SRCDIR([git.c])
-
-config_file=config.mak.autogen
-config_in=config.mak.in
-
-# Output files
-AC_CONFIG_FILES(["${config_file}":"${config_in}"])
-AC_OUTPUT

^ permalink raw reply related

* [PATCH] Add a custom ./configure script
From: Petr Baudis @ 2006-07-04  0:25 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

This patch adds a custom hand-made and supposedly easy to debug ./configure
script. It is originally based on mplayer's ./configure script but heavily
modified and of course stripped of all the mplayer-specific tests, as well
as many other tests we won't probably need (but we might reintroduce some
of them later). I kept the CPU checks since they might come handy to decide
which assembler SHA1 implementation to choose.

Also, I'm an autogeneration freak so compared to the mplayer's script
this one has a bit different design wrt. the configuration variables; instead
of adding random bits of code at various places you just insert one function
call near the top and your test near the bottom, everything else is taken
care of automagically. Also, the heavy machinery is split to a separate library
config-lib.sh.

It's a shame that we have to carry something like this around. Wouldn't the
world be much happier place if there would be something like autoconf but
instead of mucking with M4 you would just write a shell script while calling
various predefined functions? :/

The patch is on top of pu, that is Jakub Narebski's autoconf patch, because
it reuses most of its infrastructure and just replaces the configure script.

Signed-off-by: Petr Baudis <pasky@suse.cz>
---

 .gitignore    |    6 -
 INSTALL       |    1 
 config-lib.sh |  449 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 config.mak.in |   18 --
 configure     |   78 ++++++++++
 configure.ac  |   14 --
 6 files changed, 528 insertions(+), 38 deletions(-)

diff --git a/.gitignore b/.gitignore
index 616aa98..8950a9e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -136,10 +136,6 @@ git-core.spec
 *.[ao]
 *.py[co]
 config.mak
-autom4te.cache
-config.log
-config.status
-config.mak.in
 config.mak.autogen
-configure
+config.log
 git-blame
diff --git a/INSTALL b/INSTALL
index 6c8fd09..bff6aa6 100644
--- a/INSTALL
+++ b/INSTALL
@@ -16,7 +16,6 @@ install" would not work.
 Alternatively you can use autoconf generated ./configure script to
 set up install paths (via config.mak.autogen), so you can write instead
 
-	$ autoconf ;# as yourself if ./configure doesn't exist yet
 	$ ./configure --prefix=/usr ;# as yourself
 	$ make all doc ;# as yourself
 	# make install install-doc ;# as root
diff --git a/config-lib.sh b/config-lib.sh
new file mode 100755
index 0000000..68fecc5
--- /dev/null
+++ b/config-lib.sh
@@ -0,0 +1,449 @@
+# This script provides a wannabe-generic library for compile-time package
+# autoconfiguration
+# Copyright (c) Petr Baudis, 2006
+#
+#
+# Some design traits and large chunks of this script come from mplayer:
+#
+# Original version (C) 2000 Pontscho/fresh!mindworkz
+#                      pontscho@makacs.poliod.hu
+#
+# History / Contributors: check the cvs log !
+#
+# Cleanups all over the place (c) 2001 pl
+#
+#
+# This configure script is *not* autoconf-based and has different semantics.
+# It attempts to autodetect all settings and options where possible. It is
+# possible to override autodetection with the --enable-option/--disable-option
+# command line parameters.  --enable-option forces the option on skipping
+# autodetection. Yes, this means that compilation may fail and yes, this is not
+# how autoconf-based configure scripts behave.
+#
+# configure generates config.mak.autogen, then included in the Makefile.
+#
+#############################################################################
+
+# Prevent locale nonsense from breaking basic text processing utils
+LC_ALL=C
+export LC_ALL
+
+# These macros only return an error code - NO display is done
+
+compile_check() {
+{
+	echo
+	cat "$1"
+	echo
+	echo "$_cc $CFLAGS $_inc_extra $_ld_static $_ld_extra -o $TMPO $@"
+	rm -f "$TMPO"
+	$_cc $CFLAGS $_inc_extra $_ld_static $_ld_extra -o "$TMPO" "$@" || return $?
+	echo
+	echo "ldd $TMPO"
+	$_ldd "$TMPO" || return $?
+	echo
+} >>"$TMPLOG" 2>&1
+}
+
+cc_check() {
+	compile_check $TMPC $@
+}
+
+# Try to run the compiled file
+tmp_run() {
+	"$TMPO" >> "$TMPLOG" 2>&1
+}
+
+# Display error message, flushes tempfile, exit
+die () {
+	echo
+	echo "Error: $@" >&2
+	echo >&2
+	rm -f "$TMPO" "$TMPC" "$TMPS" "$TMPCPP"
+	echo "Check \"$TMPLOG\" if you do not understand why it failed." >&2
+	exit 1
+}
+
+# OS test booleans functions
+issystem() {
+	test "`echo $system_name | tr A-Z a-z`" = "`echo $1 | tr A-Z a-z`"
+}
+linux()   { issystem "Linux"   ; return "$?" ; }
+sunos()   { issystem "SunOS"   ; return "$?" ; }
+hpux()    { issystem "HP-UX"   ; return "$?" ; }
+irix()    { issystem "IRIX"    ; return "$?" ; }
+aix()     { issystem "AIX"     ; return "$?" ; }
+cygwin()  { issystem "CYGWIN"  ; return "$?" ; }
+freebsd() { issystem "FreeBSD" ; return "$?" ; }
+netbsd()  { issystem "NetBSD"  ; return "$?" ; }
+bsdos()   { issystem "BSD/OS"  ; return "$?" ; }
+openbsd() { issystem "OpenBSD" ; return "$?" ; }
+bsd()     { freebsd || netbsd || bsdos || openbsd ; return "$?" ; }
+qnx()     { issystem "QNX"     ; return "$?" ; }
+darwin()  { issystem "Darwin"  ; return "$?" ; }
+gnu()     { issystem "GNU"     ; return "$?" ; }
+mingw32() { issystem "MINGW32" ; return "$?" ; }
+morphos() { issystem "MorphOS" ; return "$?" ; }
+win32()   { cygwin || mingw32  ; return "$?" ; }
+beos()    { issystem "BEOS"    ; return "$?" ; }
+
+# arch test boolean functions
+# x86/x86pc is used by QNX
+x86() {
+	case "$host_arch" in
+		i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686) return 0 ;;
+		*) return 1 ;;
+	esac
+}
+
+x86_64() {
+	case "$host_arch" in
+		x86_64|amd64) return 0 ;;
+		*) return 1 ;;
+	esac
+}
+
+ppc() {
+	case "$host_arch" in
+		ppc) return 0;;
+		*) return 1;;
+	esac
+}
+
+alpha() {
+	case "$host_arch" in
+		alpha) return 0;;
+		*) return 1;;
+	esac
+}
+
+# not boolean test: implement the posix shell "!" operator for a
+# non-posix /bin/sh.
+#   usage:  not {command}
+# returns exit status "success" when the execution of "command"
+# fails.
+not() {
+	eval "$@"
+	test $? -ne 0
+}
+
+# Use this before starting a check
+# The second optional parameter is name of the feature variable;
+# it is preset to an empty string so that it can be dropped into
+# config.mak.autogen seamlessly; use echores_yesno() for reporting.
+echocheck() {
+	echo "============ Checking $@ ============" >> "$TMPLOG"
+	echo ${_echo_n} "Checking $@... ${_echo_c}"
+}
+
+# Use this to echo the results of a check
+echores() {
+	if test "$_res_comment" ; then
+		_res_comment="($_res_comment)"
+	fi
+	echo "Result is: $@ $_res_comment" >> "$TMPLOG"
+	echo "##########################################" >> "$TMPLOG"
+	echo "" >> "$TMPLOG"
+	echo "$@ $_res_comment"
+	_res_comment=""
+}
+
+# Use this to introduce a regular feature with a commandline switch
+# @name is the variable name
+# @switch is the commandline switch
+# @mkvar is the Makefile variable name; prefix with a space to say that it's negated (ow)
+# @desc is a line to insert to the --help output
+# @default is the default value (yes/no/auto)
+add_library() { # --with
+	name="$1"; shift; switch="$1"; shift; mkvar="$1"; shift; default="$1"; shift; desc="$1"; shift
+	case $default in
+		yes) hdefault=with;;
+		no) hdefault=without;;
+		auto) hdefault=autodetect;;
+	esac
+
+	lib_help="$lib_help
+$desc [$hdefault]"
+	switches="$switches switch_lib \"$name\" \"$switch\" \"\$ac_option\" || "
+	mkvars="$mkvars mkvar \"\$$name\" \"$mkvar\";"
+	eval "$name=$default"
+}
+
+add_feature() { # --enable
+	name="$1"; shift; switch="$1"; shift; mkvar="$1"; shift; default="$1"; shift; desc="$1"; shift
+	case $default in
+		yes) hdefault=enable;;
+		no) hdefault=disable;;
+		auto) hdefault=autodetect;;
+	esac
+
+	feature_help="$feature_help
+$desc [$hdefault]"
+	switches="$switches switch_feature \"$name\" \"$switch\" \"\$ac_option\" || "
+	mkvars="$mkvars mkvar \"\$$name\" \"$mkvar\";"
+	eval "$name=$default"
+}
+
+lib_help=
+feature_help=
+switches=
+mkvars=
+
+
+switch_lib() {
+	name="$1"; shift; switch="$1"; shift; option="$1"; shift
+	case $option in
+		--with-$switch) eval "$name=yes";;
+		--without-$switch) eval "$name=no";;
+		*) return 1
+	esac
+	return 0
+}
+
+switch_feature() {
+	name="$1"; shift; switch="$1"; shift; option="$1"; shift
+	case $option in
+		--enable-$switch) eval "$name=yes";;
+		--disable-$switch) eval "$name=no";;
+		*) return 1
+	esac
+	return 0
+}
+
+mkvar() {
+	value="$1"; shift; mkvar="$1"; shift
+	noval=""; yesval="ConfigureYesPlease"
+	case $mkvar in
+		\ *) swap="$noval"; noval="$yesval"; yesval="$swap";;
+	esac
+	case $value in
+		auto) die "$mkvar autodetection failed";;
+		no) echo "$mkvar = $noval";;
+		yes) echo "$mkvar = $yesval";;
+		*) die "$mkvar got invalid value ''$value''";;
+	esac
+}
+
+
+#############################################################################
+
+
+# Check how echo works in this /bin/sh
+case `echo -n` in
+	-n)	_echo_n=	_echo_c='\c'	;;	# SysV echo
+	*)	_echo_n='-n '	_echo_c=	;;	# BSD echo
+esac
+
+
+process_params() {
+	_install=install
+	_cc=cc
+	test "$CC" && _cc="$CC"
+
+	for ac_option do
+		case "$ac_option" in
+		--help|-help|-h)
+			cat << EOF
+Usage: $0 [OPTIONS]...
+
+Configuration:
+  -h, --help             display this help and exit
+
+Installation directories:
+  --prefix=DIR           use this prefix for installing git [HOME]
+  --bindir=DIR           use this prefix for installing git binary
+                         [PREFIX/bin]
+  --gitexecdir=DIR       use this prefix for installing individual git command
+                         binaries [BINDIR]
+  --mandir=DIR           use this prefix for installing manpages [PREFIX/man]
+  --templatedir=DIR      use this prefix for installing configuration file
+                         templates [PREFIX/share/git-core/templates]
+  --gitpythondir=DIR     use this prefix for python libraries [PREFIX/share/git-core/python]
+
+Miscellaneous options:
+  --cc=COMPILER          use this C compiler to build MPlayer [gcc]
+  --target=PLATFORM      target platform (i386-linux, arm-linux, etc)
+  --with-install=PATH    use a custom install program (useful if your OS uses
+                         a GNU-incompatible install utility by default and
+                         you want to use GNU version)
+
+For the options below, see the top of the Makefile for more detailed
+description.
+
+Optional features:$feature_help
+
+Optional libraries:$lib_help
+
+This configure script is NOT autoconf-based, even though its output is similar.
+It will try to autodetect all configuration options. If you --enable an option
+it will be forcefully turned on, skipping autodetection. This can break
+compilation, so you need to know what you are doing.
+EOF
+			exit 0 ;;
+
+		--prefix=*)
+			_prefix=`echo $ac_option | cut -d '=' -f 2` ;;
+		--bindir=*)
+			_bindir=`echo $ac_option | cut -d '=' -f 2` ;;
+		--gitexecdir=*)
+			_gitexecdir=`echo $ac_option | cut -d '=' -f 2` ;;
+		--mandir=*)
+			_mandir=`echo $ac_option | cut -d '=' -f 2` ;;
+		--templatedir=*)
+			_templatedir=`echo $ac_option | cut -d '=' -f 2` ;;
+		--gitpythondir=*)
+			_gitpythondir=`echo $ac_option | cut -d '=' -f 2` ;;
+
+		--cc=*)
+			_cc=`echo $ac_option | cut -d '=' -f 2` ;;
+		--target=*)
+			_target=`echo $ac_option | cut -d '=' -f 2` ;;
+		--with-install=*)
+			_install=`echo $ac_option | cut -d '=' -f 2 ` ;;
+
+		*)
+			# $switches is the real bulk
+			eval "$switches { echo \"Unknown parameter: $ac_option\"; exit 1; }" || exit 1 ;;
+		esac
+	done
+
+	# Determine our OS name and CPU architecture
+	if test -z "$_target" ; then
+		# OS name
+		system_name=`uname -s 2>&1`
+		case "$system_name" in
+		Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin|GNU|BeOS|MorphOS|AIX)
+			;;
+		IRIX*)
+			system_name=IRIX ;;
+		HP-UX*)
+			system_name=HP-UX ;;
+		[cC][yY][gG][wW][iI][nN]*)
+			system_name=CYGWIN ;;
+		MINGW32*)
+			system_name=MINGW32 ;;
+		*)
+			system_name="$system_name-UNKNOWN" ;;
+		esac
+
+
+		# host's CPU/instruction set
+		host_arch=`uname -p 2>&1`
+		case "$host_arch" in
+		i386|sparc|ppc|alpha|arm|mips|vax)
+			;;
+		powerpc) # Darwin returns 'powerpc'
+			host_arch=ppc ;;
+		*)	# uname -p on Linux returns 'unknown' for the processor type,
+			# OpenBSD returns 'Intel Pentium/MMX ("Genuine Intel" 586-class)'
+
+			# Maybe uname -m (machine hardware name) returns something we
+			# recognize.
+
+			# x86/x86pc is used by QNX
+			case "`uname -m 2>&1`" in
+				i[3-9]86*|x86|x86pc|k5|k6|k6_2|k6_3|k6-2|k6-3|pentium*|athlon*|i586_i686|i586-i686|BePC) host_arch=i386 ;;
+				ia64) host_arch=ia64 ;;
+				x86_64|amd64)
+				if [ -n "`$_cc -dumpmachine | sed -n '/^x86_64-/p;/^amd64-/p'`" -a \
+					-z "`echo $CFLAGS | grep -- -m32`"  ]; then
+					host_arch=x86_64
+				else
+					host_arch=i386
+				fi
+				;;
+				macppc|ppc|ppc64) host_arch=ppc ;;
+				alpha) host_arch=alpha ;;
+				sparc) host_arch=sparc ;;
+				sparc64) host_arch=sparc64 ;;
+				parisc*|hppa*|9000*) host_arch=hppa ;;
+				arm*|zaurus|cats) host_arch=arm ;;
+				s390) host_arch=s390 ;;
+				s390x) host_arch=s390x ;;
+				mips*) host_arch=mips ;;
+				vax) host_arch=vax ;;
+				*) host_arch=UNKNOWN ;;
+			esac
+			;;
+		esac
+	else # if test -z "$_target"
+		system_name=`echo $_target | cut -d '-' -f 2`
+		case "`echo $system_name | tr A-Z a-z`" in
+			linux) system_name=Linux ;;
+			freebsd) system_name=FreeBSD ;;
+			netbsd) system_name=NetBSD ;;
+			bsd/os) system_name=BSD/OS ;;
+			openbsd) system_name=OpenBSD ;;
+			sunos) system_name=SunOS ;;
+			qnx) system_name=QNX ;;
+			morphos) system_name=MorphOS ;;
+			mingw32msvc) system_name=MINGW32 ;;
+		esac
+		# We need to convert underscores so that values like k6-2 and pentium-mmx can be passed
+		host_arch=`echo $_target | cut -d '-' -f 1 | tr '_' '-'`
+	fi
+
+	echo "Detected operating system: $system_name"
+	echo "Detected host architecture: $host_arch"
+}
+
+
+test_setup() {
+	# LGB: temporary files
+	# FIXME: Use mktemp -d?
+	for I in "$TMPDIR" "$TEMPDIR" "/tmp" ; do
+		test "$I" && break
+	done
+
+	TMPLOG="config.log"
+	rm -f "$TMPLOG"
+	TMPC="$I/git-conf-$RANDOM-$$.c"
+	TMPO="$I/git-conf-$RANDOM-$$.o"
+	TMPS="$I/git-conf-$RANDOM-$$.S"
+}
+
+basic_tests() {
+	echocheck "if your build environment is sane"
+	cat > $TMPC <<EOF
+int main(void) { return 0; }
+EOF
+	{ cc_check && tmp_run; } || die "unusable compiler or produced binary"
+	echores yes
+}
+
+
+write_config() {
+	echo "Creating config.mak.autogen"
+
+	{
+		cat << EOF
+# -------- Generated by configure -----------
+
+CC = $_cc
+INSTALL = $_install
+
+EOF
+		test -z $_prefix || echo "prefix = $_prefix"
+		test -z $_bindir || echo "bindir = $_bindir"
+		test -z $_gitexecdir || echo "gitexecdir = $_gitexecdir"
+		test -z $_mandir || ( echo "mandir = $_mandir" && echo "export mandir" )
+		test -z $_templatedir || echo "template_dir = $_templatedir"
+		test -z $_gitpythondir || echo "GIT_PYTHON_DIR = $_gitpythondir"
+		echo
+		eval "$mkvars"
+	} > config.mak.autogen
+
+	cat << EOF
+
+Config files successfully generated by ./configure.
+You can inspect the results in \`\`./config.mak.autogen''.
+EOF
+}
+
+
+finish() {
+	# Last move:
+	rm -f "$TMPO" "$TMPC" "$TMPS" "$TMPCPP"
+}
+
+trap finish 0
diff --git a/config.mak.in b/config.mak.in
deleted file mode 100644
index 82c9781..0000000
--- a/config.mak.in
+++ /dev/null
@@ -1,18 +0,0 @@
-# git Makefile configuration, included in main Makefile
-# @configure_input@
-
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-bindir = @bindir@
-#gitexecdir = @libexecdir@/git-core/
-template_dir = @datadir@/git-core/templates/
-GIT_PYTHON_DIR = @datadir@/git-core/python
-
-mandir=@mandir@
-
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-export exec_prefix mandir
-export srcdir VPATH
-
diff --git a/configure b/configure
new file mode 100755
index 0000000..2604aa3
--- /dev/null
+++ b/configure
@@ -0,0 +1,78 @@
+#! /bin/sh
+#
+# This configure script is *not* autoconf-based and has different semantics.
+# It attempts to autodetect all settings and options where possible. It is
+# possible to override autodetection with the --enable-option/--disable-option
+# command line parameters.  --enable-option forces the option on skipping
+# autodetection. Yes, this means that compilation may fail and yes, this is not
+# how autoconf-based configure scripts behave.
+#
+# configure generates config.mak.autogen, then included in the Makefile.
+#
+# If you want to add a new check for $feature, add it at two places - to the
+# variable list and to the checks section. You will find both below.
+#
+#############################################################################
+
+[ -f ./config-lib.sh ] || {
+	echo "config-lib.sh not found; please run ./configure from the source tree" >&2
+	exit 1
+}
+. ./config-lib.sh
+
+
+
+#############################################################################
+
+# List variables for features and libraries here:
+
+add_feature "_no_symlink_head" "no-symlink-head" "NO_SYMLINK_HEAD" "auto" \
+"  --enable-no-symlink-head  Never have .git/HEAD as a symbolic link"
+
+add_feature "_nsec" "nsec" "USE_NSEC" "no" \
+"  --enable-nsec          Use sub-second resolution when checking mtimes"
+
+add_library "_expat" "expat" " NO_EXPAT" "auto" \
+"  --without-expat        Disable libexpat support (disables git-http-push)"
+
+
+#############################################################################
+
+
+process_params "$@"
+test_setup
+basic_tests
+
+
+#############################################################################
+
+
+echocheck "whether to prohibit usage of symlinked HEAD"
+if test "$_no_symlink_head" = auto ; then
+	if win32; then
+		_no_symlink_head=yes
+	else
+		_no_symlink_head=no
+	fi
+fi
+echores "$_no_symlink_head"
+
+
+echocheck "for expat"
+if test "$_expat" = auto ; then
+	cat > $TMPC <<EOF
+#include <expat.h>
+int main(void) { return 0; }
+EOF
+	_expat=no
+	cc_check -lexpat && _expat=yes
+fi
+echores "$_expat"
+
+
+# Insert tests for features and libraries here.
+
+#############################################################################
+
+
+write_config
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index a0374d4..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,14 +0,0 @@
-#                                               -*- Autoconf -*-
-# Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.59)
-AC_INIT([git], [1.4.1], [git@vger.kernel.org])
-
-AC_CONFIG_SRCDIR([git.c])
-
-config_file=config.mak.autogen
-config_in=config.mak.in
-
-# Output files
-AC_CONFIG_FILES(["${config_file}":"${config_in}"])
-AC_OUTPUT

^ permalink raw reply related

* Why's Git called Git ?
From: Aaron Gray @ 2006-07-04  0:56 UTC (permalink / raw)
  To: Git Mailing List

Why the name I could not find any answer in the documentation ?

Aaron

^ permalink raw reply

* Re: git-fetch per-repository speed issues
From: Jeff King @ 2006-07-04  0:21 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Keith Packard, Git Mailing List
In-Reply-To: <Pine.LNX.4.64.0607031603290.12404@g5.osdl.org>

On Mon, Jul 03, 2006 at 04:14:10PM -0700, Linus Torvalds wrote:

> Well, you could use multiple branches in the same repository, even if they 
> are totally unrealated. That would allow you to fetch them all in one go.

One annoying thing about this is that you may want to have several of
the branches checked out at a time (i.e., you want the actual directory
structure of libXrandr/, Xorg/, etc). You could pull everything down
into one repo and point small pseudo-repos at it with alternates, but I
would think that would become a mess with pushes. You can do some magic
with read-tree --prefix, but again, I'm not sure how you'd make commits
on the correct branch.  Is there an easier way to do this?

> Basically, a repo that is up-to-date should do a "git fetch" about as 
> quickly as it does a "git ls-remote". Which in turn really shouldn't be 
> doing much anything at all, apart from the connect itself:

Fetching by ssh actually makes two ssh connections (the second is to
grab tags).

-Peff

^ permalink raw reply

* Re: git-cvsimport gets parents wrong for branches
From: Martin Langhoff @ 2006-07-03 23:15 UTC (permalink / raw)
  To: Elrond, git
In-Reply-To: <20060703215303.GA24572@memak.tu-darmstadt.de>

Elrond,

you are right, the current git-cvsimport takes a very naive approach
to determine where branches open from. It uses cvsps internally, which
only reports on the ancestor branch, so we take the latest commit from
the ancestor.

Parsecvs probably has a more sophisticated approach, have you tried it?

It is pretty hard to get that one right in any case, as there are
cases where the new branch starts from something that is not a commit
in the parent (from GIT's perspective). So representing the branching
point would mean pointing to non-existing commits as parents.

If the cvs2svn documentation is not lying, it probably has the
smartest/correctest implementation. For small-medium repos, you may be
able to run cvs2svn and then import with git-svnimport.

cheers,


martin

^ permalink raw reply

* Re: git-fetch per-repository speed issues
From: Linus Torvalds @ 2006-07-03 23:14 UTC (permalink / raw)
  To: Keith Packard; +Cc: Git Mailing List
In-Reply-To: <1151949764.4723.51.camel@neko.keithp.com>



On Mon, 3 Jul 2006, Keith Packard wrote:
> 
> With git, we'd prefer to use the git protocol instead of rsync for the
> usual pack-related reasons, but that is limited to a single repository
> at a time.

Well, you could use multiple branches in the same repository, even if they 
are totally unrealated. That would allow you to fetch them all in one go.

One way to do that is to just name the branches hierarcially have one 
repo, but then call the branches something like

	libXrandr/master
	libXrandr/develop
	Xorg/master
	Xorg/develop
	..

> And, it's painfully slow, even when the repository is up to
> date:
> 
> $ cd lib/libXrandr
> $ time git-fetch origin
> ...
> 
> real    0m17.035s
> user    0m2.584s
> sys     0m0.576s

That's _seriously_ wrong. If everything is up-to-date, a fetch should be 
basically zero-cost. That's especially true with the anonymous git 
protocol, which doesn't have any connection validation overhead (for the 
ssh protocol, the cost is usually the ssh login).

But there may well be some bug there.

Look at this:

	[torvalds@g5 git]$ time git fetch git://git.kernel.org/pub/scm/git/git.git 
	
	real    0m0.431s
	user    0m0.036s
	sys     0m0.024s

and that's over my DSL line, not some studly network thing. 

Basically, a repo that is up-to-date should do a "git fetch" about as 
quickly as it does a "git ls-remote". Which in turn really shouldn't be 
doing much anything at all, apart from the connect itself:

	[torvalds@g5 git]$ time git ls-remote master.kernel.org:/pub/scm/git/git.git > /dev/null 
	
	real    0m1.758s
	user    0m0.188s
	sys     0m0.024s
	[torvalds@g5 git]$ time git ls-remote git://git.kernel.org/pub/scm/git/git.git > /dev/null 
	
	real    0m0.431s
	user    0m0.056s
	sys     0m0.016s

(note how the ssh connection is much slower - it actually ends up doing 
all the ssh back-and-forth).

Can you try from different hosts? One problem may be the remote end 
just trying to do reverse DNS lookups for xinetd or whatever?

Also, one thing to try is to just do

	strace -Ttt git-peek-remote ...

which shows where the time is going (I selected "git-peek-remote", because 
that's a simple program).

		Linus

^ permalink raw reply

* Re: Compression speed for large files
From: Linus Torvalds @ 2006-07-03 23:02 UTC (permalink / raw)
  To: Joachim Berdal Haga; +Cc: Jeff King, Joachim B Haga, git
In-Reply-To: <44A99961.8090504@fys.uio.no>



On Tue, 4 Jul 2006, Joachim Berdal Haga wrote:
> 
> Here's a test with "time gzip -[169] -c file >/dev/null". Random data
> from /dev/urandom, kernel headers are concatenation of *.h in kernel
> sources. All times in seconds, on my puny home computer (1GHz Via Nehemiah)

That "Via Nehemiah" is probably a big part of it.

I think the VIA Nehemiah just has a 64kB L2 cache, and I bet performance 
plummets if the tables end up being used past that. 

And I think a large part of the higher compressions is that they allow the 
compression window and tables to grow bigger.

		Linus

^ permalink raw reply

* git-fetch per-repository speed issues
From: Keith Packard @ 2006-07-03 18:02 UTC (permalink / raw)
  To: Git Mailing List; +Cc: keithp

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

Ok, so maybe X.org is using git in an unexpected (or even wrong)
fashion. Our environment has split development across dozens of separate
repositories which match ABI interfaces. With CVS, we were able to keep
this all in one giant CVS repository with separate modules, but git
doesn't have that notion (which is mostly good). As such, we could use
cvsup or rsync to update the entire collection of modules.

With git, we'd prefer to use the git protocol instead of rsync for the
usual pack-related reasons, but that is limited to a single repository
at a time. And, it's painfully slow, even when the repository is up to
date:

$ cd lib/libXrandr
$ time git-fetch origin
...

real    0m17.035s
user    0m2.584s
sys     0m0.576s

This is a repository with 24 files and perhaps 50 revisions. Given
X.org's 307 git repositories, I'll clearly need to find a faster way
than running git-fetch on every one.

One thing I noticed was that the git+ssh syntax found in remotes files
doesn't do what I thought it did -- I assumed this would use 'git' for
fetch and 'ssh' for push, when in fact it just uses ssh for everything.
This slows down the connection process by several seconds.

-- 
keith.packard@intel.com

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [PATCH 3/3] Make clear_commit_marks() clean harder
From: Linus Torvalds @ 2006-07-03 22:55 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Junio C Hamano, git
In-Reply-To: <Pine.LNX.4.63.0607032309190.29667@wbgn013.biozentrum.uni-wuerzburg.de>



On Mon, 3 Jul 2006, Johannes Schindelin wrote:
> 
> Traversing is actually wrong. Clearing the marks does not mean to clear 
> them on commits we did not even mark!

If we didn't mark them, then clearing them would be a no-op, so nobody 
really cares.

> But clearing on commits we _have_ -- but not parsed -- is important, 
> obviously.

Right. The point is, some logic can choose to mark commits UNINTERESTING 
without even parsing that commit, and it would be a good thing. You only 
need to parse the commit once you decide that you need its parents (or 
it's tree, of course), but you may be able to mark it uninteresting before 
that.

This is why it is _wrong_ to care about the "parsed" bit when clearing the 
flags.

		Linus

^ permalink raw reply

* Re: [PATCH 2nd try] Make git-fmt-merge-msg a builtin
From: Junio C Hamano @ 2006-07-03 22:39 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git
In-Reply-To: <Pine.LNX.4.63.0607031717540.29667@wbgn013.biozentrum.uni-wuerzburg.de>

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

> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
>
> ---
> 	This retires git-fmt-merge-msg.perl, since it passes all the
> 	tests, but removes the Perl version not now.

There is no point not removing the script if you update git.c
and Makefile to point at the new one.

We do not have a test specific for fmt-merge-msg, so it
obviously passes all the tests ;-).  A new one is attached.

I think we should extend boolean to accept 'yes' and 'no', as I
suggested earlier on the list, but other than that things look
good.

Thanks for the patch; no need to resubmit -- I'll munge the
points I raised above.

-- >8 --
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
new file mode 100755
index 0000000..63e49f3
--- /dev/null
+++ b/t/t6200-fmt-merge-msg.sh
@@ -0,0 +1,163 @@
+#!/bin/sh
+#
+# Copyright (c) 2006, Junio C Hamano
+#
+
+test_description='fmt-merge-msg test'
+
+. ./test-lib.sh
+
+datestamp=1151939923
+setdate () {
+	GIT_COMMITTER_DATE="$datestamp +0200"
+	GIT_AUTHOR_DATE="$datestamp +0200"
+	datestamp=`expr "$datestamp" + 1`
+	export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
+}
+
+test_expect_success setup '
+	echo one >one &&
+	git add one &&
+	setdate &&
+	git commit -m "Initial" &&
+
+	echo uno >one &&
+	echo dos >two &&
+	git add two &&
+	setdate &&
+	git commit -a -m "Second" &&
+
+	git checkout -b left &&
+
+	echo $datestamp >one &&
+	setdate &&
+	git commit -a -m "Common #1" &&
+
+	echo $datestamp >one &&
+	setdate &&
+	git commit -a -m "Common #2" &&
+
+	git branch right &&
+
+	echo $datestamp >two &&
+	setdate &&
+	git commit -a -m "Left #3" &&
+
+	echo $datestamp >two &&
+	setdate &&
+	git commit -a -m "Left #4" &&
+
+	echo $datestamp >two &&
+	setdate &&
+	git commit -a -m "Left #5" &&
+
+	git checkout right &&
+
+	echo $datestamp >three &&
+	git add three &&
+	setdate &&
+	git commit -a -m "Right #3" &&
+
+	echo $datestamp >three &&
+	setdate &&
+	git commit -a -m "Right #4" &&
+
+	echo $datestamp >three &&
+	setdate &&
+	git commit -a -m "Right #5" &&
+
+	git show-branch
+'
+
+cat >expected <<\EOF
+Merge branch 'left'
+EOF
+
+test_expect_success 'merge-msg test #1' '
+
+	git checkout master &&
+	git fetch . left &&
+
+	git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+	diff -u actual expected
+'
+
+cat >expected <<\EOF
+Merge branch 'left' of ../trash
+EOF
+
+test_expect_success 'merge-msg test #2' '
+
+	git checkout master &&
+	git fetch ../trash left &&
+
+	git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+	diff -u actual expected
+'
+
+cat >expected <<\EOF
+Merge branch 'left'
+
+* left:
+  Left #5
+  Left #4
+  Left #3
+  Common #2
+  Common #1
+EOF
+
+test_expect_success 'merge-msg test #3' '
+
+	git repo-config merge.summary true &&
+
+	git checkout master &&
+	setdate &&
+	git fetch . left &&
+
+	git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+	diff -u actual expected
+'
+
+cat >expected <<\EOF
+Merge branches 'left' and 'right'
+
+* left:
+  Left #5
+  Left #4
+  Left #3
+  Common #2
+  Common #1
+
+* right:
+  Right #5
+  Right #4
+  Right #3
+  Common #2
+  Common #1
+EOF
+
+test_expect_success 'merge-msg test #4' '
+
+	git repo-config merge.summary true &&
+
+	git checkout master &&
+	setdate &&
+	git fetch . left right &&
+
+	git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+	diff -u actual expected
+'
+
+test_expect_success 'merge-msg test #5' '
+
+	git repo-config merge.summary yes &&
+
+	git checkout master &&
+	setdate &&
+	git fetch . left right &&
+
+	git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+	diff -u actual expected
+'
+
+test_done

^ permalink raw reply related

* Re: Compression speed for large files
From: Joachim Berdal Haga @ 2006-07-03 22:25 UTC (permalink / raw)
  To: Jeff King; +Cc: Joachim B Haga, git
In-Reply-To: <20060703214503.GA3897@coredump.intra.peff.net>

Jeff King wrote:
> On Mon, Jul 03, 2006 at 11:13:34AM +0000, Joachim B Haga wrote:
> 
>> often binary. In git, committing of large files is very slow; I have
>> tested with a 45MB file, which takes about 1 minute to check in (on an
>> intel core-duo 2GHz).
> 
> I know this has already been somewhat solved, but I found your numbers
> curiously high. I work quite a bit with git and large files and I
> haven't noticed this slowdown. Can you be more specific about your load?
> Are you sure it is zlib?

Quite sure: at least to the extent that it is fixed by lowering the
compression level. But the wording was inexact: it's during object
creation, which happens at initial "git add" and then later during "git
commit".

But...

> y 1.8Ghz Athlon, compressing 45MB of zeros into 20K takes about 2s.
> Compressing 45MB of random data into a 45MB object takes 6.3s. In either
> case, the commit takes only about 0.5s (since cogito stores the object
> during the cg-add).
> 
> Is there some specific file pattern which is slow to compress? 

yes, it seems so. At least the effect is much more pronounced for my
files than for random/null data. "My" files are in this context generated
data files, binary or ascii.

Here's a test with "time gzip -[169] -c file >/dev/null". Random data
from /dev/urandom, kernel headers are concatenation of *.h in kernel
sources. All times in seconds, on my puny home computer (1GHz Via Nehemiah)

       random (23MB)  data (23MB)   headers (44MB)
-9     10.2           72.5          38.5
-6     10.2           13.5          12.9
-1      9.9            4.1           7.0

So... data dependent, yes. But it hits even for normal source code.

(Btw; the default (-6) seems to be less data dependent than the other
values. Maybe that's on purpose.)

If you want to look at a highly-variable dataset (the one above), try
http://lupus.ig3.net/SIMULATION.dx.gz (5MB, slow server), but that's just
an example, I see the same variability for example also on binary data files.

-j.

^ permalink raw reply

* git-cvsimport gets parents wrong for branches
From: Elrond @ 2006-07-03 21:53 UTC (permalink / raw)
  To: git

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


Hi,

Just by accident I noticed, that git-cvsimport got the
parents for branches wrong in one of my projects.

To assist in debugging this, I've made up a testcase script
(appended to this mail).
It will create a new cvs-repo, put 4 commits in it,
and finally run gitk to investigate it.

It should look something like this:

    4 [branch-stable-fixes] commit-on-branch
  3 | [master] [origin] commit-master-after-branch
  |/
  2   [tag-branchpoint] commit-first-edit
  1   commit-base

What it really looks like:

  4   ..
  3   ..
  2   ..
  1   ..

4's parent is 3, not (as it should) 2.


I've tested with 1.4.0 and the current git-cvsimport from
8fced61.

I hope the testcase helps tracking the problem down.


    Elrond

p.s.: The testcase script is not nice. It just does the
      job, nothing more.

[-- Attachment #2: cvs-branches-1.sh --]
[-- Type: application/x-sh, Size: 687 bytes --]

^ permalink raw reply

* [PATCH] Eliminate Scalar::Util for something simpler
From: Petr Baudis @ 2006-07-03 21:49 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <20060703204803.28541.67315.stgit@machine.or.cz>

Dear diary, on Mon, Jul 03, 2006 at 10:48:03PM CEST, I got a letter
where Petr Baudis <pasky@suse.cz> said that...
> +		xs__call_gate(Scalar::Util::refaddr($self), $self->repo_path());

This was silly and requires Scalar::Util.

->8-
Signed-off-by: Petr Baudis <pasky@suse.cz>
---

 perl/Git.pm |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/perl/Git.pm b/perl/Git.pm
index 65acaa7..f2467bd 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -92,13 +92,14 @@ increate nonwithstanding).
 use Carp qw(carp croak); # but croak is bad - throw instead
 use Error qw(:try);
 use Cwd qw(abs_path);
-use Scalar::Util;
 
 require XSLoader;
 XSLoader::load('Git', $VERSION);
 
 }
 
+my $instance_id = 0;
+
 
 =head1 CONSTRUCTORS
 
@@ -216,7 +217,7 @@ sub repository {
 		delete $opts{Directory};
 	}
 
-	$self = { opts => \%opts };
+	$self = { opts => \%opts, id => $instance_id++ };
 	bless $self, $class;
 }
 
@@ -855,7 +856,7 @@ sub _call_gate {
 		# For now, when we will need to do it we could temporarily
 		# chdir() there and then chdir() back after the call is done.
 
-		xs__call_gate(Scalar::Util::refaddr($self), $self->repo_path());
+		xs__call_gate($self->{id}, $self->repo_path());
 	}
 
 	# Having to call throw from the C code is a sure path to insanity.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Snow falling on Perl. White noise covering line noise.
Hides all the bugs too. -- J. Putnam

^ permalink raw reply related

* Re: Compression speed for large files
From: Jeff King @ 2006-07-03 21:45 UTC (permalink / raw)
  To: Joachim B Haga; +Cc: git
In-Reply-To: <loom.20060703T124601-969@post.gmane.org>

On Mon, Jul 03, 2006 at 11:13:34AM +0000, Joachim B Haga wrote:

> often binary. In git, committing of large files is very slow; I have
> tested with a 45MB file, which takes about 1 minute to check in (on an
> intel core-duo 2GHz).

I know this has already been somewhat solved, but I found your numbers
curiously high. I work quite a bit with git and large files and I
haven't noticed this slowdown. Can you be more specific about your load?
Are you sure it is zlib?

On my 1.8Ghz Athlon, compressing 45MB of zeros into 20K takes about 2s.
Compressing 45MB of random data into a 45MB object takes 6.3s. In either
case, the commit takes only about 0.5s (since cogito stores the object
during the cg-add).

Is there some specific file pattern which is slow to compress? 

-Peff

^ permalink raw reply

* Re: [PATCH 4/6] Make it possible to set up libgit directly (instead of from the environment)
From: Petr Baudis @ 2006-07-03 21:30 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <20060703204803.28541.67315.stgit@machine.or.cz>

Dear diary, on Mon, Jul 03, 2006 at 10:48:03PM CEST, I got a letter
where Petr Baudis <pasky@suse.cz> said that...
> This introduces a setup_git() function which is essentialy a (public)
> backend for setup_git_env() which lets anyone specify custom sources
> for the various paths instead of environment variables. Since the repositories
> may get switched on the fly, this also updates code that caches paths to
> invalidate them properly; I hope neither of those is a sweet spot.
> 
> It is used by Git.xs' xs__call_gate() to set up per-repository data
> for libgit's consumption. No code actually takes advantage of it yet
> but get_object() will in the next patches.
> 
> Signed-off-by: Petr Baudis <pasky@suse.cz>

To further clarify, this only invalidates the path cache and grafts
list, not alternates (it assumes the environment variable stays the
same for now; that is to be fixed when we extend Git.pm further)
and not pack list - we will automagically extend the list of packs when
we meet more repositories, but we will never remove old packs from the
list. (For no special reason other than this does no harm other than
possibly finding objects that should be missing, and the patch smells
bad enough enough as it is now. ;-)

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Snow falling on Perl. White noise covering line noise.
Hides all the bugs too. -- J. Putnam

^ permalink raw reply

* Re: [PATCH] Make git-fmt-merge-msg a builtin
From: Johannes Schindelin @ 2006-07-03 21:29 UTC (permalink / raw)
  To: Timo Hirvonen; +Cc: git, junkio
In-Reply-To: <20060703191635.21ba0af3.tihirvon@gmail.com>

Hi,

On Mon, 3 Jul 2006, Timo Hirvonen wrote:

> Seems that C89 requires free(NULL) to be a no-op but on some old systems 
> (SunOS) it may crash.  IMNSHO these systems were designed to crash valid 
> programs and torture developers.

At least it is not Malbolge. Or even VAX. (In that order.)

> There are probably many free(NULL) and realloc(NULL, ...) uses in the 
> git source code and are not worth fixing.

AFAIK realloc(NULL, ...) was fine even with K&R, whereas free(NULL) poses 
problems. Anyway, I do not _want_ to say that NULL should be free()d, 
because it just sounds wrong.

Ciao,
Dscho

^ permalink raw reply

* [PATCH] Use $GITPERLLIB instead of $RUNNING_GIT_TESTS and centralize @INC munging
From: Petr Baudis @ 2006-07-03 21:16 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <20060703202925.GN29115@pasky.or.cz>

This makes the Git perl scripts check $GITPERLLIB instead of
$RUNNING_GIT_TESTS, which makes more sense if you are setting up your shell
environment to use a non-installed Git instance.

It also weeds out the @INC munging from the individual scripts and makes
Makefile add it during the .perl files processing, so that we can change
just a single place when we modify this shared logic. It looks ugly in the
scripts, too. ;-)

And instead of doing arcane things with the @INC array, we just do 'use lib'
instead, which is essentialy the same thing anyway.

I first want to do three separate patches but it turned out that it's quite
a lot neater when bundled together, so I hope it's ok.

Signed-off-by: Petr Baudis <pasky@suse.cz>
---

 INSTALL                |    4 ++--
 Makefile               |    4 +++-
 git-fmt-merge-msg.perl |    5 -----
 git-mv.perl            |    5 -----
 t/test-lib.sh          |    5 ++---
 5 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/INSTALL b/INSTALL
index ed502de..4e8f883 100644
--- a/INSTALL
+++ b/INSTALL
@@ -39,8 +39,8 @@ Issues of note:
 
 	GIT_EXEC_PATH=`pwd`
 	PATH=`pwd`:$PATH
-	PERL5LIB=`pwd`/perl/blib/lib:`pwd`/perl/blib/arch/auto/Git
-	export GIT_EXEC_PATH PATH PERL5LIB
+	GITPERLLIB=`pwd`/perl/blib/lib:`pwd`/perl/blib/arch/auto/Git
+	export GIT_EXEC_PATH PATH GITPERLLIB
 
  - Git is reasonably self-sufficient, but does depend on a few external
    programs and libraries:
diff --git a/Makefile b/Makefile
index a62e8a3..bae95c2 100644
--- a/Makefile
+++ b/Makefile
@@ -552,7 +552,9 @@ common-cmds.h: Documentation/git-*.txt
 $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
 	rm -f $@ $@+
 	INSTLIBDIR=`$(MAKE) -C perl -s --no-print-directory instlibdir` && \
-	sed -e '1s|#!.*perl\(.*\)|#!$(PERL_PATH_SQ)\1|' \
+	sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|1' \
+	    -e '2i\
+	        use lib (split(/:/, $$ENV{GITPERLLIB} || '\'"$$INSTLIBDIR"\''));' \
 	    -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 	    $@.perl >$@+
diff --git a/git-fmt-merge-msg.perl b/git-fmt-merge-msg.perl
index a9805dd..f86231e 100755
--- a/git-fmt-merge-msg.perl
+++ b/git-fmt-merge-msg.perl
@@ -5,11 +5,6 @@ #
 # Read .git/FETCH_HEAD and make a human readable merge message
 # by grouping branches and tags together to form a single line.
 
-BEGIN {
-	unless (exists $ENV{'RUNNING_GIT_TESTS'}) {
-		unshift @INC, '@@INSTLIBDIR@@';
-	}
-}
 use strict;
 use Git;
 use Error qw(:try);
diff --git a/git-mv.perl b/git-mv.perl
index 5134b80..322b9fd 100755
--- a/git-mv.perl
+++ b/git-mv.perl
@@ -6,11 +6,6 @@ #
 # This file is licensed under the GPL v2, or a later version
 # at the discretion of Linus Torvalds.
 
-BEGIN {
-	unless (exists $ENV{'RUNNING_GIT_TESTS'}) {
-		unshift @INC, '@@INSTLIBDIR@@';
-	}
-}
 use warnings;
 use strict;
 use Getopt::Std;
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 298c6ca..ad9796e 100755
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -206,9 +206,8 @@ PYTHON=`sed -e '1{
 	PYTHONPATH=$(pwd)/../compat
 	export PYTHONPATH
 }
-RUNNING_GIT_TESTS=YesWeAre
-PERL5LIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
-export PERL5LIB RUNNING_GIT_TESTS
+GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
+export GITPERLLIB
 test -d ../templates/blt || {
 	error "You haven't built things yet, have you?"
 }

^ permalink raw reply related

* Re: [PATCH 3/3] Make clear_commit_marks() clean harder
From: Johannes Schindelin @ 2006-07-03 21:12 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vzmfqqxlh.fsf@assigned-by-dhcp.cox.net>

Hi,

On Mon, 3 Jul 2006, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> >> > Don't care if objects have been parsed or not and don't stop when we
> >> > reach a commit that is already clean -- its parents could be dirty.
> >> 
> >> There is something quite wrong with this patch.
> >
> > I always had the feeling that it was wrong to traverse not-yet-parsed 
> > parents: How could a revision walk possibly come to a certain commit 
> > without at least one continuous history of now-parsed objects?
> >
> > Also, AFAIK the revision walk sets flags for each commit it touched, and 
> > we should not try to be smart-asses about the flags, but just unset these 
> > flags.
> 
> The main points were made by Linus already.
> 
> Traversing is not needed -- not clearing not-yet-parsed is
> obviously wrong.

Traversing is actually wrong. Clearing the marks does not mean to clear 
them on commits we did not even mark!

But clearing on commits we _have_ -- but not parsed -- is important, 
obviously.

> > BTW some very quick tests showed that the clear_commit_marks() thing that 
> > I sent to the list was much faster than traversing all objects (which was 
> > in my original version).
> 
> I have a crude workaround pushed out last night but will be
> replacing it with something less drastic.  I think the final
> version should be what you had, perhaps minus not looking at the
> parsed flag for unmarking purposes.

Isn't the right way to go about it to just clear the marks if we have a 
commit that has at least one of the marks set, but traverse further only 
if _in addition to having at least one mark set_ the commit has been 
parsed already?

That would not be a crude workaround.

BTW what cases could have a commit, being seen by the revision walk, not 
have the SEEN mark set?

Ciao,
Dscho

^ permalink raw reply

* Re: [PATCH 3/3] Make clear_commit_marks() clean harder
From: Johannes Schindelin @ 2006-07-03 21:08 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Junio C Hamano, Rene Scharfe, git
In-Reply-To: <Pine.LNX.4.64.0607030957420.12404@g5.osdl.org>

Hi,

On Mon, 3 Jul 2006, Linus Torvalds wrote:

> 	/* Have we already cleared this? */
> 	if (!(mask & object->flags))
> 		return;
> 	object->flags &= ~mask;

I thought we already did this, and did not even check. My bad.

Ciao,
Dscho

^ permalink raw reply

* Re: contrib/ status
From: Junio C Hamano @ 2006-07-03 21:04 UTC (permalink / raw)
  To: Eric Wong; +Cc: git
In-Reply-To: <20060703080625.GB29036@hand.yhbt.net>

Eric Wong <normalperson@yhbt.net> writes:

> Junio C Hamano <junkio@cox.net> wrote:
>> Junio C Hamano <junkio@cox.net> writes:
>> 
>> > ... the
>> > things under contrib/ are not part of git.git but are there only
>> > for convenience....
>> 
>> This reminds me of something quite different.  I am getting an
>> impression that enough people have been helped by git-svn and it
>> might be a good idea to have it outside contrib/ area.
>
> That would be great.  IMHO, it puts git in a position to supplant
> centralized SVN usage one developer at a time, making it easier
> to make a gradual transition to git.  Of course, there's also svk
> in a similar position...

OK, then let's give a few days (it's a long weekend extendeding
into July 4th in the US) to let others from the list chime in,
and then please help me migrate your test scripts and Makefile
pieces into the toplevel project.

^ permalink raw reply

* Re: [PATCH 1/3] Add read_cache_from() and discard_cache()
From: Junio C Hamano @ 2006-07-03 21:04 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git
In-Reply-To: <Pine.LNX.4.63.0607021043550.29667@wbgn013.biozentrum.uni-wuerzburg.de>

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

> Okay. After reading the comment, I am quite certain we can just set the 
> index_file_timestamp to 0.

Thanks.

> So, I still think that these two lines should be in the cleanup part of 
> get_merge_bases().

I think that is sane -- please make it so.

> BTW personally, I prefer the one-function approach, i.e. a flag which says 
> if it is okay not to clean up.

Yup. Agreed.

^ 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