From 2df4e29c85dee2fe8b89e7878a38b59062e103ef Mon Sep 17 00:00:00 2001 From: John Keeping Date: Thu, 3 Sep 2015 22:48:51 +0100 Subject: Documentation/blame-options: don't list date formats This list is already incomplete (missing "raw") and we're about to add new formats. Remove it and refer to the canonical documentation in git-log(1). Signed-off-by: John Keeping Signed-off-by: Junio C Hamano diff --git a/Documentation/blame-options.txt b/Documentation/blame-options.txt index a09969b..760eab7 100644 --- a/Documentation/blame-options.txt +++ b/Documentation/blame-options.txt @@ -63,11 +63,10 @@ include::line-range-format.txt[] `-` to make the command read from the standard input). --date :: - The value is one of the following alternatives: - {relative,local,default,iso,rfc,short}. If --date is not + Specifies the format used to output dates. If --date is not provided, the value of the blame.date config variable is used. If the blame.date config variable is also not set, the - iso format is used. For more information, See the discussion + iso format is used. For supported values, see the discussion of the --date option at linkgit:git-log[1]. -M||:: -- cgit v0.10.2-6-g49f6 From 78a844160bd1273bad89fdc0df13a1037ab4b1a4 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Thu, 3 Sep 2015 22:48:52 +0100 Subject: Documentation/config: don't list date formats This list is already incomplete (missing "raw") and we're about to add new formats. Since this option sets a default for git-log's --date option, just refer to git-log(1). Signed-off-by: John Keeping Signed-off-by: Junio C Hamano diff --git a/Documentation/config.txt b/Documentation/config.txt index 3e37b93..e08be76 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1781,9 +1781,7 @@ log.abbrevCommit:: log.date:: Set the default date-time mode for the 'log' command. Setting a value for log.date is similar to using 'git log''s - `--date` option. Possible values are `relative`, `local`, - `default`, `iso`, `rfc`, and `short`; see linkgit:git-log[1] - for details. + `--date` option. See linkgit:git-log[1] for details. log.decorate:: Print out the ref names of any commits that are shown by the log -- cgit v0.10.2-6-g49f6 From 8f50d263d70702c9409eb17cce10ea5b0831223a Mon Sep 17 00:00:00 2001 From: John Keeping Date: Thu, 3 Sep 2015 22:48:53 +0100 Subject: Documentation/git-for-each-ref: don't list date formats We are about to add a new set of supported date formats and do not want to have to maintain the same list in several different bits of documentation. Refer to git-rev-list(1) which contains the full list of supported formats. Signed-off-by: John Keeping Signed-off-by: Junio C Hamano diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt index 7f8d9a5..d062639 100644 --- a/Documentation/git-for-each-ref.txt +++ b/Documentation/git-for-each-ref.txt @@ -134,9 +134,8 @@ the object referred by the ref does not cause an error. It returns an empty string instead. As a special case for the date-type fields, you may specify a format for -the date by adding one of `:default`, `:relative`, `:short`, `:local`, -`:iso8601`, `:rfc2822` or `:raw` to the end of the fieldname; e.g. -`%(taggerdate:relative)`. +the date by adding `:` followed by date format name (see the +values the `--date` option to linkgit::git-rev-list[1] takes). EXAMPLES -- cgit v0.10.2-6-g49f6 From 4b1c5e1d268fa1e7b4344e7d94de1edc5ead49a5 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Thu, 3 Sep 2015 22:48:54 +0100 Subject: Documentation/rev-list: don't list date formats We are about to add several new date formats which will make this list too long to display in a single line. Signed-off-by: John Keeping Signed-off-by: Junio C Hamano diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index b10ea60..51c7d07 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -45,7 +45,7 @@ SYNOPSIS [ --regexp-ignore-case | -i ] [ --extended-regexp | -E ] [ --fixed-strings | -F ] - [ --date=(local|relative|default|iso|iso-strict|rfc|short) ] + [ --date=] [ [ --objects | --objects-edge | --objects-edge-aggressive ] [ --unpacked ] ] [ --pretty | --header ] diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index a9b808f..14c4cce 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -699,7 +699,7 @@ include::pretty-options.txt[] --relative-date:: Synonym for `--date=relative`. ---date=(relative|local|default|iso|iso-strict|rfc|short|raw):: +--date=:: Only takes effect for dates shown in human-readable format, such as when using `--pretty`. `log.date` config variable sets a default value for the log command's `--date` option. -- cgit v0.10.2-6-g49f6 From 547ed71636dbfab2dc303ba8cabb29c2cab22f1e Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 3 Sep 2015 22:48:55 +0100 Subject: fast-import: switch crash-report date to iso8601 When fast-import emits a crash report, it does so in the user's local timezone. But because we omit the timezone completely for DATE_LOCAL, a reader of the report does not immediately know which time zone was used. Let's switch this to ISO8601 instead, which includes the time zone. This does mean we will show the time in UTC, but that's not a big deal. A crash report like this will either be looked at immediately (in which case nobody even looks at the timestamp), or it will be passed along to a developer to debug, in which case the original timezone is less likely to be of interest. Signed-off-by: Jeff King Signed-off-by: John Keeping Signed-off-by: Junio C Hamano diff --git a/fast-import.c b/fast-import.c index 9363cc7..1343865 100644 --- a/fast-import.c +++ b/fast-import.c @@ -421,7 +421,7 @@ static void write_crash_report(const char *err) fprintf(rpt, "fast-import crash report:\n"); fprintf(rpt, " fast-import process: %"PRIuMAX"\n", (uintmax_t) getpid()); fprintf(rpt, " parent process : %"PRIuMAX"\n", (uintmax_t) getppid()); - fprintf(rpt, " at %s\n", show_date(time(NULL), 0, DATE_MODE(LOCAL))); + fprintf(rpt, " at %s\n", show_date(time(NULL), 0, DATE_MODE(ISO8601))); fputc('\n', rpt); fputs("fatal: ", rpt); -- cgit v0.10.2-6-g49f6 From f95cecf43335dd8e80e954c2f998dc0e8b0dd070 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Thu, 3 Sep 2015 22:48:56 +0100 Subject: t6300: introduce test_date() helper This moves the setup of the "expected" file inside the test case. The helper function has the advantage that we can use SQ in the file content without needing to escape the quotes. Signed-off-by: John Keeping Signed-off-by: Junio C Hamano diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index c7f368c..c14c457 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -146,85 +146,73 @@ test_expect_success 'Check invalid format specifiers are errors' ' test_must_fail git for-each-ref --format="%(authordate:INVALID)" refs/heads ' -cat >expected <<\EOF -'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200' -'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200' -EOF +test_date () { + f=$1 && + committer_date=$2 && + author_date=$3 && + tagger_date=$4 && + cat >expected <<-EOF && + 'refs/heads/master' '$committer_date' '$author_date' + 'refs/tags/testtag' '$tagger_date' + EOF + ( + git for-each-ref --shell \ + --format="%(refname) %(committerdate${f:+:$f}) %(authordate${f:+:$f})" \ + refs/heads && + git for-each-ref --shell \ + --format="%(refname) %(taggerdate${f:+:$f})" \ + refs/tags + ) >actual && + test_cmp expected actual +} test_expect_success 'Check unformatted date fields output' ' - (git for-each-ref --shell --format="%(refname) %(committerdate) %(authordate)" refs/heads && - git for-each-ref --shell --format="%(refname) %(taggerdate)" refs/tags) >actual && - test_cmp expected actual + test_date "" \ + "Mon Jul 3 17:18:43 2006 +0200" \ + "Mon Jul 3 17:18:44 2006 +0200" \ + "Mon Jul 3 17:18:45 2006 +0200" ' test_expect_success 'Check format "default" formatted date fields output' ' - f=default && - (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && - git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual && - test_cmp expected actual + test_date default \ + "Mon Jul 3 17:18:43 2006 +0200" \ + "Mon Jul 3 17:18:44 2006 +0200" \ + "Mon Jul 3 17:18:45 2006 +0200" ' # Don't know how to do relative check because I can't know when this script # is going to be run and can't fake the current time to git, and hence can't # provide expected output. Instead, I'll just make sure that "relative" # doesn't exit in error -# -#cat >expected <<\EOF -# -#EOF -# test_expect_success 'Check format "relative" date fields output' ' f=relative && (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual ' -cat >expected <<\EOF -'refs/heads/master' '2006-07-03' '2006-07-03' -'refs/tags/testtag' '2006-07-03' -EOF - test_expect_success 'Check format "short" date fields output' ' - f=short && - (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && - git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual && - test_cmp expected actual + test_date short 2006-07-03 2006-07-03 2006-07-03 ' -cat >expected <<\EOF -'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006' -'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006' -EOF - test_expect_success 'Check format "local" date fields output' ' - f=local && - (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && - git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual && - test_cmp expected actual + test_date local \ + "Mon Jul 3 15:18:43 2006" \ + "Mon Jul 3 15:18:44 2006" \ + "Mon Jul 3 15:18:45 2006" ' -cat >expected <<\EOF -'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200' -'refs/tags/testtag' '2006-07-03 17:18:45 +0200' -EOF - test_expect_success 'Check format "iso8601" date fields output' ' - f=iso8601 && - (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && - git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual && - test_cmp expected actual + test_date iso8601 \ + "2006-07-03 17:18:43 +0200" \ + "2006-07-03 17:18:44 +0200" \ + "2006-07-03 17:18:45 +0200" ' -cat >expected <<\EOF -'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200' -'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200' -EOF - test_expect_success 'Check format "rfc2822" date fields output' ' - f=rfc2822 && - (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && - git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual && - test_cmp expected actual + test_date rfc2822 \ + "Mon, 3 Jul 2006 17:18:43 +0200" \ + "Mon, 3 Jul 2006 17:18:44 +0200" \ + "Mon, 3 Jul 2006 17:18:45 +0200" ' test_expect_success 'Check format of strftime date fields' ' -- cgit v0.10.2-6-g49f6 From f3c1ba502628cf0b6e8674f07c3850b21f365965 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Thu, 3 Sep 2015 22:48:57 +0100 Subject: t6300: add test for "raw" date format Signed-off-by: John Keeping Signed-off-by: Junio C Hamano diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index c14c457..c9b6e6d 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -215,6 +215,10 @@ test_expect_success 'Check format "rfc2822" date fields output' ' "Mon, 3 Jul 2006 17:18:45 +0200" ' +test_expect_success 'Check format "raw" date fields output' ' + test_date raw "1151939923 +0200" "1151939924 +0200" "1151939925 +0200" +' + test_expect_success 'Check format of strftime date fields' ' echo "my date is 2006-07-03" >expected && git for-each-ref \ -- cgit v0.10.2-6-g49f6 From dc6d782c5d2526b251061daffc3e74d15c8c7095 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Thu, 3 Sep 2015 22:48:58 +0100 Subject: date: check for "local" before anything else In a following commit we will make "local" orthogonal to the format. Although this will not apply to "relative", which does not use the timezone, it applies to all other formats so move the timezone conversion to the start of the function. Signed-off-by: John Keeping Signed-off-by: Junio C Hamano diff --git a/date.c b/date.c index 8f91569..9f0a5dd 100644 --- a/date.c +++ b/date.c @@ -174,6 +174,9 @@ const char *show_date(unsigned long time, int tz, const struct date_mode *mode) struct tm *tm; static struct strbuf timebuf = STRBUF_INIT; + if (mode->type == DATE_LOCAL) + tz = local_tzoffset(time); + if (mode->type == DATE_RAW) { strbuf_reset(&timebuf); strbuf_addf(&timebuf, "%lu %+05d", time, tz); @@ -189,9 +192,6 @@ const char *show_date(unsigned long time, int tz, const struct date_mode *mode) return timebuf.buf; } - if (mode->type == DATE_LOCAL) - tz = local_tzoffset(time); - tm = time_to_tm(time, tz); if (!tm) { tm = time_to_tm(0, 0); -- cgit v0.10.2-6-g49f6 From add00ba2de971e0c5ba00f1f02b73c5534079d2c Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 3 Sep 2015 22:48:59 +0100 Subject: date: make "local" orthogonal to date format Most of our "--date" modes are about the format of the date: which items we show and in what order. But "--date=local" is a bit of an oddball. It means "show the date in the normal format, but using the local timezone". The timezone we use is orthogonal to the actual format, and there is no reason we could not have "localized iso8601", etc. This patch adds a "local" boolean field to "struct date_mode", and drops the DATE_LOCAL element from the date_mode_type enum (it's now just DATE_NORMAL plus local=1). The new feature is accessible to users by adding "-local" to any date mode (e.g., "iso-local"), and we retain "local" as an alias for "default-local" for backwards compatibility. Signed-off-by: Jeff King Signed-off-by: John Keeping Signed-off-by: Junio C Hamano diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index 14c4cce..359587c 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -702,12 +702,16 @@ include::pretty-options.txt[] --date=:: Only takes effect for dates shown in human-readable format, such as when using `--pretty`. `log.date` config variable sets a default - value for the log command's `--date` option. + value for the log command's `--date` option. By default, dates + are shown in the original time zone (either committer's or + author's). If `-local` is appended to the format (e.g., + `iso-local`), the user's local time zone is used instead. + `--date=relative` shows dates relative to the current time, -e.g. ``2 hours ago''. +e.g. ``2 hours ago''. The `-local` option cannot be used with +`--raw` or `--relative`. + -`--date=local` shows timestamps in user's local time zone. +`--date=local` is an alias for `--date=default-local`. + `--date=iso` (or `--date=iso8601`) shows timestamps in a ISO 8601-like format. The differences to the strict ISO 8601 format are: @@ -730,10 +734,15 @@ format, often found in email messages. `--date=format:...` feeds the format `...` to your system `strftime`. Use `--date=format:%c` to show the date in your system locale's preferred format. See the `strftime` manual for a complete list of -format placeholders. +format placeholders. When using `-local`, the correct syntax is +`--date=format-local:...`. + -`--date=default` shows timestamps in the original time zone -(either committer's or author's). +`--date=default` is the default format, and is similar to +`--date=rfc2822`, with a few exceptions: + + - there is no comma after the day-of-week + + - the time zone is omitted when the local time zone is used ifdef::git-rev-list[] --header:: diff --git a/builtin/blame.c b/builtin/blame.c index 7cc499d..cb4ab20 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -2600,7 +2600,6 @@ parse_done: fewer display columns. */ blame_date_width = utf8_strwidth(_("4 years, 11 months ago")) + 1; /* add the null */ break; - case DATE_LOCAL: case DATE_NORMAL: blame_date_width = sizeof("Thu Oct 19 16:00:04 2006 -0700"); break; diff --git a/cache.h b/cache.h index 04c1907..ebb7256 100644 --- a/cache.h +++ b/cache.h @@ -1110,7 +1110,6 @@ struct date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT, - DATE_LOCAL, DATE_ISO8601, DATE_ISO8601_STRICT, DATE_RFC2822, @@ -1118,6 +1117,7 @@ struct date_mode { DATE_RAW } type; const char *strftime_fmt; + int local; }; /* diff --git a/date.c b/date.c index 9f0a5dd..7c9f769 100644 --- a/date.c +++ b/date.c @@ -166,6 +166,7 @@ struct date_mode *date_mode_from_type(enum date_mode_type type) if (type == DATE_STRFTIME) die("BUG: cannot create anonymous strftime date_mode struct"); mode.type = type; + mode.local = 0; return &mode; } @@ -174,7 +175,7 @@ const char *show_date(unsigned long time, int tz, const struct date_mode *mode) struct tm *tm; static struct strbuf timebuf = STRBUF_INIT; - if (mode->type == DATE_LOCAL) + if (mode->local) tz = local_tzoffset(time); if (mode->type == DATE_RAW) { @@ -232,7 +233,7 @@ const char *show_date(unsigned long time, int tz, const struct date_mode *mode) tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_year + 1900, - (mode->type == DATE_LOCAL) ? 0 : ' ', + mode->local ? 0 : ' ', tz); return timebuf.buf; } @@ -770,31 +771,50 @@ int parse_date(const char *date, struct strbuf *result) return 0; } +static enum date_mode_type parse_date_type(const char *format, const char **end) +{ + if (skip_prefix(format, "relative", end)) + return DATE_RELATIVE; + if (skip_prefix(format, "iso8601-strict", end) || + skip_prefix(format, "iso-strict", end)) + return DATE_ISO8601_STRICT; + if (skip_prefix(format, "iso8601", end) || + skip_prefix(format, "iso", end)) + return DATE_ISO8601; + if (skip_prefix(format, "rfc2822", end) || + skip_prefix(format, "rfc", end)) + return DATE_RFC2822; + if (skip_prefix(format, "short", end)) + return DATE_SHORT; + if (skip_prefix(format, "default", end)) + return DATE_NORMAL; + if (skip_prefix(format, "raw", end)) + return DATE_RAW; + if (skip_prefix(format, "format", end)) + return DATE_STRFTIME; + + die("unknown date format %s", format); +} + void parse_date_format(const char *format, struct date_mode *mode) { - if (!strcmp(format, "relative")) - mode->type = DATE_RELATIVE; - else if (!strcmp(format, "iso8601") || - !strcmp(format, "iso")) - mode->type = DATE_ISO8601; - else if (!strcmp(format, "iso8601-strict") || - !strcmp(format, "iso-strict")) - mode->type = DATE_ISO8601_STRICT; - else if (!strcmp(format, "rfc2822") || - !strcmp(format, "rfc")) - mode->type = DATE_RFC2822; - else if (!strcmp(format, "short")) - mode->type = DATE_SHORT; - else if (!strcmp(format, "local")) - mode->type = DATE_LOCAL; - else if (!strcmp(format, "default")) - mode->type = DATE_NORMAL; - else if (!strcmp(format, "raw")) - mode->type = DATE_RAW; - else if (skip_prefix(format, "format:", &format)) { - mode->type = DATE_STRFTIME; - mode->strftime_fmt = xstrdup(format); - } else + const char *p; + + /* historical alias */ + if (!strcmp(format, "local")) + format = "default-local"; + + mode->type = parse_date_type(format, &p); + mode->local = 0; + + if (skip_prefix(p, "-local", &p)) + mode->local = 1; + + if (mode->type == DATE_STRFTIME) { + if (!skip_prefix(p, ":", &p)) + die("date format missing colon separator: %s", format); + mode->strftime_fmt = xstrdup(p); + } else if (*p) die("unknown date format %s", format); } -- cgit v0.10.2-6-g49f6 From db7bae25ed8e80a7afad9a6a9240819528c5192c Mon Sep 17 00:00:00 2001 From: John Keeping Date: Thu, 3 Sep 2015 22:49:00 +0100 Subject: t6300: make UTC and local dates different By setting the UTC time to 23:18:43 the date in +0200 is the following day, 2006-07-04. This will ensure that the test for "short-local" to be added in the following patch tests for different output from the "short" format. Signed-off-by: John Keeping Signed-off-by: Junio C Hamano diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index c9b6e6d..4867df4 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -8,8 +8,8 @@ test_description='for-each-ref test' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-gpg.sh -# Mon Jul 3 15:18:43 2006 +0000 -datestamp=1151939923 +# Mon Jul 3 23:18:43 2006 +0000 +datestamp=1151968723 setdate_and_increment () { GIT_COMMITTER_DATE="$datestamp +0200" datestamp=$(expr "$datestamp" + 1) @@ -61,21 +61,21 @@ test_atom head object '' test_atom head type '' test_atom head '*objectname' '' test_atom head '*objecttype' '' -test_atom head author 'A U Thor 1151939924 +0200' +test_atom head author 'A U Thor 1151968724 +0200' test_atom head authorname 'A U Thor' test_atom head authoremail '' -test_atom head authordate 'Mon Jul 3 17:18:44 2006 +0200' -test_atom head committer 'C O Mitter 1151939923 +0200' +test_atom head authordate 'Tue Jul 4 01:18:44 2006 +0200' +test_atom head committer 'C O Mitter 1151968723 +0200' test_atom head committername 'C O Mitter' test_atom head committeremail '' -test_atom head committerdate 'Mon Jul 3 17:18:43 2006 +0200' +test_atom head committerdate 'Tue Jul 4 01:18:43 2006 +0200' test_atom head tag '' test_atom head tagger '' test_atom head taggername '' test_atom head taggeremail '' test_atom head taggerdate '' -test_atom head creator 'C O Mitter 1151939923 +0200' -test_atom head creatordate 'Mon Jul 3 17:18:43 2006 +0200' +test_atom head creator 'C O Mitter 1151968723 +0200' +test_atom head creatordate 'Tue Jul 4 01:18:43 2006 +0200' test_atom head subject 'Initial' test_atom head contents:subject 'Initial' test_atom head body '' @@ -96,7 +96,7 @@ test_atom tag parent '' test_atom tag numparent '' test_atom tag object $(git rev-parse refs/tags/testtag^0) test_atom tag type 'commit' -test_atom tag '*objectname' '67a36f10722846e891fbada1ba48ed035de75581' +test_atom tag '*objectname' 'ea122842f48be4afb2d1fc6a4b96c05885ab7463' test_atom tag '*objecttype' 'commit' test_atom tag author '' test_atom tag authorname '' @@ -107,18 +107,18 @@ test_atom tag committername '' test_atom tag committeremail '' test_atom tag committerdate '' test_atom tag tag 'testtag' -test_atom tag tagger 'C O Mitter 1151939925 +0200' +test_atom tag tagger 'C O Mitter 1151968725 +0200' test_atom tag taggername 'C O Mitter' test_atom tag taggeremail '' -test_atom tag taggerdate 'Mon Jul 3 17:18:45 2006 +0200' -test_atom tag creator 'C O Mitter 1151939925 +0200' -test_atom tag creatordate 'Mon Jul 3 17:18:45 2006 +0200' -test_atom tag subject 'Tagging at 1151939927' -test_atom tag contents:subject 'Tagging at 1151939927' +test_atom tag taggerdate 'Tue Jul 4 01:18:45 2006 +0200' +test_atom tag creator 'C O Mitter 1151968725 +0200' +test_atom tag creatordate 'Tue Jul 4 01:18:45 2006 +0200' +test_atom tag subject 'Tagging at 1151968727' +test_atom tag contents:subject 'Tagging at 1151968727' test_atom tag body '' test_atom tag contents:body '' test_atom tag contents:signature '' -test_atom tag contents 'Tagging at 1151939927 +test_atom tag contents 'Tagging at 1151968727 ' test_atom tag HEAD ' ' @@ -168,16 +168,16 @@ test_date () { test_expect_success 'Check unformatted date fields output' ' test_date "" \ - "Mon Jul 3 17:18:43 2006 +0200" \ - "Mon Jul 3 17:18:44 2006 +0200" \ - "Mon Jul 3 17:18:45 2006 +0200" + "Tue Jul 4 01:18:43 2006 +0200" \ + "Tue Jul 4 01:18:44 2006 +0200" \ + "Tue Jul 4 01:18:45 2006 +0200" ' test_expect_success 'Check format "default" formatted date fields output' ' test_date default \ - "Mon Jul 3 17:18:43 2006 +0200" \ - "Mon Jul 3 17:18:44 2006 +0200" \ - "Mon Jul 3 17:18:45 2006 +0200" + "Tue Jul 4 01:18:43 2006 +0200" \ + "Tue Jul 4 01:18:44 2006 +0200" \ + "Tue Jul 4 01:18:45 2006 +0200" ' # Don't know how to do relative check because I can't know when this script @@ -191,36 +191,36 @@ test_expect_success 'Check format "relative" date fields output' ' ' test_expect_success 'Check format "short" date fields output' ' - test_date short 2006-07-03 2006-07-03 2006-07-03 + test_date short 2006-07-04 2006-07-04 2006-07-04 ' test_expect_success 'Check format "local" date fields output' ' test_date local \ - "Mon Jul 3 15:18:43 2006" \ - "Mon Jul 3 15:18:44 2006" \ - "Mon Jul 3 15:18:45 2006" + "Mon Jul 3 23:18:43 2006" \ + "Mon Jul 3 23:18:44 2006" \ + "Mon Jul 3 23:18:45 2006" ' test_expect_success 'Check format "iso8601" date fields output' ' test_date iso8601 \ - "2006-07-03 17:18:43 +0200" \ - "2006-07-03 17:18:44 +0200" \ - "2006-07-03 17:18:45 +0200" + "2006-07-04 01:18:43 +0200" \ + "2006-07-04 01:18:44 +0200" \ + "2006-07-04 01:18:45 +0200" ' test_expect_success 'Check format "rfc2822" date fields output' ' test_date rfc2822 \ - "Mon, 3 Jul 2006 17:18:43 +0200" \ - "Mon, 3 Jul 2006 17:18:44 +0200" \ - "Mon, 3 Jul 2006 17:18:45 +0200" + "Tue, 4 Jul 2006 01:18:43 +0200" \ + "Tue, 4 Jul 2006 01:18:44 +0200" \ + "Tue, 4 Jul 2006 01:18:45 +0200" ' test_expect_success 'Check format "raw" date fields output' ' - test_date raw "1151939923 +0200" "1151939924 +0200" "1151939925 +0200" + test_date raw "1151968723 +0200" "1151968724 +0200" "1151968725 +0200" ' test_expect_success 'Check format of strftime date fields' ' - echo "my date is 2006-07-03" >expected && + echo "my date is 2006-07-04" >expected && git for-each-ref \ --format="%(authordate:format:my date is %Y-%m-%d)" \ refs/heads >actual && @@ -528,8 +528,8 @@ body contents $sig" cat >expected < refs/tags/master $(git rev-parse refs/tags/bogo) refs/tags/bogo +$(git rev-parse refs/tags/master) refs/tags/master EOF test_expect_success 'Verify sort with multiple keys' ' -- cgit v0.10.2-6-g49f6 From 99264e93fc87bdd61f646c53878782947d476da8 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Thu, 3 Sep 2015 22:49:01 +0100 Subject: t6300: add tests for "-local" date formats Signed-off-by: John Keeping Signed-off-by: Junio C Hamano diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index 4867df4..d6c9e62 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -180,6 +180,10 @@ test_expect_success 'Check format "default" formatted date fields output' ' "Tue Jul 4 01:18:45 2006 +0200" ' +test_expect_success 'Check format "default-local" date fields output' ' + test_date default-local "Mon Jul 3 23:18:43 2006" "Mon Jul 3 23:18:44 2006" "Mon Jul 3 23:18:45 2006" +' + # Don't know how to do relative check because I can't know when this script # is going to be run and can't fake the current time to git, and hence can't # provide expected output. Instead, I'll just make sure that "relative" @@ -190,10 +194,22 @@ test_expect_success 'Check format "relative" date fields output' ' git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual ' +# We just check that this is the same as "relative" for now. +test_expect_success 'Check format "relative-local" date fields output' ' + test_date relative-local \ + "$(git for-each-ref --format="%(committerdate:relative)" refs/heads)" \ + "$(git for-each-ref --format="%(authordate:relative)" refs/heads)" \ + "$(git for-each-ref --format="%(taggerdate:relative)" refs/tags)" +' + test_expect_success 'Check format "short" date fields output' ' test_date short 2006-07-04 2006-07-04 2006-07-04 ' +test_expect_success 'Check format "short-local" date fields output' ' + test_date short-local 2006-07-03 2006-07-03 2006-07-03 +' + test_expect_success 'Check format "local" date fields output' ' test_date local \ "Mon Jul 3 23:18:43 2006" \ @@ -208,6 +224,10 @@ test_expect_success 'Check format "iso8601" date fields output' ' "2006-07-04 01:18:45 +0200" ' +test_expect_success 'Check format "iso8601-local" date fields output' ' + test_date iso8601-local "2006-07-03 23:18:43 +0000" "2006-07-03 23:18:44 +0000" "2006-07-03 23:18:45 +0000" +' + test_expect_success 'Check format "rfc2822" date fields output' ' test_date rfc2822 \ "Tue, 4 Jul 2006 01:18:43 +0200" \ @@ -215,10 +235,18 @@ test_expect_success 'Check format "rfc2822" date fields output' ' "Tue, 4 Jul 2006 01:18:45 +0200" ' +test_expect_success 'Check format "rfc2822-local" date fields output' ' + test_date rfc2822-local "Mon, 3 Jul 2006 23:18:43 +0000" "Mon, 3 Jul 2006 23:18:44 +0000" "Mon, 3 Jul 2006 23:18:45 +0000" +' + test_expect_success 'Check format "raw" date fields output' ' test_date raw "1151968723 +0200" "1151968724 +0200" "1151968725 +0200" ' +test_expect_success 'Check format "raw-local" date fields output' ' + test_date raw-local "1151968723 +0000" "1151968724 +0000" "1151968725 +0000" +' + test_expect_success 'Check format of strftime date fields' ' echo "my date is 2006-07-04" >expected && git for-each-ref \ @@ -227,6 +255,14 @@ test_expect_success 'Check format of strftime date fields' ' test_cmp expected actual ' +test_expect_success 'Check format of strftime-local date fields' ' + echo "my date is 2006-07-03" >expected && + git for-each-ref \ + --format="%(authordate:format-local:my date is %Y-%m-%d)" \ + refs/heads >actual && + test_cmp expected actual +' + cat >expected <<\EOF refs/heads/master refs/remotes/origin/master -- cgit v0.10.2-6-g49f6