Git development
 help / color / mirror / Atom feed
From: Michal Nazarewicz <mina86@tlen.pl>
To: dhruva <dhruvakm@gmail.com>
Cc: sverre@rabbelier.nl, git@vger.kernel.org
Subject: Re: Something like $Id$, $Revision$ or $Date$?
Date: Mon, 10 Nov 2008 10:49:31 +0100	[thread overview]
Message-ID: <8763mvoqqc.fsf@erwin.mina86.com> (raw)
In-Reply-To: <e3f230850811091943k63e4a93n566402458a6947dd@mail.gmail.com> (dhruva's message of "Mon, 10 Nov 2008 09:13:04 +0530")

[-- Attachment #1: Type: text/plain, Size: 1386 bytes --]

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

dhruva <dhruvakm@gmail.com> 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 #2: Type: application/pgp-signature, Size: 196 bytes --]

  reply	other threads:[~2008-11-10  9:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-10  0:22 Something like $Id$, $Revision$ or $Date$? Michal Nazarewicz
2008-11-10  0:43 ` Sverre Rabbelier
2008-11-10  1:16   ` Michal Nazarewicz
2008-11-10  3:43     ` dhruva
2008-11-10  9:49       ` Michal Nazarewicz [this message]
2008-11-10  7:26     ` Johannes Sixt
2008-11-10 12:25     ` Johannes Schindelin
2008-11-10 14:05       ` dhruva
2008-11-10 15:48       ` Michal Nazarewicz
2008-11-10 15:58         ` Francis Galiegue
2008-11-10 15:59 ` Jakub Narebski
2008-11-10 17:38   ` Michal Nazarewicz
2008-11-10 18:03     ` Jakub Narebski
2008-11-10 20:00       ` Michal Nazarewicz
2008-11-10 20:17         ` Jakub Narebski
2008-11-10 20:24           ` Francis Galiegue
2008-11-10 20:32             ` Jakub Narebski
2008-11-10 20:58               ` Brian Gernhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8763mvoqqc.fsf@erwin.mina86.com \
    --to=mina86@tlen.pl \
    --cc=dhruvakm@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sverre@rabbelier.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox