Git development
 help / color / mirror / Atom feed
* [PATCH 4/9] git-svn: remove any need for the XML::Simple dependency
From: Eric Wong @ 2006-02-20 18:57 UTC (permalink / raw)
  To: git; +Cc: junkio, Eric Wong
In-Reply-To: <1140461846433-git-send-email-normalperson@yhbt.net>

XML::Simple was originally required back when I made svn-arch-mirror
because I needed to explictly track renames with Arch.  Then I carried
it over to git-svn because I was afraid somebody could commit an svn
log message that could throw off a non-XML log parser.  Then I noticed
the <n> lines column in the header.  So, no more XML :)

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 contrib/git-svn/git-svn |   84 ++++++++++++++++++++---------------------------
 1 files changed, 35 insertions(+), 49 deletions(-)

9b380ed2f8f1b18f95d12b86cb760f95e6e0cefe
diff --git a/contrib/git-svn/git-svn b/contrib/git-svn/git-svn
index 5f23d6b..4391bc3 100755
--- a/contrib/git-svn/git-svn
+++ b/contrib/git-svn/git-svn
@@ -21,7 +21,7 @@ $ENV{LC_ALL} = 'C';
 
 # If SVN:: library support is added, please make the dependencies
 # optional and preserve the capability to use the command-line client.
-# See what I do with XML::Simple to make the dependency optional.
+# use eval { require SVN::... } to make it lazy load
 use Carp qw/croak/;
 use IO::File qw//;
 use File::Basename qw/dirname basename/;
@@ -177,8 +177,7 @@ sub fetch {
 	push @log_args, "-r$_revision";
 	push @log_args, '--stop-on-copy' unless $_no_stop_copy;
 
-	eval { require XML::Simple or croak $! };
-	my $svn_log = $@ ? svn_log_raw(@log_args) : svn_log_xml(@log_args);
+	my $svn_log = svn_log_raw(@log_args);
 	@$svn_log = sort { $a->{revision} <=> $b->{revision} } @$svn_log;
 
 	my $base = shift @$svn_log or croak "No base revision!\n";
@@ -476,49 +475,6 @@ sub svn_commit_tree {
 	return fetch("$rev_committed=$commit")->{revision};
 }
 
-sub svn_log_xml {
-	my (@log_args) = @_;
-	my $log_fh = IO::File->new_tmpfile or croak $!;
-
-	my $pid = fork;
-	defined $pid or croak $!;
-
-	if ($pid == 0) {
-		open STDOUT, '>&', $log_fh or croak $!;
-		exec (qw(svn log --xml), @log_args) or croak $!
-	}
-
-	waitpid $pid, 0;
-	croak $? if $?;
-
-	seek $log_fh, 0, 0;
-	my @svn_log;
-	my $log = XML::Simple::XMLin( $log_fh,
-				ForceArray => ['path','revision','logentry'],
-				KeepRoot => 0,
-				KeyAttr => {	logentry => '+revision',
-						paths => '+path' },
-			)->{logentry};
-	foreach my $r (sort {$a <=> $b} keys %$log) {
-		my $log_msg = $log->{$r};
-		my ($Y,$m,$d,$H,$M,$S) = ($log_msg->{date} =~
-					/(\d{4})\-(\d\d)\-(\d\d)T
-					 (\d\d)\:(\d\d)\:(\d\d)\.\d+Z$/x)
-					 or croak "Failed to parse date: ",
-						 $log->{$r}->{date};
-		$log_msg->{date} = "+0000 $Y-$m-$d $H:$M:$S";
-
-		# XML::Simple can't handle <msg></msg> as a string:
-		if (ref $log_msg->{msg} eq 'HASH') {
-			$log_msg->{msg} = "\n";
-		} else {
-			$log_msg->{msg} .= "\n";
-		}
-		push @svn_log, $log->{$r};
-	}
-	return \@svn_log;
-}
-
 sub svn_log_raw {
 	my (@log_args) = @_;
 	my $pid = open my $log_fh,'-|';
@@ -529,21 +485,42 @@ sub svn_log_raw {
 	}
 
 	my @svn_log;
-	my $state;
+	my $state = 'sep';
 	while (<$log_fh>) {
 		chomp;
 		if (/^\-{72}$/) {
+			if ($state eq 'msg') {
+				if ($svn_log[$#svn_log]->{lines}) {
+					$svn_log[$#svn_log]->{msg} .= $_."\n";
+					unless(--$svn_log[$#svn_log]->{lines}) {
+						$state = 'sep';
+					}
+				} else {
+					croak "Log parse error at: $_\n",
+						$svn_log[$#svn_log]->{revision},
+						"\n";
+				}
+				next;
+			}
+			if ($state ne 'sep') {
+				croak "Log parse error at: $_\n",
+					"state: $state\n",
+					$svn_log[$#svn_log]->{revision},
+					"\n";
+			}
 			$state = 'rev';
 
 			# if we have an empty log message, put something there:
 			if (@svn_log) {
 				$svn_log[$#svn_log]->{msg} ||= "\n";
+				delete $svn_log[$#svn_log]->{lines};
 			}
 			next;
 		}
 		if ($state eq 'rev' && s/^r(\d+)\s*\|\s*//) {
 			my $rev = $1;
-			my ($author, $date) = split(/\s*\|\s*/, $_, 2);
+			my ($author, $date, $lines) = split(/\s*\|\s*/, $_, 3);
+			($lines) = ($lines =~ /(\d+)/);
 			my ($Y,$m,$d,$H,$M,$S,$tz) = ($date =~
 					/(\d{4})\-(\d\d)\-(\d\d)\s
 					 (\d\d)\:(\d\d)\:(\d\d)\s([\-\+]\d+)/x)
@@ -551,6 +528,7 @@ sub svn_log_raw {
 			my %log_msg = (	revision => $rev,
 					date => "$tz $Y-$m-$d $H:$M:$S",
 					author => $author,
+					lines => $lines,
 					msg => '' );
 			push @svn_log, \%log_msg;
 			$state = 'msg_start';
@@ -560,7 +538,15 @@ sub svn_log_raw {
 		if ($state eq 'msg_start' && /^$/) {
 			$state = 'msg';
 		} elsif ($state eq 'msg') {
-			$svn_log[$#svn_log]->{msg} .= $_."\n";
+			if ($svn_log[$#svn_log]->{lines}) {
+				$svn_log[$#svn_log]->{msg} .= $_."\n";
+				unless (--$svn_log[$#svn_log]->{lines}) {
+					$state = 'sep';
+				}
+			} else {
+				croak "Log parse error at: $_\n",
+					$svn_log[$#svn_log]->{revision},"\n";
+			}
 		}
 	}
 	close $log_fh or croak $?;
-- 
1.2.0.gdee6

^ permalink raw reply related

* [PATCH 6/9] contrib/git-svn.txt: add a note about renamed/copied directory support
From: Eric Wong @ 2006-02-20 18:57 UTC (permalink / raw)
  To: git; +Cc: junkio, Eric Wong
In-Reply-To: <11404618481876-git-send-email-normalperson@yhbt.net>

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 contrib/git-svn/git-svn.txt |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

72331d46b99b182406e06070e905123f76abbac8
diff --git a/contrib/git-svn/git-svn.txt b/contrib/git-svn/git-svn.txt
index 07a236f..cf098d7 100644
--- a/contrib/git-svn/git-svn.txt
+++ b/contrib/git-svn/git-svn.txt
@@ -206,6 +206,13 @@ working trees with metadata files.
 svn:keywords can't be ignored in Subversion (at least I don't know of
 a way to ignore them).
 
+Renamed and copied directories are not detected by git and hence not
+tracked when committing to SVN.  I do not plan on adding support for
+this as it's quite difficult and time-consuming to get working for all
+the possible corner cases (git doesn't do it, either).  Renamed and
+copied files are fully supported if they're similar enough for git to
+detect them.
+
 Author
 ------
 Written by Eric Wong <normalperson@yhbt.net>.
-- 
1.2.0.gdee6

^ permalink raw reply related

* [PATCH 3/9] git-svn: Allow for more argument types for commit (from..to)
From: Eric Wong @ 2006-02-20 18:57 UTC (permalink / raw)
  To: git; +Cc: junkio, Eric Wong
In-Reply-To: <11404618464102-git-send-email-normalperson@yhbt.net>

Allow 'from..to' notation from the command line.

More liberal sha1 parsing when reading from stdin no longer requires the
sha1 to be the first character, so a leading 'commit ' string is OK.

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 contrib/git-svn/git-svn     |   13 ++++++++++---
 contrib/git-svn/git-svn.txt |    2 +-
 2 files changed, 11 insertions(+), 4 deletions(-)

4d8326c4868461e8a48a4e25ef11ece6e9f92843
diff --git a/contrib/git-svn/git-svn b/contrib/git-svn/git-svn
index 477ec16..5f23d6b 100755
--- a/contrib/git-svn/git-svn
+++ b/contrib/git-svn/git-svn
@@ -216,14 +216,21 @@ sub commit {
 		print "Reading from stdin...\n";
 		@commits = ();
 		while (<STDIN>) {
-			if (/^([a-f\d]{6,40})\b/) {
+			if (/\b([a-f\d]{6,40})\b/) {
 				unshift @commits, $1;
 			}
 		}
 	}
 	my @revs;
-	foreach (@commits) {
-		push @revs, (safe_qx('git-rev-parse',$_));
+	foreach my $c (@commits) {
+		chomp(my @tmp = safe_qx('git-rev-parse',$c));
+		if (scalar @tmp == 1) {
+			push @revs, $tmp[0];
+		} elsif (scalar @tmp > 1) {
+			push @revs, reverse (safe_qx('git-rev-list',@tmp));
+		} else {
+			die "Failed to rev-parse $c\n";
+		}
 	}
 	chomp @revs;
 
diff --git a/contrib/git-svn/git-svn.txt b/contrib/git-svn/git-svn.txt
index 9912f5a..07a236f 100644
--- a/contrib/git-svn/git-svn.txt
+++ b/contrib/git-svn/git-svn.txt
@@ -149,7 +149,7 @@ Tracking and contributing to an Subversi
 # Commit only the git commits you want to SVN::
 	git-svn commit <tree-ish> [<tree-ish_2> ...]
 # Commit all the git commits from my-branch that don't exist in SVN::
-	git rev-list --pretty=oneline git-svn-HEAD..my-branch | git-svn commit
+	git commit git-svn-HEAD..my-branch
 # Something is committed to SVN, pull the latest into your branch::
 	git-svn fetch && git pull . git-svn-HEAD
 
-- 
1.2.0.gdee6

^ permalink raw reply related

* [PATCH 5/9] git-svn: change ; to && in addremove()
From: Eric Wong @ 2006-02-20 18:57 UTC (permalink / raw)
  To: git; +Cc: junkio, Eric Wong
In-Reply-To: <11404618483821-git-send-email-normalperson@yhbt.net>

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 contrib/git-svn/git-svn |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

ff01f98a865018be26baf1008c669009e95a93bf
diff --git a/contrib/git-svn/git-svn b/contrib/git-svn/git-svn
index 4391bc3..25c248d 100755
--- a/contrib/git-svn/git-svn
+++ b/contrib/git-svn/git-svn
@@ -580,10 +580,10 @@ sub sys { system(@_) == 0 or croak $? }
 
 sub git_addremove {
 	system( "git-diff-files --name-only -z ".
-				" | git-update-index --remove -z --stdin; ".
+				" | git-update-index --remove -z --stdin && ".
 		"git-ls-files -z --others ".
 			"'--exclude-from=$GIT_DIR/$GIT_SVN/info/exclude'".
-				" | git-update-index --add -z --stdin; "
+				" | git-update-index --add -z --stdin"
 		) == 0 or croak $?
 }
 
-- 
1.2.0.gdee6

^ permalink raw reply related

* git-svn: nearing 1.0.0
From: Eric Wong @ 2006-02-20 18:57 UTC (permalink / raw)
  To: git; +Cc: junkio

      
This should hopefully be the last set of bugfixes I have for git-svn.  I'm
pretty satisfied with it, as I haven't needed to directly invoke svn and wait
for it in any of my day-to-day operations for doing work on svn repositories.

Most of the major changes are in 'commit' functionality where several
corner-case bugs have been found and fixed.

      git-svn: fix a typo in defining the --no-stop-on-copy option
      git-svn: allow --find-copies-harder and -l<num> to be passed on commit
      git-svn: Allow for more argument types for commit (from..to)
      git-svn: remove any need for the XML::Simple dependency
      git-svn: change ; to && in addremove()
      contrib/git-svn.txt: add a note about renamed/copied directory support
      git-svn: fix several corner-case and rare bugs with 'commit'
      contrib/git-svn: add Makefile, test, and associated ignores
      git-svn: 0.9.1: add --version and copyright/license (GPL v2+) information

 .gitignore                 |    4 
 Makefile                   |   32 +++
 git-svn.perl               |  382 +++++++++++++++++++++++++++++++--------------
 git-svn.txt                |   16 +
 t/t0000-contrib-git-svn.sh |  216 +++++++++++++++++++++++++
 5 files changed, 532 insertions(+), 118 deletions(-)

-- 
Eric Wong

^ permalink raw reply

* [PATCH 2/9] git-svn: allow --find-copies-harder and -l<num> to be passed on commit
From: Eric Wong @ 2006-02-20 18:57 UTC (permalink / raw)
  To: git; +Cc: junkio, Eric Wong
In-Reply-To: <11404618452729-git-send-email-normalperson@yhbt.net>

Both of these options are passed directly to git-diff-tree when
committing to a SVN repository.

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 contrib/git-svn/git-svn     |   10 ++++++++--
 contrib/git-svn/git-svn.txt |    7 +++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

f00770e6f3151e5fdc94208efab22b3068dbb882
diff --git a/contrib/git-svn/git-svn b/contrib/git-svn/git-svn
index 1a8f40e..477ec16 100755
--- a/contrib/git-svn/git-svn
+++ b/contrib/git-svn/git-svn
@@ -30,7 +30,8 @@ use Getopt::Long qw/:config gnu_getopt n
 use File::Spec qw//;
 my $sha1 = qr/[a-f\d]{40}/;
 my $sha1_short = qr/[a-f\d]{6,40}/;
-my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit);
+my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit,
+	$_find_copies_harder, $_l);
 
 GetOptions(	'revision|r=s' => \$_revision,
 		'no-ignore-externals' => \$_no_ignore_ext,
@@ -38,6 +39,8 @@ GetOptions(	'revision|r=s' => \$_revisio
 		'edit|e' => \$_edit,
 		'rmdir' => \$_rmdir,
 		'help|H|h' => \$_help,
+		'find-copies-harder' => \$_find_copies_harder,
+		'l=i' => \$_l,
 		'no-stop-on-copy' => \$_no_stop_copy );
 my %cmd = (
 	fetch => [ \&fetch, "Download new revisions from SVN" ],
@@ -348,7 +351,10 @@ sub svn_checkout_tree {
 	my $pid = open my $diff_fh, '-|';
 	defined $pid or croak $!;
 	if ($pid == 0) {
-		exec(qw(git-diff-tree -z -r -C), $from, $commit) or croak $!;
+		my @diff_tree = qw(git-diff-tree -z -r -C);
+		push @diff_tree, '--find-copies-harder' if $_find_copies_harder;
+		push @diff_tree, "-l$_l" if defined $_l;
+		exec(@diff_tree, $from, $commit) or croak $!;
 	}
 	my $mods = parse_diff_tree($diff_fh);
 	unless (@$mods) {
diff --git a/contrib/git-svn/git-svn.txt b/contrib/git-svn/git-svn.txt
index 4b79fb0..9912f5a 100644
--- a/contrib/git-svn/git-svn.txt
+++ b/contrib/git-svn/git-svn.txt
@@ -99,6 +99,13 @@ OPTIONS
 	default for objects that are commits, and forced on when committing
 	tree objects.
 
+-l<num>::
+--find-copies-harder::
+	Both of these are only used with the 'commit' command.
+
+	They are both passed directly to git-diff-tree see
+	git-diff-tree(1) for more information.
+
 COMPATIBILITY OPTIONS
 ---------------------
 --no-ignore-externals::
-- 
1.2.0.gdee6

^ permalink raw reply related

* [PATCH 1/9] git-svn: fix a typo in defining the --no-stop-on-copy option
From: Eric Wong @ 2006-02-20 18:57 UTC (permalink / raw)
  To: git; +Cc: junkio, Eric Wong
In-Reply-To: <11404618453236-git-send-email-normalperson@yhbt.net>

Just a typo, I doubt anybody would use (and I highly recommend not
using) this option anyways.  But you never know...

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 contrib/git-svn/git-svn |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

7292b0320d5aab4f335b7c1198b77231bf78d44a
diff --git a/contrib/git-svn/git-svn b/contrib/git-svn/git-svn
index 71a8b3b..1a8f40e 100755
--- a/contrib/git-svn/git-svn
+++ b/contrib/git-svn/git-svn
@@ -38,7 +38,7 @@ GetOptions(	'revision|r=s' => \$_revisio
 		'edit|e' => \$_edit,
 		'rmdir' => \$_rmdir,
 		'help|H|h' => \$_help,
-		'no-stop-copy' => \$_no_stop_copy );
+		'no-stop-on-copy' => \$_no_stop_copy );
 my %cmd = (
 	fetch => [ \&fetch, "Download new revisions from SVN" ],
 	init => [ \&init, "Initialize and fetch (import)"],
-- 
1.2.0.gdee6

^ permalink raw reply related

* Should we support Perl 5.6?
From: Johannes Schindelin @ 2006-02-20 18:37 UTC (permalink / raw)
  To: git

Hi,

I just had a failure when pulling, because since a few days (to be exact, 
since commit 1cb30387, git-fmt-merge-msg uses a syntax which is not 
understood by Perl 5.6.

It is this:

	open $fh, '-|', 'git-symbolic-ref', 'HEAD' or die "$!";

I know that there was already some discussion on this list, but I don't 
remember if we decided on leaving 5.6 behind or not.

Somebody remembers?

Ciao,
Dscho

^ permalink raw reply

* Re: [PATCH 2/2] Add 'stg uncommit' command
From: Karl Hasselström @ 2006-02-20 17:30 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <b0943d9e0602200920v10ef8788o@mail.gmail.com>

On 2006-02-20 17:20:47 +0000, Catalin Marinas wrote:

> On 19/02/06, Karl Hasselström <kha@treskal.com> wrote:
>
> > By the way, it seems like my name got munged when you edited the
> > commit.
>
> I fixed the escaping in the name_email* functions (I'll push it
> tonight). It was adding a \ for every character it didn't know. It
> now only escapes the quotes and back-slashes. This is needed when
> passing the strings via the GIT_AUTHOR_* variables.

It put curly braces around the name as well.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

^ permalink raw reply

* Re: [PATCH 2/2] Add 'stg uncommit' command
From: Catalin Marinas @ 2006-02-20 17:20 UTC (permalink / raw)
  To: Karl Hasselström; +Cc: git
In-Reply-To: <20060219144752.GA5541@diana.vm.bytemark.co.uk>

On 19/02/06, Karl Hasselström <kha@treskal.com> wrote:
> By the way, it seems like my name got munged when you edited the
> commit.

I fixed the escaping in the name_email* functions (I'll push it
tonight). It was adding a \ for every character it didn't know. It now
only escapes the quotes and back-slashes. This is needed when passing
the strings via the GIT_AUTHOR_* variables.

--
Catalin

^ permalink raw reply

* Re: git faq : draft and rfc
From: Bertrand Jacquin @ 2006-02-20 13:41 UTC (permalink / raw)
  To: Thomas Riboulet; +Cc: git
In-Reply-To: <4fb292fa0602200530s3e2a2cdag39eec0282187edf3@mail.gmail.com>

On 2/20/06, Bertrand Jacquin <beber.mailing@gmail.com> wrote:
> Maybe another question :
>
> How could I merge a branch 'to-merge' with structure a/b/c into branch
> 'master' with structure g/h/i and include files from branch 'to-merge'
> in g/h/i ?

Like as Junio with branch man and html.

>
> I don't know if it's very clear
>
> --
> Beber
> #e.fr@freenode
>


--
Beber
#e.fr@freenode

^ permalink raw reply

* Re: git faq : draft and rfc
From: Bertrand Jacquin @ 2006-02-20 13:30 UTC (permalink / raw)
  To: Thomas Riboulet; +Cc: git
In-Reply-To: <22e91bb0602161552k3f88b98fu4ef2a4c97c840ad7@mail.gmail.com>

Maybe another question :

How could I merge a branch 'to-merge' with structure a/b/c into branch
'master' with structure g/h/i and include files from branch 'to-merge'
in g/h/i ?

I don't know if it's very clear

--
Beber
#e.fr@freenode

^ permalink raw reply

* Re: RFC: Subprojects
From: Uwe Zeisberger @ 2006-02-20 13:16 UTC (permalink / raw)
  To: git
In-Reply-To: <7vacdzkww3.fsf@assigned-by-dhcp.cox.net>

Hello,

Junio C Hamano wrote:
> The "containing" project would have a handful "gitlink" objects
> among other things.  The toplevel tree object from a commit in
> such a project might look like this (mode bits 0160000 is
> S_IFDIR|S_IFLNK, which is what this thing is):
> 
>       $ git ls-tree HEAD
>         0100644 blob 012345... Makefile
>         0100644 blob 123456... README
>         0160000 link 234567... gcc-4.0
>         0160000 link 345678... linux-2.6
>         0040000 tree 456789... src
>       $ git cat-file -t 345678
>         link
>       $ git cat-file link 345678
>         commit 87530db5ec7d519c7ba334e414307c5130ae2da8
>         url git://...torvalds/linux-2.6.git/
> 
>         The upstream Linux 2.6 repository.
>       $ cd linux-2.6 && git-rev-parse --verify HEAD
>         87530db5ec7d519c7ba334e414307c5130ae2da8
> 
> URL will be used as a suggestion for people who cloned this tree
> to set up their repository.
I'd prefer to have the objects needed to get the linux-2.6 tree in the
object db of the containing project.  Then "url" is not needed, and you
could directly use the commit as value for the link.  i.e.

       $ git ls-tree HEAD
         0100644 blob 012345... Makefile
         0100644 blob 123456... README
         0160000 link 435363... gcc-4.0
         0160000 link 87530d... linux-2.6
         0040000 tree 456789... src

(You could now rename "link" to "commit", but it would break the
layout.)

Moreover I prefer the the link approach over the bind method.  The
reason is, that binds use information from the commit object to build
the wc other than the tree.  Moreover the condition that the
"containing" tree must not have an entry named linux-2.6 is handled
implicitly with links.

Please correct me if I'm wrong somewhere.  It's some time ago I read the
patches and this thread.  This mail is the result of some thoughts in my
vacation.

Best regards
Uwe


-- 
Uwe Zeisberger

http://www.google.com/search?q=1+year+divided+by+3+in+seconds

^ permalink raw reply

* Re: Prepend the history of one git tree to another
From: Johannes Schindelin @ 2006-02-20 12:51 UTC (permalink / raw)
  To: Thomas Glanzmann; +Cc: Andreas Ericsson, GIT
In-Reply-To: <20060220104345.GG26454@cip.informatik.uni-erlangen.de>

Hi,

On Mon, 20 Feb 2006, Thomas Glanzmann wrote:

> Hello Andreas,
> 
> > Something like this might do the trick, depending on how linear your 
> > ancestry graph is:
> 
> > $ cd blastwave
> > $ first=$(git rev-list HEAD | tail -n 1)
> > $ git format-patch -k --stdout $first..HEAD > ../blw.mbox
> > $ cd ../blastwave.old
> > $ git am -k -3 ../blw.mbox
> 
> My graph is very linear. However. I have binaries checked into my tree.
> I am not sure if format-patch can handle this.

Do you need the history at all times? If not, you could just make a graft 
file. If you need it always, you could even check in a version of the 
graft file (but remember to copy it to .git/info/grafts, too).

Hth,
Dscho

^ permalink raw reply

* Re: Prepend the history of one git tree to another
From: Thomas Glanzmann @ 2006-02-20 12:20 UTC (permalink / raw)
  To: Ryan Anderson; +Cc: GIT
In-Reply-To: <43F9A0B3.6020304@michonline.com>

Hello,

> I wrote a program called "graft-ripple", that takes a commit, and
> rewrites the current branch's history to reflect as if it started at
> that commit. It doesn't ever actually work with diffs or anything, it
> just reads commits and trees and recreates them.

> http://www.gelato.unsw.edu.au/archives/git/0511/12965.html

that is *exactly* what I was looking for. Thanks.

> Hope this helps!

Well it does!

Thanks,
        Thomas

^ permalink raw reply

* Re: [PATCH] Convert the git faq to asciidoc
From: Thomas Riboulet @ 2006-02-20 11:14 UTC (permalink / raw)
  To: Jonas Fonseca; +Cc: git
In-Reply-To: <20060220014539.GA8759@diku.dk>

On 2/20/06, Jonas Fonseca <fonseca@diku.dk> wrote:
> Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
>
> ---
>
> Thomas Riboulet <riboulet@gmail.com> wrote Thu, Feb 16, 2006:
> > Comments and suggestions are welcome (on the content, the form, format, etc ...)
> > I'll try to add questions from the archives of this ml, I'm also open
> > to any suggestions.
>
> As promissed on the #git channel this patch converts the faq to asciidoc
> format, with a few enhancements such as links to manpages and a TOC.
>
> Previews at
> http://www.diku.dk/hjemmesider/studerende/fonseca/git/git-faq.{html,txt,xml}.
>
> ---
>
>  Makefile |   23 ++++++++
>  faq.conf |   19 +++++++
>  faq.txt  |  175 ++++++++++++++++++++++++++++++++++++++++++--------------------
>  3 files changed, 161 insertions(+), 56 deletions(-)
>
> diff --git a/Makefile b/Makefile
> new file mode 100644
> index 0000000..09f6978
> --- /dev/null
> +++ b/Makefile
> @@ -0,0 +1,23 @@
> +all: git-faq.html git-faq.xml git-faq.txt
> +
> +clean:
> +       rm -f git-faq.html git-faq.xml git-faq.txt faq-toc.txt
> +
> +git-faq.html git-faq.xml git-faq.txt: faq.txt faq-toc.txt
> +
> +git-faq.xml:
> +       asciidoc -f faq.conf -b docbook -d article -o $@ faq.txt
> +
> +git-faq.html: faq.txt faq-toc.txt
> +       asciidoc -f faq.conf -b xhtml11 -d article -o $@ faq.txt
> +
> +git-faq.txt: git-faq.html
> +       elinks --no-numbering --no-references --dump $< > $@
> +
> +faq-toc.txt: faq.txt
> +       sed -n '/^\[\[/,/--/p' < $< | while read line; do \
> +               case "$$line" in \
> +               "[["*"]]") echo -n ". <<$$line, " | sed 's/\[\[\(.*\)\]\]/\1/' ;; \
> +               --*)       echo    ">>" ;; \
> +               *)         echo -n "$$line " ;; \
> +               esac; done > $@
> diff --git a/faq.conf b/faq.conf
> new file mode 100644
> index 0000000..fa16ad6
> --- /dev/null
> +++ b/faq.conf
> @@ -0,0 +1,19 @@
> +# AsciiDoc FAQ definitions
> +
> +[attributes]
> +gitdoc-base=http://kernel.org/pub/software/scm/git/docs/
> +cgdoc-base=http://kernel.org/pub/software/scm/cogito/docs/
> +
> +ifdef::backend-docbook[]
> +[gitdoc-inlinemacro]
> +<ulink url="{gitdoc-base}{target}.html">{0}</ulink>
> +[cgdoc-inlinemacro]
> +<ulink url="{cgdoc-base}{target}.html">{0}</ulink>
> +endif::backend-docbook[]
> +
> +ifdef::backend-xhtml11[]
> +[gitdoc-inlinemacro]
> +<a href="{gitdoc-base}{target}.html">{0}</a>
> +[cgdoc-inlinemacro]
> +<a href="{cgdoc-base}{target}.html">{0}</a>
> +endif::backend-xhtml11[]
> diff --git a/faq.txt b/faq.txt
> index e719d04..9c7baa0 100644
> --- a/faq.txt
> +++ b/faq.txt
> @@ -1,68 +1,131 @@
> -Why the 'git' name ?
> -
> -As Linus' own words as the inventor of git : "git" can mean anything, depending on your mood.
> -
> -* random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of "get" may or may not be relevant.
> -*  stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
> -* global information tracker": you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
> -* "goddamn idiotic truckload of sh*t": when it breaks
> -
> -
> -Can I share a git public repository and use it in a CVS way ?
> -
> -Use cg-admin-setuprepo -g or do git-init-db --shared and some additional stuff. It's ok that refs aren't group writable, it's enough the directory is. See Cogito README or GIT's cvs-migration doc, "Emulating the CVS Development Model" for details.
> -
> -
> -Git commit is dying telling me "fatal : empty ident <user@myhost> not allowed" , what's wrong ?
> -
> -Make sure your Full Name is not empty in chsh or the 5th field of your user line in /etc/passwd isn't empty. You can also set the GIT_AUTHOR_NAME environment variable. If you @myhost is empty make sure your hostname is correctly set.
> -What's the difference between fetch and pull ?
> -
> -Fetch : download objects and a head from another repository.
> -Pull : fetch (as defined above) and merge with the current development.
> -See man git-fetch and git-pull or the tutorials for more details.
> -
> -
> -
> -Can I tell git to ignore files ?
> -
> -Yes. If you want to ignore files localy (only for you in your local work copy) put the files path in the repository in the .git/info/exclude file.
> -
> -If you want to make the ignore matters for all and everyone who checkouts the project you have to put the files path in the .gitignore in the tree itself.
> -
> -
> -Can I import from cvs ?
> -
> -Yes. Use git-cvsimport. See the cvs-migration doc for more details.
> -
> -
> -Can I import from svn ?
> -
> -Yes. Use git-svnimport. See the svn-import doc for more details.
> +The git FAQ
> +===========
> +:Author:       Thomas Riboulet
> +:CorpAuthor:   git mailing list
> +
> +//////////////////////////////////////////////////////////////////////////////
> +A note about required info for FAQ entries. Please use the following template:
> +
> +       [[question-id]]
> +       question?
> +       ---------
> +       answer.
> +
> +The question-id + question will be used for generating a table of contents.
> +//////////////////////////////////////////////////////////////////////////////
> +
> +// DocBook derived output will (hopefully) have it's own TOC
> +ifdef::backend-xhtml11[]
> +include::faq-toc.txt[]
> +endif::backend-xhtml11[]
> +
> +[[git-name]]
> +Why the 'git' name?
> +-------------------
> +In Linus' own words as the inventor of git: "git" can mean anything, depending
> +on your mood:
> +
> + - random three-letter combination that is pronounceable, and not actually
> +   used by any common UNIX command. The fact that it is a mispronunciation of
> +   "get" may or may not be relevant.
> + - stupid. contemptible and despicable. simple. Take your pick from the
> +   dictionary of slang.
> + - global information tracker": you're in a good mood, and it actually works
> +   for you. Angels sing, and a light suddenly fills the room.
> + - "goddamn idiotic truckload of sh*t": when it breaks
> +
> +
> +[[repo-sharing]]]
> +Can I share a git public repository and use it in a CVS way?
> +------------------------------------------------------------
> +Use cg-admin-setuprepo -g or do git-init-db --shared and some additional
> +stuff. It's ok that refs aren't group writable, it's enough the directory is.
> +See Cogito README or GIT's cvs-migration doc, "Emulating the CVS Development
> +Model" for details.
> +
> +
> +[[empty-ident]]
> +Git commit is dying telling me "fatal: empty ident <user@myhost> not allowed", what's wrong?
> +--------------------------------------------------------------------------------------------
> +Make sure your Full Name is not empty in chsh or the 5th field of your user
> +line in `/etc/passwd` isn't empty. You can also set the `GIT_AUTHOR_NAME`
> +environment variable. If your @myhost is empty make sure your hostname is
> +correctly set. Use gitdoc:git-var[`git-var -l`] to make git display user
> +identity variables.
> +
> +
> +[[fetch-vs-pull]]
> +What's the difference between fetch and pull?
> +---------------------------------------------
> +The short definition is:
> +
> +Fetch::        Download objects and a head from another repository.
> +Pull:: Fetch (as defined above) and merge with the current development.
> +
> +See the gitdoc:git-fetch[git-fetch(1)] and gitdoc:git-pull[git-pull(1)]
> +manpages or the tutorials for more details.
> +
> +
> +[[gitignore]]
> +Can I tell git to ignore files?
> +-------------------------------
> +Yes. If you want to ignore files localy (only for you in your local work copy)
> +put the files path in the repository in the `.git/info/exclude` file.
> +
> +If you want to make the ignore matters for all and everyone who checkouts the
> +project you have to put the files path in the `.gitignore` in the tree itself.
> +
> +
> +[[import-cvs]]
> +Can I import from CVS?
> +----------------------
> +Yes. Use git-cvsimport. See the gitdoc:git-cvsimport[git-cvsimport(1)] or
> +gitdoc:cvs-migration[the CVS migration doc] for more detail.
> +
> +
> +[[import-svn]]
> +Can I import from svn?
> +----------------------
> +Yes. Use git-svnimport. See gitdoc:git-svnimport[git-svnimport(1)] for more
> +details.
>
>
> +[[import-arch]]
>  Can I import from arch/baz/tla?
> -
> -Yes. Use git-archimport.
> +-------------------------------
> +Yes. Use git-svnimport. See gitdoc:git-archimport[git-archimport(1)] for more
> +details.
>
>
> +[[import-others]]
>  Can I import from others?
> +-------------------------
> +Maybe -- check if http://www.darcs.net/DarcsWiki/Tailor[tailor.py] can do it.
>
> -Maybe -- check if tailor.py can do it. Check http://www.darcs.net/DarcsWiki/Tailor.
> -
> -
> -How old linus bk repos have been import to git ?
>
> +[[linux-bk]]
> +How was the old Linux BitKeeper repository imported into git?
> +-------------------------------------------------------------
>  Using the CVS gateway, via git-cvsimport.
>
>
> -What can I use to setup a public repository ?
> -
> -A ssh server, an http server, or the git-daemon. See the tutorial for more details.
> -
> -
> -Why won't git let me change to a different branch using "git checkout <branch>" or "git checkout -b <branch>"?
> -
> -Instead it just says: fatal: Entry 'foo.c' not uptodate. Cannot merge.
> +[[public-repo]]
> +What can I use to setup a public repository?
> +--------------------------------------------
> +A SSH server, an HTTP server, or the gitdoc:git-daemon[git-daemon]. See the
> +tutorial for more details.
> +
> +
> +[[change-branch]]
> +Why won't git let me change to a different branch?
> +--------------------------------------------------
> +Using "git checkout <branch>" or "git checkout -b <branch>" it just says:
> +
> +       fatal: Entry 'foo.c' not uptodate. Cannot merge.
> +
> +You have changes to files in your working directory that will be overwritten,
> +removed or otherwise lost if the checkout and change to the new branch were to
> +proceed. To fix this you may either check your changes in, create a patch of
> +your changes and revert your files, or use the "-m" flag like this:
>
> -You have changes to files in your working directory that will be overwritten, removed or otherwise lost if the checkout and change to the new branch were to proceed. To fix this you may either check your changes in, create a patch of your changes and revert your files, or use the "-m" flag like this: git checkout -m -b my-branch
> +       git checkout -m -b my-branch
>
> --
> Jonas Fonseca
>

hi,

ok seems much easier than docbook to write, I've commited your
changes, I'll push them when I'll be back home.

I've tested the docbook file generated, works fine

thanks

--
Thom/ange
http://ange.librium.org

^ permalink raw reply

* Re: Prepend the history of one git tree to another
From: Ryan Anderson @ 2006-02-20 10:57 UTC (permalink / raw)
  To: Thomas Glanzmann; +Cc: Andreas Ericsson, GIT
In-Reply-To: <20060220104345.GG26454@cip.informatik.uni-erlangen.de>

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

Thomas Glanzmann wrote:

>Hello Andreas,
>
>  
>
>>Something like this might do the trick, depending on how linear your 
>>ancestry graph is:
>>    
>>
>
>  
>
>>$ cd blastwave
>>$ first=$(git rev-list HEAD | tail -n 1)
>>$ git format-patch -k --stdout $first..HEAD > ../blw.mbox
>>$ cd ../blastwave.old
>>$ git am -k -3 ../blw.mbox
>>    
>>
>
>My graph is very linear. However. I have binaries checked into my tree.
>I am not sure if format-patch can handle this.
>  
>
I wrote a program called "graft-ripple", that takes a commit, and
rewrites the current branch's history to reflect as if it started at
that commit.

It doesn't ever actually work with diffs or anything, it just reads
commits and trees and recreates them.

It's in the list archives, but I appear to have deleted it when I was
cleaning up my archives.

http://www.gelato.unsw.edu.au/archives/git/0511/12965.html

Hope this helps!

-- 

Ryan Anderson
  sometimes Pug Majere


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

^ permalink raw reply

* [PATCH] Add git-annotate, a tool for assigning blame.
From: Ryan Anderson @ 2006-02-20 10:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Ryan Anderson

Signed-off-by: Ryan Anderson <ryan@michonline.com>

---

(Pull from http://h4x0r5.com/~ryan/git/ryan.git/ annotate-upstream )

I'm pretty sure this version (finally) gets the edge cases correct.

I would appreciate some other testing on this, as I can't find a case
where it falls down, but the files with a lot of history tend to have a
lot of lines, making them hard to spotcheck without having been an
intimate part of that history.

Oh, this is the "functional" version, but it might not qualify as "nice
looking" yet, pleaes, feel free to complain.

 Makefile          |    1 
 git-annotate.perl |  321 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 322 insertions(+), 0 deletions(-)
 create mode 100755 git-annotate.perl

107045e8abb674a66ee7c682dd85a3d303f26e3c
diff --git a/Makefile b/Makefile
index 317be3c..86ffcf4 100644
--- a/Makefile
+++ b/Makefile
@@ -119,6 +119,7 @@ SCRIPT_SH = \
 SCRIPT_PERL = \
 	git-archimport.perl git-cvsimport.perl git-relink.perl \
 	git-shortlog.perl git-fmt-merge-msg.perl git-rerere.perl \
+	git-annotate.perl \
 	git-svnimport.perl git-mv.perl git-cvsexportcommit.perl
 
 SCRIPT_PYTHON = \
diff --git a/git-annotate.perl b/git-annotate.perl
new file mode 100755
index 0000000..8f98431
--- /dev/null
+++ b/git-annotate.perl
@@ -0,0 +1,321 @@
+#!/usr/bin/perl
+# Copyright 2006, Ryan Anderson <ryan@michonline.com>
+#
+# GPL v2 (See COPYING)
+#
+# This file is licensed under the GPL v2, or a later version
+# at the discretion of Linus Torvalds.
+
+use warnings;
+use strict;
+
+my $filename = shift @ARGV;
+
+
+my @stack = (
+	{
+		'rev' => "HEAD",
+		'filename' => $filename,
+	},
+);
+
+our (@lineoffsets, @pendinglineoffsets);
+our @filelines = ();
+open(F,"<",$filename)
+	or die "Failed to open filename: $!";
+
+while(<F>) {
+	chomp;
+	push @filelines, $_;
+}
+close(F);
+our $leftover_lines = @filelines;
+our %revs;
+our @revqueue;
+our $head;
+
+my $revsprocessed = 0;
+while (my $bound = pop @stack) {
+	my @revisions = git_rev_list($bound->{'rev'}, $bound->{'filename'});
+	foreach my $revinst (@revisions) {
+		my ($rev, @parents) = @$revinst;
+		$head ||= $rev;
+
+		$revs{$rev}{'filename'} = $bound->{'filename'};
+		if (scalar @parents > 0) {
+			$revs{$rev}{'parents'} = \@parents;
+			next;
+		}
+
+		my $newbound = find_parent_renames($rev, $bound->{'filename'});
+		if ( exists $newbound->{'filename'} && $newbound->{'filename'} ne $bound->{'filename'}) {
+			push @stack, $newbound;
+			$revs{$rev}{'parents'} = [$newbound->{'rev'}];
+		}
+	}
+}
+push @revqueue, $head;
+init_claim($head);
+$revs{$head}{'lineoffsets'} = {};
+handle_rev();
+
+
+my $i = 0;
+foreach my $l (@filelines) {
+	my ($output, $rev, $committer, $date);
+	if (ref $l eq 'ARRAY') {
+		($output, $rev, $committer, $date) = @$l;
+		if (length($rev) > 8) {
+			$rev = substr($rev,0,8);
+		}
+	} else {
+		$output = $l;
+		($rev, $committer, $date) = ('unknown', 'unknown', 'unknown');
+	}
+
+	printf("(%8s %10s %10s %d)%s\n", $rev, $committer, $date, $i++, $output);
+}
+
+sub init_claim {
+	my ($rev) = @_;
+	my %revinfo = git_commit_info($rev);
+	for (my $i = 0; $i < @filelines; $i++) {
+		$filelines[$i] = [ $filelines[$i], '', '', '', 1];
+			# line,
+			# rev,
+			# author,
+			# date,
+			# 1 <-- belongs to the original file.
+	}
+	$revs{$rev}{'lines'} = \@filelines;
+}
+
+
+sub handle_rev {
+	my $i = 0;
+	while (my $rev = shift @revqueue) {
+
+		my %revinfo = git_commit_info($rev);
+
+		foreach my $p (@{$revs{$rev}{'parents'}}) {
+
+			git_diff_parse($p, $rev, %revinfo);
+			push @revqueue, $p;
+		}
+
+
+		if (scalar @{$revs{$rev}{parents}} == 0) {
+			# 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 '') {
+					claim_line($i, $rev, $revs{$rev}{lines}, %revinfo);
+				}
+			}
+		}
+	}
+}
+
+
+sub git_rev_list {
+	my ($rev, $file) = @_;
+
+	open(P,"-|","git-rev-list","--parents","--remove-empty",$rev,"--",$file)
+		or die "Failed to exec git-rev-list: $!";
+
+	my @revs;
+	while(my $line = <P>) {
+		chomp $line;
+		my ($rev, @parents) = split /\s+/, $line;
+		push @revs, [ $rev, @parents ];
+	}
+	close(P);
+
+	printf("0 revs found for rev %s (%s)\n", $rev, $file) if (@revs == 0);
+	return @revs;
+}
+
+sub find_parent_renames {
+	my ($rev, $file) = @_;
+
+	open(P,"-|","git-diff-tree", "-M50", "-r","--name-status", "-z","$rev")
+		or die "Failed to exec git-diff: $!";
+
+	local $/ = "\0";
+	my %bound;
+	my $junk = <P>;
+	while (my $change = <P>) {
+		chomp $change;
+		my $filename = <P>;
+		chomp $filename;
+
+		if ($change =~ m/^[AMD]$/ ) {
+			next;
+		} elsif ($change =~ m/^R/ ) {
+			my $oldfilename = $filename;
+			$filename = <P>;
+			chomp $filename;
+			if ( $file eq $filename ) {
+				my $parent = git_find_parent($rev, $oldfilename);
+				@bound{'rev','filename'} = ($parent, $oldfilename);
+				last;
+			}
+		}
+	}
+	close(P);
+
+	return \%bound;
+}
+
+
+sub git_find_parent {
+	my ($rev, $filename) = @_;
+
+	open(REVPARENT,"-|","git-rev-list","--remove-empty", "--parents","--max-count=1","$rev","--",$filename)
+		or die "Failed to open git-rev-list to find a single parent: $!";
+
+	my $parentline = <REVPARENT>;
+	chomp $parentline;
+	my ($revfound,$parent) = split m/\s+/, $parentline;
+
+	close(REVPARENT);
+
+	return $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 ($ri, $pi) = (0,0);
+	open(DIFF,"-|","git-diff-tree","-M","-p",$rev,$parent,"--",
+			$revs{$rev}{'filename'}, $revs{$parent}{'filename'})
+		or die "Failed to call git-diff for annotation: $!";
+
+	my $slines = $revs{$rev}{'lines'};
+	my @plines;
+
+	my $gotheader = 0;
+	my ($remstart, $remlength, $addstart, $addlength);
+	my ($hunk_start, $hunk_index, $hunk_adds);
+	while(<DIFF>) {
+		chomp;
+		if (m/^@@ -(\d+),(\d+) \+(\d+),(\d+)/) {
+			($remstart, $remlength, $addstart, $addlength) = ($1, $2, $3, $4);
+			# Adjust for 0-based arrays
+			$remstart--;
+			$addstart--;
+			# Reinit hunk tracking.
+			$hunk_start = $remstart;
+			$hunk_index = 0;
+			$gotheader = 1;
+
+			for (my $i = $ri; $i < $remstart; $i++) {
+				$plines[$pi++] = $slines->[$i];
+				$ri++;
+			}
+			next;
+		} elsif (!$gotheader) {
+			next;
+		}
+
+		if (m/^\+(.*)$/) {
+			my $line = $1;
+			$plines[$pi++] = [ $line, '', '', '', 0 ];
+			next;
+
+		} 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++;
+
+		} 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);
+			}
+			$plines[$pi++] = $slines->[$ri++];
+		}
+		$hunk_index++;
+	}
+	close(DIFF);
+	for (my $i = $ri; $i < @{$slines} ; $i++) {
+		push @plines, $slines->[$ri++];
+	}
+
+	$revs{$parent}{lines} = \@plines;
+	return;
+}
+
+sub get_line {
+	my ($lines, $index) = @_;
+
+	return ref $lines->[$index] ne '' ? $lines->[$index][0] : $lines->[$index];
+}
+
+sub git_cat_file {
+	my ($parent, $filename) = @_;
+	return () unless defined $parent && defined $filename;
+	my $blobline = `git-ls-tree $parent $filename`;
+	my ($mode, $type, $blob, $tfilename) = split(/\s+/, $blobline, 4);
+
+	open(C,"-|","git-cat-file", "blob", $blob)
+		or die "Failed to git-cat-file blob $blob (rev $parent, file $filename): " . $!;
+
+	my @lines;
+	while(<C>) {
+		chomp;
+		push @lines, $_;
+	}
+	close(C);
+
+	return @lines;
+}
+
+
+sub claim_line {
+	my ($floffset, $rev, $lines, %revinfo) = @_;
+	my $oline = get_line($lines, $floffset);
+	@{$lines->[$floffset]} = ( $oline, $rev,
+		$revinfo{'author'}, $revinfo{'author_date'} );
+	#printf("Claiming line %d with rev %s: '%s'\n",
+	#		$floffset, $rev, $oline) if 1;
+}
+
+sub git_commit_info {
+	my ($rev) = @_;
+	open(COMMIT, "-|","git-cat-file", "commit", $rev)
+		or die "Failed to call git-cat-file: $!";
+
+	my %info;
+	while(<COMMIT>) {
+		chomp;
+		last if (length $_ == 0);
+
+		if (m/^author (.*) <(.*)> (.*)$/) {
+			$info{'author'} = $1;
+			$info{'author_email'} = $2;
+			$info{'author_date'} = $3;
+		} elsif (m/^committer (.*) <(.*)> (.*)$/) {
+			$info{'committer'} = $1;
+			$info{'committer_email'} = $2;
+			$info{'committer_date'} = $3;
+		}
+	}
+	close(COMMIT);
+
+	return %info;
+}
-- 
1.2.2.gb342

^ permalink raw reply related

* Re: Prepend the history of one git tree to another
From: Thomas Glanzmann @ 2006-02-20 10:43 UTC (permalink / raw)
  To: Andreas Ericsson; +Cc: GIT
In-Reply-To: <43F99684.5070403@op5.se>

Hello Andreas,

> Something like this might do the trick, depending on how linear your 
> ancestry graph is:

> $ cd blastwave
> $ first=$(git rev-list HEAD | tail -n 1)
> $ git format-patch -k --stdout $first..HEAD > ../blw.mbox
> $ cd ../blastwave.old
> $ git am -k -3 ../blw.mbox

My graph is very linear. However. I have binaries checked into my tree.
I am not sure if format-patch can handle this.

        Thomas

^ permalink raw reply

* Re: [PATCH] Add a Documentation/git-tools.txt
From: Catalin Marinas @ 2006-02-20 10:31 UTC (permalink / raw)
  To: Marco Costalba; +Cc: git, junkio
In-Reply-To: <e5bfff550602190200j1ef3858as6a1564064dc81fef@mail.gmail.com>

"Marco Costalba" <mcostalba@gmail.com> wrote:
> +        - *StGit* (http://homepage.ntlworld.com/cmarinas/stgit/)

This line should be:

+        - *StGIT* (http://www.procode.org/stgit/)

The URL you put is just the download area which may change.

Thanks.

-- 
Catalin

^ permalink raw reply

* Re: Prepend the history of one git tree to another
From: Andreas Ericsson @ 2006-02-20 10:14 UTC (permalink / raw)
  To: Thomas Glanzmann; +Cc: GIT
In-Reply-To: <20060220090909.GT6558@cip.informatik.uni-erlangen.de>

Thomas Glanzmann wrote:
> Hello,
> I have two trees: blastwave and blastwave.old. blastwave.old is the
> BitKeeper -> CVS -> GIT Tree of the project and blastwave is the newer
> one that I started when I stoped using bitkeeper. What I want is to 
> append the history of blastwave to blastwave.old. The problem is that I
> need to create new commit objects for every commit I want to append to
> the old history. Is there a script which does that for me? Or do I have
> to write this script myself?
> 

Something like this might do the trick, depending on how linear your 
ancestry graph is:

$ cd blastwave
$ first=$(git rev-list HEAD | tail -n 1)
$ git format-patch -k --stdout $first..HEAD > ../blw.mbox
$ cd ../blastwave.old
$ git am -k -3 ../blw.mbox

YMMV though, so set an anchor tag at the HEAD of blastwave.old so you 
can return to it if things go awry. If the history is very non-linear I 
think you'll have to do the same for each and every branch, although 
you'd have to use "git merge-base" to figure out how long to go.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

^ permalink raw reply

* Re: What's in git.git
From: Junio C Hamano @ 2006-02-20  9:47 UTC (permalink / raw)
  To: Andreas Ericsson; +Cc: git
In-Reply-To: <43F97F0D.9080500@op5.se>

Andreas Ericsson <ae@op5.se> writes:

> Junio C Hamano wrote:
>>
>> The updated pack-object series is now in "next" branch, and
>> seems to be cooking nicely.  The "reuse from existing pack"
>> change seems to be a huge win and I haven't found problems in
>> there.
>
> Wonderful news. I'll cherry-pick them and do some further testing.

BTW, the point of "next" is that you do not have to necessarily
cherry pick.  The topic branches in there are supposed to be in
testable shape.

Having said that, you could disect them out if you wanted to:

$ git log --pretty=oneline next | grep jc/pack- | head -n 8
5be4eabf90a4f6d14d3ae16772e6b2e063d71587 Merge branch 'jc/pack-thin' into next
bb837eccf42e5e8bbd4fe0927e7fa2afcfd2b564 Merge branch 'jc/pack-thin' into next
416b3cb4303e1a13ed05413bef7a0c1b9f7fc09e Merge branch 'jc/pack-reuse'
07e8ab9be913bd50595707f21a896ac15c4f5a89 Merge branch 'jc/pack-reuse'

The tip of jc/pack-reuse (that is the "reuse data from existing
packs" topic branch) jc/pack-thin ("thin packs") are at 416b3c^2
and 5be4ea^2 respectively.

So to check out the "reuse", you would:

$ git branch -f jc/pack-reuse 416b3c^2
$ git pull . jc/pack-reuse

If you want to try out "thin packs", you would need both
pack-objects change and rev-list change (the tip of jc/rev-list
is at 8c0db2^2).

$ git branch -f jc/rev-list 8c0db2^2
$ git branch -f jc/pack-thin 5be4ea^2
$ git pull . jc/pack-thin
$ git pull . jc/rev-list

^ permalink raw reply

* Prepend the history of one git tree to another
From: Thomas Glanzmann @ 2006-02-20  9:09 UTC (permalink / raw)
  To: GIT

Hello,
I have two trees: blastwave and blastwave.old. blastwave.old is the
BitKeeper -> CVS -> GIT Tree of the project and blastwave is the newer
one that I started when I stoped using bitkeeper. What I want is to 
append the history of blastwave to blastwave.old. The problem is that I
need to create new commit objects for every commit I want to append to
the old history. Is there a script which does that for me? Or do I have
to write this script myself?

        Thomas

^ permalink raw reply

* Re: What's in git.git
From: Junio C Hamano @ 2006-02-20  9:04 UTC (permalink / raw)
  To: Andreas Ericsson; +Cc: git
In-Reply-To: <43F97F0D.9080500@op5.se>

Andreas Ericsson <ae@op5.se> writes:

> Junio C Hamano wrote:
>
>> There now is further performance improvements for git-send-pack
>> to avoid sending a huge blob or tree object in its full
>> representation when we know the other end has a suitable object
>> to use as the base; instead we can just send it out deltified.
>> The other end would expand it to a loose object and this would
>> not make abit of difference in the resulting repository -- only
>> the bandwidth requirement reduction is visible [*1*].
>
> How likely is this to increase the CPU-power needed on the
> server-side? If there is a blob on the server-side, but far from the
> deltified object I suppose we have to look at each commit, perhaps
> only to discover that the client doesn't have them and we need to
> construct the blob anyways.

Not much.  It deliberately keeps the set of blobs and trees to
consider for remote base to minimum -- just the trees contained
in the boundary commits.  That way we may miss the best base
candidate that are further back in history, but it does not
matter because even using the less optimum one as a base saves
us from sending the base object at all.

^ permalink raw reply

* Re: What's in git.git
From: Andreas Ericsson @ 2006-02-20  8:34 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7v3bieea32.fsf@assigned-by-dhcp.cox.net>

Junio C Hamano wrote:
> The updated pack-object series is now in "next" branch, and
> seems to be cooking nicely.  The "reuse from existing pack"
> change seems to be a huge win and I haven't found problems in
> there.
> 

Wonderful news. I'll cherry-pick them and do some further testing.

> There now is further performance improvements for git-send-pack
> to avoid sending a huge blob or tree object in its full
> representation when we know the other end has a suitable object
> to use as the base; instead we can just send it out deltified.
> The other end would expand it to a loose object and this would
> not make abit of difference in the resulting repository -- only
> the bandwidth requirement reduction is visible [*1*].
> 

How likely is this to increase the CPU-power needed on the server-side? 
If there is a blob on the server-side, but far from the deltified object 
I suppose we have to look at each commit, perhaps only to discover that 
the client doesn't have them and we need to construct the blob anyways.

> 
> After a bit more testing, we might want to make --thin transfer
> the default (even without an option to turn it off -- I just do
> not see a point not to use it if it is bug-free).
> 

If the answer to my question above is "minimal to none", I agree most 
vehemently. ;)

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

^ 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