[PATCH 7/7] Teach git-mktag to register softrefs for all tag objects

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Johan Herland
Date: Saturday, June 9, 2007 - 11:24 am

For each tag object created, we create a corresponding softref from the
tagged object to the tag object itself. This is needed to enable efficient
lookup of which tag objects that point to a given commit/object.

Signed-off-by: Johan Herland <johan@herland.net>
---
 mktag.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/mktag.c b/mktag.c
index af0cfa6..db8a6b8 100644
--- a/mktag.c
+++ b/mktag.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "tag.h"
+#include "softrefs.h"
 
 /*
  * Tag object data has the following format: two mandatory lines of
@@ -32,6 +33,7 @@ int main(int argc, char **argv)
 {
 	unsigned long size = 4096;
 	char *buffer = xmalloc(size);
+	struct tag result_tag;
 	unsigned char result_sha1[20];
 
 	if (argc != 1)
@@ -46,7 +48,7 @@ int main(int argc, char **argv)
 	buffer[size] = 0;
 
 	/* Verify tag object data */
-	if (parse_and_verify_tag_buffer(0, buffer, size, 1)) {
+	if (parse_and_verify_tag_buffer(&result_tag, buffer, size, 1)) {
 		free(buffer);
 		die("invalid tag data file");
 	}
@@ -57,6 +59,13 @@ int main(int argc, char **argv)
 	}
 
 	free(buffer);
+
+	/* Create reverse mapping softref */
+	if (add_softref(result_tag.tagged->sha1, result_sha1) < 0) {
+		die("unable to create softref for resulting tag object %s",
+			sha1_to_hex(result_sha1));
+	}
+
 	printf("%s\n", sha1_to_hex(result_sha1));
 	return 0;
 }
-- 
1.5.2.1.144.gabc40

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/6] Refactor the tag object, Johan Herland, (Sun Jun 3, 5:51 pm)
Re: [PATCH 3/6] git-fsck: Do thorough verification of tag ..., Matthias Lederhofer, (Sun Jun 3, 10:56 pm)
Re: [PATCH 0/6] Refactor the tag object, Junio C Hamano, (Mon Jun 4, 1:32 pm)
[PATCH 0/7] Introduce soft references (softrefs), Johan Herland, (Sat Jun 9, 11:19 am)
[PATCH 2/7] Softrefs: Add implementation of softrefs API, Johan Herland, (Sat Jun 9, 11:22 am)
[PATCH 7/7] Teach git-mktag to register softrefs for all t ..., Johan Herland, (Sat Jun 9, 11:24 am)
Comment on weak refs, Junio C Hamano, (Sat Jun 9, 4:55 pm)
Re: Comment on weak refs, Johan Herland, (Sat Jun 9, 6:25 pm)
Re: Comment on weak refs, Johannes Schindelin, (Sat Jun 9, 11:33 pm)
Re: [PATCH 1/7] Softrefs: Add softrefs header file with AP ..., Johannes Schindelin, (Sat Jun 9, 11:58 pm)
Re: [PATCH 1/7] Softrefs: Add softrefs header file with AP ..., Johannes Schindelin, (Sun Jun 10, 12:54 am)
Re: [PATCH] Change softrefs file format from text (82 byte ..., Johannes Schindelin, (Sun Jun 10, 1:02 am)
Re: Comment on weak refs, Pierre Habouzit, (Sun Jun 10, 2:03 am)
Re: [PATCH] Change softrefs file format from text (82 byte ..., Johannes Schindelin, (Sun Jun 10, 2:46 am)
Re: Comment on weak refs, Johan Herland, (Sun Jun 10, 6:41 am)
Re: Comment on weak refs, Pierre Habouzit, (Sun Jun 10, 7:09 am)
Re: Comment on weak refs, Pierre Habouzit, (Sun Jun 10, 7:25 am)