* Integrating with hooks
@ 2007-11-13 17:37 Todd A. Jacobs
2007-11-13 23:07 ` Jakub Narebski
0 siblings, 1 reply; 6+ messages in thread
From: Todd A. Jacobs @ 2007-11-13 17:37 UTC (permalink / raw)
To: git
I've created some bash functions which handle tagging some files with
revision information, but even after reading the git manual I'm not
really sure how to integrate them so that they remove revision expansion
before each check-in (to avoid cluttering the repository with keyword
substitutions), and add them back (with the current commit info) after
each commit.
These are the functions:
# Show some kind of useful revision string, like the RCS $Id$ string. I
# think commit hash, filename, hostname containing the repository, and
# timestamp should be plenty of information to track down a given file.
git-id () {
for file in "$@"; do
_date=$(date +'%F %T %Z')
git log -1 \
--pretty=format:"[%h] \"$file\" $(hostname -f) ($_date)" \
"$file"
done
}
# Replace the $Id$ keyword string in the file itself.
git-export () {
for file in "$@"; do
echo Modifying $file...
_id=$(git-id "$file")
sed -ri 's/\$(Id|Revision).*\$/$Id: '"$_id"' $/' "$file"
done
}
# Clean the $Id$ keyword string to prevent cluttering the repository
# with keyword-revision diffs when we check the file back in.
git-unexport () {
for file in "$@"; do
echo Resetting $file...
sed -ri 's/\$Id.*\$/$Id$/' "$file"
done
}
How do I hook this in the way I want so that it's handled automatically?
--
"Oh, look: rocks!"
-- Doctor Who, "Destiny of the Daleks"
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Integrating with hooks
2007-11-13 17:37 Integrating with hooks Todd A. Jacobs
@ 2007-11-13 23:07 ` Jakub Narebski
2007-11-15 1:18 ` Todd A. Jacobs
0 siblings, 1 reply; 6+ messages in thread
From: Jakub Narebski @ 2007-11-13 23:07 UTC (permalink / raw)
To: git
[Cc: Todd A. Jacobs <nospam@codegnome.org>, git@vger.kernel.org]
Todd A. Jacobs wrote:
> I've created some bash functions which handle tagging some files with
> revision information, but even after reading the git manual I'm not
> really sure how to integrate them so that they remove revision expansion
> before each check-in (to avoid cluttering the repository with keyword
> substitutions), and add them back (with the current commit info) after
> each commit.
>
> These are the functions:
[...]
> How do I hook this in the way I want so that it's handled automatically?
Take a look at gitattributes(5), namely 'filter' attribute.
Although instead of implementing it "by hand", perhaps it would be
enough to use 'ident' and/or 'export-subs' attribute.
P.S. Because of the way git updates files, and git thinks about files
it is I think universally regarded to be bad idea to put in a file
any Id that depend on commit data.
--
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Integrating with hooks
2007-11-13 23:07 ` Jakub Narebski
@ 2007-11-15 1:18 ` Todd A. Jacobs
2007-11-15 1:43 ` Jakub Narebski
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Todd A. Jacobs @ 2007-11-15 1:18 UTC (permalink / raw)
To: git
On Wed, Nov 14, 2007 at 12:07:29AM +0100, Jakub Narebski wrote:
> Take a look at gitattributes(5), namely 'filter' attribute.
Thanks, I took a look at the man page you suggested. The "ident" feature
almost does what I want, but doesn't seem to take any sort of format
string. So, I thought I'd explore "filter," but can't really find any
examples of how to implement the smudge and clean commands, which seem
to be what I'm really trying to do here.
Is there an example somewhere that you can point me to? The man page
doesn't really show any examples of how to implement the filter
attribute, so I'm a little unsure how to proceed.
--
"Oh, look: rocks!"
-- Doctor Who, "Destiny of the Daleks"
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Integrating with hooks
2007-11-15 1:18 ` Todd A. Jacobs
@ 2007-11-15 1:43 ` Jakub Narebski
2007-11-15 1:43 ` Johannes Schindelin
2007-11-15 7:57 ` Johannes Sixt
2 siblings, 0 replies; 6+ messages in thread
From: Jakub Narebski @ 2007-11-15 1:43 UTC (permalink / raw)
To: git
Todd A. Jacobs wrote:
> On Wed, Nov 14, 2007 at 12:07:29AM +0100, Jakub Narebski wrote:
>
>> Take a look at gitattributes(5), namely 'filter' attribute.
>
> Thanks, I took a look at the man page you suggested. The "ident" feature
> almost does what I want, but doesn't seem to take any sort of format
> string.
The `ident` feature provides only sensible Id for a file (if you want to
avoid potentially rewriting _all_ and not only changed files on checkout /
switching branch / reset --hard). All Ids which have commit info, like
commit id, commit date, author are not sensible in mentioned sense.
> So, I thought I'd explore "filter," but can't really find any
> examples of how to implement the smudge and clean commands, which seem
> to be what I'm really trying to do here.
>
> Is there an example somewhere that you can point me to? The man page
> doesn't really show any examples of how to implement the filter
> attribute, so I'm a little unsure how to proceed.
Cannot help you there, but see examples of `diff` and `merge` attributes,
it should I think be similar.
--
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Integrating with hooks
2007-11-15 1:18 ` Todd A. Jacobs
2007-11-15 1:43 ` Jakub Narebski
@ 2007-11-15 1:43 ` Johannes Schindelin
2007-11-15 7:57 ` Johannes Sixt
2 siblings, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2007-11-15 1:43 UTC (permalink / raw)
To: Todd A. Jacobs; +Cc: git
Hi,
On Wed, 14 Nov 2007, Todd A. Jacobs wrote:
> On Wed, Nov 14, 2007 at 12:07:29AM +0100, Jakub Narebski wrote:
>
> > Take a look at gitattributes(5), namely 'filter' attribute.
>
> Thanks, I took a look at the man page you suggested. The "ident" feature
> almost does what I want, but doesn't seem to take any sort of format
> string.
Note that the ident feature will give you _only_ the blob sha1.
I guess that you're more interested in the export-subst feature.
Hth,
Dscho
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Integrating with hooks
2007-11-15 1:18 ` Todd A. Jacobs
2007-11-15 1:43 ` Jakub Narebski
2007-11-15 1:43 ` Johannes Schindelin
@ 2007-11-15 7:57 ` Johannes Sixt
2 siblings, 0 replies; 6+ messages in thread
From: Johannes Sixt @ 2007-11-15 7:57 UTC (permalink / raw)
To: Todd A. Jacobs; +Cc: git
Todd A. Jacobs schrieb:
> On Wed, Nov 14, 2007 at 12:07:29AM +0100, Jakub Narebski wrote:
>
>> Take a look at gitattributes(5), namely 'filter' attribute.
>
> Thanks, I took a look at the man page you suggested. The "ident" feature
> almost does what I want, but doesn't seem to take any sort of format
> string. So, I thought I'd explore "filter," but can't really find any
> examples of how to implement the smudge and clean commands, which seem
> to be what I'm really trying to do here.
A clean and smudge filter processes one file at a time. It reads the old
content from stdin and writes the result to stdout.
There is a tiny example in the test suite, t/t0021-conversion.sh, look for
rot13.sh.
-- Hannes
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-11-15 7:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-13 17:37 Integrating with hooks Todd A. Jacobs
2007-11-13 23:07 ` Jakub Narebski
2007-11-15 1:18 ` Todd A. Jacobs
2007-11-15 1:43 ` Jakub Narebski
2007-11-15 1:43 ` Johannes Schindelin
2007-11-15 7:57 ` Johannes Sixt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).