From: skimo@liacs.nl
To: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 2/4] export add_ref_decoration
Date: Sun, 8 Jul 2007 18:23:25 +0200 [thread overview]
Message-ID: <11839118083737-git-send-email-skimo@liacs.nl> (raw)
In-Reply-To: <11839118073186-git-send-email-skimo@liacs.nl>
From: Sven Verdoolaege <skimo@kotnet.org>
add_ref_decoration is also useful outside of git-log.
Since the name_decoration declaration appears in commit.h,
the function is moved to commit.c.
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
---
builtin-log.c | 25 -------------------------
commit.c | 27 +++++++++++++++++++++++++++
commit.h | 3 +++
log-tree.c | 2 --
4 files changed, 30 insertions(+), 27 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index 13bae31..c14eea5 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -21,31 +21,6 @@ static const char *fmt_patch_subject_prefix = "PATCH";
/* this is in builtin-diff.c */
void add_head(struct rev_info *revs);
-static void add_name_decoration(const char *prefix, const char *name, struct object *obj)
-{
- int plen = strlen(prefix);
- int nlen = strlen(name);
- struct name_decoration *res = xmalloc(sizeof(struct name_decoration) + plen + nlen);
- memcpy(res->name, prefix, plen);
- memcpy(res->name + plen, name, nlen + 1);
- res->next = add_decoration(&name_decoration, obj, res);
-}
-
-static int add_ref_decoration(const char *refname, const unsigned char *sha1, int flags, void *cb_data)
-{
- struct object *obj = parse_object(sha1);
- if (!obj)
- return 0;
- add_name_decoration("", refname, obj);
- while (obj->type == OBJ_TAG) {
- obj = ((struct tag *)obj)->tagged;
- if (!obj)
- break;
- add_name_decoration("tag: ", refname, obj);
- }
- return 0;
-}
-
static void cmd_log_init(int argc, const char **argv, const char *prefix,
struct rev_info *rev)
{
diff --git a/commit.c b/commit.c
index 03436b1..24d7dd4 100644
--- a/commit.c
+++ b/commit.c
@@ -1553,3 +1553,30 @@ int in_merge_bases(struct commit *commit, struct commit **reference, int num)
free_commit_list(bases);
return ret;
}
+
+struct decoration name_decoration = { "object names" };
+
+static void add_name_decoration(const char *prefix, const char *name, struct object *obj)
+{
+ int plen = strlen(prefix);
+ int nlen = strlen(name);
+ struct name_decoration *res = xmalloc(sizeof(struct name_decoration) + plen + nlen);
+ memcpy(res->name, prefix, plen);
+ memcpy(res->name + plen, name, nlen + 1);
+ res->next = add_decoration(&name_decoration, obj, res);
+}
+
+int add_ref_decoration(const char *refname, const unsigned char *sha1, int flags, void *cb_data)
+{
+ struct object *obj = parse_object(sha1);
+ if (!obj)
+ return 0;
+ add_name_decoration("", refname, obj);
+ while (obj->type == OBJ_TAG) {
+ obj = ((struct tag *)obj)->tagged;
+ if (!obj)
+ break;
+ add_name_decoration("tag: ", refname, obj);
+ }
+ return 0;
+}
diff --git a/commit.h b/commit.h
index 467872e..bf23535 100644
--- a/commit.h
+++ b/commit.h
@@ -122,4 +122,7 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads,
int depth, int shallow_flag, int not_shallow_flag);
int in_merge_bases(struct commit *, struct commit **, int);
+
+extern int add_ref_decoration(const char *refname, const unsigned char *sha1, int flags, void *cb_data);
+
#endif /* COMMIT_H */
diff --git a/log-tree.c b/log-tree.c
index 8624d5a..b69f029 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -4,8 +4,6 @@
#include "log-tree.h"
#include "reflog-walk.h"
-struct decoration name_decoration = { "object names" };
-
static void show_parents(struct commit *commit, int abbrev)
{
struct commit_list *p;
--
1.5.3.rc0.68.geec71-dirty
next prev parent reply other threads:[~2007-07-08 16:23 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-08 16:23 [PATCH 0/4] Add git-rewrite-commits skimo
2007-07-08 16:23 ` [PATCH 1/4] export get_short_sha1 skimo
2007-07-08 16:23 ` skimo [this message]
2007-07-08 16:23 ` [PATCH 3/4] revision: mark commits that didn't match a pattern for later use skimo
2007-07-08 16:23 ` [PATCH 4/4] Add git-rewrite-commits skimo
2007-07-08 16:37 ` Johannes Schindelin
2007-07-08 17:30 ` Sven Verdoolaege
2007-07-08 18:17 ` Johannes Schindelin
2007-07-08 19:11 ` Sven Verdoolaege
2007-07-08 18:04 ` Steven Grimm
2007-07-08 18:15 ` Sven Verdoolaege
2007-07-08 18:41 ` Johannes Schindelin
2007-07-08 21:10 ` Sven Verdoolaege
2007-07-09 9:01 ` Johannes Sixt
2007-07-09 9:48 ` Sven Verdoolaege
2007-07-09 11:57 ` Johannes Schindelin
2007-07-08 23:56 ` Johannes Schindelin
2007-07-09 9:47 ` Sven Verdoolaege
2007-07-09 12:57 ` Johannes Schindelin
2007-07-09 13:49 ` Sven Verdoolaege
2007-07-09 14:11 ` Johannes Schindelin
2007-07-09 14:42 ` Sven Verdoolaege
2007-07-09 14:59 ` Johannes Schindelin
2007-07-09 12:36 ` Jeff King
2007-07-09 13:16 ` Johannes Schindelin
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=11839118083737-git-send-email-skimo@liacs.nl \
--to=skimo@liacs.nl \
--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).