# # patch "git.cc" # from [78ab61d53da4bcf05d4fcffb563249d8a42d25fc] # to [d82e766ae0ad5cb94a3ca0a2d5f3d704b148adcd] # ======================================================================== --- git.cc 78ab61d53da4bcf05d4fcffb563249d8a42d25fc +++ git.cc d82e766ae0ad5cb94a3ca0a2d5f3d704b148adcd @@ -96,7 +96,7 @@ { const fs::path path; - filebuf &get_object(const string type, const git_object_id objid); + void get_object(const string type, const git_object_id objid, filebuf &fb); void get_object(const string type, const git_object_id objid, data &dat); // DAG of the revision ancestry in topological order @@ -130,8 +130,8 @@ // This should change to libgit calls in the future -static filebuf & -capture_cmd_output(boost::format const & fmt) +static void +capture_cmd_output(boost::format const & fmt, filebuf &fb) { string str; try @@ -155,25 +155,23 @@ L(F("Capturing cmd output: %s") % cmdline); N(system(cmdline.c_str()), F("git command %s failed") % str); - filebuf &fb = *new filebuf; fb.open(tmpfile.c_str(), ios::in); close(fd); fs::remove(tmpfile); - return fb; } -filebuf & -git_db::get_object(const string type, const git_object_id objid) +void +git_db::get_object(const string type, const git_object_id objid, filebuf &fb) { - filebuf &fb = capture_cmd_output(F("git-cat-file %s %s") % type % objid()); - return fb; + capture_cmd_output(F("git-cat-file %s %s") % type % objid(), fb); } void git_db::get_object(const string type, const git_object_id objid, data &dat) { - filebuf &fb = get_object(type, objid); + filebuf fb; + get_object(type, objid, fb); istream stream(&fb); Botan::Pipe pipe; @@ -181,7 +179,6 @@ stream >> pipe; pipe.end_msg(); dat = pipe.read_all_as_string(); - delete &fb; } @@ -193,8 +190,9 @@ i != exclude.end(); ++i) excludestr += " \"^" + (*i)() + "\""; - filebuf &fb = capture_cmd_output(F("git-rev-list --topo-order %s %s") - % revision % excludestr); + filebuf fb; + capture_cmd_output(F("git-rev-list --topo-order %s %s") + % revision % excludestr, fb); istream stream(&fb); stack st; @@ -208,7 +206,6 @@ st.push(git_object_id(string(revbuf))); } L(F("Loaded all revisions")); - delete &fb; return st; } @@ -466,7 +463,8 @@ import_git_commit(git_history &git, app_state &app, git_object_id gitrid) { L(F("Importing commit '%s'") % gitrid()); - filebuf &fb = git.db.get_object("commit", gitrid); + filebuf fb; + git.db.get_object("commit", gitrid, fb); istream stream(&fb); bool header = true; @@ -593,8 +591,6 @@ } } - delete &fb; - revision_id rid; calculate_ident(rev, rid); L(F("[%s] Monotone commit ID: '%s'") % gitrid() % rid.inner());