[MinGW port] Unable to repack on Clearcase dynamic views

Subsystems: the rest

13 messages, 6 authors, 2016-06-15 · open the first message on its own page

[MinGW port] Unable to repack on Clearcase dynamic views

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:43:13

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

Re: [MinGW port] Unable to repack on Clearcase dynamic views

From: Paolo Teti <hidden>
Date: 2016-06-15 22:43:13

2007/5/30, Nguyen Thai Ngoc Duy [off-list ref]:
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.

Re: [MinGW port] Unable to repack on Clearcase dynamic views

From: Johannes Sixt <hidden>
Date: 2016-06-15 22:43:13

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
quoted hunk
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

Re: [MinGW port] Unable to repack on Clearcase dynamic views

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:43:13

On 5/30/07, Paolo Teti [off-list ref] wrote:
2007/5/30, Nguyen Thai Ngoc Duy [off-list ref]:
quoted
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

Re: [MinGW port] Unable to repack on Clearcase dynamic views

From: Paolo Teti <hidden>
Date: 2016-06-15 22:43:13

2007/5/30, Nguyen Thai Ngoc Duy [off-list ref]:
On 5/30/07, Paolo Teti [off-list ref] wrote:
quoted
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.

Re: [MinGW port] Unable to repack on Clearcase dynamic views

From: Robin Rosenberg <hidden>
Date: 2016-06-15 22:43:13

onsdag 30 maj 2007 skrev Nguyen Thai Ngoc Duy:
On 5/30/07, Paolo Teti [off-list ref] wrote:
quoted
2007/5/30, Nguyen Thai Ngoc Duy [off-list ref]:
quoted
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

Re: [MinGW port] Unable to repack on Clearcase dynamic views

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:13

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

Re: [MinGW port] Unable to repack on Clearcase dynamic views

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:43:13

On 5/30/07, Robin Rosenberg [off-list ref] wrote:
onsdag 30 maj 2007 skrev Nguyen Thai Ngoc Duy:
quoted
On 5/30/07, Paolo Teti [off-list ref] wrote:
quoted
2007/5/30, Nguyen Thai Ngoc Duy [off-list ref]:
quoted
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

Re: [MinGW port] Unable to repack on Clearcase dynamic views

From: Robin Rosenberg <hidden>
Date: 2016-06-15 22:43:13

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

Re: [MinGW port] Unable to repack on Clearcase dynamic views

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:43:13

On 5/30/07, Robin Rosenberg [off-list ref] wrote:
onsdag 30 maj 2007 skrev Nguyen Thai Ngoc Duy:
quoted
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

Re: [MinGW port] Unable to repack on Clearcase dynamic views

From: Paolo Teti <hidden>
Date: 2016-06-15 22:43:13

2007/5/30, Robin Rosenberg [off-list ref]:
BTW, Does anyone have something like git-cvsexportcommit for clearcase?
a stupid workaround is git-cvsexportcommit + clearimport /clearexport_cvs.

Re: [MinGW port] Unable to repack on Clearcase dynamic views

From: Robin Rosenberg <hidden>
Date: 2016-06-15 22:43:13

torsdag 31 maj 2007 skrev Paolo Teti:
2007/5/30, Robin Rosenberg [off-list ref]:
quoted
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

Re: [MinGW port] Unable to repack on Clearcase dynamic views

From: Jan Hudec <hidden>
Date: 2016-06-15 22:43:13

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 [off-list ref]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help