From: Jeff King <peff@peff.net>
To: "MichaelTiloDressel@t-online.de" <MichaelTiloDressel@t-online.de>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: [PATCH 1/2] decorate: allow const objects to be decorated
Date: Wed, 20 Aug 2008 13:55:33 -0400 [thread overview]
Message-ID: <20080820175532.GA32005@sigill.intra.peff.net> (raw)
In-Reply-To: <20080820175325.GD27773@sigill.intra.peff.net>
We don't actually modify the struct object, so there is no
reason not to accept const versions (and this allows other
callsites, like the next patch, to use the decoration
machinery).
Signed-off-by: Jeff King <peff@peff.net>
---
This one is hopefully a no-brainer, and is required for the next patch.
decorate.c | 11 ++++++-----
decorate.h | 6 +++---
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/decorate.c b/decorate.c
index d9668d2..82d9e22 100644
--- a/decorate.c
+++ b/decorate.c
@@ -6,13 +6,13 @@
#include "object.h"
#include "decorate.h"
-static unsigned int hash_obj(struct object *obj, unsigned int n)
+static unsigned int hash_obj(const struct object *obj, unsigned int n)
{
unsigned int hash = *(unsigned int *)obj->sha1;
return hash % n;
}
-static void *insert_decoration(struct decoration *n, struct object *base, void *decoration)
+static void *insert_decoration(struct decoration *n, const struct object *base, void *decoration)
{
int size = n->size;
struct object_decoration *hash = n->hash;
@@ -44,7 +44,7 @@ static void grow_decoration(struct decoration *n)
n->nr = 0;
for (i = 0; i < old_size; i++) {
- struct object *base = old_hash[i].base;
+ const struct object *base = old_hash[i].base;
void *decoration = old_hash[i].decoration;
if (!base)
@@ -55,7 +55,8 @@ static void grow_decoration(struct decoration *n)
}
/* Add a decoration pointer, return any old one */
-void *add_decoration(struct decoration *n, struct object *obj, void *decoration)
+void *add_decoration(struct decoration *n, const struct object *obj,
+ void *decoration)
{
int nr = n->nr + 1;
@@ -65,7 +66,7 @@ void *add_decoration(struct decoration *n, struct object *obj, void *decoration)
}
/* Lookup a decoration pointer */
-void *lookup_decoration(struct decoration *n, struct object *obj)
+void *lookup_decoration(struct decoration *n, const struct object *obj)
{
int j;
diff --git a/decorate.h b/decorate.h
index 1fa4ad9..e732804 100644
--- a/decorate.h
+++ b/decorate.h
@@ -2,7 +2,7 @@
#define DECORATE_H
struct object_decoration {
- struct object *base;
+ const struct object *base;
void *decoration;
};
@@ -12,7 +12,7 @@ struct decoration {
struct object_decoration *hash;
};
-extern void *add_decoration(struct decoration *n, struct object *obj, void *decoration);
-extern void *lookup_decoration(struct decoration *n, struct object *obj);
+extern void *add_decoration(struct decoration *n, const struct object *obj, void *decoration);
+extern void *lookup_decoration(struct decoration *n, const struct object *obj);
#endif
--
1.6.0.90.g00a5c.dirty
next prev parent reply other threads:[~2008-08-20 17:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-20 12:25 [BUG?] git log does not decorate when custom format is used MichaelTiloDressel
2008-08-20 17:53 ` Jeff King
2008-08-20 17:55 ` Jeff King [this message]
2008-08-20 18:00 ` [PATCH 2/2] allow '%d' pretty format specifier to show decoration Jeff King
2008-08-20 18:32 ` Junio C Hamano
2008-08-20 18:43 ` Johannes Schindelin
2008-08-20 19:01 ` Junio C Hamano
2008-08-20 19:53 ` Johannes Schindelin
2008-09-03 19:36 ` Jeff King
2008-08-20 19:51 ` Michael Dressel
2008-08-20 20:21 ` Junio C Hamano
2008-08-20 21:05 ` Michael Dressel
2008-08-21 5:02 ` "log --pretty=format:" language Teemu Likonen
2008-08-24 18:30 ` Jakub Narebski
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=20080820175532.GA32005@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=MichaelTiloDressel@t-online.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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;
as well as URLs for NNTP newsgroup(s).