Re: How to determine age of HEAD commit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2019-12-08 at 12:09 +0000, Philip Oakley wrote:
> Is there a command that does return the numeric agedness of a commit 
> (e.g. now - commit_date, in seconds)?

Hi

I don't know a specific command for the age. But `git cat-file commit
HEAD`, will give you the commit's timestamps in seconds from the the
epoch. (Plus some timezone info).

I can construct a bash script, shown below (warning: only had the most 
rudimentary testing), which turns that into an age. For your use case
you might be better getting yesterdays unix-timestamp from date, if GNU
date is available, and directly comparing it to the commit timestamp.

------
#!/bin/bash

now=$(date +"%s")
commit=$(git cat-file commit HEAD | grep committer)
commit=${commit##*>}
commit=${commit%%+*}
echo $(( $now-$commit ))
#--------------

-- 
Roger Gammans <rgammans@xxxxxxxxxxxxxxxxxx>




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux