- Actual resolution of Bug #1001. The Edit command was actually changing
  the working directory without going back to the original one
  afterwards.
This commit is contained in:
Louis-Claude Canon 2012-06-30 17:23:33 +02:00 committed by Paul Beckingham
parent e1407437e0
commit b1e63e575a
3 changed files with 12 additions and 5 deletions

View file

@ -31,6 +31,7 @@
#include <fstream>
#include <sstream>
#include <algorithm>
#include <assert.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
@ -395,8 +396,8 @@ int Context::dispatch (std::string &out)
return rc;
}
if (commands["help"])
return commands["help"]->execute (out);
assert (commands["help"]);
return commands["help"]->execute (out);
return 1;
}

View file

@ -629,7 +629,6 @@ bool CmdEdit::editFile (Task& task)
// Create a temp file name in data.location.
std::stringstream file;
file << "task." << getpid () << "." << task.id << ".task";
std::string path = location._data + "/" + file.str ();
// Determine the output date format, which uses a hierarchy of definitions.
// rc.dateformat.edit
@ -638,10 +637,13 @@ bool CmdEdit::editFile (Task& task)
if (dateformat == "")
dateformat = context.config.get ("dateformat");
// Format the contents, T -> text, write to a file.
std::string before = formatTask (task, dateformat);
// Change directory for the editor
char* current_dir = get_current_dir_name ();
int ignored = chdir (location._data.c_str ());
++ignored; // Keep compiler quiet.
// Format the contents, T -> text, write to a file.
std::string before = formatTask (task, dateformat);
File::write (file.str (), before);
// Determine correct editor: .taskrc:editor > $VISUAL > $EDITOR > vi
@ -711,6 +713,8 @@ ARE_THESE_REALLY_HARMFUL:
// Cleanup.
File::remove (file.str ());
ignored = chdir (current_dir);
free (current_dir);
return changes;
}

View file

@ -32,6 +32,7 @@
#include <Context.h>
#include <Uri.h>
#include <Transport.h>
#include <assert.h>
#include <i18n.h>
#include <text.h>
#include <util.h>
@ -131,6 +132,7 @@ int CmdMerge::execute (std::string& output)
context.a3.push_back (Arg (uri._data, Arg::cat_literal));
std::string out;
assert (context.commands["push"]);
context.commands["push"]->execute (out);
}
}