Christian Couder <christian.cou...@gmail.com> writes: > Introduce set_index_file() to be able to temporarily change the index file. > > It should be used like this: > > /* Save current index file */ > old_index_file = get_index_file(); > set_index_file((char *)tmp_index_file); > > /* Do stuff that will use tmp_index_file as the index file */ > ... > > /* When finished reset the index file */ > set_index_file(old_index_file);
WHY is glaringly missing. > Signed-off-by: Christian Couder <chrisc...@tuxfamily.org> > --- Doesn't calling this have a global effect that is flowned upon when used by a library-ish function? Who is the expected caller in this series that wants to "libify" a part of the system? > cache.h | 1 + > environment.c | 10 ++++++++++ > 2 files changed, 11 insertions(+) > > diff --git a/cache.h b/cache.h > index c73becb..8854365 100644 > --- a/cache.h > +++ b/cache.h > @@ -461,6 +461,7 @@ extern int is_inside_work_tree(void); > extern const char *get_git_dir(void); > extern const char *get_git_common_dir(void); > extern char *get_object_directory(void); > +extern void set_index_file(char *index_file); > extern char *get_index_file(void); > extern char *get_graft_file(void); > extern int set_git_dir(const char *path); > diff --git a/environment.c b/environment.c > index ca72464..7a53799 100644 > --- a/environment.c > +++ b/environment.c > @@ -292,6 +292,16 @@ int odb_pack_keep(char *name, size_t namesz, const > unsigned char *sha1) > return open(name, O_RDWR|O_CREAT|O_EXCL, 0600); > } > > +/* > + * Temporarily change the index file. > + * Please save the current index file using get_index_file() before changing > + * the index file. And when finished, reset it to the saved value. > + */ > +void set_index_file(char *index_file) > +{ > + git_index_file = index_file; > +} > + > char *get_index_file(void) > { > if (!git_index_file) -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html