{"thread":{"id":"29229","subject":"[PATCH] git-commit: add option --date-now","startedAt":"2011-12-21T14:56:43Z","lastAt":"2011-12-21T20:25:01Z","messageCount":4,"participants":["Michael Schubert","Carlos Martín Nieto","Matthieu Moy","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"181578","messageId":"4EF1F3AB.5080607@elegosoft.com","threadId":"29229","inReplyTo":null,"subject":"[PATCH] git-commit: add option --date-now","fromName":"Michael Schubert","fromEmail":"mschub@elegosoft.com","sentAt":"2011-12-21T14:56:43Z","receivedAt":"2011-12-21T14:56:43Z","isPatch":true,"sender":{"key":"mschub@elegosoft.com","avatar":null},"body":"Currently, Git doesn't provide an easy way to use the current date when\namending a commit or reusing an existing commmit with -C/-c. Therefore,\nadd --date-now.\n\nSigned-off-by: Michael Schubert <mschub@elegosoft.com>\n---\n Documentation/git-commit.txt |    7 +++++--\n builtin/commit.c             |    9 ++++++++-\n 2 files changed, 13 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 5cc84a1..b7c6f0d 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -12,8 +12,8 @@ SYNOPSIS\n \t   [--dry-run] [(-c | -C | --fixup | --squash) <commit>]\n \t   [-F <file> | -m <msg>] [--reset-author] [--allow-empty]\n \t   [--allow-empty-message] [--no-verify] [-e] [--author=<author>]\n-\t   [--date=<date>] [--cleanup=<mode>] [--status | --no-status]\n-\t   [-i | -o] [--] [<file>...]\n+\t   [--date=<date> | --date-now] [--cleanup=<mode>]\n+\t   [--status | --no-status] [-i | -o] [--] [<file>...]\n \n DESCRIPTION\n -----------\n@@ -126,6 +126,9 @@ OPTIONS\n --date=<date>::\n \tOverride the author date used in the commit.\n \n+--date-now\n+\tOverride the author date used in the commit with the current local time.\n+\n -m <msg>::\n --message=<msg>::\n \tUse the given <msg> as the commit message.\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex be1ab2e..28fdf1a 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -82,6 +82,7 @@ static const char *author_message, *author_message_buffer;\n static char *edit_message, *use_message;\n static char *fixup_message, *squash_message;\n static int all, also, interactive, patch_interactive, only, amend, signoff;\n+static int date_now;\n static int edit_flag = -1; /* unspecified */\n static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;\n static int no_post_rewrite, allow_empty_message;\n@@ -134,6 +135,7 @@ static struct option builtin_commit_options[] = {\n \tOPT_FILENAME('F', \"file\", &logfile, \"read message from file\"),\n \tOPT_STRING(0, \"author\", &force_author, \"author\", \"override author for commit\"),\n \tOPT_STRING(0, \"date\", &force_date, \"date\", \"override date for commit\"),\n+\tOPT_BOOLEAN(0, \"date-now\", &date_now, \"override date for commit with current local time\"),\n \tOPT_CALLBACK('m', \"message\", &message, \"message\", \"commit message\", opt_parse_m),\n \tOPT_STRING('c', \"reedit-message\", &edit_message, \"commit\", \"reuse and edit message from specified commit\"),\n \tOPT_STRING('C', \"reuse-message\", &use_message, \"commit\", \"reuse message from specified commit\"),\n@@ -557,7 +559,9 @@ static void determine_author_info(struct strbuf *author_ident)\n \t\t\t\t\t(lb - strlen(\" \") -\n \t\t\t\t\t (a + strlen(\"\\nauthor \"))));\n \t\temail = xmemdupz(lb + strlen(\"<\"), rb - (lb + strlen(\"<\")));\n-\t\tdate = xmemdupz(rb + strlen(\"> \"), eol - (rb + strlen(\"> \")));\n+\t\tif (!date_now)\n+\t\t\tdate = xmemdupz(rb + strlen(\"> \"),\n+\t\t\t\t\teol - (rb + strlen(\"> \")));\n \t}\n \n \tif (force_author) {\n@@ -1018,6 +1022,9 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \tif (force_author && renew_authorship)\n \t\tdie(_(\"Using both --reset-author and --author does not make sense\"));\n \n+\tif (force_date && date_now)\n+\t\tdie(_(\"Using both --date and --date-now does not make sense\"));\n+\n \tif (logfile || message.len || use_message || fixup_message)\n \t\tuse_editor = 0;\n \tif (0 <= edit_flag)\n-- \n1.7.8.521.g64725\n"},{"id":"181579","messageId":"20111221153837.GC2160@beez.lab.cmartin.tk","threadId":"29229","inReplyTo":"4EF1F3AB.5080607@elegosoft.com","subject":"Re: [PATCH] git-commit: add option --date-now","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2011-12-21T15:38:37Z","receivedAt":"2011-12-21T15:38:37Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"On Wed, Dec 21, 2011 at 03:56:43PM +0100, Michael Schubert wrote:\n> Currently, Git doesn't provide an easy way to use the current date when\n> amending a commit or reusing an existing commmit with -C/-c. Therefore,\n> add --date-now.\n\nThe option --reset-author also resets the date. So 'git commit\n--ammend --reset-author' does what 'git commit --amend --date-now'\nwould do in most cases. I was surpised when I tried 'git commit\n--amend --date=now' that git didn't understand 'now' as a date, which\nseems like a more obvious place to fix it.\n\n> \n> Signed-off-by: Michael Schubert <mschub@elegosoft.com>\n> ---\n>  Documentation/git-commit.txt |    7 +++++--\n>  builtin/commit.c             |    9 ++++++++-\n>  2 files changed, 13 insertions(+), 3 deletions(-)\n> \n> diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\n> index 5cc84a1..b7c6f0d 100644\n> --- a/Documentation/git-commit.txt\n> +++ b/Documentation/git-commit.txt\n> @@ -12,8 +12,8 @@ SYNOPSIS\n>  \t   [--dry-run] [(-c | -C | --fixup | --squash) <commit>]\n>  \t   [-F <file> | -m <msg>] [--reset-author] [--allow-empty]\n>  \t   [--allow-empty-message] [--no-verify] [-e] [--author=<author>]\n> -\t   [--date=<date>] [--cleanup=<mode>] [--status | --no-status]\n> -\t   [-i | -o] [--] [<file>...]\n> +\t   [--date=<date> | --date-now] [--cleanup=<mode>]\n> +\t   [--status | --no-status] [-i | -o] [--] [<file>...]\n>  \n>  DESCRIPTION\n>  -----------\n> @@ -126,6 +126,9 @@ OPTIONS\n>  --date=<date>::\n>  \tOverride the author date used in the commit.\n>  \n> +--date-now\n> +\tOverride the author date used in the commit with the current local time.\n> +\n>  -m <msg>::\n>  --message=<msg>::\n>  \tUse the given <msg> as the commit message.\n> diff --git a/builtin/commit.c b/builtin/commit.c\n> index be1ab2e..28fdf1a 100644\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -82,6 +82,7 @@ static const char *author_message, *author_message_buffer;\n>  static char *edit_message, *use_message;\n>  static char *fixup_message, *squash_message;\n>  static int all, also, interactive, patch_interactive, only, amend, signoff;\n> +static int date_now;\n>  static int edit_flag = -1; /* unspecified */\n>  static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;\n>  static int no_post_rewrite, allow_empty_message;\n> @@ -134,6 +135,7 @@ static struct option builtin_commit_options[] = {\n>  \tOPT_FILENAME('F', \"file\", &logfile, \"read message from file\"),\n>  \tOPT_STRING(0, \"author\", &force_author, \"author\", \"override author for commit\"),\n>  \tOPT_STRING(0, \"date\", &force_date, \"date\", \"override date for commit\"),\n> +\tOPT_BOOLEAN(0, \"date-now\", &date_now, \"override date for commit with current local time\"),\n>  \tOPT_CALLBACK('m', \"message\", &message, \"message\", \"commit message\", opt_parse_m),\n>  \tOPT_STRING('c', \"reedit-message\", &edit_message, \"commit\", \"reuse and edit message from specified commit\"),\n>  \tOPT_STRING('C', \"reuse-message\", &use_message, \"commit\", \"reuse message from specified commit\"),\n> @@ -557,7 +559,9 @@ static void determine_author_info(struct strbuf *author_ident)\n>  \t\t\t\t\t(lb - strlen(\" \") -\n>  \t\t\t\t\t (a + strlen(\"\\nauthor \"))));\n>  \t\temail = xmemdupz(lb + strlen(\"<\"), rb - (lb + strlen(\"<\")));\n> -\t\tdate = xmemdupz(rb + strlen(\"> \"), eol - (rb + strlen(\"> \")));\n> +\t\tif (!date_now)\n> +\t\t\tdate = xmemdupz(rb + strlen(\"> \"),\n> +\t\t\t\t\teol - (rb + strlen(\"> \")));\n>  \t}\n>  \n>  \tif (force_author) {\n> @@ -1018,6 +1022,9 @@ static int parse_and_validate_options(int argc, const char *argv[],\n>  \tif (force_author && renew_authorship)\n>  \t\tdie(_(\"Using both --reset-author and --author does not make sense\"));\n>  \n> +\tif (force_date && date_now)\n> +\t\tdie(_(\"Using both --date and --date-now does not make sense\"));\n> +\n>  \tif (logfile || message.len || use_message || fixup_message)\n>  \t\tuse_editor = 0;\n>  \tif (0 <= edit_flag)\n> -- \n> 1.7.8.521.g64725\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n> \n"},{"id":"181582","messageId":"vpqmxalrixy.fsf@bauges.imag.fr","threadId":"29229","inReplyTo":"20111221153837.GC2160@beez.lab.cmartin.tk","subject":"Re: [PATCH] git-commit: add option --date-now","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2011-12-21T16:24:57Z","receivedAt":"2011-12-21T16:24:57Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Carlos Martín Nieto <cmn@elego.de> writes:\n\n> I was surpised when I tried 'git commit --amend --date=now' that git\n> didn't understand 'now' as a date, which seems like a more obvious\n> place to fix it.\n\n+1\n\nI really don't think Git wants yet-another-option for each use-case we\nfind, and accepting \"now\" as a date (either by hardcoding \"now\" as an\naccepted value, or by running approxidate on the argument of --date).\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"181597","messageId":"20111221202501.GA14895@sigill.intra.peff.net","threadId":"29229","inReplyTo":"vpqmxalrixy.fsf@bauges.imag.fr","subject":"Re: [PATCH] git-commit: add option --date-now","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-12-21T20:25:01Z","receivedAt":"2011-12-21T20:25:01Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 21, 2011 at 05:24:57PM +0100, Matthieu Moy wrote:\n\n> Carlos Martín Nieto <cmn@elego.de> writes:\n> \n> > I was surpised when I tried 'git commit --amend --date=now' that git\n> > didn't understand 'now' as a date, which seems like a more obvious\n> > place to fix it.\n> \n> +1\n> \n> I really don't think Git wants yet-another-option for each use-case we\n> find, and accepting \"now\" as a date (either by hardcoding \"now\" as an\n> accepted value, or by running approxidate on the argument of --date).\n\nI'm curious of the use case where one wants \"--date=now\" but not\n\"--reset-author\". Or is it simply that \"--reset-author\" is a less\nobvious thing to try?\n\nAt any rate, if we are going to do that, I agree it should be spelled\n\"--date=now\", and not \"--date-now\".\n\n-Peff\n"}]}