bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cvs has problems using LockDir when CVSROOT holds a symlink


From: Larry Jones
Subject: Re: cvs has problems using LockDir when CVSROOT holds a symlink
Date: Tue, 23 Sep 2003 14:19:17 -0400 (EDT)

Mark D. Baushke writes:
> 
> I will rework my patch to follow Derek's suggested advice.
> 
> I will probably use realpath() to create the canonical path rather than
> either xwcd() or xreadlink().

Please don't -- realpath() does not exist on all systems.  Also, the
most common implementation just calls getcwd() to do the real work
anyway, so we might as well just use xgetwd().

You can also simplify the code in lock_name():

Index: lock.c
===================================================================
RCS file: /cvs/ccvs/src/lock.c,v
retrieving revision 1.59.4.2
diff -u -r1.59.4.2 lock.c
--- lock.c      27 Jun 2003 19:12:03 -0000      1.59.4.2
+++ lock.c      23 Sep 2003 17:23:26 -0000
@@ -179,16 +179,22 @@
     {
        struct stat sb;
        mode_t new_mode = 0;
+       size_t parsed_root_len;
 
        /* The interesting part of the repository is the part relative
           to CVSROOT.  */
        assert (current_parsed_root != NULL);
        assert (current_parsed_root->directory != NULL);
-       assert (strncmp (repository, current_parsed_root->directory,
-                        strlen (current_parsed_root->directory)) == 0);
-       short_repos = repository + strlen (current_parsed_root->directory) + 1;
+       parsed_root_len = strlen (current_parsed_root->dirpath);
+       if (strncmp (repository, current_parsed_root->dirpath,
+                    parsed_root_len) != 0)
+       {
+           parsed_root_len = strlen (current_parsed_root->directory);
+           assert (strncmp (repository, current_parsed_root->directory, 
parsed_root_len) == 0);
+       }
+       short_repos = repository + parsed_root_len + 1;
 
-       if (strcmp (repository, current_parsed_root->directory) == 0)
+       if (short_repos[-1] == '\0')
            short_repos = ".";
        else
            assert (short_repos[-1] == '/');

-Larry Jones

These things just seem to happen. -- Calvin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]