Attached is the code to address this problem.
donald
On Fri, May 25, 2001 at 01:14:22PM -0400, Derek R. Price wrote:
> Donald Sharp wrote:
>
> > So I think that the correct time to check for safe_location is
> > after the directory tree has been built and chdir'ed into.
>
> That makes some sense, since otherwise the code that figures out which directory to
> checkout into may be run twice... it leaves a directory to cleanup in the failure
> case though.
>
> What about trying the parent dir too (as determined using the last_component
> function) if errno after the chdir is ENOEXIST or whatever...
>
> If both chdirs fail, then safe_location can too since we know that CVS will only
> build one level if directories due to a -d switch.
>
> I was about to code this, but if you have it in hand, I'll let you...
>
> Derek
>
> --
> Derek Price CVS Solutions Architect ( http://CVSHome.org )
> mailto:[EMAIL PROTECTED] CollabNet ( http://collab.net )
> --
> I will not fake my way through life.
> I will not fake my way through life.
> I will not fake my way through life...
>
> - Bart Simpson on chalkboard, _The Simpsons_
>
>
>
>
> _______________________________________________
> Bug-cvs mailing list
> [EMAIL PROTECTED]
> http://mail.gnu.org/mailman/listinfo/bug-cvs
Index: ChangeLog
===================================================================
RCS file: /home2/cvsroot/ccvs/src/ChangeLog,v
retrieving revision 1.2142
diff -c -r1.2142 ChangeLog
*** ChangeLog 29 May 2001 19:04:21 -0000 1.2142
--- ChangeLog 30 May 2001 13:50:43 -0000
***************
*** 1,3 ****
--- 1,9 ----
+ 2001-05-20 Donald Sharp <[EMAIL PROTECTED]>
+
+ * checkout.c (safe_location): cvs co -d <directory> still had
+ failure modes from the way the -d option works.
+ sanity.sh: fixed some test cases for the new methodology.
+
2001-05-29 Derek Price <[EMAIL PROTECTED]>
* Makefile.am (cvs_SOURCES): Add root.h.
Index: checkout.c
===================================================================
RCS file: /home2/cvsroot/ccvs/src/checkout.c,v
retrieving revision 1.102
diff -c -r1.102 checkout.c
*** checkout.c 29 May 2001 18:59:24 -0000 1.102
--- checkout.c 30 May 2001 13:50:43 -0000
***************
*** 424,429 ****
--- 424,457 ----
free( current );
current = where_location;
}
+ else
+ {
+ if( ( errno = ENOENT ) && ( last_component( where ) != where ) )
+ {
+ char *parent;
+
+ where_location = strdup( where );
+ parent = last_component( where_location );
+
+ parent[0] = '\0';
+ if( chdir( where_location ) != -1 )
+ {
+ where_location = xgetwd();
+ if( where_location == NULL )
+ {
+ error( 1, errno, "could not get working directory" );
+ }
+
+ if( chdir( current ) == -1 )
+ error( 1, errno, "Could not change directory" );
+
+ free( current );
+ current = where_location;
+ }
+ else
+ error( 1, errno, "Could not change directory into requested checkout
+directory" );
+ }
+ }
}
hardpath_len = strlen (hardpath);
Index: sanity.sh
===================================================================
RCS file: /home2/cvsroot/ccvs/src/sanity.sh,v
retrieving revision 1.697
diff -c -r1.697 sanity.sh
*** sanity.sh 26 May 2001 07:02:17 -0000 1.697
--- sanity.sh 30 May 2001 13:50:45 -0000
***************
*** 10764,10771 ****
##################################################
dotest_fail cvsadm-2d3-1 "${testcvs} co -d dir/dir2 1mod" \
! "${PROG} [a-z]*: cannot chdir to dir: No such file or directory
! ${PROG} [a-z]*: ignoring module 1mod"
if $remote; then :; else
# Remote can't handle this, even with the "mkdir dir".
--- 10764,10770 ----
##################################################
dotest_fail cvsadm-2d3-1 "${testcvs} co -d dir/dir2 1mod" \
! "${PROG} \[checkout aborted\]: Could not change directory into requested checkout
directory: No such file or directory"
if $remote; then :; else
# Remote can't handle this, even with the "mkdir dir".
***************
*** 11274,11285 ****
# this is the behavior of CVS 1.9 and earlier.
if $remote; then :; else
dotest_fail abspath-3.1 "${testcvs} co -d ${TESTDIR}/1/2 mod1" \
! "${PROG} [a-z]*: cannot chdir to 1: No such file or directory
! ${PROG} [a-z]*: ignoring module mod1"
fi
dotest_fail abspath-3.2 "${testcvs} co -d 1/2 mod1" \
! "${PROG} [a-z]*: cannot chdir to 1: No such file or directory
! ${PROG} [a-z]*: ignoring module mod1"
mkdir 1
if $remote; then
--- 11273,11283 ----
# this is the behavior of CVS 1.9 and earlier.
if $remote; then :; else
dotest_fail abspath-3.1 "${testcvs} co -d ${TESTDIR}/1/2 mod1" \
! "${PROG} \[checkout aborted\]: Could not change directory into requested checkout
directory: No such file or directory"
fi
dotest_fail abspath-3.2 "${testcvs} co -d 1/2 mod1" \
! "${PROG} \[checkout aborted\]: Could not change directory into requested checkout
directory: No such file or directory"
!
mkdir 1
if $remote; then
***************
*** 11287,11294 ****
# a bug, it should only need to exist on the client side.
# See also cvsadm-2d3.
dotest_fail abspath-3a "${testcvs} co -d 1/2 mod1" \
! "${PROG} [a-z]*: cannot chdir to 1: No such file or directory
! ${PROG} [a-z]*: ignoring module mod1"
cd 1
dotest abspath-3a-try2 "${testcvs} co -d 2 mod1" \
"${PROG} [a-z]*: Updating 2
--- 11285,11291 ----
# a bug, it should only need to exist on the client side.
# See also cvsadm-2d3.
dotest_fail abspath-3a "${testcvs} co -d 1/2 mod1" \
! "${PROG} \[server aborted\]: Could not change directory into requested checkout
directory: No such file or directory"
cd 1
dotest abspath-3a-try2 "${testcvs} co -d 2 mod1" \
"${PROG} [a-z]*: Updating 2