git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Teach revision walker about reflog ranges

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 29, 2007, 23:02 UTC
Message-ID
<Pine.LNX.4.64.0712300000170.14355@wbgn129.biozentrum.uni-wuerzburg.de>
Now you can ask for a revision range
	master@{2.weeks.ago..1.day.ago}
or even something like
	HEAD@{20..yesterday}

It does this by allocating an strbuf to construct the second ref string (in the above examples "master@{1.day.ago}" and "HEAD@{yesterday}", respectively), which is never free()d.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	Another nail in the coffin of libification, but for the common 
	one-shot command, it is the easiest way to support reflog ranges.
 revision.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/revision.c b/revision.c
index 6e85aaa..3e7a834 100644
--- a/revision.c
+++ b/revision.c
@@ -794,10 +794,24 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
 		const char *this = arg;
 		int symmetric = *next == '.';
 		unsigned int flags_exclude = flags ^ UNINTERESTING;
+		const char *at;
 
 		*dotdot = 0;
 		next += symmetric;
 
+		at = strstr(arg, "@{");
+		if (at && !strchr(at + 2, '}')) {
+			struct strbuf buf;
+			strcpy(dotdot, "}");
+			strbuf_init(&buf, 0);
+			strbuf_insert(&buf, 0, arg, at + 2 - arg);
+			if (!strcmp(next, "}"))
+				strbuf_addch(&buf, '0');
+			strbuf_addstr(&buf, next);
+			/* we will not free() this buffer */
+			next = buf.buf;
+		}
+
 		if (!*next)
 			next = "HEAD";
 		if (dotdot == arg)
-- 
1.5.4.rc2.5.g44b6d-dirty
Next: Junio C Hamano
Message 1 of 3 in “Teach revision walker about reflog ranges”
  1. Teach revision walker about reflog rangesJohannes Schindelin, Dec 29, 2007
  2. Junio C HamanoDec 30, 2007
  3. Johannes SchindelinDec 30, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.