Skip to contentSkip to conversation

Teach rev-parse the ... syntax.

PATCH In review Santi Béjar 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Teach rev-parse the ... syntax.

---

I think this time the mail patch is OK, I've tested it.

 builtin-rev-parse.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
builtin-rev-parse.c +16 -1
index 5f5ade4..8d2beb2 100644
@@ -331,14 +331,29 @@ int cmd_rev_parse(int argc, const char *
 			unsigned char end[20];
 			const char *next = dotdot + 2;
 			const char *this = arg;
+			int symmetric = *next == '.';
+
 			*dotdot = 0;
+			next += symmetric;
+
 			if (!*next)
 				next = "HEAD";
 			if (dotdot == arg)
 				this = "HEAD";
 			if (!get_sha1(this, sha1) && !get_sha1(next, end)) {
 				show_rev(NORMAL, end, next);
-				show_rev(REVERSED, sha1, this);
+				show_rev(symmetric?NORMAL:REVERSED, sha1, this);
+				if (symmetric) {
+				  struct commit *a, *b;
+				  a = lookup_commit_reference(sha1);
+				  b = lookup_commit_reference(end);
+				  struct commit_list *exclude = get_merge_bases(a, b,1);
+				  while (exclude) {
+				    show_rev(REVERSED,
+					     exclude->item->object.sha1,NULL);
+				    exclude = exclude->next;
+				  }
+				}
 				continue;
 			}
 			*dotdot = '.';
Signature · 1 line
1.4.1.ge6c0-dirty
#1 lore raw

Hi,

builtin-rev-parse.c int cmd_rev_parse(int argc, const char * · line 350

Quoted 1 line · Santi Béjar
builtin-rev-parse.c +1 -0
+				  struct commit_list *exclude = get_merge_bases(a, b,1);

You never free_commit_list() exclude.

Side thought: we do not really support multiple ranges, do we? E.g.

	git-rev-list HEAD~10..HEAD~8 HEAD^..

would not yield the intended result, right? (And same goes for ... ranges) Maybe we should at least warn about that.

Ciao,
Dscho

author
#2 lore raw

2006/7/4, Johannes Schindelin <[email protected]>:

Quoted 8 lines

Hi,

Quoted 1 line · Santi Béjar

+ struct commit_list *exclude = get_merge_bases(a, b,1);

You never free_commit_list() exclude.

Ups! But thanks to Junio it is already there :)

Santi

Signature · 2 lines
Looking for signature...
Looking for signature...done