# [MinGW port] Unable to repack on Clearcase dynamic views

14 messages from 2007-05-30 to 2007-06-01. Participants: Nguyen Thai Ngoc Duy, Paolo Teti, Johannes Sixt, Robin Rosenberg, Johannes Schindelin, Jan Hudec.
Thread: https://gitlist.dev/t/8364

## Nguyen Thai Ngoc Duy, 2007-05-30 14:42

Subject: [MinGW port] Unable to repack on Clearcase dynamic views
Message-ID: <fcaeb9bf0705300742u22b54c78vccbc037fb553141f@mail.gmail.com>
URL: https://gitlist.dev/e/fcaeb9bf0705300742u22b54c78vccbc037fb553141f%40mail.gmail.com

```
Hi,

On clearcase dynamic views (kind of virtual drives), "mv -f a b" won't
work if "a" is read-only. Because git-repack.sh removes all write
permission before moving packs, it fails on clearcase dynamic views.

My approach is rather ugly. Does anyone have a better solution?

diff --git a/git-repack.sh b/git-repack.sh
index acb78ba..76a9525 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -86,10 +86,22 @@ else
 	mv -f "$PACKTMP-$name.idx"  "$PACKDIR/pack-$name.idx" &&
 	test -f "$PACKDIR/pack-$name.pack" &&
 	test -f "$PACKDIR/pack-$name.idx" || {
-		echo >&2 "Couldn't replace the existing pack with updated one."
-		echo >&2 "The original set of packs have been saved as"
-		echo >&2 "old-pack-$name.{pack,idx} in $PACKDIR."
-		exit 1
+		# Clearcase dynamic views do not allow to move file without write permission
+		# Try the second time with write allowed
+		chmod u+w "$PACKTMP-$name.pack"
+		chmod u+w "$PACKTMP-$name.idx"
+
+		mv -f "$PACKTMP-$name.pack" "$PACKDIR/pack-$name.pack" &&
+		mv -f "$PACKTMP-$name.idx"  "$PACKDIR/pack-$name.idx" &&
+		test -f "$PACKDIR/pack-$name.pack" &&
+		test -f "$PACKDIR/pack-$name.idx" || {
+			echo >&2 "Couldn't replace the existing pack with updated one."
+			echo >&2 "The original set of packs have been saved as"
+			echo >&2 "old-pack-$name.{pack,idx} in $PACKDIR."
+			exit 1
+		}
+		chmod a-w "$PACKDIR/pack-$name.pack"
+		chmod a-w "$PACKDIR/pack-$name.idx"
 	}
 	rm -f "$PACKDIR/old-pack-$name.pack" "$PACKDIR/old-pack-$name.idx"
 fi


-- 
Duy

```

## Paolo Teti, 2007-05-30 15:11

Subject: Re: [MinGW port] Unable to repack on Clearcase dynamic views
Message-ID: <34a7ae040705300811o22a7d9e9y1ca6e52c4bf23fcc@mail.gmail.com>
URL: https://gitlist.dev/e/34a7ae040705300811o22a7d9e9y1ca6e52c4bf23fcc%40mail.gmail.com
In-Reply-To: <fcaeb9bf0705300742u22b54c78vccbc037fb553141f@mail.gmail.com>

```
2007/5/30, Nguyen Thai Ngoc Duy <pclouds@gmail.com>:
> Hi,
>
> On clearcase dynamic views (kind of virtual drives), "mv -f a b" won't
> work if "a" is read-only. Because git-repack.sh removes all write
> permission before moving packs, it fails on clearcase dynamic views.
>
> My approach is rather ugly. Does anyone have a better solution?

I hate clearcase, but honestly I have used it forced by a customer..
The real problem is why you need to do a repack in a CC view, but..

to move a file in a Clearcase view you have to use 'cleartool mv ...'
(or 'cleartool relocate') and not the UNIX mv command...

..and he directory where the element to be moved or renamed resides
must be checked out.

```

## Johannes Sixt, 2007-05-30 15:28

Subject: Re: [MinGW port] Unable to repack on Clearcase dynamic views
Message-ID: <465D982C.B46DD718@eudaptics.com>
URL: https://gitlist.dev/e/465D982C.B46DD718%40eudaptics.com
In-Reply-To: <fcaeb9bf0705300742u22b54c78vccbc037fb553141f@mail.gmail.com>

```
Nguyen Thai Ngoc Duy wrote:
> On clearcase dynamic views (kind of virtual drives), "mv -f a b" won't
> work if "a" is read-only. Because git-repack.sh removes all write
> permission before moving packs, it fails on clearcase dynamic views.
> 
> My approach is rather ugly. Does anyone have a better solution?

If you do two 'git repack -a -d' in a row, the second one fails even
with this patch, right? To fix it, you must 'chmod u+w' in the for-loop
right above this hunk, too.

Since you 'chmod a-w' after the mv, why not just remove the first ones
before the first mv? Then you can get rid of the second try.

-- Hannes

> 
> diff --git a/git-repack.sh b/git-repack.sh
> index acb78ba..76a9525 100755
> --- a/git-repack.sh
> +++ b/git-repack.sh
> @@ -86,10 +86,22 @@ else
>         mv -f "$PACKTMP-$name.idx"  "$PACKDIR/pack-$name.idx" &&
>         test -f "$PACKDIR/pack-$name.pack" &&
>         test -f "$PACKDIR/pack-$name.idx" || {
> -               echo >&2 "Couldn't replace the existing pack with updated one."
> -               echo >&2 "The original set of packs have been saved as"
> -               echo >&2 "old-pack-$name.{pack,idx} in $PACKDIR."
> -               exit 1
> +               # Clearcase dynamic views do not allow to move file without write permission
> +               # Try the second time with write allowed
> +               chmod u+w "$PACKTMP-$name.pack"
> +               chmod u+w "$PACKTMP-$name.idx"
> +
> +               mv -f "$PACKTMP-$name.pack" "$PACKDIR/pack-$name.pack" &&
> +               mv -f "$PACKTMP-$name.idx"  "$PACKDIR/pack-$name.idx" &&
> +               test -f "$PACKDIR/pack-$name.pack" &&
> +               test -f "$PACKDIR/pack-$name.idx" || {
> +                       echo >&2 "Couldn't replace the existing pack with updated one."
> +                       echo >&2 "The original set of packs have been saved as"
> +                       echo >&2 "old-pack-$name.{pack,idx} in $PACKDIR."
> +                       exit 1
> +               }
> +               chmod a-w "$PACKDIR/pack-$name.pack"
> +               chmod a-w "$PACKDIR/pack-$name.idx"
>         }
>         rm -f "$PACKDIR/old-pack-$name.pack" "$PACKDIR/old-pack-$name.idx"
>  fi
> 
> --
> Duy

```

## Nguyen Thai Ngoc Duy, 2007-05-30 15:33

Subject: Re: [MinGW port] Unable to repack on Clearcase dynamic views
Message-ID: <fcaeb9bf0705300833t6f0639ddx2f507996e48d838c@mail.gmail.com>
URL: https://gitlist.dev/e/fcaeb9bf0705300833t6f0639ddx2f507996e48d838c%40mail.gmail.com
In-Reply-To: <34a7ae040705300811o22a7d9e9y1ca6e52c4bf23fcc@mail.gmail.com>

```
On 5/30/07, Paolo Teti <paolo.teti@gmail.com> wrote:
> 2007/5/30, Nguyen Thai Ngoc Duy <pclouds@gmail.com>:
> > Hi,
> >
> > On clearcase dynamic views (kind of virtual drives), "mv -f a b" won't
> > work if "a" is read-only. Because git-repack.sh removes all write
> > permission before moving packs, it fails on clearcase dynamic views.
> >
> > My approach is rather ugly. Does anyone have a better solution?
>
> I hate clearcase, but honestly I have used it forced by a customer..
> The real problem is why you need to do a repack in a CC view, but..

I don't like it either :) But you remind me the Matthias' workdir
patchset. With that I can move out .git to a real drive/filesystem
(which should also give better performance).

I think it's a valid use case. Anyone remember why Matthias' patchset
was dropped?
It was last mentioned in
http://article.gmane.org/gmane.comp.version-control.git/43041

Junio, Matthias? May I help?

>
> to move a file in a Clearcase view you have to use 'cleartool mv ...'
> (or 'cleartool relocate') and not the UNIX mv command...

'cleartool mv' is used for clearcase-manages files. My git repository
are private files.

>
> ..and he directory where the element to be moved or renamed resides
> must be checked out.
>


-- 
Duy

```

## Nguyen Thai Ngoc Duy, 2007-05-30 15:43

Subject: Fwd: [MinGW port] Unable to repack on Clearcase dynamic views
Message-ID: <fcaeb9bf0705300843v10782be3i985d10144535868c@mail.gmail.com>
URL: https://gitlist.dev/e/fcaeb9bf0705300843v10782be3i985d10144535868c%40mail.gmail.com
In-Reply-To: <fcaeb9bf0705300840w221c46c1y742388fc9e61c2fa@mail.gmail.com>

```
I'm sorry, forgot to CC the list.

---------- Forwarded message ----------
From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date: May 30, 2007 11:40 AM
Subject: Re: [MinGW port] Unable to repack on Clearcase dynamic views
To: Johannes Sixt <J.Sixt@eudaptics.com>


On 5/30/07, Johannes Sixt <J.Sixt@eudaptics.com> wrote:
> Nguyen Thai Ngoc Duy wrote:
> > On clearcase dynamic views (kind of virtual drives), "mv -f a b" won't
> > work if "a" is read-only. Because git-repack.sh removes all write
> > permission before moving packs, it fails on clearcase dynamic views.
> >
> > My approach is rather ugly. Does anyone have a better solution?
>
> If you do two 'git repack -a -d' in a row, the second one fails even
> with this patch, right? To fix it, you must 'chmod u+w' in the for-loop
> right above this hunk, too.

Well, I'm not sure I understand it. git-repack with the patch applied
runs fine for me. Can you explain it more detail please?

>
> Since you 'chmod a-w' after the mv, why not just remove the first ones
> before the first mv? Then you can get rid of the second try.

Because I'm not sure what that command is for :) I suspect that packs
(or anything inside .git/objects) are read-only and the author want to
make sure no one can write to the packs as soon as they are created.
The other way to do is to move 'chmod a-w' down several lines -- we
only make those files read-only after moving them to
.git/objects/packs.

>
> -- Hannes
>
> >
> > diff --git a/git-repack.sh b/git-repack.sh
> > index acb78ba..76a9525 100755
> > --- a/git-repack.sh
> > +++ b/git-repack.sh
> > @@ -86,10 +86,22 @@ else
> >         mv -f "$PACKTMP-$name.idx"  "$PACKDIR/pack-$name.idx" &&
> >         test -f "$PACKDIR/pack-$name.pack" &&
> >         test -f "$PACKDIR/pack-$name.idx" || {
> > -               echo >&2 "Couldn't replace the existing pack with updated one."
> > -               echo >&2 "The original set of packs have been saved as"
> > -               echo >&2 "old-pack-$name.{pack,idx} in $PACKDIR."
> > -               exit 1
> > +               # Clearcase dynamic views do not allow to move file without write permission
> > +               # Try the second time with write allowed
> > +               chmod u+w "$PACKTMP-$name.pack"
> > +               chmod u+w "$PACKTMP-$name.idx"
> > +
> > +               mv -f "$PACKTMP-$name.pack" "$PACKDIR/pack-$name.pack" &&
> > +               mv -f "$PACKTMP-$name.idx"  "$PACKDIR/pack-$name.idx" &&
> > +               test -f "$PACKDIR/pack-$name.pack" &&
> > +               test -f "$PACKDIR/pack-$name.idx" || {
> > +                       echo >&2 "Couldn't replace the existing pack with updated one."
> > +                       echo >&2 "The original set of packs have been saved as"
> > +                       echo >&2 "old-pack-$name.{pack,idx} in $PACKDIR."
> > +                       exit 1
> > +               }
> > +               chmod a-w "$PACKDIR/pack-$name.pack"
> > +               chmod a-w "$PACKDIR/pack-$name.idx"
> >         }
> >         rm -f "$PACKDIR/old-pack-$name.pack" "$PACKDIR/old-pack-$name.idx"
> >  fi
> >
> > --
> > Duy
>
>


--
Duy


-- 
Duy

```

## Paolo Teti, 2007-05-30 16:30

Subject: Re: [MinGW port] Unable to repack on Clearcase dynamic views
Message-ID: <34a7ae040705300930l6b43aeb9qcb2a68858848d3d@mail.gmail.com>
URL: https://gitlist.dev/e/34a7ae040705300930l6b43aeb9qcb2a68858848d3d%40mail.gmail.com
In-Reply-To: <fcaeb9bf0705300833t6f0639ddx2f507996e48d838c@mail.gmail.com>

```
2007/5/30, Nguyen Thai Ngoc Duy <pclouds@gmail.com>:
> On 5/30/07, Paolo Teti <paolo.teti@gmail.com> wrote:

> > to move a file in a Clearcase view you have to use 'cleartool mv ...'
> > (or 'cleartool relocate') and not the UNIX mv command...
>
> 'cleartool mv' is used for clearcase-manages files. My git repository
> are private files.

ok, but also cleartool mv works for private file..

Take a look at:

http://www-1.ibm.com/support/docview.wss?rs=984&context=SSSH27&context=SSCGQ7D&q1=mv+read-only+files&uid=swg1IC46584&loc=en_US&cs=utf-8&lang=en

should be a clearcase bug.

```

## Robin Rosenberg, 2007-05-30 18:28

Subject: Re: [MinGW port] Unable to repack on Clearcase dynamic views
Message-ID: <200705302028.15549.robin.rosenberg.lists@dewire.com>
URL: https://gitlist.dev/e/200705302028.15549.robin.rosenberg.lists%40dewire.com
In-Reply-To: <fcaeb9bf0705300833t6f0639ddx2f507996e48d838c@mail.gmail.com>

```
onsdag 30 maj 2007 skrev Nguyen Thai Ngoc Duy:
> On 5/30/07, Paolo Teti <paolo.teti@gmail.com> wrote:
> > 2007/5/30, Nguyen Thai Ngoc Duy <pclouds@gmail.com>:
> > > Hi,
> > >
> > > On clearcase dynamic views (kind of virtual drives), "mv -f a b" won't
> > > work if "a" is read-only. Because git-repack.sh removes all write
> > > permission before moving packs, it fails on clearcase dynamic views.
> > >
> > > My approach is rather ugly. Does anyone have a better solution?
> >
> > I hate clearcase, but honestly I have used it forced by a customer..
> > The real problem is why you need to do a repack in a CC view, but..
> 
> I don't like it either :) But you remind me the Matthias' workdir
> patchset. With that I can move out .git to a real drive/filesystem
> (which should also give better performance).
> 
> I think it's a valid use case. Anyone remember why Matthias' patchset
> was dropped?
> It was last mentioned in
> http://article.gmane.org/gmane.comp.version-control.git/43041
> 
> Junio, Matthias? May I help?

Wasn't because it's better to make .git a link to a repository somewhere 
else? Just a guess.

ln -s /somewhere/repo/.git .git

Works fine for me (yes, in a clearcase dynamic view).

BTW, Does anyone have something like git-cvsexportcommit for clearcase?

-- robin

```

## Johannes Schindelin, 2007-05-30 18:44

Subject: Re: [MinGW port] Unable to repack on Clearcase dynamic views
Message-ID: <Pine.LNX.4.64.0705301944220.4046@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0705301944220.4046%40racer.site
In-Reply-To: <200705302028.15549.robin.rosenberg.lists@dewire.com>

```
Hi,

On Wed, 30 May 2007, Robin Rosenberg wrote:

> Wasn't because it's better to make .git a link to a repository somewhere 
> else? Just a guess.
> 
> ln -s /somewhere/repo/.git .git
> 
> Works fine for me (yes, in a clearcase dynamic view).

MinGW does not know symbolic links (at least not on the common 
filesystems).

Ciao,
Dscho

```

## Nguyen Thai Ngoc Duy, 2007-05-30 19:08

Subject: Re: [MinGW port] Unable to repack on Clearcase dynamic views
Message-ID: <fcaeb9bf0705301208p6ce00315uc3cde4d43903ec0c@mail.gmail.com>
URL: https://gitlist.dev/e/fcaeb9bf0705301208p6ce00315uc3cde4d43903ec0c%40mail.gmail.com
In-Reply-To: <200705302028.15549.robin.rosenberg.lists@dewire.com>

```
On 5/30/07, Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote:
> onsdag 30 maj 2007 skrev Nguyen Thai Ngoc Duy:
> > On 5/30/07, Paolo Teti <paolo.teti@gmail.com> wrote:
> > > 2007/5/30, Nguyen Thai Ngoc Duy <pclouds@gmail.com>:
> > > > Hi,
> > > >
> > > > On clearcase dynamic views (kind of virtual drives), "mv -f a b" won't
> > > > work if "a" is read-only. Because git-repack.sh removes all write
> > > > permission before moving packs, it fails on clearcase dynamic views.
> > > >
> > > > My approach is rather ugly. Does anyone have a better solution?
> > >
> > > I hate clearcase, but honestly I have used it forced by a customer..
> > > The real problem is why you need to do a repack in a CC view, but..
> >
> > I don't like it either :) But you remind me the Matthias' workdir
> > patchset. With that I can move out .git to a real drive/filesystem
> > (which should also give better performance).
> >
> > I think it's a valid use case. Anyone remember why Matthias' patchset
> > was dropped?
> > It was last mentioned in
> > http://article.gmane.org/gmane.comp.version-control.git/43041
> >
> > Junio, Matthias? May I help?
>
> Wasn't because it's better to make .git a link to a repository somewhere
> else? Just a guess.
>
> ln -s /somewhere/repo/.git .git
>
> Works fine for me (yes, in a clearcase dynamic view).

Clearcase symlinks require checkout/checkin stuffs that I really don't
want to mess up with. Moreover, it seems not work if the link
destination is out of clearcase view (which is what I wanted).
-- 
Duy

```

## Robin Rosenberg, 2007-05-30 19:28

Subject: Re: [MinGW port] Unable to repack on Clearcase dynamic views
Message-ID: <200705302128.34111.robin.rosenberg.lists@dewire.com>
URL: https://gitlist.dev/e/200705302128.34111.robin.rosenberg.lists%40dewire.com
In-Reply-To: <fcaeb9bf0705301208p6ce00315uc3cde4d43903ec0c@mail.gmail.com>

```
onsdag 30 maj 2007 skrev Nguyen Thai Ngoc Duy:
> Clearcase symlinks require checkout/checkin stuffs that I really don't
> want to mess up with. Moreover, it seems not work if the link
> destination is out of clearcase view (which is what I wanted).

Well obviously.. :/

I guess junction points in dynamic views are out of the question too. Would
setting GIT_DIR be too cumbersome?

-- robin

```

## Nguyen Thai Ngoc Duy, 2007-05-30 19:48

Subject: Re: [MinGW port] Unable to repack on Clearcase dynamic views
Message-ID: <fcaeb9bf0705301248o4609d532p60ba24805fa0e5ad@mail.gmail.com>
URL: https://gitlist.dev/e/fcaeb9bf0705301248o4609d532p60ba24805fa0e5ad%40mail.gmail.com
In-Reply-To: <200705302128.34111.robin.rosenberg.lists@dewire.com>

```
On 5/30/07, Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote:
> onsdag 30 maj 2007 skrev Nguyen Thai Ngoc Duy:
> > Clearcase symlinks require checkout/checkin stuffs that I really don't
> > want to mess up with. Moreover, it seems not work if the link
> > destination is out of clearcase view (which is what I wanted).
>
> Well obviously.. :/
>
> I guess junction points in dynamic views are out of the question too. Would
> setting GIT_DIR be too cumbersome?

Well, I've got the same errors as before in this thread :)
http://thread.gmane.org/gmane.comp.version-control.git/41586
-- 
Duy

```

## Paolo Teti, 2007-05-31 09:46

Subject: Re: [MinGW port] Unable to repack on Clearcase dynamic views
Message-ID: <34a7ae040705310246w72c30c19ic063895a46b8f3fb@mail.gmail.com>
URL: https://gitlist.dev/e/34a7ae040705310246w72c30c19ic063895a46b8f3fb%40mail.gmail.com
In-Reply-To: <200705302028.15549.robin.rosenberg.lists@dewire.com>

```
2007/5/30, Robin Rosenberg <robin.rosenberg.lists@dewire.com>:

> BTW, Does anyone have something like git-cvsexportcommit for clearcase?

a stupid workaround is git-cvsexportcommit + clearimport /clearexport_cvs.

```

## Robin Rosenberg, 2007-05-31 18:51

Subject: Re: [MinGW port] Unable to repack on Clearcase dynamic views
Message-ID: <200705312051.46429.robin.rosenberg.lists@dewire.com>
URL: https://gitlist.dev/e/200705312051.46429.robin.rosenberg.lists%40dewire.com
In-Reply-To: <34a7ae040705310246w72c30c19ic063895a46b8f3fb@mail.gmail.com>

```
torsdag 31 maj 2007 skrev Paolo Teti:
> 2007/5/30, Robin Rosenberg <robin.rosenberg.lists@dewire.com>:
> 
> > BTW, Does anyone have something like git-cvsexportcommit for clearcase?
> 
> a stupid workaround is git-cvsexportcommit + clearimport /clearexport_cvs.
> -
That would require a clearcase to cvs converter, wouldn't it, so I'd have something to commit to..
Even more stupid than my attempt at a clearcase to git converter.

-- robin

```

## Jan Hudec, 2007-06-01 18:11

Subject: Re: [MinGW port] Unable to repack on Clearcase dynamic views
Message-ID: <20070601181137.GA3002@efreet.light.src>
URL: https://gitlist.dev/e/20070601181137.GA3002%40efreet.light.src
In-Reply-To: <200705302028.15549.robin.rosenberg.lists@dewire.com>

```
On Wed, May 30, 2007 at 20:28:15 +0200, Robin Rosenberg wrote:
> Wasn't because it's better to make .git a link to a repository somewhere 
> else? Just a guess.
> 
> ln -s /somewhere/repo/.git .git
> 
> Works fine for me (yes, in a clearcase dynamic view).

It works for me too. It requires cygwin version of git though, since windows
don't have native symlinks.

> BTW, Does anyone have something like git-cvsexportcommit for clearcase?

No, but it should not be too hard to create.

If you want to quickly import something, you can try starting with something
like:

diff clearcase-view git-checkout > p
lsdiff p | xargs -d '\n' cleartool checkout
patch -p $n < p

You'll have to sort out which directories to run which command in and how
many components to strip with -p in the patch. It also does not handle adding
and removing.

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

```
