{"thread":{"id":"13591","subject":"Re: using rev-list to tell if a branch is behind or ahead","startedAt":"2008-05-20T20:33:57Z","lastAt":"2008-05-20T20:33:57Z","messageCount":1,"participants":["Tim Harper"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"77343","messageId":"19466E30-0877-4AE9-BA1D-A8A32C8989C5@gmail.com","threadId":"13591","inReplyTo":"F3CD27F7-D509-41A3-B3C8-0B9124537DDA@gmail.com","subject":"Re: using rev-list to tell if a branch is behind or ahead","fromName":"Tim Harper","fromEmail":"timcharper@gmail.com","sentAt":"2008-05-20T20:33:57Z","receivedAt":"2008-05-20T20:33:57Z","isPatch":false,"sender":{"key":"timcharper@gmail.com","avatar":"https://gravatar.com/avatar/1a2e0c06c7862ff065ee6b1d53195333a5a0577c040ecb2856a150d8e0b00ecd?d=mp&s=160"},"body":"On May 20, 2008, at 2:24 PM, Shawn O. Pearce wrote:\n> Tim Harper <timcharper@gmail.com> wrote:\n>> I'm implementing a ruby interface to git and am wanting to be able to\n>> ask if a branch is ahead or behind.\n>>\n>> I looked in the builtin-checkout.c file and see this code:\n>>\n>> /* Run \"rev-list --left-right ours...theirs\" internally... */\n> ...\n>> It looks like it's calling rev-parse.  But, when I call it with the\n>> same arguments (using branches or commit sha1's), it only will list\n>> commits that are in right and not in left.  I need it to show both\n>> ways: commits that are in the right and not in left, and commits that\n>> are in the left but not in right.\n>>\n>> Do I need to call rev-parse twice to achieve this?\n>\n> No.  You need to use the triple dot operator (\"...\") not the\n> double dot operator (\"..\").\n>\n\nUgh... figured it was something simple.  Funny thing is, when I was  \nlooking at the c code:\nstrcpy(symmetric, sha1_to_hex(ours->object.sha1));\nstrcpy(symmetric + 40, \"...\");\nstrcpy(symmetric + 43, sha1_to_hex(theirs->object.sha1));\n\nI was like \"I wonder why the 3rd line is +43, and not +42\".\n\n\n\n>> Here's a sample of what I'm trying currently:\n>> ~ $ mkdir test\n>> ~ $ cd test/\n>> ~/test $ git init\n>> Initialized empty Git repository in .git/\n>> ~/test $ git\n>> ~/test $ echo content > file.txt\n>> ~/test $ git add file.txt && git commit -m \"Initial commit\"\n>> Created initial commit f5e4160: Initial commit\n>> 1 files changed, 1 insertions(+), 0 deletions(-)\n>> create mode 100644 file.txt\n>> ~/test master$ git co -b task\n>> Switched to a new branch \"task\"\n>> ~/test task$ echo changes >> file.txt\n>> ~/test task$ git add file.txt && git commit -m \"Some changes\"\n>> Created commit 96492ee: Some changes\n>> 1 files changed, 1 insertions(+), 0 deletions(-)\n>> ~/test task$ git rev-list --left-right task..master --\n>\n> You need an extra \".\" between task and master, this should be:\n>\n> git rev-list --left-right task...master --\n>\n>> ~/test task$ git rev-list --left-right master..task --\n>>> 96492ee80143f43417b00699ff29330d0027df7f\n>\n> -- \n> Shawn.\n\nThat did it, thanks\n\nTim\n"}]}