{"thread":{"id":"33991","subject":"[PATCH 0/4] Trivial patches","startedAt":"2013-05-30T13:56:17Z","lastAt":"2013-06-03T20:51:03Z","messageCount":8,"participants":["Felipe Contreras","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"219005","messageId":"1369922181-31016-1-git-send-email-felipe.contreras@gmail.com","threadId":"33991","inReplyTo":null,"subject":"[PATCH 0/4] Trivial patches","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-30T13:56:17Z","receivedAt":"2013-05-30T13:56:17Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nHere's a bunch of  trivial patches, mostly syle, but the first one might be\nimportant.\n\nFelipe Contreras (4):\n  read-cache: fix wrong 'the_index' usage\n  read-cache: trivial style cleanups\n  unpack-trees: trivial cleanup\n  sha1_file: trivial style cleanup\n\n read-cache.c   | 6 +++---\n sha1_file.c    | 2 +-\n unpack-trees.c | 3 +--\n 3 files changed, 5 insertions(+), 6 deletions(-)\n\n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"219006","messageId":"1369922181-31016-2-git-send-email-felipe.contreras@gmail.com","threadId":"33991","inReplyTo":"1369922181-31016-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 1/4] read-cache: fix wrong 'the_index' usage","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-30T13:56:18Z","receivedAt":"2013-05-30T13:56:18Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We are dealing with the 'istate' index, not 'the_index'.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n read-cache.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex 04ed561..5253ec5 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -626,7 +626,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,\n \t\t\tif (*ptr == '/') {\n \t\t\t\tstruct cache_entry *foundce;\n \t\t\t\t++ptr;\n-\t\t\t\tfoundce = index_name_exists(&the_index, ce->name, ptr - ce->name, ignore_case);\n+\t\t\t\tfoundce = index_name_exists(istate, ce->name, ptr - ce->name, ignore_case);\n \t\t\t\tif (foundce) {\n \t\t\t\t\tmemcpy((void *)startPtr, foundce->name + (startPtr - ce->name), ptr - startPtr);\n \t\t\t\t\tstartPtr = ptr;\n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"219007","messageId":"1369922181-31016-3-git-send-email-felipe.contreras@gmail.com","threadId":"33991","inReplyTo":"1369922181-31016-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 2/4] read-cache: trivial style cleanups","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-30T13:56:19Z","receivedAt":"2013-05-30T13:56:19Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n read-cache.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex 5253ec5..7040e79 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -979,7 +979,7 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti\n \tif (istate->cache_nr == istate->cache_alloc) {\n \t\tistate->cache_alloc = alloc_nr(istate->cache_alloc);\n \t\tistate->cache = xrealloc(istate->cache,\n-\t\t\t\t\tistate->cache_alloc * sizeof(struct cache_entry *));\n+\t\t\t\t\tistate->cache_alloc * sizeof(*istate->cache));\n \t}\n \n \t/* Add it in.. */\n@@ -1449,7 +1449,7 @@ int read_index_from(struct index_state *istate, const char *path)\n \tistate->version = ntohl(hdr->hdr_version);\n \tistate->cache_nr = ntohl(hdr->hdr_entries);\n \tistate->cache_alloc = alloc_nr(istate->cache_nr);\n-\tistate->cache = xcalloc(istate->cache_alloc, sizeof(struct cache_entry *));\n+\tistate->cache = xcalloc(istate->cache_alloc, sizeof(*istate->cache));\n \tistate->initialized = 1;\n \n \tif (istate->version == 4)\n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"219008","messageId":"1369922181-31016-4-git-send-email-felipe.contreras@gmail.com","threadId":"33991","inReplyTo":"1369922181-31016-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 3/4] unpack-trees: trivial cleanup","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-30T13:56:20Z","receivedAt":"2013-05-30T13:56:20Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"dfc has not been initialized at this point.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n unpack-trees.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex ede4299..36f4ff7 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -1040,8 +1040,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options\n \tif (!o->skip_sparse_checkout)\n \t\tmark_new_skip_worktree(o->el, o->src_index, 0, CE_NEW_SKIP_WORKTREE);\n \n-\tif (!dfc)\n-\t\tdfc = xcalloc(1, cache_entry_size(0));\n+\tdfc = xcalloc(1, cache_entry_size(0));\n \to->df_conflict_entry = dfc;\n \n \tif (len) {\n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"219009","messageId":"1369922181-31016-5-git-send-email-felipe.contreras@gmail.com","threadId":"33991","inReplyTo":"1369922181-31016-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 4/4] sha1_file: trivial style cleanup","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-30T13:56:21Z","receivedAt":"2013-05-30T13:56:21Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n sha1_file.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 67e815b..b114cc9 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -2138,7 +2138,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,\n \t\tif (!data)\n \t\t\tdie(\"failed to apply delta\");\n \n-\t\tfree (delta_data);\n+\t\tfree(delta_data);\n \t}\n \n \t*final_type = type;\n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"219245","messageId":"7v4ndfi0ir.fsf@alter.siamese.dyndns.org","threadId":"33991","inReplyTo":"1369922181-31016-2-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH 1/4] read-cache: fix wrong 'the_index' usage","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-03T17:09:48Z","receivedAt":"2013-06-03T17:09:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> We are dealing with the 'istate' index, not 'the_index'.\n>\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n> ---\n\nGood catch; will apply.\n\n>  read-cache.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/read-cache.c b/read-cache.c\n> index 04ed561..5253ec5 100644\n> --- a/read-cache.c\n> +++ b/read-cache.c\n> @@ -626,7 +626,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,\n>  \t\t\tif (*ptr == '/') {\n>  \t\t\t\tstruct cache_entry *foundce;\n>  \t\t\t\t++ptr;\n> -\t\t\t\tfoundce = index_name_exists(&the_index, ce->name, ptr - ce->name, ignore_case);\n> +\t\t\t\tfoundce = index_name_exists(istate, ce->name, ptr - ce->name, ignore_case);\n>  \t\t\t\tif (foundce) {\n>  \t\t\t\t\tmemcpy((void *)startPtr, foundce->name + (startPtr - ce->name), ptr - startPtr);\n>  \t\t\t\t\tstartPtr = ptr;\n"},{"id":"219246","messageId":"7vzjv7glrw.fsf@alter.siamese.dyndns.org","threadId":"33991","inReplyTo":"1369922181-31016-4-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH 3/4] unpack-trees: trivial cleanup","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-03T17:13:39Z","receivedAt":"2013-06-03T17:13:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> dfc has not been initialized at this point.\n>\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n> ---\n\nUpon the first entry to this function, because dfc is \n\n\tstatic struct cache_entry *dfc;\n\nit is NULL.  In that case, we allocate one instance.  When the\nfunction is called again, we can reuse the entry, because it merely\nacts as a unique sentinel value.\n\nAnd we do not free() it.\n\n>  unpack-trees.c | 3 +--\n>  1 file changed, 1 insertion(+), 2 deletions(-)\n>\n> diff --git a/unpack-trees.c b/unpack-trees.c\n> index ede4299..36f4ff7 100644\n> --- a/unpack-trees.c\n> +++ b/unpack-trees.c\n> @@ -1040,8 +1040,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options\n>  \tif (!o->skip_sparse_checkout)\n>  \t\tmark_new_skip_worktree(o->el, o->src_index, 0, CE_NEW_SKIP_WORKTREE);\n>  \n> -\tif (!dfc)\n> -\t\tdfc = xcalloc(1, cache_entry_size(0));\n> +\tdfc = xcalloc(1, cache_entry_size(0));\n>  \to->df_conflict_entry = dfc;\n>  \n>  \tif (len) {\n"},{"id":"219296","messageId":"CAMP44s0rHtrf0aa6sgQxM=vsMcYXOt5Jian-wuP9AA_rXesBmw@mail.gmail.com","threadId":"33991","inReplyTo":"7vzjv7glrw.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 3/4] unpack-trees: trivial cleanup","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-06-03T20:51:03Z","receivedAt":"2013-06-03T20:51:03Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Mon, Jun 3, 2013 at 12:13 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> dfc has not been initialized at this point.\n>>\n>> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n>> ---\n>\n> Upon the first entry to this function, because dfc is\n>\n>         static struct cache_entry *dfc;\n\nAh, I didn't notice it's static. Smells error-prone, but I guess it's\nOK for now.\n\n-- \nFelipe Contreras\n"}]}