git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] make git-cvsimport work on ref-packed repositories
@ 2007-05-23  7:13 Stephan Springl
  2007-05-23 11:13 ` [PATCH] Use git-for-each-ref to check whether the origin branch exists Johannes Schindelin
  0 siblings, 1 reply; 4+ messages in thread
From: Stephan Springl @ 2007-05-23  7:13 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1742 bytes --]

Hi!

      This helps us to use git-cvsimport on our ref-packed repositories.
Maybe you want to use this or a similar solution to be integrated in
stock git.

Thank you.

Stephan.



commit 83f8922f1ad385ef3493684838e11a34edbf68a7
Author: Stephan Springl <springl-git@bfw-online.de>
Date:   Wed May 23 09:06:37 2007 +0200

     Use git-for-each-ref to check whether the origin (or opt_o) branch exists.
     This works in repositories that have their refs packed by
     "git-pack-refs --all --prune" whereas testing the file
     $git_dir/refs/heads/$opt_o does not.

diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index ac74bc5..f68afe7 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -559,11 +559,6 @@ unless (-d $git_dir) {
  	$last_branch = $opt_o;
  	$orig_branch = "";
  } else {
-	-f "$git_dir/refs/heads/$opt_o"
-		or die "Branch '$opt_o' does not exist.\n".
-		       "Either use the correct '-o branch' option,\n".
-		       "or import to a new repository.\n";
-
  	open(F, "git-symbolic-ref HEAD |") or
  		die "Cannot run git-symbolic-ref: $!\n";
  	chomp ($last_branch = <F>);
@@ -588,6 +583,11 @@ unless (-d $git_dir) {
  		$branch_date{$head} = $1;
  	}
  	close(H);
+        if (!exists $branch_date{$opt_o}) {
+		die "Branch '$opt_o' does not exist.\n".
+		       "Either use the correct '-o branch' option,\n".
+		       "or import to a new repository.\n";
+        }
  }

  -d $git_dir


--
Stephan Springl                           BFW Werner Völk GmbH
springl-git@bfw-online.de                 Energiemesstechnik & Service
+49 89 82917-452                          Drosselgasse 5
                                           82166 Gräfelfing/München

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] Use git-for-each-ref to check whether the origin branch exists.
  2007-05-23  7:13 [PATCH] make git-cvsimport work on ref-packed repositories Stephan Springl
@ 2007-05-23 11:13 ` Johannes Schindelin
  2007-05-23 11:59   ` Stephan Springl
  2007-05-23 18:06   ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Johannes Schindelin @ 2007-05-23 11:13 UTC (permalink / raw)
  To: Stephan Springl; +Cc: git

From: Stephan Springl <springl-git@bfw-online.de>

This works in repositories that have their refs packed by
"git-pack-refs --all --prune" whereas testing the file
$git_dir/refs/heads/$opt_o does not.

Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

---

	On Wed, 23 May 2007, Stephan Springl wrote:
	
	> This helps us to use git-cvsimport on our ref-packed 
	> repositories.

	Default for ref-packed repositories is to pack only the tags, 
	therefore you usually do not need this patch. However, it looks 
	obviously correct to me. A cursory test also showed that it does 
	not break anything.

	> Maybe you want to use this or a similar solution to be 
	> integrated in stock git.
	
	Unfortunately your patch is white-space corrupted (it has an extra 
	space on all lines starting with a space, it seems). Therefore I 
	redid it with this email.

	It would be nice to follow Documentation/SubmittingPatches next 
	time. For example, I guess that you want to sign off on it...

 git-cvsimport.perl |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index ac74bc5..f68afe7 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -559,11 +559,6 @@ unless (-d $git_dir) {
 	$last_branch = $opt_o;
 	$orig_branch = "";
 } else {
-	-f "$git_dir/refs/heads/$opt_o"
-		or die "Branch '$opt_o' does not exist.\n".
-		       "Either use the correct '-o branch' option,\n".
-		       "or import to a new repository.\n";
-
 	open(F, "git-symbolic-ref HEAD |") or
 		die "Cannot run git-symbolic-ref: $!\n";
 	chomp ($last_branch = <F>);
@@ -588,6 +583,11 @@ unless (-d $git_dir) {
 		$branch_date{$head} = $1;
 	}
 	close(H);
+        if (!exists $branch_date{$opt_o}) {
+		die "Branch '$opt_o' does not exist.\n".
+		       "Either use the correct '-o branch' option,\n".
+		       "or import to a new repository.\n";
+        }
 }
 
 -d $git_dir
-- 
1.5.2.2527.ga2df

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Use git-for-each-ref to check whether the origin branch exists.
  2007-05-23 11:13 ` [PATCH] Use git-for-each-ref to check whether the origin branch exists Johannes Schindelin
@ 2007-05-23 11:59   ` Stephan Springl
  2007-05-23 18:06   ` Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: Stephan Springl @ 2007-05-23 11:59 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

On Wed, 23 May 2007, Johannes Schindelin wrote:

> From: Stephan Springl <springl-git@bfw-online.de>
> This works in repositories that have their refs packed by
> "git-pack-refs --all --prune" whereas testing the file
> $git_dir/refs/heads/$opt_o does not.
>
> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
>  Unfortunately your patch is white-space corrupted (it has an extra
>  space on all lines starting with a space, it seems). Therefore I
>  redid it with this email.
Sorry for that especially as we are very very strict with whitespace and 
coding conventions in our own development ... arrg. Thanks anyway.

Stephan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Use git-for-each-ref to check whether the origin branch exists.
  2007-05-23 11:13 ` [PATCH] Use git-for-each-ref to check whether the origin branch exists Johannes Schindelin
  2007-05-23 11:59   ` Stephan Springl
@ 2007-05-23 18:06   ` Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2007-05-23 18:06 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Stephan Springl, git

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

> 	Default for ref-packed repositories is to pack only the tags, 
> 	therefore you usually do not need this patch. However, it looks 
> 	obviously correct to me. A cursory test also showed that it does 
> 	not break anything.
>
> 	> Maybe you want to use this or a similar solution to be 
> 	> integrated in stock git.
> 	
> 	Unfortunately your patch is white-space corrupted (it has an extra 
> 	space on all lines starting with a space, it seems). Therefore I 
> 	redid it with this email.
>
> 	It would be nice to follow Documentation/SubmittingPatches next 
> 	time. For example, I guess that you want to sign off on it...

Thanks both.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-05-23 18:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-23  7:13 [PATCH] make git-cvsimport work on ref-packed repositories Stephan Springl
2007-05-23 11:13 ` [PATCH] Use git-for-each-ref to check whether the origin branch exists Johannes Schindelin
2007-05-23 11:59   ` Stephan Springl
2007-05-23 18:06   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).