I'm implementing a ruby interface to git and am wanting to be able to
ask if a branch is ahead or behind.
I looked in the builtin-checkout.c file and see this code:
/* Run "rev-list --left-right ours...theirs" internally... */
rev_argc = 0;
rev_argv[rev_argc++] = NULL;
rev_argv[rev_argc++] = "--left-right";
rev_argv[rev_argc++] = symmetric;
rev_argv[rev_argc++] = "--";
rev_argv[rev_argc] = NULL;
strcpy(symmetric, sha1_to_hex(ours->object.sha1));
strcpy(symmetric + 40, "...");
strcpy(symmetric + 43, sha1_to_hex(theirs->object.sha1));
init_revisions(&revs, NULL);
setup_revisions(rev_argc, rev_argv, &revs, NULL);
prepare_revision_walk(&revs);
/* ... and count the commits on each side. */
num_ours = 0;
num_theirs = 0;
while (1) {
struct commit *c = get_revision(&revs);
if (!c)
break;
if (c->object.flags & SYMMETRIC_LEFT)
num_ours++;
else
num_theirs++;
}
It looks like it's calling rev-parse. But, when I call it with the
same arguments (using branches or commit sha1's), it only will list
commits that are in right and not in left. I need it to show both
ways: commits that are in the right and not in left, and commits that
are in the left but not in right.
Do I need to call rev-parse twice to achieve this?
Here's a sample of what I'm trying currently:
~ $ mkdir test
~ $ cd test/
~/test $ git init
Initialized empty Git repository in .git/
~/test $ git
~/test $ echo content > file.txt
~/test $ git add file.txt && git commit -m "Initial commit"
Created initial commit f5e4160: Initial commit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 file.txt
~/test master$ git co -b task
Switched to a new branch "task"
~/test task$ echo changes >> file.txt
~/test task$ git add file.txt && git commit -m "Some changes"
Created commit 96492ee: Some changes
1 files changed, 1 insertions(+), 0 deletions(-)
~/test task$ git rev-list --left-right task..master --
~/test task$ git rev-list --left-right master..task --
>96492ee80143f43417b00699ff29330d0027df7f
Thanks,
Tim
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
| David Miller | Slow DOWN, please!!! |
| KAMEZAWA Hiroyuki | Re: 2.6.22-rc1-mm1 |
| Steven Rostedt | [RFC PATCH 1/3] Unified trace buffer |
| Steven Rostedt | [RFC PATCH 0/6] Convert all tasklets to workqueues |
git: | |
| Peter Klavins | Re: CRLF problems with Git on Win32 |
| J. Bruce Fields | Re: Git User's Survey 2007 unfinished summary continued |
| Linus Torvalds | Re: VCS comparison table |
| Junichi Uekawa | Re: [ANNOUNCE] GIT 1.5.4 |
| Arjan van de Ven | Re: [GIT]: Networking |
| Rémi | [PATCH 0/6] [RFC] Phonet pipes protocol (v2) |
| Jarek Poplawski | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Jozsef Kadlecsik | Re: TCP connection stalls under 2.6.24.7 |
| Richard Stallman | Real men don't attack straw men |
| Rogier Krieger | Re: bcw(4) is gone |
| Leon Dippenaar | New tcp stack attack |
| Brandon Lee | DELL PERC 5iR slow performance |
| high memory | 5 hours ago | Linux kernel |
| semaphore access speed | 8 hours ago | Applications and Utilities |
| the kernel how to power off the machine | 9 hours ago | Linux kernel |
| Easter Eggs in windows XP | 12 hours ago | Windows |
| Shared swap partition | 13 hours ago | Linux general |
| Root password | 13 hours ago | Linux general |
| Where/when DNOTIFY is used? | 15 hours ago | Linux kernel |
| How to convert Linux Kernel built-in module into a loadable module | 17 hours ago | Linux kernel |
| Linux 2.6.24 and I/O schedulers | 18 hours ago | Linux kernel |
| USB Driver -- Interrupt Polling -- A Little Help Please | 23 hours ago | Linux general |
