threads / discuss / 20025

cvs import and internal plumbing commands

Subject: cvs import and internal plumbing commands

## tl;dr

14 messages between Jul 5, 2009 and Jul 22, 2009.

replies: 13people: 3as markdown or json

Antony Stubbs· Jul 5, 2009, 02:43 UTC · lore

I've got a new install from mac-ports and am having trouble with cvs import not finding the plumbing commands.

It seems that cvsimport still uses all the old style git-hash-object type commands, instead of the new " git hash-object" command style. And on my system, I don't have any of the old style commands.

I'm working on patching cvsimport to the new style, but would appreicate anyone pointing out anything I'm missing...

If i am indeed correct, then a little help with this would be great (I'm not a perl programmer):

diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index e439202..de40933 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -920,7 +920,7 @@ while (<CVS>) {
                         my $pid = open(my $F, '-|');
                         die $! unless defined $pid;
                         if (!$pid) {
-                           exec("git-hash-object", "-w", $tmpname)
+                           exec("git", "hash-object -w", $tmpname)
                                 or die "Cannot create object: $!\n";
                         }
                         my $sha = <$F>;

git: 'hash-object -w' is not a git-command. See 'git --help'.

Regards,
Antony Stubbs

Talk to me about Wicket, Spring, Maven consulting, small scale  
outsourcing to Australasia and India and Open Source development!

Website: http://sharca.com
Blog: http://stubbisms.wordpress.com
Linked In: http://www.linkedin.com/in/antonystubbs
Podcast: http://www.illegalargument.com
Antony Stubbs· Jul 5, 2009, 06:28 UTC · re: Antony Stubbs · lore

Re: cvs import and internal plumbing commands

OK, I have it running now - didn't know exec takes all command line arguments as a list. So here's the patch. It's not finished importing yet - it will probably take a while, but I'll report back once it's done.

 From 7394424e9892feb4a1274a7c57a11fd81af5a31a Mon Sep 17 00:00:00 2001
From: Antony Stubbs <antony.stubbs@gmail.com>
Date: Sun, 5 Jul 2009 18:09:32 +1200
Subject: [PATCH] migrate to internal git * commands
---
  git-cvsimport.perl |   64 +++++++++++++++++++++++++ 
+--------------------------
  1 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index e439202..80c9710 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -560,16 +560,16 @@ $orig_git_index = $ENV{GIT_INDEX_FILE} if exists  
$ENV{GIT_INDEX_FILE};
  my %index; # holds filenames of one index per branch

  unless (-d $git_dir) {
-	system("git-init");
+	system("git", "init");
  	die "Cannot init the GIT db at $git_tree: $?\n" if $?;
-	system("git-read-tree");
+	system("git", "read-tree");
  	die "Cannot init an empty tree: $?\n" if $?;

  	$last_branch = $opt_o;
  	$orig_branch = "";
  } else {
-	open(F, "git-symbolic-ref HEAD |") or
-		die "Cannot run git-symbolic-ref: $!\n";
+	open(F, "git symbolic-ref HEAD |") or
+		die "Cannot run git symbolic-ref: $!\n";
  	chomp ($last_branch = <F>);
  	$last_branch = basename($last_branch);
  	close(F);
@@ -578,12 +578,12 @@ unless (-d $git_dir) {
  		$last_branch = "master";
  	}
  	$orig_branch = $last_branch;
-	$tip_at_start = `git-rev-parse --verify HEAD`;
+	$tip_at_start = `git rev-parse --verify HEAD`;

  	# Get the last import timestamps
  	my $fmt = '($ref, $author) = (%(refname), %(author));';
-	open(H, "git-for-each-ref --perl --format='$fmt' $remote |") or
-		die "Cannot run git-for-each-ref: $!\n";
+	open(H, "git for-each-ref --perl --format='$fmt' $remote |") or
+		die "Cannot run git for-each-ref: $!\n";
  	while (defined(my $entry = <H>)) {
  		my ($ref, $author);
  		eval($entry) || die "cannot eval refs list: $@";
@@ -638,7 +638,7 @@ unless ($opt_P) {
  	    print $cvspsfh $_;
  	}
  	close CVSPS;
-	$? == 0 or die "git-cvsimport: fatal: cvsps reported error\n";
+	$? == 0 or die "git cvsimport: fatal: cvsps reported error\n";
  	close $cvspsfh;
  } else {
  	$cvspsfile = $opt_P;
@@ -667,27 +667,27 @@ my $state = 0;
  sub update_index (\@\@) {
  	my $old = shift;
  	my $new = shift;
-	open(my $fh, '|-', qw(git-update-index -z --index-info))
-		or die "unable to open git-update-index: $!";
+	open(my $fh, '|-', qw(git update-index -z --index-info))
+		or die "unable to open git update-index: $!";
  	print $fh
  		(map { "0 0000000000000000000000000000000000000000\t$_\0" }
  			@$old),
  		(map { '100' . sprintf('%o', $_->[0]) . " $_->[1]\t$_->[2]\0" }
  			@$new)
-		or die "unable to write to git-update-index: $!";
+		or die "unable to write to git update-index: $!";
  	close $fh
-		or die "unable to write to git-update-index: $!";
-	$? and die "git-update-index reported error: $?";
+		or die "unable to write to git update-index: $!";
+	$? and die "git update-index reported error: $?";
  }

  sub write_tree () {
-	open(my $fh, '-|', qw(git-write-tree))
-		or die "unable to open git-write-tree: $!";
+	open(my $fh, '-|', qw(git write-tree))
+		or die "unable to open git write-tree: $!";
  	chomp(my $tree = <$fh>);
  	is_sha1($tree)
  		or die "Cannot get tree id ($tree): $!";
  	close($fh)
-		or die "Error running git-write-tree: $?\n";
+		or die "Error running git write-tree: $?\n";
  	print "Tree ID $tree\n" if $opt_v;
  	return $tree;
  }
@@ -702,7 +702,7 @@ sub commit {
  	if ($branch eq $opt_o && !$index{branch} &&
  		!get_headref("$remote/$branch")) {
  	    # looks like an initial commit
-	    # use the index primed by git-init
+	    # use the index primed by git init
  	    $ENV{GIT_INDEX_FILE} = "$git_dir/index";
  	    $index{$branch} = "$git_dir/index";
  	} else {
@@ -712,9 +712,9 @@ sub commit {
  		$index{$branch} = tmpnam();
  		$ENV{GIT_INDEX_FILE} = $index{$branch};
  		if ($ancestor) {
-		    system("git-read-tree", "$remote/$ancestor");
+		    system("git", "read-tree", "$remote/$ancestor");
  		} else {
-		    system("git-read-tree", "$remote/$branch");
+		    system("git", "read-tree", "$remote/$branch");
  		}
  		die "read-tree failed: $?\n" if $?;
  	    }
@@ -749,7 +749,7 @@ sub commit {
  	$ENV{GIT_COMMITTER_EMAIL} = $author_email;
  	$ENV{GIT_COMMITTER_DATE} = $commit_date;
  	my $pid = open2(my $commit_read, my $commit_write,
-		'git-commit-tree', $tree, @commit_args);
+		'git', 'commit-tree', $tree, @commit_args);

  	# compatibility with git2cvs
  	substr($logmsg,32767) = "" if length($logmsg) > 32767;
@@ -762,7 +762,7 @@ sub commit {
  	}

  	print($commit_write "$logmsg\n") && close($commit_write)
-		or die "Error writing to git-commit-tree: $!\n";
+		or die "Error writing to git commit-tree: $!\n";

  	print "Committed patch $patchset ($branch $commit_date)\n" if $opt_v;
  	chomp(my $cid = <$commit_read>);
@@ -771,9 +771,9 @@ sub commit {
  	close($commit_read);

  	waitpid($pid,0);
-	die "Error running git-commit-tree: $?\n" if $?;
+	die "Error running git commit-tree: $?\n" if $?;

-	system('git-update-ref', "$remote/$branch", $cid) == 0
+	system('git', 'update-ref', "$remote/$branch", $cid) == 0
  		or die "Cannot write branch $branch for update: $!\n";

  	if ($tag) {
@@ -783,7 +783,7 @@ sub commit {
  		$xtag =~ s/[\/]/$opt_s/g;
  		$xtag =~ s/\[//g;

-		system('git-tag', '-f', $xtag, $cid) == 0
+		system('git', 'tag', '-f', $xtag, $cid) == 0
  			or die "Cannot create tag $xtag: $!\n";

  		print "Created tag '$xtag' on '$branch'\n" if $opt_v;
@@ -920,7 +920,7 @@ while (<CVS>) {
  			my $pid = open(my $F, '-|');
  			die $! unless defined $pid;
  			if (!$pid) {
-			    exec("git-hash-object", "-w", $tmpname)
+			    exec("git", "hash-object", "-w", $tmpname)
  				or die "Cannot create object: $!\n";
  			}
  			my $sha = <$F>;
@@ -964,7 +964,7 @@ unless ($opt_P) {
  # The heuristic of repacking every 1024 commits can leave a
  # lot of unpacked data.  If there is more than 1MB worth of
  # not-packed objects, repack once more.
-my $line = `git-count-objects`;
+my $line = `git count-objects`;
  if ($line =~ /^(\d+) objects, (\d+) kilobytes$/) {
    my ($n_objects, $kb) = ($1, $2);
    1024 < $kb
@@ -989,26 +989,26 @@ if ($orig_branch) {
  	if ($opt_i) {
  		exit 0;
  	}
-	my $tip_at_end = `git-rev-parse --verify HEAD`;
+	my $tip_at_end = `git rev-parse --verify HEAD`;
  	if ($tip_at_start ne $tip_at_end) {
  		for ($tip_at_start, $tip_at_end) { chomp; }
  		print "Fetched into the current branch.\n" if $opt_v;
-		system(qw(git-read-tree -u -m),
+		system(qw(git read-tree -u -m),
  		       $tip_at_start, $tip_at_end);
  		die "Fast-forward update failed: $?\n" if $?;
  	}
  	else {
-		system(qw(git-merge cvsimport HEAD), "$remote/$opt_o");
+		system(qw(git merge cvsimport HEAD), "$remote/$opt_o");
  		die "Could not merge $opt_o into the current branch.\n" if $?;
  	}
  } else {
  	$orig_branch = "master";
  	print "DONE; creating $orig_branch branch\n" if $opt_v;
-	system("git-update-ref", "refs/heads/master", "$remote/$opt_o")
+	system("git", "update-ref", "refs/heads/master", "$remote/$opt_o")
  		unless defined get_headref('refs/heads/master');
-	system("git-symbolic-ref", "$remote/HEAD", "$remote/$opt_o")
+	system("git", "symbolic-ref", "$remote/HEAD", "$remote/$opt_o")
  		if ($opt_r && $opt_o ne 'HEAD');
-	system('git-update-ref', 'HEAD', "$orig_branch");
+	system('git', 'update-ref', 'HEAD', "$orig_branch");
  	unless ($opt_i) {
  		system('git checkout -f');
  		die "checkout failed: $?\n" if $?;
-- 
1.6.3.1




Regards,
Antony Stubbs

Talk to me about Wicket, Spring, Maven consulting, small scale  
outsourcing to Australasia and India and Open Source development!

Website: http://sharca.com
Blog: http://stubbisms.wordpress.com
Linked In: http://www.linkedin.com/in/antonystubbs
Podcast: http://www.illegalargument.com

On 5/07/2009, at 2:43 PM, Antony Stubbs wrote:

> I've got a new install from mac-ports and am having trouble with cvs  
> import not finding the plumbing commands.
>
> It seems that cvsimport still uses all the old style git-hash-object  
> type commands, instead of the new " git hash-object" command style.  
> And on my system, I don't have any of the old style commands.
>
> I'm working on patching cvsimport to the new style, but would  
> appreicate anyone pointing out anything I'm missing...
>
> If i am indeed correct, then a little help with this would be great  
> (I'm not a perl programmer):
>
> diff --git a/git-cvsimport.perl b/git-cvsimport.perl
> index e439202..de40933 100755
> --- a/git-cvsimport.perl
> +++ b/git-cvsimport.perl
> @@ -920,7 +920,7 @@ while (<CVS>) {
>                        my $pid = open(my $F, '-|');
>                        die $! unless defined $pid;
>                        if (!$pid) {
> -                           exec("git-hash-object", "-w", $tmpname)
> +                           exec("git", "hash-object -w", $tmpname)
>                                or die "Cannot create object: $!\n";
>                        }
>                        my $sha = <$F>;
>
> git: 'hash-object -w' is not a git-command. See 'git --help'.
>
> Regards,
> Antony Stubbs
>
> Talk to me about Wicket, Spring, Maven consulting, small scale  
> outsourcing to Australasia and India and Open Source development!
>
> Website: http://sharca.com
> Blog: http://stubbisms.wordpress.com
> Linked In: http://www.linkedin.com/in/antonystubbs
> Podcast: http://www.illegalargument.com
>
astubbs· Jul 6, 2009, 12:15 UTC · re: Antony Stubbs · lore

[PATCH 1/1] Re: cvs import and internal plumbing commands

fyi this is a patch
astubbs wrote:
Show 280 quoted lines
> 
> OK, I have it running now - didn't know exec takes all command line  
> arguments as a list. So here's the patch. It's not finished importing  
> yet - it will probably take a while, but I'll report back once it's  
> done.
> 
>  From 7394424e9892feb4a1274a7c57a11fd81af5a31a Mon Sep 17 00:00:00 2001
> From: Antony Stubbs <antony.stubbs@gmail.com>
> Date: Sun, 5 Jul 2009 18:09:32 +1200
> Subject: [PATCH] migrate to internal git * commands
> 
> ---
>   git-cvsimport.perl |   64 +++++++++++++++++++++++++ 
> +--------------------------
>   1 files changed, 32 insertions(+), 32 deletions(-)
> 
> diff --git a/git-cvsimport.perl b/git-cvsimport.perl
> index e439202..80c9710 100755
> --- a/git-cvsimport.perl
> +++ b/git-cvsimport.perl
> @@ -560,16 +560,16 @@ $orig_git_index = $ENV{GIT_INDEX_FILE} if exists  
> $ENV{GIT_INDEX_FILE};
>   my %index; # holds filenames of one index per branch
> 
>   unless (-d $git_dir) {
> -	system("git-init");
> +	system("git", "init");
>   	die "Cannot init the GIT db at $git_tree: $?\n" if $?;
> -	system("git-read-tree");
> +	system("git", "read-tree");
>   	die "Cannot init an empty tree: $?\n" if $?;
> 
>   	$last_branch = $opt_o;
>   	$orig_branch = "";
>   } else {
> -	open(F, "git-symbolic-ref HEAD |") or
> -		die "Cannot run git-symbolic-ref: $!\n";
> +	open(F, "git symbolic-ref HEAD |") or
> +		die "Cannot run git symbolic-ref: $!\n";
>   	chomp ($last_branch = <F>);
>   	$last_branch = basename($last_branch);
>   	close(F);
> @@ -578,12 +578,12 @@ unless (-d $git_dir) {
>   		$last_branch = "master";
>   	}
>   	$orig_branch = $last_branch;
> -	$tip_at_start = `git-rev-parse --verify HEAD`;
> +	$tip_at_start = `git rev-parse --verify HEAD`;
> 
>   	# Get the last import timestamps
>   	my $fmt = '($ref, $author) = (%(refname), %(author));';
> -	open(H, "git-for-each-ref --perl --format='$fmt' $remote |") or
> -		die "Cannot run git-for-each-ref: $!\n";
> +	open(H, "git for-each-ref --perl --format='$fmt' $remote |") or
> +		die "Cannot run git for-each-ref: $!\n";
>   	while (defined(my $entry = <H>)) {
>   		my ($ref, $author);
>   		eval($entry) || die "cannot eval refs list: $@";
> @@ -638,7 +638,7 @@ unless ($opt_P) {
>   	    print $cvspsfh $_;
>   	}
>   	close CVSPS;
> -	$? == 0 or die "git-cvsimport: fatal: cvsps reported error\n";
> +	$? == 0 or die "git cvsimport: fatal: cvsps reported error\n";
>   	close $cvspsfh;
>   } else {
>   	$cvspsfile = $opt_P;
> @@ -667,27 +667,27 @@ my $state = 0;
>   sub update_index (\@\@) {
>   	my $old = shift;
>   	my $new = shift;
> -	open(my $fh, '|-', qw(git-update-index -z --index-info))
> -		or die "unable to open git-update-index: $!";
> +	open(my $fh, '|-', qw(git update-index -z --index-info))
> +		or die "unable to open git update-index: $!";
>   	print $fh
>   		(map { "0 0000000000000000000000000000000000000000\t$_\0" }
>   			@$old),
>   		(map { '100' . sprintf('%o', $_->[0]) . " $_->[1]\t$_->[2]\0" }
>   			@$new)
> -		or die "unable to write to git-update-index: $!";
> +		or die "unable to write to git update-index: $!";
>   	close $fh
> -		or die "unable to write to git-update-index: $!";
> -	$? and die "git-update-index reported error: $?";
> +		or die "unable to write to git update-index: $!";
> +	$? and die "git update-index reported error: $?";
>   }
> 
>   sub write_tree () {
> -	open(my $fh, '-|', qw(git-write-tree))
> -		or die "unable to open git-write-tree: $!";
> +	open(my $fh, '-|', qw(git write-tree))
> +		or die "unable to open git write-tree: $!";
>   	chomp(my $tree = <$fh>);
>   	is_sha1($tree)
>   		or die "Cannot get tree id ($tree): $!";
>   	close($fh)
> -		or die "Error running git-write-tree: $?\n";
> +		or die "Error running git write-tree: $?\n";
>   	print "Tree ID $tree\n" if $opt_v;
>   	return $tree;
>   }
> @@ -702,7 +702,7 @@ sub commit {
>   	if ($branch eq $opt_o && !$index{branch} &&
>   		!get_headref("$remote/$branch")) {
>   	    # looks like an initial commit
> -	    # use the index primed by git-init
> +	    # use the index primed by git init
>   	    $ENV{GIT_INDEX_FILE} = "$git_dir/index";
>   	    $index{$branch} = "$git_dir/index";
>   	} else {
> @@ -712,9 +712,9 @@ sub commit {
>   		$index{$branch} = tmpnam();
>   		$ENV{GIT_INDEX_FILE} = $index{$branch};
>   		if ($ancestor) {
> -		    system("git-read-tree", "$remote/$ancestor");
> +		    system("git", "read-tree", "$remote/$ancestor");
>   		} else {
> -		    system("git-read-tree", "$remote/$branch");
> +		    system("git", "read-tree", "$remote/$branch");
>   		}
>   		die "read-tree failed: $?\n" if $?;
>   	    }
> @@ -749,7 +749,7 @@ sub commit {
>   	$ENV{GIT_COMMITTER_EMAIL} = $author_email;
>   	$ENV{GIT_COMMITTER_DATE} = $commit_date;
>   	my $pid = open2(my $commit_read, my $commit_write,
> -		'git-commit-tree', $tree, @commit_args);
> +		'git', 'commit-tree', $tree, @commit_args);
> 
>   	# compatibility with git2cvs
>   	substr($logmsg,32767) = "" if length($logmsg) > 32767;
> @@ -762,7 +762,7 @@ sub commit {
>   	}
> 
>   	print($commit_write "$logmsg\n") && close($commit_write)
> -		or die "Error writing to git-commit-tree: $!\n";
> +		or die "Error writing to git commit-tree: $!\n";
> 
>   	print "Committed patch $patchset ($branch $commit_date)\n" if $opt_v;
>   	chomp(my $cid = <$commit_read>);
> @@ -771,9 +771,9 @@ sub commit {
>   	close($commit_read);
> 
>   	waitpid($pid,0);
> -	die "Error running git-commit-tree: $?\n" if $?;
> +	die "Error running git commit-tree: $?\n" if $?;
> 
> -	system('git-update-ref', "$remote/$branch", $cid) == 0
> +	system('git', 'update-ref', "$remote/$branch", $cid) == 0
>   		or die "Cannot write branch $branch for update: $!\n";
> 
>   	if ($tag) {
> @@ -783,7 +783,7 @@ sub commit {
>   		$xtag =~ s/[\/]/$opt_s/g;
>   		$xtag =~ s/\[//g;
> 
> -		system('git-tag', '-f', $xtag, $cid) == 0
> +		system('git', 'tag', '-f', $xtag, $cid) == 0
>   			or die "Cannot create tag $xtag: $!\n";
> 
>   		print "Created tag '$xtag' on '$branch'\n" if $opt_v;
> @@ -920,7 +920,7 @@ while (<CVS>) {
>   			my $pid = open(my $F, '-|');
>   			die $! unless defined $pid;
>   			if (!$pid) {
> -			    exec("git-hash-object", "-w", $tmpname)
> +			    exec("git", "hash-object", "-w", $tmpname)
>   				or die "Cannot create object: $!\n";
>   			}
>   			my $sha = <$F>;
> @@ -964,7 +964,7 @@ unless ($opt_P) {
>   # The heuristic of repacking every 1024 commits can leave a
>   # lot of unpacked data.  If there is more than 1MB worth of
>   # not-packed objects, repack once more.
> -my $line = `git-count-objects`;
> +my $line = `git count-objects`;
>   if ($line =~ /^(\d+) objects, (\d+) kilobytes$/) {
>     my ($n_objects, $kb) = ($1, $2);
>     1024 < $kb
> @@ -989,26 +989,26 @@ if ($orig_branch) {
>   	if ($opt_i) {
>   		exit 0;
>   	}
> -	my $tip_at_end = `git-rev-parse --verify HEAD`;
> +	my $tip_at_end = `git rev-parse --verify HEAD`;
>   	if ($tip_at_start ne $tip_at_end) {
>   		for ($tip_at_start, $tip_at_end) { chomp; }
>   		print "Fetched into the current branch.\n" if $opt_v;
> -		system(qw(git-read-tree -u -m),
> +		system(qw(git read-tree -u -m),
>   		       $tip_at_start, $tip_at_end);
>   		die "Fast-forward update failed: $?\n" if $?;
>   	}
>   	else {
> -		system(qw(git-merge cvsimport HEAD), "$remote/$opt_o");
> +		system(qw(git merge cvsimport HEAD), "$remote/$opt_o");
>   		die "Could not merge $opt_o into the current branch.\n" if $?;
>   	}
>   } else {
>   	$orig_branch = "master";
>   	print "DONE; creating $orig_branch branch\n" if $opt_v;
> -	system("git-update-ref", "refs/heads/master", "$remote/$opt_o")
> +	system("git", "update-ref", "refs/heads/master", "$remote/$opt_o")
>   		unless defined get_headref('refs/heads/master');
> -	system("git-symbolic-ref", "$remote/HEAD", "$remote/$opt_o")
> +	system("git", "symbolic-ref", "$remote/HEAD", "$remote/$opt_o")
>   		if ($opt_r && $opt_o ne 'HEAD');
> -	system('git-update-ref', 'HEAD', "$orig_branch");
> +	system('git', 'update-ref', 'HEAD', "$orig_branch");
>   	unless ($opt_i) {
>   		system('git checkout -f');
>   		die "checkout failed: $?\n" if $?;
> -- 
> 1.6.3.1
> 
> 
> 
> 
> Regards,
> Antony Stubbs
> 
> Talk to me about Wicket, Spring, Maven consulting, small scale  
> outsourcing to Australasia and India and Open Source development!
> 
> Website: http://sharca.com
> Blog: http://stubbisms.wordpress.com
> Linked In: http://www.linkedin.com/in/antonystubbs
> Podcast: http://www.illegalargument.com
> 
> On 5/07/2009, at 2:43 PM, Antony Stubbs wrote:
> 
>> I've got a new install from mac-ports and am having trouble with cvs  
>> import not finding the plumbing commands.
>>
>> It seems that cvsimport still uses all the old style git-hash-object  
>> type commands, instead of the new " git hash-object" command style.  
>> And on my system, I don't have any of the old style commands.
>>
>> I'm working on patching cvsimport to the new style, but would  
>> appreicate anyone pointing out anything I'm missing...
>>
>> If i am indeed correct, then a little help with this would be great  
>> (I'm not a perl programmer):
>>
>> diff --git a/git-cvsimport.perl b/git-cvsimport.perl
>> index e439202..de40933 100755
>> --- a/git-cvsimport.perl
>> +++ b/git-cvsimport.perl
>> @@ -920,7 +920,7 @@ while (<CVS>) {
>>                        my $pid = open(my $F, '-|');
>>                        die $! unless defined $pid;
>>                        if (!$pid) {
>> -                           exec("git-hash-object", "-w", $tmpname)
>> +                           exec("git", "hash-object -w", $tmpname)
>>                                or die "Cannot create object: $!\n";
>>                        }
>>                        my $sha = <$F>;
>>
>> git: 'hash-object -w' is not a git-command. See 'git --help'.
>>
>> Regards,
>> Antony Stubbs
>>
>> Talk to me about Wicket, Spring, Maven consulting, small scale  
>> outsourcing to Australasia and India and Open Source development!
>>
>> Website: http://sharca.com
>> Blog: http://stubbisms.wordpress.com
>> Linked In: http://www.linkedin.com/in/antonystubbs
>> Podcast: http://www.illegalargument.com
>>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
-- 
View this message in context: http://n2.nabble.com/cvs-import-and-internal-plumbing-commands-tp3207876p3212716.html
Sent from the git mailing list archive at Nabble.com.
Jeff King· Jul 16, 2009, 10:01 UTC · re: Antony Stubbs · lore

Re: cvs import and internal plumbing commands

On Sun, Jul 05, 2009 at 02:43:01PM +1200, Antony Stubbs wrote:
Show 6 quoted lines
> I've got a new install from mac-ports and am having trouble with cvs
> import not finding the plumbing commands.
> 
> It seems that cvsimport still uses all the old style git-hash-object
> type commands, instead of the new " git hash-object" command style.
> And on my system, I don't have any of the old style commands.

The old style commands should be in the execdir (e.g., /usr/local/libexec/git-core). That directory should be placed at the beginning of the PATH when you run "git cvsimport".

If you run "git --exec-path", what directory does it print? If you go to that directory, is it filled with dashed git commands?

-Peff
Antony Stubbs· Jul 17, 2009, 21:44 UTC · re: Jeff King · lore

Re: cvs import and internal plumbing commands

On 16/07/2009, at 10:01 PM, Jeff King <peff@peff.net> wrote:
Show 18 quoted lines
> On Sun, Jul 05, 2009 at 02:43:01PM +1200, Antony Stubbs wrote:
>
>> I've got a new install from mac-ports and am having trouble with cvs
>> import not finding the plumbing commands.
>>
>> It seems that cvsimport still uses all the old style git-hash-object
>> type commands, instead of the new " git hash-object" command style.
>> And on my system, I don't have any of the old style commands.
>
> The old style commands should be in the execdir (e.g.,
> /usr/local/libexec/git-core). That directory should be placed at the
> beginning of the PATH when you run "git cvsimport".
>
> If you run "git --exec-path", what directory does it print? If you  
> go to
> that directory, is it filled with dashed git commands?
>
> -Peff
Ok cool, I'll have a look when I get home.

But should we not migrate it for the future anyway? An at least that way it would work by default, in this environment?

Cheers, Antony

www.sharca.com
Jeff King· Jul 17, 2009, 21:45 UTC · re: Antony Stubbs · lore

Re: cvs import and internal plumbing commands

On Sat, Jul 18, 2009 at 09:44:08AM +1200, Antony Stubbs wrote:
Show 8 quoted lines
> >The old style commands should be in the execdir (e.g.,
> >/usr/local/libexec/git-core). That directory should be placed at the
> >beginning of the PATH when you run "git cvsimport".
> 
> Ok cool, I'll have a look when I get home.
> 
> But should we not migrate it for the future anyway? An at least that
> way it would work by default, in this environment?

Yes, I think it is reasonable to migrate it in any case, if only because it serves as an example when people read it, and we are trying to encourage the dashless form.

-Peff
Antony Stubbs· Jul 17, 2009, 21:59 UTC · re: Jeff King · lore

Re: cvs import and internal plumbing commands

On 18/07/2009, at 9:45 AM, Jeff King <peff@peff.net> wrote:
Show 15 quoted lines
> On Sat, Jul 18, 2009 at 09:44:08AM +1200, Antony Stubbs wrote:
>
>>> The old style commands should be in the execdir (e.g.,
>>> /usr/local/libexec/git-core). That directory should be placed at the
>>> beginning of the PATH when you run "git cvsimport".
>>
>> Ok cool, I'll have a look when I get home.
>>
>> But should we not migrate it for the future anyway? An at least that
>> way it would work by default, in this environment?
>
> Yes, I think it is reasonable to migrate it in any case, if only  
> because
> it serves as an example when people read it, and we are trying to
> encourage the dashless form.

Great - ok, is there anything else I need to do re the patch I wrote, in your opinion?

--Antony
Antony Stubbs· Jul 19, 2009, 23:57 UTC · re: Antony Stubbs · lore

Re: [PATCH] cvs import and internal plumbing commands

Signed-off patch, post discussion with Jeff King.
From: Antony Stubbs <antony.stubbs@gmail.com>
Date: Sun, 5 Jul 2009 18:09:32 +1200
migrate cvs-import to internal git * commands
Signed-off-by: Antony Stubbs <antony.stubbs@gmail.com>
---
  git-cvsimport.perl |   64 +++++++++++++++++++++++++ 
+--------------------------
  1 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index e439202..80c9710 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -560,16 +560,16 @@ $orig_git_index = $ENV{GIT_INDEX_FILE} if exists  
$ENV{GIT_INDEX_FILE};
  my %index; # holds filenames of one index per branch

  unless (-d $git_dir) {
-	system("git-init");
+	system("git", "init");
  	die "Cannot init the GIT db at $git_tree: $?\n" if $?;
-	system("git-read-tree");
+	system("git", "read-tree");
  	die "Cannot init an empty tree: $?\n" if $?;

  	$last_branch = $opt_o;
  	$orig_branch = "";
  } else {
-	open(F, "git-symbolic-ref HEAD |") or
-		die "Cannot run git-symbolic-ref: $!\n";
+	open(F, "git symbolic-ref HEAD |") or
+		die "Cannot run git symbolic-ref: $!\n";
  	chomp ($last_branch = <F>);
  	$last_branch = basename($last_branch);
  	close(F);
@@ -578,12 +578,12 @@ unless (-d $git_dir) {
  		$last_branch = "master";
  	}
  	$orig_branch = $last_branch;
-	$tip_at_start = `git-rev-parse --verify HEAD`;
+	$tip_at_start = `git rev-parse --verify HEAD`;

  	# Get the last import timestamps
  	my $fmt = '($ref, $author) = (%(refname), %(author));';
-	open(H, "git-for-each-ref --perl --format='$fmt' $remote |") or
-		die "Cannot run git-for-each-ref: $!\n";
+	open(H, "git for-each-ref --perl --format='$fmt' $remote |") or
+		die "Cannot run git for-each-ref: $!\n";
  	while (defined(my $entry = <H>)) {
  		my ($ref, $author);
  		eval($entry) || die "cannot eval refs list: $@";
@@ -638,7 +638,7 @@ unless ($opt_P) {
  	    print $cvspsfh $_;
  	}
  	close CVSPS;
-	$? == 0 or die "git-cvsimport: fatal: cvsps reported error\n";
+	$? == 0 or die "git cvsimport: fatal: cvsps reported error\n";
  	close $cvspsfh;
  } else {
  	$cvspsfile = $opt_P;
@@ -667,27 +667,27 @@ my $state = 0;
  sub update_index (\@\@) {
  	my $old = shift;
  	my $new = shift;
-	open(my $fh, '|-', qw(git-update-index -z --index-info))
-		or die "unable to open git-update-index: $!";
+	open(my $fh, '|-', qw(git update-index -z --index-info))
+		or die "unable to open git update-index: $!";
  	print $fh
  		(map { "0 0000000000000000000000000000000000000000\t$_\0" }
  			@$old),
  		(map { '100' . sprintf('%o', $_->[0]) . " $_->[1]\t$_->[2]\0" }
  			@$new)
-		or die "unable to write to git-update-index: $!";
+		or die "unable to write to git update-index: $!";
  	close $fh
-		or die "unable to write to git-update-index: $!";
-	$? and die "git-update-index reported error: $?";
+		or die "unable to write to git update-index: $!";
+	$? and die "git update-index reported error: $?";
  }

  sub write_tree () {
-	open(my $fh, '-|', qw(git-write-tree))
-		or die "unable to open git-write-tree: $!";
+	open(my $fh, '-|', qw(git write-tree))
+		or die "unable to open git write-tree: $!";
  	chomp(my $tree = <$fh>);
  	is_sha1($tree)
  		or die "Cannot get tree id ($tree): $!";
  	close($fh)
-		or die "Error running git-write-tree: $?\n";
+		or die "Error running git write-tree: $?\n";
  	print "Tree ID $tree\n" if $opt_v;
  	return $tree;
  }
@@ -702,7 +702,7 @@ sub commit {
  	if ($branch eq $opt_o && !$index{branch} &&
  		!get_headref("$remote/$branch")) {
  	    # looks like an initial commit
-	    # use the index primed by git-init
+	    # use the index primed by git init
  	    $ENV{GIT_INDEX_FILE} = "$git_dir/index";
  	    $index{$branch} = "$git_dir/index";
  	} else {
@@ -712,9 +712,9 @@ sub commit {
  		$index{$branch} = tmpnam();
  		$ENV{GIT_INDEX_FILE} = $index{$branch};
  		if ($ancestor) {
-		    system("git-read-tree", "$remote/$ancestor");
+		    system("git", "read-tree", "$remote/$ancestor");
  		} else {
-		    system("git-read-tree", "$remote/$branch");
+		    system("git", "read-tree", "$remote/$branch");
  		}
  		die "read-tree failed: $?\n" if $?;
  	    }
@@ -749,7 +749,7 @@ sub commit {
  	$ENV{GIT_COMMITTER_EMAIL} = $author_email;
  	$ENV{GIT_COMMITTER_DATE} = $commit_date;
  	my $pid = open2(my $commit_read, my $commit_write,
-		'git-commit-tree', $tree, @commit_args);
+		'git', 'commit-tree', $tree, @commit_args);

  	# compatibility with git2cvs
  	substr($logmsg,32767) = "" if length($logmsg) > 32767;
@@ -762,7 +762,7 @@ sub commit {
  	}

  	print($commit_write "$logmsg\n") && close($commit_write)
-		or die "Error writing to git-commit-tree: $!\n";
+		or die "Error writing to git commit-tree: $!\n";

  	print "Committed patch $patchset ($branch $commit_date)\n" if $opt_v;
  	chomp(my $cid = <$commit_read>);
@@ -771,9 +771,9 @@ sub commit {
  	close($commit_read);

  	waitpid($pid,0);
-	die "Error running git-commit-tree: $?\n" if $?;
+	die "Error running git commit-tree: $?\n" if $?;

-	system('git-update-ref', "$remote/$branch", $cid) == 0
+	system('git', 'update-ref', "$remote/$branch", $cid) == 0
  		or die "Cannot write branch $branch for update: $!\n";

  	if ($tag) {
@@ -783,7 +783,7 @@ sub commit {
  		$xtag =~ s/[\/]/$opt_s/g;
  		$xtag =~ s/\[//g;

-		system('git-tag', '-f', $xtag, $cid) == 0
+		system('git', 'tag', '-f', $xtag, $cid) == 0
  			or die "Cannot create tag $xtag: $!\n";

  		print "Created tag '$xtag' on '$branch'\n" if $opt_v;
@@ -920,7 +920,7 @@ while (<CVS>) {
  			my $pid = open(my $F, '-|');
  			die $! unless defined $pid;
  			if (!$pid) {
-			    exec("git-hash-object", "-w", $tmpname)
+			    exec("git", "hash-object", "-w", $tmpname)
  				or die "Cannot create object: $!\n";
  			}
  			my $sha = <$F>;
@@ -964,7 +964,7 @@ unless ($opt_P) {
  # The heuristic of repacking every 1024 commits can leave a
  # lot of unpacked data.  If there is more than 1MB worth of
  # not-packed objects, repack once more.
-my $line = `git-count-objects`;
+my $line = `git count-objects`;
  if ($line =~ /^(\d+) objects, (\d+) kilobytes$/) {
    my ($n_objects, $kb) = ($1, $2);
    1024 < $kb
@@ -989,26 +989,26 @@ if ($orig_branch) {
  	if ($opt_i) {
  		exit 0;
  	}
-	my $tip_at_end = `git-rev-parse --verify HEAD`;
+	my $tip_at_end = `git rev-parse --verify HEAD`;
  	if ($tip_at_start ne $tip_at_end) {
  		for ($tip_at_start, $tip_at_end) { chomp; }
  		print "Fetched into the current branch.\n" if $opt_v;
-		system(qw(git-read-tree -u -m),
+		system(qw(git read-tree -u -m),
  		       $tip_at_start, $tip_at_end);
  		die "Fast-forward update failed: $?\n" if $?;
  	}
  	else {
-		system(qw(git-merge cvsimport HEAD), "$remote/$opt_o");
+		system(qw(git merge cvsimport HEAD), "$remote/$opt_o");
  		die "Could not merge $opt_o into the current branch.\n" if $?;
  	}
  } else {
  	$orig_branch = "master";
  	print "DONE; creating $orig_branch branch\n" if $opt_v;
-	system("git-update-ref", "refs/heads/master", "$remote/$opt_o")
+	system("git", "update-ref", "refs/heads/master", "$remote/$opt_o")
  		unless defined get_headref('refs/heads/master');
-	system("git-symbolic-ref", "$remote/HEAD", "$remote/$opt_o")
+	system("git", "symbolic-ref", "$remote/HEAD", "$remote/$opt_o")
  		if ($opt_r && $opt_o ne 'HEAD');
-	system('git-update-ref', 'HEAD', "$orig_branch");
+	system('git', 'update-ref', 'HEAD', "$orig_branch");
  	unless ($opt_i) {
  		system('git checkout -f');
  		die "checkout failed: $?\n" if $?;
-- 
1.6.3.3



On 18/07/2009, at 9:59 AM, Antony Stubbs wrote:

> On 18/07/2009, at 9:45 AM, Jeff King <peff@peff.net> wrote:
>
>> On Sat, Jul 18, 2009 at 09:44:08AM +1200, Antony Stubbs wrote:
>>
>>>> The old style commands should be in the execdir (e.g.,
>>>> /usr/local/libexec/git-core). That directory should be placed at  
>>>> the
>>>> beginning of the PATH when you run "git cvsimport".
>>>
>>> Ok cool, I'll have a look when I get home.
>>>
>>> But should we not migrate it for the future anyway? An at least that
>>> way it would work by default, in this environment?
>>
>> Yes, I think it is reasonable to migrate it in any case, if only  
>> because
>> it serves as an example when people read it, and we are trying to
>> encourage the dashless form.
>
> Great - ok, is there anything else I need to do re the patch I  
> wrote, in your opinion?
>
> --Antony
Junio C Hamano· Jul 20, 2009, 02:43 UTC · re: Jeff King · lore

Re: cvs import and internal plumbing commands

Jeff King <peff@peff.net> writes:
> Yes, I think it is reasonable to migrate it in any case, if only because
> it serves as an example when people read it, and we are trying to
> encourage the dashless form.
Hmm, I am of two minds.

We encourage script writers to just prepend "git --exec-path" at the beginning of their PATH and give guarantee that this simple procedure will keep their scripts working, so it might be a good idea to have an example for that as well.

So the preferred fix might be just the matter of adding one line
	$ENV{'PATH'} = `git --exec-path`. ":$ENV{'PATH'}";
at the beginning of the script.
Jeff King· Jul 20, 2009, 15:34 UTC · re: Junio C Hamano · lore

Re: cvs import and internal plumbing commands

On Sun, Jul 19, 2009 at 07:43:28PM -0700, Junio C Hamano wrote:
> We encourage script writers to just prepend "git --exec-path" at the
> beginning of their PATH and give guarantee that this simple procedure will
> keep their scripts working, so it might be a good idea to have an example
> for that as well.

I had it in my head that such a strategy was supposed to be a temporary step in the process of getting rid of dashed forms. That is, you can do that now to avoid having your scripts break, but in the long run, you should be converting to the space form.

But I guess the plan was softened, and we have no deprecation plan for dashed forms in exec-path. So maybe my thinking was outdated.

Show 5 quoted lines
> So the preferred fix might be just the matter of adding one line
> 
> 	$ENV{'PATH'} = `git --exec-path`. ":$ENV{'PATH'}";
> 
> at the beginning of the script.

I can see that for a totally third-party script which wanted to use git plumbing. But why do that for a git-* script? The "git" wrapper sets up the environment like that already.

-Peff
Antony Stubbs· Jul 21, 2009, 23:24 UTC · re: Jeff King · lore

Re: cvs import and internal plumbing commands

But regardless, surely calling straight into git is simpler/nicer and more likely to just work (as on OSX)?

 From the 1.6.0 release notes (http://www.kernel.org/pub/software/scm/git/docs/RelNotes-1.6.0.txt 
):
"""With the default Makefile settings, most of the programs are now
installed outside your $PATH, except for "git", "gitk" and some server  
side programs that need to be accessible for technical reasons.  
Invoking a git subcommand as "git-xyzzy" from the command line has  
been deprecated since early 2006 (and officially announced in 1.5.4  
release notes); use of them from your scripts after adding output from  
"git --exec-path" to the $PATH is still supported in this release, but  
users are again strongly encouraged to adjust their scripts to use  
"git xyzzy" form, as we will stop installing "git-xyzzy" hardlinks for  
built-in commands in later releases. """

note the "but users are again strongly encouraged to adjust their scripts to use "git xyzzy" form". Why not just apply the patch and be done with it?

-Antony
On 21/07/2009, at 3:34 AM, Jeff King wrote:
Show 32 quoted lines
> On Sun, Jul 19, 2009 at 07:43:28PM -0700, Junio C Hamano wrote:
>
>> We encourage script writers to just prepend "git --exec-path" at the
>> beginning of their PATH and give guarantee that this simple  
>> procedure will
>> keep their scripts working, so it might be a good idea to have an  
>> example
>> for that as well.
>
> I had it in my head that such a strategy was supposed to be a  
> temporary
> step in the process of getting rid of dashed forms. That is, you can  
> do
> that now to avoid having your scripts break, but in the long run, you
> should be converting to the space form.
>
> But I guess the plan was softened, and we have no deprecation plan for
> dashed forms in exec-path. So maybe my thinking was outdated.
>
>> So the preferred fix might be just the matter of adding one line
>>
>> 	$ENV{'PATH'} = `git --exec-path`. ":$ENV{'PATH'}";
>>
>> at the beginning of the script.
>
> I can see that for a totally third-party script which wanted to use  
> git
> plumbing.  But why do that for a git-* script? The "git" wrapper  
> sets up
> the environment like that already.
>
> -Peff
Junio C Hamano· Jul 22, 2009, 00:43 UTC · re: Antony Stubbs · lore

Re: cvs import and internal plumbing commands

Antony Stubbs <antony.stubbs@gmail.com> writes:
Show 18 quoted lines
> On 21/07/2009, at 3:34 AM, Jeff King wrote:
> ...
>> But I guess the plan was softened, and we have no deprecation plan for
>> dashed forms in exec-path. So maybe my thinking was outdated.
>>
>>> So the preferred fix might be just the matter of adding one line
>>>
>>> 	$ENV{'PATH'} = `git --exec-path`. ":$ENV{'PATH'}";
>>>
>>> at the beginning of the script.
>>
>> I can see that for a totally third-party script which wanted to use
>> git
>> plumbing.  But why do that for a git-* script? The "git" wrapper
>> sets up
>> the environment like that already.
>>
>> -Peff
[note: do not top post]
Show 15 quoted lines
> But regardless, surely calling straight into git is simpler/nicer and
> more likely to just work (as on OSX)?
>
> From the 1.6.0 release notes
> (http://www.kernel.org/pub/software/scm/git/docs/RelNotes-1.6.0.txt ):
> """With the default Makefile settings, most of the programs are now
> installed outside your $PATH, except for "git", "gitk" and some server
> side programs that need to be accessible for technical reasons.
> Invoking a git subcommand as "git-xyzzy" from the command line has
> been deprecated since early 2006 (and officially announced in 1.5.4
> release notes); use of them from your scripts after adding output from
> "git --exec-path" to the $PATH is still supported in this release, but
> users are again strongly encouraged to adjust their scripts to use
> "git xyzzy" form, as we will stop installing "git-xyzzy" hardlinks for
> built-in commands in later releases. """

In case you are too new to the git land, I'd point out that "... as we will stop installing" part was rescinded after a big fiasco that immediately followed 1.6.0 release.

> note the "but users are again strongly encouraged to adjust their
> scripts to use "git xyzzy" form". Why not just apply the patch and be
> done with it?

Note that my suggestion on $PATH=$(git --exec-path):$PATH was a response to Jeff's message, which was the same message your patch was response to. In other words, our messages crossed, and I do not have an issue with fixing this either way. If your patch fixes the issue correctly that would be great.

Has anybody reviewed the submitted patch? I do not use cvsimport these days anymore for anything real, so the only assurance I have on your patch so far are my eyeballs and whatever tests done in test scripts in the t/ directory. Independent "Yeah, it looks good and it works for me" would make me feel a bit safer.

Jeff King· Jul 22, 2009, 02:59 UTC · re: Junio C Hamano · lore

Re: cvs import and internal plumbing commands

On Tue, Jul 21, 2009 at 05:43:08PM -0700, Junio C Hamano wrote:
Show 5 quoted lines
> Note that my suggestion on $PATH=$(git --exec-path):$PATH was a response
> to Jeff's message, which was the same message your patch was response to.
> In other words, our messages crossed, and I do not have an issue with
> fixing this either way.  If your patch fixes the issue correctly that
> would be great.

I am still confused about what the "issue" is. That is, why this is a bugfix for Anthony instead of simply a code modernization. IOW, I think there is something else broken about his install if cvsimport cannot find the dashed plumbing commands, and we may simply be papering over it.

That being said, I think the code modernization is of value itself, so let's do it.

Show 5 quoted lines
> Has anybody reviewed the submitted patch?  I do not use cvsimport these
> days anymore for anything real, so the only assurance I have on your patch
> so far are my eyeballs and whatever tests done in test scripts in the t/
> directory.  Independent "Yeah, it looks good and it works for me" would
> make me feel a bit safer.

I am lucky enough not to have needed git-cvsimport for some time, so I cannot say "it works for me." But I have read the patch; I didn't see any errors in the conversion, and assuming the conversion is done correctly, the behavior should be otherwise identical. So

Acked-by: Jeff King <peff@peff.net>
-Peff
Junio C Hamano· Jul 22, 2009, 03:06 UTC · re: Jeff King · lore

Re: cvs import and internal plumbing commands

Jeff King <peff@peff.net> writes:
Show 13 quoted lines
> On Tue, Jul 21, 2009 at 05:43:08PM -0700, Junio C Hamano wrote:
>
>> Note that my suggestion on $PATH=$(git --exec-path):$PATH was a response
>> to Jeff's message, which was the same message your patch was response to.
>> In other words, our messages crossed, and I do not have an issue with
>> fixing this either way.  If your patch fixes the issue correctly that
>> would be great.
>
> I am still confused about what the "issue" is. That is, why this is a
> bugfix for Anthony instead of simply a code modernization. IOW, I think
> there is something else broken about his install if cvsimport cannot
> find the dashed plumbing commands, and we may simply be papering over
> it.

I simply assumed that he was a correct install but for whatever crazy reason is running /usr/local/libexec/git-core/git-cvsimport directly from the command line. That usage won't be helped with the git wrapper at all.

I suspect shell scripted Porcelains like "git-pull" have the same issue, as we do not seem to have "prepend to PATH" in git-sh-setup.sh at all. Some like git-gui and instaweb do protect themselves, though.

> That being said, I think the code modernization is of value itself, so
> let's do it.
Agreed, and thanks.

← back to recent threads