示例#1
0
文件: oricmd.cpp 项目: ailidani/dfs
string OriCommand::cmd_branch(strstream &str)
{
    FUSE_PLOG("Command: branch");

    string subcmd;
    strwstream resp;
    LocalRepo *repo = priv->getRepo();

    // Parse Command
    str.readPStr(subcmd);

    if (subcmd == "get") {
        resp.writeLPStr(repo->getBranch());
        return resp.str();
    }
    if (subcmd == "set") {
        string branch;
        str.readPStr(branch);

        repo->setBranch(branch);

        resp.writeLPStr("");

        return resp.str();
    }
    if (subcmd == "list") {
        set<string> branches = repo->listBranches();
        set<string>::iterator it;

        resp.writeUInt32(branches.size());
        for (it = branches.begin(); it != branches.end(); it++) {
            resp.writeLPStr(*it);
        }

        return resp.str();
    }

    return "Unknown remote subcommand";
}