From e1e4389832f32bb6ce029d6a6b110aa9ec768ea8 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 4 Feb 2009 02:50:15 +0100 Subject: apply: fix access to an uninitialized mode variable, found by valgrind When 'tpatch' was initialized successfully, st_mode was already taken from the previous diff. We should not try to override it with data from an lstat() that was never called. This is a companion patch to 7a07841(git-apply: handle a patch that touches the same path more than once better). Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- builtin-apply.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin-apply.c b/builtin-apply.c index 50b623e54..7a1ff041f 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -2445,7 +2445,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s return error("%s: %s", old_name, strerror(errno)); } - if (!cached) + if (!cached && !tpatch) st_mode = ce_mode_from_stat(*ce, st->st_mode); if (patch->is_new < 0) -- cgit v1.2.1 From c9a8abcf9a9997d463a6a05668fd9a90a26df1f2 Mon Sep 17 00:00:00 2001 From: Guanqun Lu Date: Thu, 5 Feb 2009 05:00:40 +0800 Subject: fix typo in Documentation Signed-off-by: Guanqun Lu Signed-off-by: Junio C Hamano --- Documentation/technical/api-strbuf.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/technical/api-strbuf.txt b/Documentation/technical/api-strbuf.txt index a9668e5f2..4242dc014 100644 --- a/Documentation/technical/api-strbuf.txt +++ b/Documentation/technical/api-strbuf.txt @@ -21,7 +21,7 @@ allocated memory or not), use `strbuf_detach()` to unwrap a memory buffer from its strbuf shell in a safe way. That is the sole supported way. This will give you a malloced buffer that you can later `free()`. + -However, it it totally safe to modify anything in the string pointed by +However, it is totally safe to modify anything in the string pointed by the `buf` member, between the indices `0` and `len-1` (inclusive). . The `buf` member is a byte array that has at least `len + 1` bytes -- cgit v1.2.1 From 37fc57a213c5dd7a15dfdf571ce4a58de124cb0f Mon Sep 17 00:00:00 2001 From: Guanqun Lu Date: Thu, 5 Feb 2009 05:00:41 +0800 Subject: add test-dump-cache-tree in Makefile 5c5ba73 (Makefile: Use generic rule to build test programs, 2007-05-31) tried to use generic rule to build test programs, but it misses the file 'dump-cache-tree.c', since its name is not prefixed by 'test-'. This commit solves this little problem by renaming this file instead of carrying out an explicit rule in Makefile. Signed-off-by: Guanqun Lu Signed-off-by: Junio C Hamano --- Makefile | 2 +- dump-cache-tree.c | 64 -------------------------------------------------- test-dump-cache-tree.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 65 deletions(-) delete mode 100644 dump-cache-tree.c create mode 100644 test-dump-cache-tree.c diff --git a/Makefile b/Makefile index 186a8efd1..5de4247fb 100644 --- a/Makefile +++ b/Makefile @@ -1301,7 +1301,7 @@ endif ### Testing rules -TEST_PROGRAMS = test-chmtime$X test-genrandom$X test-date$X test-delta$X test-sha1$X test-match-trees$X test-parse-options$X test-path-utils$X +TEST_PROGRAMS = test-chmtime$X test-dump-cache-tree$X test-genrandom$X test-date$X test-delta$X test-sha1$X test-match-trees$X test-parse-options$X test-path-utils$X all:: $(TEST_PROGRAMS) diff --git a/dump-cache-tree.c b/dump-cache-tree.c deleted file mode 100644 index 1f73f1ea7..000000000 --- a/dump-cache-tree.c +++ /dev/null @@ -1,64 +0,0 @@ -#include "cache.h" -#include "tree.h" -#include "cache-tree.h" - - -static void dump_one(struct cache_tree *it, const char *pfx, const char *x) -{ - if (it->entry_count < 0) - printf("%-40s %s%s (%d subtrees)\n", - "invalid", x, pfx, it->subtree_nr); - else - printf("%s %s%s (%d entries, %d subtrees)\n", - sha1_to_hex(it->sha1), x, pfx, - it->entry_count, it->subtree_nr); -} - -static int dump_cache_tree(struct cache_tree *it, - struct cache_tree *ref, - const char *pfx) -{ - int i; - int errs = 0; - - if (!it || !ref) - /* missing in either */ - return 0; - - if (it->entry_count < 0) { - dump_one(it, pfx, ""); - dump_one(ref, pfx, "#(ref) "); - if (it->subtree_nr != ref->subtree_nr) - errs = 1; - } - else { - dump_one(it, pfx, ""); - if (hashcmp(it->sha1, ref->sha1) || - ref->entry_count != it->entry_count || - ref->subtree_nr != it->subtree_nr) { - dump_one(ref, pfx, "#(ref) "); - errs = 1; - } - } - - for (i = 0; i < it->subtree_nr; i++) { - char path[PATH_MAX]; - struct cache_tree_sub *down = it->down[i]; - struct cache_tree_sub *rdwn; - - rdwn = cache_tree_sub(ref, down->name); - sprintf(path, "%s%.*s/", pfx, down->namelen, down->name); - if (dump_cache_tree(down->cache_tree, rdwn->cache_tree, path)) - errs = 1; - } - return errs; -} - -int main(int ac, char **av) -{ - struct cache_tree *another = cache_tree(); - if (read_cache() < 0) - die("unable to read index file"); - cache_tree_update(another, active_cache, active_nr, 0, 1); - return dump_cache_tree(active_cache_tree, another, ""); -} diff --git a/test-dump-cache-tree.c b/test-dump-cache-tree.c new file mode 100644 index 000000000..1f73f1ea7 --- /dev/null +++ b/test-dump-cache-tree.c @@ -0,0 +1,64 @@ +#include "cache.h" +#include "tree.h" +#include "cache-tree.h" + + +static void dump_one(struct cache_tree *it, const char *pfx, const char *x) +{ + if (it->entry_count < 0) + printf("%-40s %s%s (%d subtrees)\n", + "invalid", x, pfx, it->subtree_nr); + else + printf("%s %s%s (%d entries, %d subtrees)\n", + sha1_to_hex(it->sha1), x, pfx, + it->entry_count, it->subtree_nr); +} + +static int dump_cache_tree(struct cache_tree *it, + struct cache_tree *ref, + const char *pfx) +{ + int i; + int errs = 0; + + if (!it || !ref) + /* missing in either */ + return 0; + + if (it->entry_count < 0) { + dump_one(it, pfx, ""); + dump_one(ref, pfx, "#(ref) "); + if (it->subtree_nr != ref->subtree_nr) + errs = 1; + } + else { + dump_one(it, pfx, ""); + if (hashcmp(it->sha1, ref->sha1) || + ref->entry_count != it->entry_count || + ref->subtree_nr != it->subtree_nr) { + dump_one(ref, pfx, "#(ref) "); + errs = 1; + } + } + + for (i = 0; i < it->subtree_nr; i++) { + char path[PATH_MAX]; + struct cache_tree_sub *down = it->down[i]; + struct cache_tree_sub *rdwn; + + rdwn = cache_tree_sub(ref, down->name); + sprintf(path, "%s%.*s/", pfx, down->namelen, down->name); + if (dump_cache_tree(down->cache_tree, rdwn->cache_tree, path)) + errs = 1; + } + return errs; +} + +int main(int ac, char **av) +{ + struct cache_tree *another = cache_tree(); + if (read_cache() < 0) + die("unable to read index file"); + cache_tree_update(another, active_cache, active_nr, 0, 1); + return dump_cache_tree(active_cache_tree, another, ""); +} -- cgit v1.2.1 From 7a85f6ae88be5937c32a7b61601a40a02c03fb3f Mon Sep 17 00:00:00 2001 From: William Pursell Date: Tue, 3 Feb 2009 22:41:14 +0000 Subject: User-manual: "git stash " form is long gone These days you must explicitly say "git stash save ". Signed-off-by: William Pursell Signed-off-by: Junio C Hamano --- Documentation/user-manual.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt index 99cb80878..2ae88c575 100644 --- a/Documentation/user-manual.txt +++ b/Documentation/user-manual.txt @@ -1497,7 +1497,7 @@ so on a different branch and then coming back), unstash the work-in-progress changes. ------------------------------------------------ -$ git stash "work in progress for foo feature" +$ git stash save "work in progress for foo feature" ------------------------------------------------ This command will save your changes away to the `stash`, and -- cgit v1.2.1