git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: [PATCH] rev-list: make --max- and --min-age a bit more usable.
Date: Wed, 02 Nov 2005 11:02:40 -0800	[thread overview]
Message-ID: <7vbr12swj3.fsf_-_@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0510301838110.27915@g5.osdl.org> (Linus Torvalds's message of "Sun, 30 Oct 2005 18:52:11 -0800 (PST)")

Linus Torvalds <torvalds@osdl.org> writes:

> I've several times been surprised to see people not realize that
> "git-whatchanged" takes a file list to limit the files it is interested 
> in. I also suspect people don't realize that you can limit it by time and 
> version and file list, all at the same time.

The current "time based limiting" is not very user friendly, so
people not knowing the limit-by-time is not a surprise.

> 	git-whatchanged -p --pretty=short --since="2 weeks ago" v0.99.8..v0.99.9 Makefile
>
> is a valid query

Well, it is not a valid query ;-) Nobody implemented --since
yet, but you could spell it --max-age.  It would not grok "2
weeks ago" though.

With the attached patch, you could at least do:

	git log --max-age='2005-10-25' v0.99.8..v0.99.9 Makefile

There are still a couple of things that bothers me.

(1) The underlying workhorse, rev-list, takes max-age and
    min-age.  While these names are logically correct, it feels
    a bit hard and counterintuitive when deciding which one to
    use in order to ask "what are the ones that happened after
    Wednesday last week?".  The query talks about the commits
    being young, so --max-age=2005-10-26 is the right query
    (i.e. "I want to discard things that are older than that
    time"), but as soon as I type "max", my mind starts
    comparing date strings, and surely 2005-10-21 is smaller
    than 2005-10-26 and I am saying 2005-10-26 is the max, which
    confuses me to think that 2005-10-21 would be included in
    the result (it would not be -- we are talking about age, so
    2005-10-21 one is older, which means its age is greater than
    specified). It takes some mental effort to do this, at least
    for me.

    I *hate* to suggest this change at this late stage of the
    game, but maybe they should be renamed or at least acquire 
    less confusing synonyms, perhaps?

	--max-age	= --min-timestamp, --since
        --min-age	= --max-timestamp, --until

(2) If I run the above --max-age query, the last commit
    displayed is this one:

        commit f3123c4ab3d3698262e59561ac084de45b10365a
        Author: Junio C Hamano <junkio@cox.net>
        Date:   Sat Oct 22 01:28:13 2005 -0700

    This is because the age limit uses commit date (which is a
    sensible thing to do) while the display shows author date.
    To an uninitiated, this takes some explanation and
    justification (i.e. counterintuitive again).

    Incidenally, I have not found a way to prettyprint the
    commit date; --pretty=raw gives that information, but in
    really raw format.  --pretty=full does not even give any
    timestamp.

    Again I *hate* to suggest this, but maybe --pretty=full
    should show both author and commit timestamp as well, like
    this?

        commit f3123c4ab3d3698262e59561ac084de45b10365a
        Author: Junio C Hamano <junkio@cox.net>
        A-Date: Sat Oct 22 01:28:13 2005 -0700
        Commit: Junio C Hamano <junkio@cox.net>
        C-Date: Wed Oct 26 12:37:49 2005 -0700


-- >8 -- cut here -- >8 --

Earlier we just did atoi to accept these parameters, which meant
that the user needed to specify the raw UNIX time format to use
them.

This still does not make it accept '2 weeks ago', but at least
it now can take --max-age='2005-10-15', which is a start.

Signed-off-by: Junio C Hamano <junkio@cox.net>

---

 rev-list.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

applies-to: 0c9683fe37dbc43713faaa15fcce14bfe5621bba
9dc13af3f916803d270d3387032eb0e91b940417
diff --git a/rev-list.c b/rev-list.c
index 6e6ffde..7a73703 100644
--- a/rev-list.c
+++ b/rev-list.c
@@ -712,6 +712,21 @@ static void handle_all(struct commit_lis
 	global_lst = NULL;
 }
 
+static unsigned long getdate(const char *arg, const char *label)
+{
+	char text[80];
+	unsigned long date;
+
+	if (parse_date(arg, text, sizeof(text)) < 0) {
+		/* Maybe handle "4 days ago" and the like here... */
+		die("bad time specification for %s: %s", label, arg);
+	}
+	date = strtoul(text, NULL, 10);
+	if (date == ULONG_MAX)
+		die("unparsable time specification for %s: %s", label, arg);
+	return date;
+}
+
 int main(int argc, const char **argv)
 {
 	const char *prefix = setup_git_directory();
@@ -730,12 +745,12 @@ int main(int argc, const char **argv)
 			continue;
 		}
 		if (!strncmp(arg, "--max-age=", 10)) {
-			max_age = atoi(arg + 10);
+			max_age = getdate(arg + 10, "max-age");
 			limited = 1;
 			continue;
 		}
 		if (!strncmp(arg, "--min-age=", 10)) {
-			min_age = atoi(arg + 10);
+			min_age = getdate(arg + 10, "min-age");
 			limited = 1;
 			continue;
 		}
---
0.99.9.GIT

  parent reply	other threads:[~2005-11-02 19:02 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-30  1:29 GIT 0.99.9 Junio C Hamano
2005-10-30  3:16 ` A Large Angry SCM
2005-10-30  3:39   ` Junio C Hamano
2005-10-30  4:03     ` A Large Angry SCM
2005-10-30 13:21       ` Johannes Schindelin
2005-10-30  5:05 ` Linus Torvalds
2005-10-30  8:37   ` rev-list --sparse? Junio C Hamano
2005-10-30 21:42     ` Linus Torvalds
2005-10-30 23:31       ` Junio C Hamano
2005-10-30 17:20 ` GIT 0.99.9 Wolfgang Denk
2005-10-30 17:31   ` Junio C Hamano
2005-10-30 20:23     ` Wolfgang Denk
2005-10-30 20:46       ` Junio C Hamano
2005-10-31  3:21       ` Horst von Brand
2005-10-30 20:38     ` Wolfgang Denk
2005-10-30 22:31       ` Ryan Anderson
2005-10-30 22:54       ` Junio C Hamano
2005-10-30 23:03         ` H. Peter Anvin
2005-10-31  2:52 ` Linus Torvalds
2005-10-31  3:08   ` Junio C Hamano
2005-10-31  4:05     ` Linus Torvalds
2005-10-31 21:40     ` Archaeology [Was: Re: GIT 0.99.9] Horst von Brand
2005-10-31 23:47   ` Date-based limits (Was Re: GIT 0.99.9) Daniel Barkalow
2005-11-01  0:37     ` Date-based limits Junio C Hamano
2005-11-01  0:43       ` Daniel Barkalow
2005-11-02 19:02   ` Junio C Hamano [this message]
2005-11-03  3:11     ` [PATCH] rev-list: make --max- and --min-age a bit more usable Linus Torvalds
2005-11-03  7:40       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vbr12swj3.fsf_-_@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).