From: antirez Date: Thu, 4 Mar 2010 15:43:50 +0000 (+0100) Subject: Merge branch 'zsl-get-rank' of git://github.com/pietern/redis X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/947efa8d6e37f38bdd8485b64f7c139d1e310e70?hp=a50ea45c841e980f7692a9cd97130f0f37e5917b Merge branch 'zsl-get-rank' of git://github.com/pietern/redis --- diff --git a/redis-cli.c b/redis-cli.c index 14b24f75..bbcac0c5 100644 --- a/redis-cli.c +++ b/redis-cli.c @@ -420,7 +420,7 @@ static void usage() { fprintf(stderr, "example: cat /etc/passwd | redis-cli set my_passwd\n"); fprintf(stderr, "example: redis-cli get my_passwd\n"); fprintf(stderr, "example: redis-cli -r 100 lpush mylist x\n"); - fprintf(stderr, "\nRun in interactive mode: redis-cli -i \n"); + fprintf(stderr, "\nRun in interactive mode: redis-cli -i or just don't pass any command\n"); exit(1); } @@ -486,12 +486,10 @@ int main(int argc, char **argv) { config.interactive = 0; firstarg = parseOptions(argc,argv); - argc -= firstarg; argv += firstarg; - if (config.interactive == 1) repl(); - if (argc < 1) usage(); + if (argc == 0 || config.interactive == 1) repl(); argvcopy = convertToSds(argc, argv); diff --git a/redis.c b/redis.c index 4f7d3efc..331aaaa0 100644 --- a/redis.c +++ b/redis.c @@ -4075,7 +4075,7 @@ static void pushGenericCommand(redisClient *c, int where) { lobj = lookupKeyWrite(c->db,c->argv[1]); if (lobj == NULL) { if (handleClientsWaitingListPush(c,c->argv[1],c->argv[2])) { - addReply(c,shared.ok); + addReply(c,shared.cone); return; } lobj = createListObject(); @@ -4094,7 +4094,7 @@ static void pushGenericCommand(redisClient *c, int where) { return; } if (handleClientsWaitingListPush(c,c->argv[1],c->argv[2])) { - addReply(c,shared.ok); + addReply(c,shared.cone); return; } list = lobj->ptr; @@ -4106,7 +4106,7 @@ static void pushGenericCommand(redisClient *c, int where) { incrRefCount(c->argv[2]); } server.dirty++; - addReply(c,shared.ok); + addReplySds(c,sdscatprintf(sdsempty(),":%d\r\n",listLength(list))); } static void lpushCommand(redisClient *c) { diff --git a/test-redis.tcl b/test-redis.tcl index 0fc1e7df..a6acea18 100644 --- a/test-redis.tcl +++ b/test-redis.tcl @@ -406,15 +406,20 @@ proc main {server port} { } {1} test {Basic LPUSH, RPUSH, LLENGTH, LINDEX} { - $r lpush mylist a - $r lpush mylist b - $r rpush mylist c - set res [$r llen mylist] + set res [$r lpush mylist a] + append res [$r lpush mylist b] + append res [$r rpush mylist c] + append res [$r llen mylist] + append res [$r rpush anotherlist d] + append res [$r lpush anotherlist e] + append res [$r llen anotherlist] append res [$r lindex mylist 0] append res [$r lindex mylist 1] append res [$r lindex mylist 2] + append res [$r lindex anotherlist 0] + append res [$r lindex anotherlist 1] list $res [$r lindex mylist 100] - } {3bac {}} + } {1233122baced {}} test {DEL a list} { $r del mylist