Re: Something like $Id$, $Revision$ or $Date$?

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

 



Hi,

On Mon, Nov 10, 2008 at 6:46 AM, Michal Nazarewicz <mina86@xxxxxxx> wrote:
> "Sverre Rabbelier" <alturin@xxxxxxxxx> writes:
>
>> On Mon, Nov 10, 2008 at 01:22, Michal Nazarewicz <mina86@xxxxxxx> wrote:
>>> Now, what I need is such feature in GIT.  Upon committing I would like
>>> some magic string (say "$Date$") to be replaced with some value
>>> identifying uniquely given version of a file (a date of the commit would
>>> be sufficient).
>>
>> Please have a look at the relevant entry in the faq [0].
>>
>> [0] http://git.or.cz/gitwiki/GitFaq#head-4a0afe71a2bb7734777a8b0b345e0308aefdbd40
>
> Thanks for the quick reply (and yes, I can't believe I couldn't find
> that myself...) but it still lacks one thing that I'd like to have.
> I would like the "$Id$" sequences to be updated automatically after
> a commit (ie. without the need to check out).  (Besides I would prefer
> $Date$ more but I can live with $Id$ I guess ;) ).

I have worked on this topic quite a bit to fix issues in git-p4. There
is no direct way to get this $Id$ expansion in git, however you can
use a simple pre-commit hook (alpha state, more a proof of concept
that happens to work for me)

#!/usr/bin/env bash

for file in `git diff-index --name-only --diff-filter=AM HEAD` ; do
        perl -pi -e 's/(\$[ \t]*Id)(.*)([ \t]*\$)/"\$Id: git
".time()." \$"/e' ${file}
        git add ${file} > /dev/null
done

-dhruva

-- 
Contents reflect my personal views only!
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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