- changed the parsing of ssh:// URIs, paths are now absolute by default
This commit is contained in:
Johannes Schlatow 2011-05-02 16:18:40 +02:00
parent df8496edae
commit 398371d324
4 changed files with 24 additions and 11 deletions

View file

@ -155,8 +155,8 @@ a second database.
Here is a basic example of the procedure: Here is a basic example of the procedure:
$ task merge ssh://user@myremotehost/.task/ $ task merge ssh://user@myremotehost/~/.task/
$ task push ssh://user@myremotehost/.task/ $ task push ssh://user@myremotehost/~/.task/
The first command fetches the undo.data file from the remote system, reads the The first command fetches the undo.data file from the remote system, reads the
changes made and updates the local database. When this merge command completes, changes made and updates the local database. When this merge command completes,

View file

@ -109,19 +109,26 @@ All the other URIs allow access to remote machines. The first uses SSH and scp
.br .br
.RS .RS
ssh://[user@]host[:port]/path/to/.task/ ssh://[user@]host[:port]/absolute/path/to/.task/
.br .br
[user@]host:path/to/.task/ [user@]host:/absolute/path/to/.task/
.RE .RE
Remember that in both cases paths are considered to be relative to the users home directory, In both cases paths are considered to be absolute. You can specify paths relative to the
i.e. they will expand to ~/path/to/.task/. You can specify absolute paths as follows: users home directory as follows:
.br .br
.RS .RS
ssh://[user@]host[:port]//absolute/path/to/.task/ ssh://[user@]host[:port]/~/.task/
.br .br
[user@]host:/absolute/path/to/.task/ [user@]host:~/.task/
.RE
or even shorter
.br
.RS
[user@]host:.task/
.RE .RE
Remark: Since taskwarrior simply calls the scp binary you can specify very much anything Remark: Since taskwarrior simply calls the scp binary you can specify very much anything
@ -130,9 +137,9 @@ expansion:
.br .br
.RS .RS
ssh://configured-host/~[user]/.task/ ssh://configured-host/~[username]/.task/
.br .br
configured-host:~[user]/.task/ configured-host:~[username]/.task/
.RE .RE

View file

@ -255,6 +255,12 @@ void Uri::parse ()
throw std::string ("The uri '") + data + "' is not in the expected format."; throw std::string ("The uri '") + data + "' is not in the expected format.";
} }
// path is absolute for ssh:// syntax
if ( (protocol == "ssh") && (pathDelimiter == "/") )
{
path = "/" + path;
}
// port specified? // port specified?
// remark: this find() will never be != npos for scp-like syntax // remark: this find() will never be != npos for scp-like syntax
// because we found pathDelimiter, which is ":", before // because we found pathDelimiter, which is ":", before

View file

@ -125,7 +125,7 @@ int main (int argc, char** argv)
t.is (uri11.user, "user.name", "Uri::parse() : ssh://user.name@host.com/undo.data"); t.is (uri11.user, "user.name", "Uri::parse() : ssh://user.name@host.com/undo.data");
t.is (uri11.host, "host.com", "Uri::parse() : ssh://user.name@host.com/undo.data"); t.is (uri11.host, "host.com", "Uri::parse() : ssh://user.name@host.com/undo.data");
t.is (uri11.port, "", "Uri::parse() : ssh://user.name@host.com/undo.data"); t.is (uri11.port, "", "Uri::parse() : ssh://user.name@host.com/undo.data");
t.is (uri11.path, "undo.data", "Uri::parse() : ssh://user.name@host.com/undo.data"); t.is (uri11.path, "/undo.data", "Uri::parse() : ssh://user.name@host.com/undo.data");
t.is (uri11.protocol, "ssh", "Uri::parse() : ssh://user.name@host.com/undo.data"); t.is (uri11.protocol, "ssh", "Uri::parse() : ssh://user.name@host.com/undo.data");