]> git.ipfire.org Git - thirdparty/git.git/commitdiff
lstat_cache(): swap func(length, string) into func(string, length)
authorKjetil Barvik <barvik@broadpark.no>
Mon, 9 Feb 2009 20:54:06 +0000 (21:54 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 10 Feb 2009 04:59:26 +0000 (20:59 -0800)
Swap function argument pair (length, string) into (string, length) to
conform with the commonly used order inside the GIT source code.

Also, add a note about this fact into the coding guidelines.

Signed-off-by: Kjetil Barvik <barvik@broadpark.no>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/CodingGuidelines
builtin-add.c
builtin-apply.c
builtin-update-index.c
cache.h
diff-lib.c
dir.c
entry.c
symlinks.c
unpack-trees.c

index 0d7fa9cca9e5c3ec8a11cd2c878f5a7afe353abe..b8bf618a30fd32a014e41e1ba9914f5e652bdefd 100644 (file)
@@ -129,3 +129,6 @@ For C programs:
    used in the git core command set (unless your command is clearly
    separate from it, such as an importer to convert random-scm-X
    repositories to git).
+
+ - When we pass <string, length> pair to functions, we should try to
+   pass them in that order.
index ac98c8354d84a7f556c22c53fbe9007832ac4346..a23ad967737cc3473e28a954f5b2125b6aad794f 100644 (file)
@@ -148,7 +148,7 @@ static const char **validate_pathspec(int argc, const char **argv, const char *p
        if (pathspec) {
                const char **p;
                for (p = pathspec; *p; p++) {
-                       if (has_symlink_leading_path(strlen(*p), *p)) {
+                       if (has_symlink_leading_path(*p, strlen(*p))) {
                                int len = prefix ? strlen(prefix) : 0;
                                die("'%s' is beyond a symbolic link", *p + len);
                        }
index f312798af38553e0badeda9732736a62460eae05..106be94105dbff4c150deac7854a50c67ecd974d 100644 (file)
@@ -2360,7 +2360,7 @@ static int check_to_create_blob(const char *new_name, int ok_if_exists)
                 * In such a case, path "new_name" does not exist as
                 * far as git is concerned.
                 */
-               if (has_symlink_leading_path(strlen(new_name), new_name))
+               if (has_symlink_leading_path(new_name, strlen(new_name)))
                        return 0;
 
                return error("%s: already exists in working directory", new_name);
index 560497750586ec61be4e34de6dedd9c307129817..6c55527513675ffd0dd70c294d8d4412af64ed93 100644 (file)
@@ -195,7 +195,7 @@ static int process_path(const char *path)
        struct stat st;
 
        len = strlen(path);
-       if (has_symlink_leading_path(len, path))
+       if (has_symlink_leading_path(path, len))
                return error("'%s' is beyond a symbolic link", path);
 
        /*
diff --git a/cache.h b/cache.h
index 2d889deb264f189e16c2e9d2fc9d6fb795180773..80eeeb7db8d36316badd9a3a02926132d3b36a01 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -724,10 +724,10 @@ struct checkout {
 };
 
 extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath);
-extern int has_symlink_leading_path(int len, const char *name);
-extern int has_symlink_or_noent_leading_path(int len, const char *name);
-extern int has_dirs_only_path(int len, const char *name, int prefix_len);
-extern void invalidate_lstat_cache(int len, const char *name);
+extern int has_symlink_leading_path(const char *name, int len);
+extern int has_symlink_or_noent_leading_path(const char *name, int len);
+extern int has_dirs_only_path(const char *name, int len, int prefix_len);
+extern void invalidate_lstat_cache(const char *name, int len);
 extern void clear_lstat_cache(void);
 
 extern struct alternate_object_database {
index a41e1ec07ccd707969aa51768dac3e2b6356ddc6..a3ba20ee294df4c68599e73fd6a350d4166340bb 100644 (file)
@@ -31,7 +31,7 @@ static int check_removed(const struct cache_entry *ce, struct stat *st)
                        return -1;
                return 1;
        }
-       if (has_symlink_leading_path(ce_namelen(ce), ce->name))
+       if (has_symlink_leading_path(ce->name, ce_namelen(ce)))
                return 1;
        if (S_ISDIR(st->st_mode)) {
                unsigned char sub[20];
diff --git a/dir.c b/dir.c
index cfd1ea587d9cce825e238ca81ea99b752543dada..8fb52265424c2003bb4bb35390aa4f6d2b491614 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -720,7 +720,7 @@ int read_directory(struct dir_struct *dir, const char *path, const char *base, i
 {
        struct path_simplify *simplify;
 
-       if (has_symlink_leading_path(strlen(path), path))
+       if (has_symlink_leading_path(path, strlen(path)))
                return dir->nr;
 
        simplify = create_simplify(pathspec);
diff --git a/entry.c b/entry.c
index 05aa58d34823258789ec9e32abc897b8e6777412..bb6bdb90e3b976ca8045b74338980a3cb627fcb9 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -20,7 +20,7 @@ static void create_directories(const char *path, const struct checkout *state)
                 * we test the path components of the prefix with the
                 * stat() function instead of the lstat() function.
                 */
-               if (has_dirs_only_path(len, buf, state->base_dir_len))
+               if (has_dirs_only_path(buf, len, state->base_dir_len))
                        continue; /* ok, it is already a directory. */
 
                /*
index 4596aee9dc32c7664a1c0933138a9319dd4ae868..51672868d15e9aec30b82e7c88e46368448763b6 100644 (file)
@@ -70,7 +70,7 @@ static inline void reset_lstat_cache(void)
  * of the prefix, where the cache should use the stat() function
  * instead of the lstat() function to test each path component.
  */
-static int lstat_cache(int len, const char *name,
+static int lstat_cache(const char *name, int len,
                       int track_flags, int prefix_len_stat_func)
 {
        int match_len, last_slash, last_slash_dir, previous_slash;
@@ -185,7 +185,7 @@ static int lstat_cache(int len, const char *name,
  * Invalidate the given 'name' from the cache, if 'name' matches
  * completely with the cache.
  */
-void invalidate_lstat_cache(int len, const char *name)
+void invalidate_lstat_cache(const char *name, int len)
 {
        int match_len, previous_slash;
 
@@ -214,9 +214,9 @@ void clear_lstat_cache(void)
 /*
  * Return non-zero if path 'name' has a leading symlink component
  */
-int has_symlink_leading_path(int len, const char *name)
+int has_symlink_leading_path(const char *name, int len)
 {
-       return lstat_cache(len, name,
+       return lstat_cache(name, len,
                           FL_SYMLINK|FL_DIR, USE_ONLY_LSTAT) &
                FL_SYMLINK;
 }
@@ -225,9 +225,9 @@ int has_symlink_leading_path(int len, const char *name)
  * Return non-zero if path 'name' has a leading symlink component or
  * if some leading path component does not exists.
  */
-int has_symlink_or_noent_leading_path(int len, const char *name)
+int has_symlink_or_noent_leading_path(const char *name, int len)
 {
-       return lstat_cache(len, name,
+       return lstat_cache(name, len,
                           FL_SYMLINK|FL_NOENT|FL_DIR, USE_ONLY_LSTAT) &
                (FL_SYMLINK|FL_NOENT);
 }
@@ -239,9 +239,9 @@ int has_symlink_or_noent_leading_path(int len, const char *name)
  * 'prefix_len', thus we then allow for symlinks in the prefix part as
  * long as those points to real existing directories.
  */
-int has_dirs_only_path(int len, const char *name, int prefix_len)
+int has_dirs_only_path(const char *name, int len, int prefix_len)
 {
-       return lstat_cache(len, name,
+       return lstat_cache(name, len,
                           FL_DIR|FL_FULLPATH, prefix_len) &
                FL_DIR;
 }
index e547282ed5c0027b35cbbd8e4f07bf968c6f2171..22931588503f2833ac27db18b332720f1168036a 100644 (file)
@@ -61,7 +61,7 @@ static void unlink_entry(struct cache_entry *ce)
        char *cp, *prev;
        char *name = ce->name;
 
-       if (has_symlink_or_noent_leading_path(ce_namelen(ce), ce->name))
+       if (has_symlink_or_noent_leading_path(ce->name, ce_namelen(ce)))
                return;
        if (unlink(name))
                return;
@@ -583,7 +583,7 @@ static int verify_absent(struct cache_entry *ce, const char *action,
        if (o->index_only || o->reset || !o->update)
                return 0;
 
-       if (has_symlink_or_noent_leading_path(ce_namelen(ce), ce->name))
+       if (has_symlink_or_noent_leading_path(ce->name, ce_namelen(ce)))
                return 0;
 
        if (!lstat(ce->name, &st)) {