* [PATCH] git-cvsimport: fix initial checkout
@ 2008-03-13 19:09 Marc-Andre Lureau
2008-03-13 21:05 ` Junio C Hamano
2008-03-13 22:18 ` Martin Langhoff
0 siblings, 2 replies; 9+ messages in thread
From: Marc-Andre Lureau @ 2008-03-13 19:09 UTC (permalink / raw)
To: git; +Cc: Martin Langhoff, Marc-Andre Lureau
git-symbolic-ref HEAD returns master reference, even if the file does
not exists. That prevents the initial checkout and fails in
git-rev-parse. The patch checks the existence of the reference file
before assuming an original branch exists. There might be better
solutions than checking file existence.
---
git-cvsimport.perl | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 95c5eec..1512fe4 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -570,12 +570,16 @@ unless (-d $git_dir) {
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);
- unless ($last_branch) {
+ if (-f "$git_dir/$last_branch") {
+ $last_branch = basename($last_branch);
+ unless ($last_branch) {
warn "Cannot read the last branch name: $! -- assuming 'master'\n";
$last_branch = "master";
+ }
+ } else {
+ $last_branch = "";
}
+ close(F);
$orig_branch = $last_branch;
$tip_at_start = `git-rev-parse --verify HEAD`;
@@ -953,6 +957,7 @@ while (<CVS>) {
print "* UNKNOWN LINE * $_\n";
}
}
+
commit() if $branch and $state != 11;
unless ($opt_P) {
--
1.5.4.4.534.gfb90c.dirty
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] git-cvsimport: fix initial checkout
2008-03-13 19:09 [PATCH] git-cvsimport: fix initial checkout Marc-Andre Lureau
@ 2008-03-13 21:05 ` Junio C Hamano
2008-03-13 22:18 ` Martin Langhoff
1 sibling, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2008-03-13 21:05 UTC (permalink / raw)
To: Marc-Andre Lureau; +Cc: git, Martin Langhoff
Marc-Andre Lureau <marcandre.lureau@gmail.com> writes:
> git-symbolic-ref HEAD returns master reference, even if the file does
> not exists. That prevents the initial checkout and fails in
> git-rev-parse.
I had an impression that this check was deliberately done, but I do not
recall the details. Martin?
> diff --git a/git-cvsimport.perl b/git-cvsimport.perl
> index 95c5eec..1512fe4 100755
> --- a/git-cvsimport.perl
> +++ b/git-cvsimport.perl
> @@ -570,12 +570,16 @@ unless (-d $git_dir) {
> 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);
> - unless ($last_branch) {
> + if (-f "$git_dir/$last_branch") {
> + $last_branch = basename($last_branch);
> + unless ($last_branch) {
> warn "Cannot read the last branch name: $! -- assuming 'master'\n";
> $last_branch = "master";
> + }
In any case, what if last_branch is a branch with hierarchical name, I
have to wonder. If you are on a branch whose name has a slash
in it, like "frotz/nitfol" when you start cvsimport, doesn't this (before
or after the patch) code break your repository?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] git-cvsimport: fix initial checkout
2008-03-13 19:09 [PATCH] git-cvsimport: fix initial checkout Marc-Andre Lureau
2008-03-13 21:05 ` Junio C Hamano
@ 2008-03-13 22:18 ` Martin Langhoff
2008-03-13 23:04 ` Marc-André Lureau
` (2 more replies)
1 sibling, 3 replies; 9+ messages in thread
From: Martin Langhoff @ 2008-03-13 22:18 UTC (permalink / raw)
To: Marc-Andre Lureau; +Cc: git
Marc-Andre Lureau wrote:
> git-symbolic-ref HEAD returns master reference, even if the file does
> not exists. That prevents the initial checkout and fails in
> git-rev-parse.
But you are patching the block that gets triggered on subsequent
imports, this code does not deal with "initial checkout" unless
something else is wrong. The line right above the open() is an else that
has the block that matters.
> The patch checks the existence of the reference file
> before assuming an original branch exists. There might be better
> solutions than checking file existence.
There are indeed. If we need this patch -- then you can call git
ref-parse right to see if you get a sha1.
> - unless ($last_branch) {
> + if (-f "$git_dir/$last_branch") {
Note that the file won't exist there in any modern git. It will be in
$git_dir/refs/heads/$last_branch. Did you test this patch?
What's your workflow with cvsimport? Perhaps you are doing something
strange with it... :-)
cheers,
martin
--
-----------------------------------------------------------------------
Martin @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St
NZ: +64(4)916-7224 MOB: +64(21)364-017 UK: 0845 868 5733 ext 7224
Make things as simple as possible, but no simpler - Einstein
-----------------------------------------------------------------------
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] git-cvsimport: fix initial checkout
2008-03-13 22:18 ` Martin Langhoff
@ 2008-03-13 23:04 ` Marc-André Lureau
2008-03-13 23:07 ` Marc-André Lureau
2008-03-13 23:29 ` Martin Langhoff
2008-03-13 23:15 ` Junio C Hamano
2008-03-13 23:22 ` Marc-André Lureau
2 siblings, 2 replies; 9+ messages in thread
From: Marc-André Lureau @ 2008-03-13 23:04 UTC (permalink / raw)
To: Martin Langhoff; +Cc: git
Hi
On Fri, Mar 14, 2008 at 12:18 AM, Martin Langhoff
<martin@catalyst.net.nz> wrote:
> Marc-Andre Lureau wrote:
> > git-symbolic-ref HEAD returns master reference, even if the file does
> > not exists. That prevents the initial checkout and fails in
> > git-rev-parse.
>
> But you are patching the block that gets triggered on subsequent
> imports, this code does not deal with "initial checkout" unless
> something else is wrong. The line right above the open() is an else that
> has the block that matters.
>
Yeah, it failed in the middle of a ~4h import, I did not restart it.
git-cvsimport -r cvs -p b,HEAD -k -m -a -v -d
:pserver:anoncvs@anoncvs.freedesktop.org:/cvs/gstreamer -C
gst-plugins-good gst-plugins-good
This is a quite problematic CVS, btw. (missing patches/files in the
end, branch merge fail ... see my previous patch)
> > The patch checks the existence of the reference file
> > before assuming an original branch exists. There might be better
> > solutions than checking file existence.
>
> There are indeed. If we need this patch -- then you can call git
> ref-parse right to see if you get a sha1.
Ok, which one is prefered? ref-parse I guess? I am mostly ignorant of
all the plumbing stuff.
> > - unless ($last_branch) {
> > + if (-f "$git_dir/$last_branch") {
>
> Note that the file won't exist there in any modern git. It will be in
> $git_dir/refs/heads/$last_branch. Did you test this patch?
>
Crap. The patch indeed worked, because the file did not exist. The
second time it also worked:
skip patchset 5825: 1205277122 before 1205418644
skip patchset 5826: 1205418644 before 1205418644
DONE.
Already up-to-date.
*** Building gst-plugins-good *** [1/145]
make -j2
Result is here: http://git.infradead.org/users/elmarco/gst-plugins-good.git
Thanks for the review!!
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] git-cvsimport: fix initial checkout
2008-03-13 23:04 ` Marc-André Lureau
@ 2008-03-13 23:07 ` Marc-André Lureau
2008-03-13 23:29 ` Martin Langhoff
1 sibling, 0 replies; 9+ messages in thread
From: Marc-André Lureau @ 2008-03-13 23:07 UTC (permalink / raw)
To: Martin Langhoff; +Cc: git
Hi again,
Btw, the missing checkout file is,
sys / osxvideo / Makefile.am
I have a clue why (strange version number), but no idea how to fix it.
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] git-cvsimport: fix initial checkout
2008-03-13 22:18 ` Martin Langhoff
2008-03-13 23:04 ` Marc-André Lureau
@ 2008-03-13 23:15 ` Junio C Hamano
2008-03-13 23:27 ` Martin Langhoff
2008-03-13 23:22 ` Marc-André Lureau
2 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2008-03-13 23:15 UTC (permalink / raw)
To: Martin Langhoff; +Cc: Marc-Andre Lureau, git
Martin Langhoff <martin@catalyst.net.nz> writes:
> Marc-Andre Lureau wrote:
>> git-symbolic-ref HEAD returns master reference, even if the file does
>> not exists. That prevents the initial checkout and fails in
>> git-rev-parse.
>
> But you are patching the block that gets triggered on subsequent
> imports, this code does not deal with "initial checkout" unless
> something else is wrong. The line right above the open() is an else that
> has the block that matters.
>
>> The patch checks the existence of the reference file
>> before assuming an original branch exists. There might be better
>> solutions than checking file existence.
>
> There are indeed. If we need this patch -- then you can call git
> ref-parse right to see if you get a sha1.
>
>> - unless ($last_branch) {
>> + if (-f "$git_dir/$last_branch") {
>
> Note that the file won't exist there in any modern git. It will be in
> $git_dir/refs/heads/$last_branch. Did you test this patch?
Martin, it may not even be in $git_dir/refs/heads/$last_branch ;-) The
refs can be packed.
By the way, doesn't cvsimport fail when your HEAD is detached with this
code?
I always have cvsimport update the pristine upstream branch and rebase my
work against it, so I never have the branch cvsimport updates checked
out, and for meit seems to work wonderfully (well, at least as wonderful
as a workflow that involves any CVS in it could be). I do not see a
reason why it should not to work similarly well when my HEAD is detached..
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] git-cvsimport: fix initial checkout
2008-03-13 22:18 ` Martin Langhoff
2008-03-13 23:04 ` Marc-André Lureau
2008-03-13 23:15 ` Junio C Hamano
@ 2008-03-13 23:22 ` Marc-André Lureau
2 siblings, 0 replies; 9+ messages in thread
From: Marc-André Lureau @ 2008-03-13 23:22 UTC (permalink / raw)
To: Martin Langhoff; +Cc: git
Hi
On Fri, Mar 14, 2008 at 12:18 AM, Martin Langhoff
<martin@catalyst.net.nz> wrote:
> > - unless ($last_branch) {
> > + if (-f "$git_dir/$last_branch") {
>
> Note that the file won't exist there in any modern git. It will be in
> $git_dir/refs/heads/$last_branch. Did you test this patch?
>
git-symbolic-ref HEAD do return "refs/heads/master" on my initial
in-the-middle checkout (I still have a copy),
So it seems correct for now, but i'll change it to use rev-parse
instead as it seems more correct.
Regards
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] git-cvsimport: fix initial checkout
2008-03-13 23:15 ` Junio C Hamano
@ 2008-03-13 23:27 ` Martin Langhoff
0 siblings, 0 replies; 9+ messages in thread
From: Martin Langhoff @ 2008-03-13 23:27 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Marc-Andre Lureau, git
Junio C Hamano wrote:
> Martin, it may not even be in $git_dir/refs/heads/$last_branch ;-) The
> refs can be packed.
Yes. I was suggesting git-ref-parse to support packed refs, but this
slipped ;-)
> By the way, doesn't cvsimport fail when your HEAD is detached with this
> code?
Perhaps. Importing on a working repo with -i is a bit messy, and
detached heads may well break it. I'm not that conversant on how
detached heads look ;-)
> I always have cvsimport update the pristine upstream branch and rebase my
> work against it, so I never have the branch cvsimport updates checked
> out, and for meit seems to work wonderfully (well, at least as wonderful
> as a workflow that involves any CVS in it could be). I do not see a
> reason why it should not to work similarly well when my HEAD is detached..
sounds reasonable.
m
--
-----------------------------------------------------------------------
Martin @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St
NZ: +64(4)916-7224 MOB: +64(21)364-017 UK: 0845 868 5733 ext 7224
Make things as simple as possible, but no simpler - Einstein
-----------------------------------------------------------------------
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] git-cvsimport: fix initial checkout
2008-03-13 23:04 ` Marc-André Lureau
2008-03-13 23:07 ` Marc-André Lureau
@ 2008-03-13 23:29 ` Martin Langhoff
1 sibling, 0 replies; 9+ messages in thread
From: Martin Langhoff @ 2008-03-13 23:29 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: git
Marc-André Lureau wrote:
> Yeah, it failed in the middle of a ~4h import, I did not restart it.
there are no guarantees then of correctness (there seldom are, but a
failed import can leave your repo in a number of odd states...).
I'd suggest parsecvs for the initial import of a messy repo. You can
continue to do incrementas with cvsimport after the initial import.
cheers,
m
--
-----------------------------------------------------------------------
Martin @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St
NZ: +64(4)916-7224 MOB: +64(21)364-017 UK: 0845 868 5733 ext 7224
Make things as simple as possible, but no simpler - Einstein
-----------------------------------------------------------------------
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-03-13 23:30 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-13 19:09 [PATCH] git-cvsimport: fix initial checkout Marc-Andre Lureau
2008-03-13 21:05 ` Junio C Hamano
2008-03-13 22:18 ` Martin Langhoff
2008-03-13 23:04 ` Marc-André Lureau
2008-03-13 23:07 ` Marc-André Lureau
2008-03-13 23:29 ` Martin Langhoff
2008-03-13 23:15 ` Junio C Hamano
2008-03-13 23:27 ` Martin Langhoff
2008-03-13 23:22 ` Marc-André Lureau
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).