{"thread":{"id":"37060","subject":"[PATCH 1/2] symlinks: remove PATH_MAX limitation","startedAt":"2014-07-04T22:41:46Z","lastAt":"2014-07-14T04:29:51Z","messageCount":16,"participants":["Karsten Blees","Johannes Schindelin","Duy Nguyen","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"245413","messageId":"53B72DAA.5050007@gmail.com","threadId":"37060","inReplyTo":null,"subject":"[PATCH 1/2] symlinks: remove PATH_MAX limitation","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-07-04T22:41:46Z","receivedAt":"2014-07-04T22:41:46Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"'git checkout' fails if a directory is longer than PATH_MAX, because the\nlstat_cache in symlinks.c checks if the leading directory exists using\nPATH_MAX-bounded string operations.\n\nRemove the limitation by using strbuf instead.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\n---\n\nThis fixes a bug on Windows with long paths [1].\n\n[1] https://github.com/msysgit/msysgit/issues/227\n\n cache.h         |  8 ++++++--\n preload-index.c |  4 ++--\n symlinks.c      | 63 +++++++++++++++++++++++++--------------------------------\n 3 files changed, 36 insertions(+), 39 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex df65231..44aa439 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1090,12 +1090,16 @@ struct checkout {\n extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath);\n \n struct cache_def {\n-\tchar path[PATH_MAX + 1];\n-\tint len;\n+\tstruct strbuf path;\n \tint flags;\n \tint track_flags;\n \tint prefix_len_stat_func;\n };\n+#define CACHE_DEF_INIT { STRBUF_INIT, 0, 0, 0 }\n+static inline void cache_def_free(struct cache_def *cache)\n+{\n+\tstrbuf_release(&cache->path);\n+}\n \n extern int has_symlink_leading_path(const char *name, int len);\n extern int threaded_has_symlink_leading_path(struct cache_def *, const char *, int);\ndiff --git a/preload-index.c b/preload-index.c\nindex 968ee25..79ce8a9 100644\n--- a/preload-index.c\n+++ b/preload-index.c\n@@ -37,9 +37,8 @@ static void *preload_thread(void *_data)\n \tstruct thread_data *p = _data;\n \tstruct index_state *index = p->index;\n \tstruct cache_entry **cep = index->cache + p->offset;\n-\tstruct cache_def cache;\n+\tstruct cache_def cache = CACHE_DEF_INIT;\n \n-\tmemset(&cache, 0, sizeof(cache));\n \tnr = p->nr;\n \tif (nr + p->offset > index->cache_nr)\n \t\tnr = index->cache_nr - p->offset;\n@@ -64,6 +63,7 @@ static void *preload_thread(void *_data)\n \t\t\tcontinue;\n \t\tce_mark_uptodate(ce);\n \t} while (--nr > 0);\n+\tcache_def_free(&cache);\n \treturn NULL;\n }\n \ndiff --git a/symlinks.c b/symlinks.c\nindex c2b41a8..5261e8c 100644\n--- a/symlinks.c\n+++ b/symlinks.c\n@@ -35,12 +35,11 @@ static int longest_path_match(const char *name_a, int len_a,\n \treturn match_len;\n }\n \n-static struct cache_def default_cache;\n+static struct cache_def default_cache = CACHE_DEF_INIT;\n \n static inline void reset_lstat_cache(struct cache_def *cache)\n {\n-\tcache->path[0] = '\\0';\n-\tcache->len = 0;\n+\tstrbuf_reset(&cache->path);\n \tcache->flags = 0;\n \t/*\n \t * The track_flags and prefix_len_stat_func members is only\n@@ -73,7 +72,7 @@ static int lstat_cache_matchlen(struct cache_def *cache,\n \t\t\t\tint prefix_len_stat_func)\n {\n \tint match_len, last_slash, last_slash_dir, previous_slash;\n-\tint save_flags, max_len, ret;\n+\tint save_flags, ret;\n \tstruct stat st;\n \n \tif (cache->track_flags != track_flags ||\n@@ -93,14 +92,14 @@ static int lstat_cache_matchlen(struct cache_def *cache,\n \t\t * the 2 \"excluding\" path types.\n \t\t */\n \t\tmatch_len = last_slash =\n-\t\t\tlongest_path_match(name, len, cache->path, cache->len,\n-\t\t\t\t\t   &previous_slash);\n+\t\t\tlongest_path_match(name, len, cache->path.buf,\n+\t\t\t\t\t   cache->path.len, &previous_slash);\n \t\t*ret_flags = cache->flags & track_flags & (FL_NOENT|FL_SYMLINK);\n \n \t\tif (!(track_flags & FL_FULLPATH) && match_len == len)\n \t\t\tmatch_len = last_slash = previous_slash;\n \n-\t\tif (*ret_flags && match_len == cache->len)\n+\t\tif (*ret_flags && match_len == cache->path.len)\n \t\t\treturn match_len;\n \t\t/*\n \t\t * If we now have match_len > 0, we would know that\n@@ -121,21 +120,22 @@ static int lstat_cache_matchlen(struct cache_def *cache,\n \t */\n \t*ret_flags = FL_DIR;\n \tlast_slash_dir = last_slash;\n-\tmax_len = len < PATH_MAX ? len : PATH_MAX;\n-\twhile (match_len < max_len) {\n+\tif (len > cache->path.len)\n+\t\tstrbuf_grow(&cache->path, len - cache->path.len);\n+\twhile (match_len < len) {\n \t\tdo {\n-\t\t\tcache->path[match_len] = name[match_len];\n+\t\t\tcache->path.buf[match_len] = name[match_len];\n \t\t\tmatch_len++;\n-\t\t} while (match_len < max_len && name[match_len] != '/');\n-\t\tif (match_len >= max_len && !(track_flags & FL_FULLPATH))\n+\t\t} while (match_len < len && name[match_len] != '/');\n+\t\tif (match_len >= len && !(track_flags & FL_FULLPATH))\n \t\t\tbreak;\n \t\tlast_slash = match_len;\n-\t\tcache->path[last_slash] = '\\0';\n+\t\tcache->path.buf[last_slash] = '\\0';\n \n \t\tif (last_slash <= prefix_len_stat_func)\n-\t\t\tret = stat(cache->path, &st);\n+\t\t\tret = stat(cache->path.buf, &st);\n \t\telse\n-\t\t\tret = lstat(cache->path, &st);\n+\t\t\tret = lstat(cache->path.buf, &st);\n \n \t\tif (ret) {\n \t\t\t*ret_flags = FL_LSTATERR;\n@@ -158,12 +158,11 @@ static int lstat_cache_matchlen(struct cache_def *cache,\n \t * for the moment!\n \t */\n \tsave_flags = *ret_flags & track_flags & (FL_NOENT|FL_SYMLINK);\n-\tif (save_flags && last_slash > 0 && last_slash <= PATH_MAX) {\n-\t\tcache->path[last_slash] = '\\0';\n-\t\tcache->len = last_slash;\n+\tif (save_flags && last_slash > 0) {\n+\t\tcache->path.buf[last_slash] = '\\0';\n+\t\tcache->path.len = last_slash;\n \t\tcache->flags = save_flags;\n-\t} else if ((track_flags & FL_DIR) &&\n-\t\t   last_slash_dir > 0 && last_slash_dir <= PATH_MAX) {\n+\t} else if ((track_flags & FL_DIR) && last_slash_dir > 0) {\n \t\t/*\n \t\t * We have a separate test for the directory case,\n \t\t * since it could be that we have found a symlink or a\n@@ -175,8 +174,8 @@ static int lstat_cache_matchlen(struct cache_def *cache,\n \t\t * can still cache the path components before the last\n \t\t * one (the found symlink or non-existing component).\n \t\t */\n-\t\tcache->path[last_slash_dir] = '\\0';\n-\t\tcache->len = last_slash_dir;\n+\t\tcache->path.buf[last_slash_dir] = '\\0';\n+\t\tcache->path.len = last_slash_dir;\n \t\tcache->flags = FL_DIR;\n \t} else {\n \t\treset_lstat_cache(cache);\n@@ -273,21 +272,18 @@ static int threaded_has_dirs_only_path(struct cache_def *cache, const char *name\n \t\tFL_DIR;\n }\n \n-static struct removal_def {\n-\tchar path[PATH_MAX];\n-\tint len;\n-} removal;\n+static struct strbuf removal = STRBUF_INIT;\n \n static void do_remove_scheduled_dirs(int new_len)\n {\n \twhile (removal.len > new_len) {\n-\t\tremoval.path[removal.len] = '\\0';\n-\t\tif (rmdir(removal.path))\n+\t\tremoval.buf[removal.len] = '\\0';\n+\t\tif (rmdir(removal.buf))\n \t\t\tbreak;\n \t\tdo {\n \t\t\tremoval.len--;\n \t\t} while (removal.len > new_len &&\n-\t\t\t removal.path[removal.len] != '/');\n+\t\t\t removal.buf[removal.len] != '/');\n \t}\n \tremoval.len = new_len;\n }\n@@ -297,7 +293,7 @@ void schedule_dir_for_removal(const char *name, int len)\n \tint match_len, last_slash, i, previous_slash;\n \n \tmatch_len = last_slash = i =\n-\t\tlongest_path_match(name, len, removal.path, removal.len,\n+\t\tlongest_path_match(name, len, removal.buf, removal.len,\n \t\t\t\t   &previous_slash);\n \t/* Find last slash inside 'name' */\n \twhile (i < len) {\n@@ -317,11 +313,8 @@ void schedule_dir_for_removal(const char *name, int len)\n \t * If we go deeper down the directory tree, we only need to\n \t * save the new path components as we go down.\n \t */\n-\tif (match_len < last_slash) {\n-\t\tmemcpy(&removal.path[match_len], &name[match_len],\n-\t\t       last_slash - match_len);\n-\t\tremoval.len = last_slash;\n-\t}\n+\tif (match_len < last_slash)\n+\t\tstrbuf_add(&removal, &name[match_len], last_slash - match_len);\n }\n \n void remove_scheduled_dirs(void)\n-- \n1.9.4.msysgit.0.5.g1471ac1\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"245414","messageId":"53B72DD5.6020603@gmail.com","threadId":"37060","inReplyTo":"53B72DAA.5050007@gmail.com","subject":"[PATCH 2/2] dir: remove PATH_MAX limitation","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-07-04T22:42:29Z","receivedAt":"2014-07-04T22:42:29Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"'git status' segfaults if a directory is longer than PATH_MAX, because\nprocessing .gitignore files in prep_exclude() writes past the end of a\nPATH_MAX-bounded buffer.\n\nRemove the limitation by using strbuf instead.\n\nNote: this fix just 'abuses' strbuf as string allocator, len is always 0.\nprep_exclude() can probably be simplified using more strbuf APIs.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\n---\n dir.c | 35 +++++++++++++++++++----------------\n dir.h |  4 ++--\n 2 files changed, 21 insertions(+), 18 deletions(-)\n\ndiff --git a/dir.c b/dir.c\nindex e65888d..8d4d83c 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -798,7 +798,7 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)\n \t * path being checked. */\n \twhile ((stk = dir->exclude_stack) != NULL) {\n \t\tif (stk->baselen <= baselen &&\n-\t\t    !strncmp(dir->basebuf, base, stk->baselen))\n+\t\t    !strncmp(dir->base.buf, base, stk->baselen))\n \t\t\tbreak;\n \t\tel = &group->el[dir->exclude_stack->exclude_ix];\n \t\tdir->exclude_stack = stk->prev;\n@@ -833,48 +833,50 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)\n \t\tstk->baselen = cp - base;\n \t\tstk->exclude_ix = group->nr;\n \t\tel = add_exclude_list(dir, EXC_DIRS, NULL);\n-\t\tmemcpy(dir->basebuf + current, base + current,\n+\t\tstrbuf_grow(&dir->base, stk->baselen);\n+\t\tmemcpy(dir->base.buf + current, base + current,\n \t\t       stk->baselen - current);\n \n \t\t/* Abort if the directory is excluded */\n \t\tif (stk->baselen) {\n \t\t\tint dt = DT_DIR;\n-\t\t\tdir->basebuf[stk->baselen - 1] = 0;\n+\t\t\tdir->base.buf[stk->baselen - 1] = 0;\n \t\t\tdir->exclude = last_exclude_matching_from_lists(dir,\n-\t\t\t\tdir->basebuf, stk->baselen - 1,\n-\t\t\t\tdir->basebuf + current, &dt);\n-\t\t\tdir->basebuf[stk->baselen - 1] = '/';\n+\t\t\t\tdir->base.buf, stk->baselen - 1,\n+\t\t\t\tdir->base.buf + current, &dt);\n+\t\t\tdir->base.buf[stk->baselen - 1] = '/';\n \t\t\tif (dir->exclude &&\n \t\t\t    dir->exclude->flags & EXC_FLAG_NEGATIVE)\n \t\t\t\tdir->exclude = NULL;\n \t\t\tif (dir->exclude) {\n-\t\t\t\tdir->basebuf[stk->baselen] = 0;\n+\t\t\t\tdir->base.buf[stk->baselen] = 0;\n \t\t\t\tdir->exclude_stack = stk;\n \t\t\t\treturn;\n \t\t\t}\n \t\t}\n \n-\t\t/* Try to read per-directory file unless path is too long */\n-\t\tif (dir->exclude_per_dir &&\n-\t\t    stk->baselen + strlen(dir->exclude_per_dir) < PATH_MAX) {\n-\t\t\tstrcpy(dir->basebuf + stk->baselen,\n+\t\t/* Try to read per-directory file */\n+\t\tif (dir->exclude_per_dir) {\n+\t\t\tstrbuf_grow(&dir->base, stk->baselen +\n+\t\t\t\t    strlen(dir->exclude_per_dir));\n+\t\t\tstrcpy(dir->base.buf + stk->baselen,\n \t\t\t\t\tdir->exclude_per_dir);\n \t\t\t/*\n-\t\t\t * dir->basebuf gets reused by the traversal, but we\n+\t\t\t * dir->base gets reused by the traversal, but we\n \t\t\t * need fname to remain unchanged to ensure the src\n \t\t\t * member of each struct exclude correctly\n \t\t\t * back-references its source file.  Other invocations\n \t\t\t * of add_exclude_list provide stable strings, so we\n \t\t\t * strdup() and free() here in the caller.\n \t\t\t */\n-\t\t\tel->src = strdup(dir->basebuf);\n-\t\t\tadd_excludes_from_file_to_list(dir->basebuf,\n-\t\t\t\t\tdir->basebuf, stk->baselen, el, 1);\n+\t\t\tel->src = strdup(dir->base.buf);\n+\t\t\tadd_excludes_from_file_to_list(dir->base.buf,\n+\t\t\t\t\tdir->base.buf, stk->baselen, el, 1);\n \t\t}\n \t\tdir->exclude_stack = stk;\n \t\tcurrent = stk->baselen;\n \t}\n-\tdir->basebuf[baselen] = '\\0';\n+\tdir->base.buf[baselen] = '\\0';\n }\n \n /*\n@@ -1671,4 +1673,5 @@ void clear_directory(struct dir_struct *dir)\n \t\tfree(stk);\n \t\tstk = prev;\n \t}\n+\tstrbuf_release(&dir->base);\n }\ndiff --git a/dir.h b/dir.h\nindex 55e5345..e870fb6 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -111,13 +111,13 @@ struct dir_struct {\n \t * per-directory exclude lists.\n \t *\n \t * exclude_stack points to the top of the exclude_stack, and\n-\t * basebuf contains the full path to the current\n+\t * base contains the full path to the current\n \t * (sub)directory in the traversal. Exclude points to the\n \t * matching exclude struct if the directory is excluded.\n \t */\n \tstruct exclude_stack *exclude_stack;\n \tstruct exclude *exclude;\n-\tchar basebuf[PATH_MAX];\n+\tstruct strbuf base;\n };\n \n /*\n-- \n1.9.4.msysgit.0.5.g1471ac1\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"245423","messageId":"alpine.DEB.1.00.1407050449220.14982@s15462909.onlinehome-server.info","threadId":"37060","inReplyTo":"53B72DAA.5050007@gmail.com","subject":"Re: [PATCH 1/2] symlinks: remove PATH_MAX limitation","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2014-07-05T02:52:56Z","receivedAt":"2014-07-05T02:52:56Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 5 Jul 2014, Karsten Blees wrote:\n\n> 'git checkout' fails if a directory is longer than PATH_MAX, because the\n> lstat_cache in symlinks.c checks if the leading directory exists using\n> PATH_MAX-bounded string operations.\n> \n> Remove the limitation by using strbuf instead.\n> \n> Signed-off-by: Karsten Blees <blees@dcon.de>\n> ---\n> \n> This fixes a bug on Windows with long paths [1].\n> \n> [1] https://github.com/msysgit/msysgit/issues/227\n\nFor context: on Windows, PATH_MAX is ridiculously small. And it really is\nthat small, file functions of the Win32 API cannot handle longer paths.\n\nHowever, there is a (pretty ugly, if you ask me) workaround: prefixing the\npaths with \"\\\\?\\\" and lo and behold, *many* (but not all) Win32 API\nfunctions can then handle paths up to something around 32,000 characters!\n\nThe problem Karsten addressed here is caused exactly by this oddity: we\n*can* handle paths much longer than PATH_MAX. Therefore, we need to\ndecouple the path buffers from that hardcoded limitation.\n\nKarsten, you rock.\n\nCiao,\nDscho\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"245424","messageId":"CACsJy8AXAusNHb5GJgrcbgzXY-1_ER2CNmah=vkJzOgPHMHudA@mail.gmail.com","threadId":"37060","inReplyTo":"53B72DD5.6020603@gmail.com","subject":"Re: [PATCH 2/2] dir: remove PATH_MAX limitation","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2014-07-05T10:48:49Z","receivedAt":"2014-07-05T10:48:49Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Jul 5, 2014 at 5:42 AM, Karsten Blees <karsten.blees@gmail.com> wrote:\n> 'git status' segfaults if a directory is longer than PATH_MAX, because\n> processing .gitignore files in prep_exclude() writes past the end of a\n> PATH_MAX-bounded buffer.\n>\n> Remove the limitation by using strbuf instead.\n>\n> Note: this fix just 'abuses' strbuf as string allocator, len is always 0.\n> prep_exclude() can probably be simplified using more strbuf APIs.\n\nFYI I had a similar patch [1] that attempted to lazily strbuf_init()\ninstead so that strbuf_ API could be used.\n\n[1] http://article.gmane.org/gmane.comp.version-control.git/248310\n-- \nDuy\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"245486","messageId":"xmqqsimdc988.fsf@gitster.dls.corp.google.com","threadId":"37060","inReplyTo":"53B72DAA.5050007@gmail.com","subject":"Re: [PATCH 1/2] symlinks: remove PATH_MAX limitation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-07-07T18:30:30Z","receivedAt":"2014-07-07T18:30:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karsten Blees <karsten.blees@gmail.com> writes:\n\n> 'git checkout' fails if a directory is longer than PATH_MAX, because the\n> lstat_cache in symlinks.c checks if the leading directory exists using\n> PATH_MAX-bounded string operations.\n>\n> Remove the limitation by using strbuf instead.\n\nGood.\n\n> diff --git a/cache.h b/cache.h\n> index df65231..44aa439 100644\n> --- a/cache.h\n> +++ b/cache.h\n> @@ -1090,12 +1090,16 @@ struct checkout {\n>  extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath);\n>  \n>  struct cache_def {\n> -\tchar path[PATH_MAX + 1];\n> -\tint len;\n> +\tstruct strbuf path;\n>  \tint flags;\n>  \tint track_flags;\n>  \tint prefix_len_stat_func;\n>  };\n> +#define CACHE_DEF_INIT { STRBUF_INIT, 0, 0, 0 }\n> +static inline void cache_def_free(struct cache_def *cache)\n> +{\n> +\tstrbuf_release(&cache->path);\n> +}\n\nThe above cache_def_free(cache) does not free the cache itself, but\nonly its associated data, so the name cache_def_free() is somewhat\nmisleading.\n\nIt seems that we use the name that consists solely of \"something\"\nand \"free\" if the pointer to \"something\" itself is also freed.  For\nexample \"diff_free_filespec_data(struct diff_filespec *)\" frees data\nassociated with the filespec but not the filespec itself, which is\ndone with \"diff_free_filespec()\".\n\nAnother name that may not be misleading would be cache_def_clear();\nI think I'd prefer it over cache_def_free_data().\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"245570","messageId":"20140709054215.GE2318@sigill.intra.peff.net","threadId":"37060","inReplyTo":"53B72DD5.6020603@gmail.com","subject":"Re: [PATCH 2/2] dir: remove PATH_MAX limitation","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-07-09T05:42:16Z","receivedAt":"2014-07-09T05:42:16Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Jul 05, 2014 at 12:42:29AM +0200, Karsten Blees wrote:\n\n> Note: this fix just 'abuses' strbuf as string allocator, len is always 0.\n> prep_exclude() can probably be simplified using more strbuf APIs.\n\nHrm. It looks like you grow it and add some data, but really don't want\nthe length to expand (because the caller depends on it).\n\nIn other directory-traversal code we follow a pattern like:\n\n  size_t prefix_len = dir->base.len;\n\n  strbuf_add(&dir->base, cp, stk->baselen - current);\n  /* use full path in dir->base, then \"pop\" */\n  strbuf_setlen(&dir->base, stk->baselen);\n\nThat makes it a little more obvious that the memcpy matches the\nstrbuf_grow (because it all happens inside strbuf_add).\n\nIs it possible to do something like that here?\n\n-Peff\n"},{"id":"245639","messageId":"xmqqa98i7aqt.fsf@gitster.dls.corp.google.com","threadId":"37060","inReplyTo":"53B72DD5.6020603@gmail.com","subject":"Re: [PATCH 2/2] dir: remove PATH_MAX limitation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-07-09T16:33:30Z","receivedAt":"2014-07-09T16:33:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karsten Blees <karsten.blees@gmail.com> writes:\n\n> 'git status' segfaults if a directory is longer than PATH_MAX, because\n> processing .gitignore files in prep_exclude() writes past the end of a\n> PATH_MAX-bounded buffer.\n>\n> Remove the limitation by using strbuf instead.\n>\n> Note: this fix just 'abuses' strbuf as string allocator, len is always 0.\n> prep_exclude() can probably be simplified using more strbuf APIs.\n\nIn addition to what Jeff already said, I am afraid that this may\nmake things a lot worse for normal case.  By sizing the strbuf to\nabsolute minimum as you dig deeper at each level, wouldn't you copy\nand reallocate the buffer a lot more, compared to the case where\neverything fits in the original buffer?\n\n\n> Signed-off-by: Karsten Blees <blees@dcon.de>\n> ---\n>  dir.c | 35 +++++++++++++++++++----------------\n>  dir.h |  4 ++--\n>  2 files changed, 21 insertions(+), 18 deletions(-)\n>\n> diff --git a/dir.c b/dir.c\n> index e65888d..8d4d83c 100644\n> --- a/dir.c\n> +++ b/dir.c\n> @@ -798,7 +798,7 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)\n>  \t * path being checked. */\n>  \twhile ((stk = dir->exclude_stack) != NULL) {\n>  \t\tif (stk->baselen <= baselen &&\n> -\t\t    !strncmp(dir->basebuf, base, stk->baselen))\n> +\t\t    !strncmp(dir->base.buf, base, stk->baselen))\n>  \t\t\tbreak;\n>  \t\tel = &group->el[dir->exclude_stack->exclude_ix];\n>  \t\tdir->exclude_stack = stk->prev;\n> @@ -833,48 +833,50 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)\n>  \t\tstk->baselen = cp - base;\n>  \t\tstk->exclude_ix = group->nr;\n>  \t\tel = add_exclude_list(dir, EXC_DIRS, NULL);\n> -\t\tmemcpy(dir->basebuf + current, base + current,\n> +\t\tstrbuf_grow(&dir->base, stk->baselen);\n> +\t\tmemcpy(dir->base.buf + current, base + current,\n>  \t\t       stk->baselen - current);\n>  \n>  \t\t/* Abort if the directory is excluded */\n>  \t\tif (stk->baselen) {\n>  \t\t\tint dt = DT_DIR;\n> -\t\t\tdir->basebuf[stk->baselen - 1] = 0;\n> +\t\t\tdir->base.buf[stk->baselen - 1] = 0;\n>  \t\t\tdir->exclude = last_exclude_matching_from_lists(dir,\n> -\t\t\t\tdir->basebuf, stk->baselen - 1,\n> -\t\t\t\tdir->basebuf + current, &dt);\n> -\t\t\tdir->basebuf[stk->baselen - 1] = '/';\n> +\t\t\t\tdir->base.buf, stk->baselen - 1,\n> +\t\t\t\tdir->base.buf + current, &dt);\n> +\t\t\tdir->base.buf[stk->baselen - 1] = '/';\n>  \t\t\tif (dir->exclude &&\n>  \t\t\t    dir->exclude->flags & EXC_FLAG_NEGATIVE)\n>  \t\t\t\tdir->exclude = NULL;\n>  \t\t\tif (dir->exclude) {\n> -\t\t\t\tdir->basebuf[stk->baselen] = 0;\n> +\t\t\t\tdir->base.buf[stk->baselen] = 0;\n>  \t\t\t\tdir->exclude_stack = stk;\n>  \t\t\t\treturn;\n>  \t\t\t}\n>  \t\t}\n>  \n> -\t\t/* Try to read per-directory file unless path is too long */\n> -\t\tif (dir->exclude_per_dir &&\n> -\t\t    stk->baselen + strlen(dir->exclude_per_dir) < PATH_MAX) {\n> -\t\t\tstrcpy(dir->basebuf + stk->baselen,\n> +\t\t/* Try to read per-directory file */\n> +\t\tif (dir->exclude_per_dir) {\n> +\t\t\tstrbuf_grow(&dir->base, stk->baselen +\n> +\t\t\t\t    strlen(dir->exclude_per_dir));\n> +\t\t\tstrcpy(dir->base.buf + stk->baselen,\n>  \t\t\t\t\tdir->exclude_per_dir);\n>  \t\t\t/*\n> -\t\t\t * dir->basebuf gets reused by the traversal, but we\n> +\t\t\t * dir->base gets reused by the traversal, but we\n>  \t\t\t * need fname to remain unchanged to ensure the src\n>  \t\t\t * member of each struct exclude correctly\n>  \t\t\t * back-references its source file.  Other invocations\n>  \t\t\t * of add_exclude_list provide stable strings, so we\n>  \t\t\t * strdup() and free() here in the caller.\n>  \t\t\t */\n> -\t\t\tel->src = strdup(dir->basebuf);\n> -\t\t\tadd_excludes_from_file_to_list(dir->basebuf,\n> -\t\t\t\t\tdir->basebuf, stk->baselen, el, 1);\n> +\t\t\tel->src = strdup(dir->base.buf);\n> +\t\t\tadd_excludes_from_file_to_list(dir->base.buf,\n> +\t\t\t\t\tdir->base.buf, stk->baselen, el, 1);\n>  \t\t}\n>  \t\tdir->exclude_stack = stk;\n>  \t\tcurrent = stk->baselen;\n>  \t}\n> -\tdir->basebuf[baselen] = '\\0';\n> +\tdir->base.buf[baselen] = '\\0';\n>  }\n>  \n>  /*\n> @@ -1671,4 +1673,5 @@ void clear_directory(struct dir_struct *dir)\n>  \t\tfree(stk);\n>  \t\tstk = prev;\n>  \t}\n> +\tstrbuf_release(&dir->base);\n>  }\n> diff --git a/dir.h b/dir.h\n> index 55e5345..e870fb6 100644\n> --- a/dir.h\n> +++ b/dir.h\n> @@ -111,13 +111,13 @@ struct dir_struct {\n>  \t * per-directory exclude lists.\n>  \t *\n>  \t * exclude_stack points to the top of the exclude_stack, and\n> -\t * basebuf contains the full path to the current\n> +\t * base contains the full path to the current\n>  \t * (sub)directory in the traversal. Exclude points to the\n>  \t * matching exclude struct if the directory is excluded.\n>  \t */\n>  \tstruct exclude_stack *exclude_stack;\n>  \tstruct exclude *exclude;\n> -\tchar basebuf[PATH_MAX];\n> +\tstruct strbuf base;\n>  };\n>  \n>  /*\n> -- \n> 1.9.4.msysgit.0.5.g1471ac1\n>\n> -- \n"},{"id":"245818","messageId":"53C036C3.10103@gmail.com","threadId":"37060","inReplyTo":"CACsJy8AXAusNHb5GJgrcbgzXY-1_ER2CNmah=vkJzOgPHMHudA@mail.gmail.com","subject":"Re: [PATCH 2/2] dir: remove PATH_MAX limitation","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-07-11T19:10:59Z","receivedAt":"2014-07-11T19:10:59Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Am 05.07.2014 12:48, schrieb Duy Nguyen:\n> On Sat, Jul 5, 2014 at 5:42 AM, Karsten Blees <karsten.blees@gmail.com> wrote:\n>> 'git status' segfaults if a directory is longer than PATH_MAX, because\n>> processing .gitignore files in prep_exclude() writes past the end of a\n>> PATH_MAX-bounded buffer.\n>>\n>> Remove the limitation by using strbuf instead.\n>>\n>> Note: this fix just 'abuses' strbuf as string allocator, len is always 0.\n>> prep_exclude() can probably be simplified using more strbuf APIs.\n> \n> FYI I had a similar patch [1] that attempted to lazily strbuf_init()\n> instead so that strbuf_ API could be used.\n> \n> [1] http://article.gmane.org/gmane.comp.version-control.git/248310\n> \n\nSorry, I missed that one.\n\nIn my version, strbuf_grow() does the lazy initialization (in fact, many\nstrbuf_* functions can handle memset(0) strbufs just fine).\n\nI was simply too lazy to understand (again) how prep_exclude works exactly, and\nas string calculations like that have the tendency to be just 1 char off, I went\nfor the obviously correct solution (i.e. s/dir->basebuf/dir->base.buf/ plus\nstrbuf_grow() before we write the buffer).\n\nBut IMO your version is much cleaner already.\n\nHowever, api-strbuf.txt says that buf != NULL is invariant after init, and\nalloc is \"somehow private\" :-) , so perhaps you should\n\n-\tif (!dir->basebuf.alloc)\n+\tif (!dir->basebuf.buf)\n\t\tstrbuf_init(&dir->basebuf, PATH_MAX);\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"245819","messageId":"53C036CD.902@gmail.com","threadId":"37060","inReplyTo":"xmqqa98i7aqt.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 2/2] dir: remove PATH_MAX limitation","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-07-11T19:11:09Z","receivedAt":"2014-07-11T19:11:09Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Am 09.07.2014 18:33, schrieb Junio C Hamano:\n> Karsten Blees <karsten.blees@gmail.com> writes:\n> \n>> 'git status' segfaults if a directory is longer than PATH_MAX, because\n>> processing .gitignore files in prep_exclude() writes past the end of a\n>> PATH_MAX-bounded buffer.\n>>\n>> Remove the limitation by using strbuf instead.\n>>\n>> Note: this fix just 'abuses' strbuf as string allocator, len is always 0.\n>> prep_exclude() can probably be simplified using more strbuf APIs.\n> \n> In addition to what Jeff already said, I am afraid that this may\n> make things a lot worse for normal case.  By sizing the strbuf to\n> absolute minimum as you dig deeper at each level, wouldn't you copy\n> and reallocate the buffer a lot more, compared to the case where\n> everything fits in the original buffer?\n> \n\nstrbuf uses ALLOC_GROW, which resizes in (x+16)*1.5 steps (i.e. 24, 60, 114,\n195, 316...). Max path len in git is 85, and linux and WebKit are 170ish. I\ndon't think three or four extra reallocs per directory traversal will be\nnoticeable.\n\nAnyways, I'd like to kindly withdraw this patch in favor of Duy's version.\n\nhttp://article.gmane.org/gmane.comp.version-control.git/248310\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"245820","messageId":"53C036DB.7000505@gmail.com","threadId":"37060","inReplyTo":"xmqqsimdc988.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 1/2] symlinks: remove PATH_MAX limitation","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-07-11T19:11:23Z","receivedAt":"2014-07-11T19:11:23Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Am 07.07.2014 20:30, schrieb Junio C Hamano:\n> Karsten Blees <karsten.blees@gmail.com> writes:\n> \n> The above cache_def_free(cache) does not free the cache itself, but\n> only its associated data, so the name cache_def_free() is somewhat\n> misleading.\n> \n\nYou already merged this to master (\"kb/path-max-must-go\" lol), should\nI send a fixup! s/cache_def_free/cache_def_clear/ or is it OK as is?\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"245838","messageId":"xmqqd2db35dm.fsf@gitster.dls.corp.google.com","threadId":"37060","inReplyTo":"53C036DB.7000505@gmail.com","subject":"Re: [PATCH 1/2] symlinks: remove PATH_MAX limitation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-07-11T22:19:49Z","receivedAt":"2014-07-11T22:19:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karsten Blees <karsten.blees@gmail.com> writes:\n\n> Am 07.07.2014 20:30, schrieb Junio C Hamano:\n>> Karsten Blees <karsten.blees@gmail.com> writes:\n>> \n>> The above cache_def_free(cache) does not free the cache itself, but\n>> only its associated data, so the name cache_def_free() is somewhat\n>> misleading.\n>> \n>\n> You already merged this to master (\"kb/path-max-must-go\" lol), should\n> I send a fixup! s/cache_def_free/cache_def_clear/ or is it OK as is?\n\nI do not think a fix-up would hurt other topics in flight, so\nplease do so.\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"245841","messageId":"xmqq4myn34xo.fsf@gitster.dls.corp.google.com","threadId":"37060","inReplyTo":"53C036CD.902@gmail.com","subject":"Re: [PATCH 2/2] dir: remove PATH_MAX limitation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-07-11T22:29:23Z","receivedAt":"2014-07-11T22:29:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karsten Blees <karsten.blees@gmail.com> writes:\n\n> Anyways, I'd like to kindly withdraw this patch in favor of Duy's version.\n>\n> http://article.gmane.org/gmane.comp.version-control.git/248310\n\nThanks; I've already reverted it from 'next'.\n\nIs Duy's patch still viable?\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"245850","messageId":"53C06D0A.2000704@gmail.com","threadId":"37060","inReplyTo":"xmqqd2db35dm.fsf@gitster.dls.corp.google.com","subject":"[PATCH] fixup! symlinks: remove PATH_MAX limitation","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-07-11T23:02:34Z","receivedAt":"2014-07-11T23:02:34Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Rename cache_def_free to cache_def_clear as it doesn't free the struct\ncache_def, but just clears its content.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\n---\n cache.h         | 2 +-\n preload-index.c | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 44aa439..378ee7f 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1096,7 +1096,7 @@ struct cache_def {\n \tint prefix_len_stat_func;\n };\n #define CACHE_DEF_INIT { STRBUF_INIT, 0, 0, 0 }\n-static inline void cache_def_free(struct cache_def *cache)\n+static inline void cache_def_clear(struct cache_def *cache)\n {\n \tstrbuf_release(&cache->path);\n }\ndiff --git a/preload-index.c b/preload-index.c\nindex 79ce8a9..c1fe3a3 100644\n--- a/preload-index.c\n+++ b/preload-index.c\n@@ -63,7 +63,7 @@ static void *preload_thread(void *_data)\n \t\t\tcontinue;\n \t\tce_mark_uptodate(ce);\n \t} while (--nr > 0);\n-\tcache_def_free(&cache);\n+\tcache_def_clear(&cache);\n \treturn NULL;\n }\n \n-- \n2.0.1.563.g66f467c.dirty\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"245856","messageId":"53C076B8.9030209@gmail.com","threadId":"37060","inReplyTo":"xmqq4myn34xo.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 2/2] dir: remove PATH_MAX limitation","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-07-11T23:43:52Z","receivedAt":"2014-07-11T23:43:52Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Am 12.07.2014 00:29, schrieb Junio C Hamano:\n> Karsten Blees <karsten.blees@gmail.com> writes:\n> \n>> Anyways, I'd like to kindly withdraw this patch in favor of Duy's version.\n>>\n>> http://article.gmane.org/gmane.comp.version-control.git/248310\n> \n> Thanks; I've already reverted it from 'next'.\n> \n> Is Duy's patch still viable?\n> \n\nI think so. It fixes the segfault with long paths on Windows as well\n(Tested-by: <me>), uses strbuf APIs as Peff suggested, and initializes the\nstrbuf with PATH_MAX (i.e. no reallocs in the common case either ;-) ).\n\nAFAICT the first two patches of that series are also completely unrelated\nto the untracked-cache, so we may want to fast-track these?\n\n[01/20] dir.c: coding style fix\n[02/20] dir.h: move struct exclude declaration to top level\n[03/20] prep_exclude: remove the artificial PATH_MAX limit\n\n...perhaps with s/if (!dir->basebuf.alloc)/if (!dir->basebuf.buf)/\n\n@Duy any reason for not signing off that series?\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"245878","messageId":"CACsJy8BOdQwht_b2D48cZP-NFosT2FxGg+hkEthsGBvW7EE=FQ@mail.gmail.com","threadId":"37060","inReplyTo":"53C076B8.9030209@gmail.com","subject":"Re: [PATCH 2/2] dir: remove PATH_MAX limitation","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2014-07-12T02:56:17Z","receivedAt":"2014-07-12T02:56:17Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Jul 12, 2014 at 6:43 AM, Karsten Blees <karsten.blees@gmail.com> wrote:\n> Am 12.07.2014 00:29, schrieb Junio C Hamano:\n>> Karsten Blees <karsten.blees@gmail.com> writes:\n>>\n>>> Anyways, I'd like to kindly withdraw this patch in favor of Duy's version.\n>>>\n>>> http://article.gmane.org/gmane.comp.version-control.git/248310\n>>\n>> Thanks; I've already reverted it from 'next'.\n>>\n>> Is Duy's patch still viable?\n>>\n>\n> I think so. It fixes the segfault with long paths on Windows as well\n> (Tested-by: <me>), uses strbuf APIs as Peff suggested, and initializes the\n> strbuf with PATH_MAX (i.e. no reallocs in the common case either ;-) ).\n>\n> AFAICT the first two patches of that series are also completely unrelated\n> to the untracked-cache, so we may want to fast-track these?\n>\n> [01/20] dir.c: coding style fix\n> [02/20] dir.h: move struct exclude declaration to top level\n> [03/20] prep_exclude: remove the artificial PATH_MAX limit\n>\n> ...perhaps with s/if (!dir->basebuf.alloc)/if (!dir->basebuf.buf)/\n>\n> @Duy any reason for not signing off that series?\n\nThat series still need a lot more work, but for those first three, if\nyou want to fast track, you have my sign-offs.\n-- \nDuy\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"245965","messageId":"xmqqzjgczhog.fsf@gitster.dls.corp.google.com","threadId":"37060","inReplyTo":"CACsJy8BOdQwht_b2D48cZP-NFosT2FxGg+hkEthsGBvW7EE=FQ@mail.gmail.com","subject":"Re: [PATCH 2/2] dir: remove PATH_MAX limitation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-07-14T04:29:51Z","receivedAt":"2014-07-14T04:29:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n>> [01/20] dir.c: coding style fix\n>> [02/20] dir.h: move struct exclude declaration to top level\n>> [03/20] prep_exclude: remove the artificial PATH_MAX limit\n>>\n>> ...perhaps with s/if (!dir->basebuf.alloc)/if (!dir->basebuf.buf)/\n>>\n>> @Duy any reason for not signing off that series?\n>\n> That series still need a lot more work, but for those first three, if\n> you want to fast track, you have my sign-offs.\n\nIf it is not too much trouble, can you send only the relevant\npatches (these three) with sign-off again?  I'd prefer to give\npatches a new chance to be eyeballed by people, and they will tend\nto have a better chance by being a smaller and an isolated topic.\n\nThanks.\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"}]}