* [PATCH] git-commit: add option --date-now
@ 2011-12-21 14:56 Michael Schubert
2011-12-21 15:38 ` Carlos Martín Nieto
0 siblings, 1 reply; 4+ messages in thread
From: Michael Schubert @ 2011-12-21 14:56 UTC (permalink / raw)
To: git
Currently, Git doesn't provide an easy way to use the current date when
amending a commit or reusing an existing commmit with -C/-c. Therefore,
add --date-now.
Signed-off-by: Michael Schubert <mschub@elegosoft.com>
---
Documentation/git-commit.txt | 7 +++++--
builtin/commit.c | 9 ++++++++-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 5cc84a1..b7c6f0d 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -12,8 +12,8 @@ SYNOPSIS
[--dry-run] [(-c | -C | --fixup | --squash) <commit>]
[-F <file> | -m <msg>] [--reset-author] [--allow-empty]
[--allow-empty-message] [--no-verify] [-e] [--author=<author>]
- [--date=<date>] [--cleanup=<mode>] [--status | --no-status]
- [-i | -o] [--] [<file>...]
+ [--date=<date> | --date-now] [--cleanup=<mode>]
+ [--status | --no-status] [-i | -o] [--] [<file>...]
DESCRIPTION
-----------
@@ -126,6 +126,9 @@ OPTIONS
--date=<date>::
Override the author date used in the commit.
+--date-now
+ Override the author date used in the commit with the current local time.
+
-m <msg>::
--message=<msg>::
Use the given <msg> as the commit message.
diff --git a/builtin/commit.c b/builtin/commit.c
index be1ab2e..28fdf1a 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -82,6 +82,7 @@ static const char *author_message, *author_message_buffer;
static char *edit_message, *use_message;
static char *fixup_message, *squash_message;
static int all, also, interactive, patch_interactive, only, amend, signoff;
+static int date_now;
static int edit_flag = -1; /* unspecified */
static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
static int no_post_rewrite, allow_empty_message;
@@ -134,6 +135,7 @@ static struct option builtin_commit_options[] = {
OPT_FILENAME('F', "file", &logfile, "read message from file"),
OPT_STRING(0, "author", &force_author, "author", "override author for commit"),
OPT_STRING(0, "date", &force_date, "date", "override date for commit"),
+ OPT_BOOLEAN(0, "date-now", &date_now, "override date for commit with current local time"),
OPT_CALLBACK('m', "message", &message, "message", "commit message", opt_parse_m),
OPT_STRING('c', "reedit-message", &edit_message, "commit", "reuse and edit message from specified commit"),
OPT_STRING('C', "reuse-message", &use_message, "commit", "reuse message from specified commit"),
@@ -557,7 +559,9 @@ static void determine_author_info(struct strbuf *author_ident)
(lb - strlen(" ") -
(a + strlen("\nauthor "))));
email = xmemdupz(lb + strlen("<"), rb - (lb + strlen("<")));
- date = xmemdupz(rb + strlen("> "), eol - (rb + strlen("> ")));
+ if (!date_now)
+ date = xmemdupz(rb + strlen("> "),
+ eol - (rb + strlen("> ")));
}
if (force_author) {
@@ -1018,6 +1022,9 @@ static int parse_and_validate_options(int argc, const char *argv[],
if (force_author && renew_authorship)
die(_("Using both --reset-author and --author does not make sense"));
+ if (force_date && date_now)
+ die(_("Using both --date and --date-now does not make sense"));
+
if (logfile || message.len || use_message || fixup_message)
use_editor = 0;
if (0 <= edit_flag)
--
1.7.8.521.g64725
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] git-commit: add option --date-now
2011-12-21 14:56 [PATCH] git-commit: add option --date-now Michael Schubert
@ 2011-12-21 15:38 ` Carlos Martín Nieto
2011-12-21 16:24 ` Matthieu Moy
0 siblings, 1 reply; 4+ messages in thread
From: Carlos Martín Nieto @ 2011-12-21 15:38 UTC (permalink / raw)
To: Michael Schubert; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 4129 bytes --]
On Wed, Dec 21, 2011 at 03:56:43PM +0100, Michael Schubert wrote:
> Currently, Git doesn't provide an easy way to use the current date when
> amending a commit or reusing an existing commmit with -C/-c. Therefore,
> add --date-now.
The option --reset-author also resets the date. So 'git commit
--ammend --reset-author' does what 'git commit --amend --date-now'
would do in most cases. I was surpised when I tried 'git commit
--amend --date=now' that git didn't understand 'now' as a date, which
seems like a more obvious place to fix it.
>
> Signed-off-by: Michael Schubert <mschub@elegosoft.com>
> ---
> Documentation/git-commit.txt | 7 +++++--
> builtin/commit.c | 9 ++++++++-
> 2 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
> index 5cc84a1..b7c6f0d 100644
> --- a/Documentation/git-commit.txt
> +++ b/Documentation/git-commit.txt
> @@ -12,8 +12,8 @@ SYNOPSIS
> [--dry-run] [(-c | -C | --fixup | --squash) <commit>]
> [-F <file> | -m <msg>] [--reset-author] [--allow-empty]
> [--allow-empty-message] [--no-verify] [-e] [--author=<author>]
> - [--date=<date>] [--cleanup=<mode>] [--status | --no-status]
> - [-i | -o] [--] [<file>...]
> + [--date=<date> | --date-now] [--cleanup=<mode>]
> + [--status | --no-status] [-i | -o] [--] [<file>...]
>
> DESCRIPTION
> -----------
> @@ -126,6 +126,9 @@ OPTIONS
> --date=<date>::
> Override the author date used in the commit.
>
> +--date-now
> + Override the author date used in the commit with the current local time.
> +
> -m <msg>::
> --message=<msg>::
> Use the given <msg> as the commit message.
> diff --git a/builtin/commit.c b/builtin/commit.c
> index be1ab2e..28fdf1a 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -82,6 +82,7 @@ static const char *author_message, *author_message_buffer;
> static char *edit_message, *use_message;
> static char *fixup_message, *squash_message;
> static int all, also, interactive, patch_interactive, only, amend, signoff;
> +static int date_now;
> static int edit_flag = -1; /* unspecified */
> static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
> static int no_post_rewrite, allow_empty_message;
> @@ -134,6 +135,7 @@ static struct option builtin_commit_options[] = {
> OPT_FILENAME('F', "file", &logfile, "read message from file"),
> OPT_STRING(0, "author", &force_author, "author", "override author for commit"),
> OPT_STRING(0, "date", &force_date, "date", "override date for commit"),
> + OPT_BOOLEAN(0, "date-now", &date_now, "override date for commit with current local time"),
> OPT_CALLBACK('m', "message", &message, "message", "commit message", opt_parse_m),
> OPT_STRING('c', "reedit-message", &edit_message, "commit", "reuse and edit message from specified commit"),
> OPT_STRING('C', "reuse-message", &use_message, "commit", "reuse message from specified commit"),
> @@ -557,7 +559,9 @@ static void determine_author_info(struct strbuf *author_ident)
> (lb - strlen(" ") -
> (a + strlen("\nauthor "))));
> email = xmemdupz(lb + strlen("<"), rb - (lb + strlen("<")));
> - date = xmemdupz(rb + strlen("> "), eol - (rb + strlen("> ")));
> + if (!date_now)
> + date = xmemdupz(rb + strlen("> "),
> + eol - (rb + strlen("> ")));
> }
>
> if (force_author) {
> @@ -1018,6 +1022,9 @@ static int parse_and_validate_options(int argc, const char *argv[],
> if (force_author && renew_authorship)
> die(_("Using both --reset-author and --author does not make sense"));
>
> + if (force_date && date_now)
> + die(_("Using both --date and --date-now does not make sense"));
> +
> if (logfile || message.len || use_message || fixup_message)
> use_editor = 0;
> if (0 <= edit_flag)
> --
> 1.7.8.521.g64725
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] git-commit: add option --date-now
2011-12-21 15:38 ` Carlos Martín Nieto
@ 2011-12-21 16:24 ` Matthieu Moy
2011-12-21 20:25 ` Jeff King
0 siblings, 1 reply; 4+ messages in thread
From: Matthieu Moy @ 2011-12-21 16:24 UTC (permalink / raw)
To: Carlos Martín Nieto; +Cc: Michael Schubert, git
Carlos Martín Nieto <cmn@elego.de> writes:
> I was surpised when I tried 'git commit --amend --date=now' that git
> didn't understand 'now' as a date, which seems like a more obvious
> place to fix it.
+1
I really don't think Git wants yet-another-option for each use-case we
find, and accepting "now" as a date (either by hardcoding "now" as an
accepted value, or by running approxidate on the argument of --date).
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] git-commit: add option --date-now
2011-12-21 16:24 ` Matthieu Moy
@ 2011-12-21 20:25 ` Jeff King
0 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2011-12-21 20:25 UTC (permalink / raw)
To: Matthieu Moy; +Cc: Carlos Martín Nieto, Michael Schubert, git
On Wed, Dec 21, 2011 at 05:24:57PM +0100, Matthieu Moy wrote:
> Carlos Martín Nieto <cmn@elego.de> writes:
>
> > I was surpised when I tried 'git commit --amend --date=now' that git
> > didn't understand 'now' as a date, which seems like a more obvious
> > place to fix it.
>
> +1
>
> I really don't think Git wants yet-another-option for each use-case we
> find, and accepting "now" as a date (either by hardcoding "now" as an
> accepted value, or by running approxidate on the argument of --date).
I'm curious of the use case where one wants "--date=now" but not
"--reset-author". Or is it simply that "--reset-author" is a less
obvious thing to try?
At any rate, if we are going to do that, I agree it should be spelled
"--date=now", and not "--date-now".
-Peff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-12-21 20:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-21 14:56 [PATCH] git-commit: add option --date-now Michael Schubert
2011-12-21 15:38 ` Carlos Martín Nieto
2011-12-21 16:24 ` Matthieu Moy
2011-12-21 20:25 ` Jeff King
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.