From: Junio C Hamano Date: Fri, 9 Sep 2016 04:35:52 +0000 (-0700) Subject: Merge branch 'jk/reflog-date' into maint X-Git-Tag: v2.9.4~22 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/f59c6e6ccb1386f0fdde2753f62536dfd3343118?ds=inline;hp=-c Merge branch 'jk/reflog-date' into maint The reflog output format is documented better, and a new format --date=unix to report the seconds-since-epoch (without timezone) has been added. * jk/reflog-date: date: clarify --date=raw description date: add "unix" format date: document and test "raw-local" mode doc/pretty-formats: explain shortening of %gd doc/pretty-formats: describe index/time formats for %gd doc/rev-list-options: explain "-g" output formats doc/rev-list-options: clarify "commit@{Nth}" for "-g" option --- f59c6e6ccb1386f0fdde2753f62536dfd3343118 diff --combined Documentation/rev-list-options.txt index c5bd21812d,bee54a6177..eac982cd66 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@@ -193,7 -193,7 +193,7 @@@ endif::git-rev-list[ --stdin:: In addition to the '' listed on the command - line, read them from the standard input. If a '--' separator is + line, read them from the standard input. If a `--` separator is seen, stop reading commits and start reading paths to limit the result. @@@ -252,10 -252,25 +252,25 @@@ list + With `--pretty` format other than `oneline` (for obvious reasons), this causes the output to have two extra lines of information - taken from the reflog. By default, 'commit@\{Nth}' notation is - used in the output. When the starting commit is specified as - 'commit@\{now}', output also uses 'commit@\{timestamp}' notation - instead. Under `--pretty=oneline`, the commit message is + taken from the reflog. The reflog designator in the output may be shown + as `ref@{Nth}` (where `Nth` is the reverse-chronological index in the + reflog) or as `ref@{timestamp}` (with the timestamp for that entry), + depending on a few rules: + + + -- + 1. If the starting point is specified as `ref@{Nth}`, show the index + format. + + + 2. If the starting point was specified as `ref@{now}`, show the + timestamp format. + + + 3. If neither was used, but `--date` was given on the command line, show + the timestamp in the format requested by `--date`. + + + 4. Otherwise, show the index format. + -- + + + Under `--pretty=oneline`, the commit message is prefixed with this information on the same line. This option cannot be combined with `--reverse`. See also linkgit:git-reflog[1]. @@@ -710,8 -725,8 +725,8 @@@ include::pretty-options.txt[ `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''. The `-local` option cannot be used with - `--raw` or `--relative`. + e.g. ``2 hours ago''. The `-local` option has no effect for + `--date=relative`. + `--date=local` is an alias for `--date=default-local`. + @@@ -731,7 -746,18 +746,18 @@@ format, often found in email messages + `--date=short` shows only the date, but not the time, in `YYYY-MM-DD` format. + - `--date=raw` shows the date in the internal raw Git format `%s %z` format. + `--date=raw` shows the date as seconds since the epoch (1970-01-01 + 00:00:00 UTC), followed by a space, and then the timezone as an offset + from UTC (a `+` or `-` with four digits; the first two are hours, and + the second two are minutes). I.e., as if the timestamp were formatted + with `strftime("%s %z")`). + Note that the `-local` option does not affect the seconds-since-epoch + value (which is always measured in UTC), but does switch the accompanying + timezone value. + + + `--date=unix` shows the date as a Unix epoch timestamp (seconds since + 1970). As with `--raw`, this is always in UTC and therefore `-local` + has no effect. + `--date=format:...` feeds the format `...` to your system `strftime`. Use `--date=format:%c` to show the date in your system locale's diff --combined builtin/blame.c index d123e2e6ae,002e70f9b5..5e5d30ecbc --- a/builtin/blame.c +++ b/builtin/blame.c @@@ -134,7 -134,7 +134,7 @@@ struct progress_info int blamed_lines; }; -static int diff_hunks(mmfile_t *file_a, mmfile_t *file_b, long ctxlen, +static int diff_hunks(mmfile_t *file_a, mmfile_t *file_b, xdl_emit_hunk_consume_func_t hunk_func, void *cb_data) { xpparam_t xpp = {0}; @@@ -142,6 -142,7 +142,6 @@@ xdemitcb_t ecb = {NULL}; xpp.flags = xdl_opts; - xecfg.ctxlen = ctxlen; xecfg.hunk_func = hunk_func; ecb.priv = cb_data; return xdi_diff(file_a, file_b, &xpp, &xecfg, &ecb); @@@ -979,7 -980,7 +979,7 @@@ static void pass_blame_to_parent(struc fill_origin_blob(&sb->revs->diffopt, target, &file_o); num_get_patch++; - if (diff_hunks(&file_p, &file_o, 0, blame_chunk_cb, &d)) + if (diff_hunks(&file_p, &file_o, blame_chunk_cb, &d)) die("unable to generate diff (%s -> %s)", oid_to_hex(&parent->commit->object.oid), oid_to_hex(&target->commit->object.oid)); @@@ -1128,7 -1129,7 +1128,7 @@@ static void find_copy_in_blob(struct sc * file_p partially may match that image. */ memset(split, 0, sizeof(struct blame_entry [3])); - if (diff_hunks(file_p, &file_o, 1, handle_split_cb, &d)) + if (diff_hunks(file_p, &file_o, handle_split_cb, &d)) die("unable to generate diff (%s)", oid_to_hex(&parent->commit->object.oid)); /* remainder, if any, all match the preimage */ @@@ -2229,7 -2230,6 +2229,7 @@@ static int git_blame_config(const char static void verify_working_tree_path(struct commit *work_tree, const char *path) { struct commit_list *parents; + int pos; for (parents = work_tree->parents; parents; parents = parents->next) { const unsigned char *commit_sha1 = parents->item->object.oid.hash; @@@ -2240,14 -2240,7 +2240,14 @@@ sha1_object_info(blob_sha1, NULL) == OBJ_BLOB) return; } - die("no such path '%s' in HEAD", path); + + pos = cache_name_pos(path, strlen(path)); + if (pos >= 0) + ; /* path is in the index */ + else if (!strcmp(active_cache[-1 - pos]->name, path)) + ; /* path is in the index, unmerged */ + else + die("no such path '%s' in HEAD", path); } static struct commit_list **append_parent(struct commit_list **tail, const unsigned char *sha1) @@@ -2633,6 -2626,9 +2633,9 @@@ parse_done case DATE_RAW: blame_date_width = sizeof("1161298804 -0700"); break; + case DATE_UNIX: + blame_date_width = sizeof("1161298804"); + break; case DATE_SHORT: blame_date_width = sizeof("2006-10-19"); break; diff --combined cache.h index c0d6cdb60c,ace7f70e3b..1fd2d5dc3e --- a/cache.h +++ b/cache.h @@@ -632,7 -632,6 +632,7 @@@ extern void fill_stat_cache_info(struc #define REFRESH_IGNORE_SUBMODULES 0x0010 /* ignore submodules */ #define REFRESH_IN_PORCELAIN 0x0020 /* user friendly output, not "needs update" */ extern int refresh_index(struct index_state *, unsigned int flags, const struct pathspec *pathspec, char *seen, const char *header_msg); +extern struct cache_entry *refresh_cache_entry(struct cache_entry *, unsigned int); extern void update_index_if_able(struct index_state *, struct lock_file *); @@@ -1224,7 -1223,8 +1224,8 @@@ struct date_mode DATE_ISO8601_STRICT, DATE_RFC2822, DATE_STRFTIME, - DATE_RAW + DATE_RAW, + DATE_UNIX } type; const char *strftime_fmt; int local; @@@ -1263,7 -1263,6 +1264,7 @@@ extern const char *ident_default_email( extern const char *git_editor(void); extern const char *git_pager(int stdout_is_tty); extern int git_ident_config(const char *, const char *, void *); +extern void reset_ident_date(void); struct ident_split { const char *name_begin; @@@ -1510,7 -1509,7 +1511,7 @@@ struct object_info /* Request */ enum object_type *typep; unsigned long *sizep; - unsigned long *disk_sizep; + off_t *disk_sizep; unsigned char *delta_base_sha1; struct strbuf *typename; @@@ -1723,6 -1722,7 +1724,6 @@@ extern int copy_file(const char *dst, c extern int copy_file_with_time(const char *dst, const char *src, int mode); extern void write_or_die(int fd, const void *buf, size_t count); -extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg); extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg); extern void fsync_or_die(int fd, const char *);