On Tue, May 13, 2014 at 1:15 PM, Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> wrote: > The daemon would immediately load the new index in memory in > background. Next time Git needs to read the index again, everything is > ready. > > Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> > --- > cache.h | 1 + > read-cache.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++----- > 2 files changed, 49 insertions(+), 5 deletions(-) > > diff --git a/cache.h b/cache.h > index fb29c7e..3115b86 100644 > --- a/cache.h > +++ b/cache.h > @@ -483,6 +483,7 @@ extern int is_index_unborn(struct index_state *); > extern int read_index_unmerged(struct index_state *); > #define COMMIT_LOCK (1 << 0) > #define CLOSE_LOCK (1 << 1) > +#define REFRESH_DAEMON (1 << 2) > extern int write_locked_index(struct index_state *, struct lock_file *lock, unsigned flags); > extern int discard_index(struct index_state *); > extern int unmerged_index(const struct index_state *); > diff --git a/read-cache.c b/read-cache.c > index e98521f..d5c9247 100644 > --- a/read-cache.c > +++ b/read-cache.c > @@ -16,6 +16,9 @@ > #include "varint.h" > #include "split-index.h" > #include "sigchain.h" > +#include "unix-socket.h" > +#include "pkt-line.h" > +#include "run-command.h" > > static struct cache_entry *refresh_cache_entry(struct cache_entry *ce, > unsigned int options); > @@ -2030,6 +2033,32 @@ void set_alternate_index_output(const char *name) > alternate_index_output = name; > } > > +static void refresh_daemon(struct index_state *istate) > +{ > + int fd; > + fd = unix_stream_connect(git_path("daemon/index")); > + if (fd < 0) { > + struct child_process cp; > + const char *av[] = {"read-cache--daemon", "--detach", NULL }; > + memset(&cp, 0, sizeof(cp)); > + cp.argv = av; > + cp.git_cmd = 1; > + cp.no_stdin = 1; > + if (run_command(&cp)) > + warning(_("failed to start read-cache--daemon: %s"), > + strerror(errno)); > + return; > + } > + /* > + * packet_write() could die() but unless this is from > + * update_index_if_able(), we're about to exit anyway, > + * probably ok to die (for now). Blocking mode is another > + * problem to deal with later. > + */ > + packet_write(fd, "refresh"); > + close(fd); > +} > + Seems the argument 'istate' isn't used. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html