summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 148bc06)
raw | patch | inline | side by side (parent: 148bc06)
author | Kjetil Barvik <barvik@broadpark.no> | |
Mon, 9 Feb 2009 20:54:06 +0000 (21:54 +0100) | ||
committer | Junio 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>
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 | patch | blob | history | |
builtin-add.c | patch | blob | history | |
builtin-apply.c | patch | blob | history | |
builtin-update-index.c | patch | blob | history | |
cache.h | patch | blob | history | |
diff-lib.c | patch | blob | history | |
dir.c | patch | blob | history | |
entry.c | patch | blob | history | |
symlinks.c | patch | blob | history | |
unpack-trees.c | patch | blob | history |
index 0d7fa9cca9e5c3ec8a11cd2c878f5a7afe353abe..b8bf618a30fd32a014e41e1ba9914f5e652bdefd 100644 (file)
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.
diff --git a/builtin-add.c b/builtin-add.c
index ac98c8354d84a7f556c22c53fbe9007832ac4346..a23ad967737cc3473e28a954f5b2125b6aad794f 100644 (file)
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -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);
}
diff --git a/builtin-apply.c b/builtin-apply.c
index f312798af38553e0badeda9732736a62460eae05..106be94105dbff4c150deac7854a50c67ecd974d 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
* 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);
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 560497750586ec61be4e34de6dedd9c307129817..6c55527513675ffd0dd70c294d8d4412af64ed93 100644 (file)
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
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);
/*
index 2d889deb264f189e16c2e9d2fc9d6fb795180773..80eeeb7db8d36316badd9a3a02926132d3b36a01 100644 (file)
--- a/cache.h
+++ b/cache.h
};
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 {
diff --git a/diff-lib.c b/diff-lib.c
index a41e1ec07ccd707969aa51768dac3e2b6356ddc6..a3ba20ee294df4c68599e73fd6a350d4166340bb 100644 (file)
--- a/diff-lib.c
+++ b/diff-lib.c
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];
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);
index 05aa58d34823258789ec9e32abc897b8e6777412..bb6bdb90e3b976ca8045b74338980a3cb627fcb9 100644 (file)
--- a/entry.c
+++ b/entry.c
* 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. */
/*
diff --git a/symlinks.c b/symlinks.c
index 4596aee9dc32c7664a1c0933138a9319dd4ae868..51672868d15e9aec30b82e7c88e46368448763b6 100644 (file)
--- a/symlinks.c
+++ b/symlinks.c
* 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;
* 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;
/*
* 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;
}
* 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);
}
* '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;
}
diff --git a/unpack-trees.c b/unpack-trees.c
index e547282ed5c0027b35cbbd8e4f07bf968c6f2171..22931588503f2833ac27db18b332720f1168036a 100644 (file)
--- a/unpack-trees.c
+++ b/unpack-trees.c
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;
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)) {