{"thread":{"id":"8300","subject":"[PATCH] name-rev: tolerate clock skew in committer dates","startedAt":"2007-05-24T19:21:55Z","lastAt":"2007-05-24T19:46:21Z","messageCount":2,"participants":["Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"43170","messageId":"7vr6p6vxgs.fsf@assigned-by-dhcp.cox.net","threadId":"8300","inReplyTo":null,"subject":"[PATCH] name-rev: tolerate clock skew in committer dates","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-24T19:21:55Z","receivedAt":"2007-05-24T19:21:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"In git.git repository, \"git-name-rev v1.3.0~158\" cannot name the\nrev, while adjacent revs can be named.\n\nThis was because it gives up traversal from the tips of existing\nrefs as soon as it sees a commit that has older commit timestamp\nthan what is being named.  This is usually a good heuristics,\nbut v1.3.0~158 has a slightly older commit timestamp than\nv1.3.0~157 (i.e. it's child), as these two were made in a\nseparate repostiory (in fact, in a different continent).\n\nThis adds a hardcoded slop value (1 day) to the cut-off\nheuristics to work this kind of problem around.  The current\nalgorithm essentially runs around from the available tips down\nto ancient commits and names every single rev available that are\nnewer than cut-off date, so a single day slop would not add that\nmuch overhead in repositories with long enough history where the\nperformance of name-rev matters.\n\nI think the algorithm could be made a bit smarter by deepening\nthe graph on demand as a new commit is asked to be named (this\nwould require rewriting of name_rev() function not to recurse\nitself but use a traversal list like revision.c traverser does),\nbut that would be a separate issue.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n builtin-name-rev.c |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-name-rev.c b/builtin-name-rev.c\nindex a639e2f..d3c42ed 100644\n--- a/builtin-name-rev.c\n+++ b/builtin-name-rev.c\n@@ -4,6 +4,8 @@\n #include \"tag.h\"\n #include \"refs.h\"\n \n+#define CUTOFF_DATE_SLOP 86400 /* one day */\n+\n static const char name_rev_usage[] =\n \t\"git-name-rev [--tags | --refs=<pattern>] ( --all | --stdin | committish [committish...] )\\n\";\n \n@@ -216,6 +218,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\tadd_object_array((struct object *)commit, *argv, &revs);\n \t}\n \n+\tif (cutoff)\n+\t\tcutoff = cutoff - CUTOFF_DATE_SLOP;\n \tfor_each_ref(name_ref, &data);\n \n \tif (transform_stdin) {\n-- \n1.5.2.58.g98ee\n"},{"id":"43174","messageId":"Pine.LNX.4.64.0705242042530.4648@racer.site","threadId":"8300","inReplyTo":"7vr6p6vxgs.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] name-rev: tolerate clock skew in committer dates","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-05-24T19:46:21Z","receivedAt":"2007-05-24T19:46:21Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 24 May 2007, Junio C Hamano wrote:\n\n> This adds a hardcoded slop value (1 day) to the cut-off\n> heuristics to work this kind of problem around.\n\nSounds sensible. (ACK.)\n\n> I think the algorithm could be made a bit smarter by deepening the graph \n> on demand as a new commit is asked to be named (this would require \n> rewriting of name_rev() function not to recurse itself but use a \n> traversal list like revision.c traverser does), but that would be a \n> separate issue.\n\nI also wanted to make the decorator (optionally) smarter, to actually do \nsomething like name_rev on demand, which would be much faster than (and \ncoloured, in contrast to) `git log | git -p name-rev --stdin`.\n\nCiao,\nDscho\n"}]}