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

Re: Joining cg-*-id

From
Linus Torvalds <torvalds@osdl.org>
Date
Sep 20, 2005, 16:54 UTC
Message-ID
<Pine.LNX.4.58.0509200906120.2553@g5.osdl.org>
In-Reply-To
<20050920150719.GB1836@pasky.or.cz>
On Tue, 20 Sep 2005, Petr Baudis wrote:
> 
> I'll just drop the date revision specifier support from Cogito. I don't
> know if any measurable number of people actually use it in the real
> world anyway.
I think the date specifier makes sense for cg-log, though. 

Ie it doesn't make sense as a generic cg-*-id thing, but it _does_ make sense as a totally log-specific case.

Maybe it could use "-d" instead of "-r", since it's really a totally separate control. For example, there's nothing wrong with

	cg-log -d yesterday v2.6.12..
which would limit the revisions _both_ to a date _and_ to a version.

So it's just "diff against time" that makes no sense. But both "git log" and "git whatchanged" are sensible in time: there's no problem with saying "what commits happened in the last 24 hours", but there _is_ a problem with saying "show me the difference from 24 hours ago".

See? The "list of commits" is sensible, it's just the "one revision" thing that isn't.

Here's a stupid example of how to do this in git. 
With this silly patch, this like
	git whatchanged --since="1 month ago"
	git log --since="5 days ago"
	gitk --since=yesterday
all work. I don't know how _useful_ it is, but it's kind of cool.

(Side note: the "gitk" thing works really badly. gitk doesn't quote its arguments to "git-rev-list", so something like

	gitk --since="1 month ago"

does NOT work, while "--since=yesterday" does, because it has no spaces. Gaah. "Obi-Paul Mackerras, you're our only hope")

		Linus
---
diff --git a/rev-parse.c b/rev-parse.c
--- a/rev-parse.c
+++ b/rev-parse.c
@@ -6,6 +6,7 @@
 #include "cache.h"
 #include "commit.h"
 #include "refs.h"
+#include "quote.h"
 
 #define DO_REVS		1
 #define DO_NOREV	2
@@ -125,6 +126,27 @@ static int show_reference(const char *re
 	return 0;
 }
 
+static void show_datestring(const char *datestr)
+{
+	FILE *date;
+	static char buffer[100] = "--max-age=";
+	static char cmd[1000];
+	int len;
+
+	/* date handling requires both flags and revs */
+	if ((filter & (DO_FLAGS | DO_REVS)) != (DO_FLAGS | DO_REVS))
+		return;
+	snprintf(cmd, sizeof(cmd), "date --date=%s +%%s", sq_quote(datestr));
+	date = popen(cmd, "r");
+	if (!date || !fgets(buffer + 10, sizeof(buffer) - 10, date))
+		die("git-rev-list: bad date string");
+	pclose(date);
+	len = strlen(buffer);
+	if (buffer[len-1] == '\n')
+		buffer[--len] = 0;
+	show(buffer);
+}
+
 int main(int argc, char **argv)
 {
 	int i, as_is = 0, verify = 0;
@@ -207,6 +229,10 @@ int main(int argc, char **argv)
 				printf("%s/.git\n", cwd);
 				continue;
 			}
+			if (!strncmp(arg, "--since=", 8)) {
+				show_datestring(arg+8);
+				continue;
+			}
 			if (verify)
 				die("Needed a single revision");
 			show_flag(arg);
Previous: Petr BaudisNext: Linus Torvalds
Message 9 of 22 in “Joining cg-*-id”
  1. Pavel RoskinSep 19, 2005
  2. Petr BaudisSep 19, 2005
  3. Linus TorvaldsSep 19, 2005
  4. Petr BaudisSep 19, 2005
  5. Linus TorvaldsSep 20, 2005
  6. Petr BaudisSep 20, 2005
  7. Linus TorvaldsSep 20, 2005
  8. Petr BaudisSep 20, 2005
  9. Linus TorvaldsSep 20, 2005
  10. Linus TorvaldsSep 20, 2005
  11. Paul MackerrasSep 21, 2005
  12. Linus TorvaldsSep 21, 2005
  13. Paul MackerrasSep 21, 2005
  14. Petr BaudisSep 21, 2005
  15. Matthias UrlichsSep 20, 2005
  16. Junio C HamanoSep 20, 2005
  17. Matthias UrlichsSep 20, 2005
  18. Paul MackerrasSep 20, 2005
  19. Pavel RoskinSep 19, 2005
  20. Petr BaudisSep 19, 2005
  21. Pavel RoskinSep 20, 2005
  22. Petr BaudisSep 20, 2005

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.