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

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

 



> On Mon, Nov 10, 2008 at 6:46 AM, Michal Nazarewicz <mina86@xxxxxxx> wrote:
>> I would like the "$Id$" sequences to be updated automatically after
>> a commit (ie. without the need to check out).

dhruva <dhruvakm@xxxxxxxxx> writes:
> 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

In fact the following works just as well:

#v+
files=$(git diff-index --name-only --diff-filter=AM HEAD)
perl -pi -e 's/\$\s*Id.*?\$/\$Id: git '$(TZ=UTC date +%s)' \$/g' $files
git add $files
#v-

But then again, it has two unpleasant side effects: (i) all modified
files are added and (ii) if I abort a commit the file stays modified.
(i) can be fixed by removing "git add" but then again (iii) even files
which are not committed will be modified.

-- 
Best regards,                                         _     _
 .o. | Liege of Serenly Enlightened Majesty of      o' \,=./ `o
 ..o | Computer Science,  Michal "mina86" Nazarewicz   (o o)
 ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--

Attachment: pgpLYH7ATwCvW.pgp
Description: PGP signature


[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