summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 171dccd)
raw | patch | inline | side by side (parent: 171dccd)
author | Linus Torvalds <torvalds@linux-foundation.org> | |
Wed, 21 Mar 2007 17:07:46 +0000 (10:07 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 21 Mar 2007 17:21:56 +0000 (10:21 -0700) |
Since we have the "tree_entry_len()" helper function these days, and
don't need to do a full strlen(), there's no point in saving the path
length - it's just redundant information.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
don't need to do a full strlen(), there's no point in saving the path
length - it's just redundant information.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-grep.c | patch | blob | history | |
builtin-pack-objects.c | patch | blob | history | |
merge-tree.c | patch | blob | history | |
tree-walk.c | patch | blob | history | |
tree-walk.h | patch | blob | history | |
tree.c | patch | blob | history |
diff --git a/builtin-grep.c b/builtin-grep.c
index 4510d353247355a28979fbf63b15523c2e705591..1348cc92efc19b30f3bbda15ef4205ec2ffabb85 100644 (file)
--- a/builtin-grep.c
+++ b/builtin-grep.c
* decide if we want to descend into "abc"
* directory.
*/
- strcpy(path_buf + len + entry.pathlen, "/");
+ strcpy(path_buf + len + tree_entry_len(entry.path, entry.sha1), "/");
if (!pathspec_matches(paths, down))
;
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 73d448b890d61b79793290b6b9b9aceea0a89cdc..9231b6564ff08315f205ba630a238d3c56deac4f 100644 (file)
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
unsigned long size;
enum object_type type;
- if (entry.pathlen != cmplen ||
+ if (tree_entry_len(entry.path, entry.sha1) != cmplen ||
memcmp(entry.path, name, cmplen) ||
!has_sha1_file(entry.sha1) ||
(type = sha1_object_info(entry.sha1, &size)) < 0)
diff --git a/merge-tree.c b/merge-tree.c
index b2867ba7226ea6ff69876f8f20da87d200fe5fca..3b8d9e6887ae051bf61cc0833f97d83bb47a0bae 100644 (file)
--- a/merge-tree.c
+++ b/merge-tree.c
@@ -188,7 +188,7 @@ static void resolve(const char *base, struct name_entry *branch1, struct name_en
static int unresolved_directory(const char *base, struct name_entry n[3])
{
- int baselen;
+ int baselen, pathlen;
char *newbase;
struct name_entry *p;
struct tree_desc t[3];
if (!S_ISDIR(p->mode))
return 0;
baselen = strlen(base);
- newbase = xmalloc(baselen + p->pathlen + 2);
+ pathlen = tree_entry_len(p->path, p->sha1);
+ newbase = xmalloc(baselen + pathlen + 2);
memcpy(newbase, base, baselen);
- memcpy(newbase + baselen, p->path, p->pathlen);
- memcpy(newbase + baselen + p->pathlen, "/", 2);
+ memcpy(newbase + baselen, p->path, pathlen);
+ memcpy(newbase + baselen + pathlen, "/", 2);
buf0 = fill_tree_descriptor(t+0, n[0].sha1);
buf1 = fill_tree_descriptor(t+1, n[1].sha1);
diff --git a/tree-walk.c b/tree-walk.c
index a4a4e2a9892fb10df32b113ca8b05848d11aff78..1869baede56da54f964e4300d0b4148e66999cab 100644 (file)
--- a/tree-walk.c
+++ b/tree-walk.c
static int entry_compare(struct name_entry *a, struct name_entry *b)
{
return base_name_compare(
- a->path, a->pathlen, a->mode,
- b->path, b->pathlen, b->mode);
+ a->path, tree_entry_len(a->path, a->sha1), a->mode,
+ b->path, tree_entry_len(b->path, b->sha1), b->mode);
}
static void entry_clear(struct name_entry *a)
static void entry_extract(struct tree_desc *t, struct name_entry *a)
{
a->sha1 = tree_entry_extract(t, &a->path, &a->mode);
- a->pathlen = tree_entry_len(a->path, a->sha1);
}
void update_tree_entry(struct tree_desc *desc)
entry->path = path;
len = strlen(path);
- entry->pathlen = len;
path += len + 1;
entry->sha1 = (const unsigned char *) path;
diff --git a/tree-walk.h b/tree-walk.h
index a0d7afd89bee1746912c61164e839daaa05a9b0c..149393aaa476985d3607f796366b537b6622d50e 100644 (file)
--- a/tree-walk.h
+++ b/tree-walk.h
const unsigned char *sha1;
const char *path;
unsigned int mode;
- int pathlen;
};
static inline int tree_entry_len(const char *name, const unsigned char *sha1)
index 24f8fb676650ff0c95baffe79966219fa026f09f..705a4812558654a35f03d669431d2d962b3b1bb1 100644 (file)
--- a/tree.c
+++ b/tree.c
if (S_ISDIR(entry.mode)) {
int retval;
char *newbase;
+ unsigned int pathlen = tree_entry_len(entry.path, entry.sha1);
- newbase = xmalloc(baselen + 1 + entry.pathlen);
+ newbase = xmalloc(baselen + 1 + pathlen);
memcpy(newbase, base, baselen);
- memcpy(newbase + baselen, entry.path, entry.pathlen);
- newbase[baselen + entry.pathlen] = '/';
+ memcpy(newbase + baselen, entry.path, pathlen);
+ newbase[baselen + pathlen] = '/';
retval = read_tree_recursive(lookup_tree(entry.sha1),
newbase,
- baselen + entry.pathlen + 1,
+ baselen + pathlen + 1,
stage, match, fn);
free(newbase);
if (retval)