{"thread":{"id":"2771","subject":"[PATCH] cg-object-id: use git-rev-parse(1) for date parsing","startedAt":"2005-12-07T21:40:13Z","lastAt":"2005-12-07T21:40:13Z","messageCount":1,"participants":["Jonas Fonseca"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"13334","messageId":"20051207214013.GD25890@diku.dk","threadId":"2771","inReplyTo":null,"subject":"[PATCH] cg-object-id: use git-rev-parse(1) for date parsing","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-12-07T21:40:13Z","receivedAt":"2005-12-07T21:40:13Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Using the --until switch, git-rev-parse(1) will first be given the ID. If it\ncannot make sense of the ID fallback to using date(1).\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n\n---\n\n The mixing of date parsing behaviours might be a little questionable,\n but it's good to stay compatible with git.\n\ncommit 41447107236a7d23daa6ab0f40a0829935485bc8\ntree 27863684c19e7f129304d2a1573c08f974126e2a\nparent f0535e9952f1cace89d03649e8238aca69a6df44\nauthor Jonas Fonseca <fonseca@diku.dk> Wed, 07 Dec 2005 22:16:50 +0100\ncommitter Jonas Fonseca <fonseca@antimatter.localdomain> Wed, 07 Dec 2005 22:16:50 +0100\n\n cg-object-id |    9 ++++++++-\n 1 files changed, 8 insertions(+), 1 deletions(-)\n\ndiff --git a/cg-object-id b/cg-object-id\nindex ea04dca..baf096e 100755\n--- a/cg-object-id\n+++ b/cg-object-id\n@@ -73,7 +73,14 @@ normalize_id()\n \tfi\n \n \tif [ \"$id\" != \" \" ] && [ ! \"$valid\" ]; then\n-\t\treqsecs=$(date --date=\"$id\" +'%s' 2>/dev/null)\n+\t\tcurtime=$(date +'%s' 2>/dev/null)\n+\t\treqsecs=$(git-rev-parse --until=\"$id\"); reqsecs=${reqsecs:10}\n+\n+\t\t# git-rev-parse(1) will output the current time if the ID\n+\t\t# doesn't make sense. Workaround it so date(1) can have a try.\n+\t\tif [ \"$curtime\" -le \"$reqsecs\" ]; then\n+\t\t\treqsecs=$(date --date=\"$id\" +'%s' 2>/dev/null)\n+\t\tfi\n \n \t\tif [ \"$reqsecs\" ]; then\n \t\t\tid=$(git-rev-list --min-age=$reqsecs --max-count=1 HEAD)\n\n-- \nJonas Fonseca\n"}]}