pack-refs: Store the full name of the ref even when packing only tags.
Using for_each_tag_ref() to enumerate tags is wrong since it removes the refs/tags/ prefix, we need to always use for_each_ref() and filter out non-tag references in the callback. Signed-off-by: Alexandre Julliard <julliard@winehq.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Alexandre Julliard committed
Nov 2, 2006 at 12:13 UTC
ca8e2d86c44e5cea0def1d01edfb4e6aaf642dee
1 file changed
+5
-3
builtin-pack-refs.c
+5
-3
@@ -12,6 +12,7 @@ struct ref_to_prune {
12
13
struct pack_refs_cb_data {
14
int prune;
15
+ int all;
16
struct ref_to_prune *ref_to_prune;
17
FILE *refs_file;
18
};
@@ -29,6 +30,8 @@ static int handle_one_ref(const char *path, const unsigned char *sha1,
30
{
31
struct pack_refs_cb_data *cb = cb_data;
32
33
+ if (!cb->all && strncmp(path, "refs/tags/", 10))
34
+ return 0;
35
/* Do not pack the symbolic refs */
36
if (!(flags & REF_ISSYMREF))
37
fprintf(cb->refs_file, "%s %s\n", sha1_to_hex(sha1), path);
@@ -68,7 +71,6 @@ int cmd_pack_refs(int argc, const char **argv, const char *prefix)
71
{
72
int fd, i;
73
struct pack_refs_cb_data cbdata;
71
- int (*iterate_ref)(each_ref_fn, void *) = for_each_tag_ref;
74
75
memset(&cbdata, 0, sizeof(cbdata));
76
@@ -79,7 +81,7 @@ int cmd_pack_refs(int argc, const char **argv, const char *prefix)
81
continue;
82
}
83
if (!strcmp(arg, "--all")) {
82
- iterate_ref = for_each_ref;
84
+ cbdata.all = 1;
85
continue;
86
}
87
/* perhaps other parameters later... */
@@ -93,7 +95,7 @@ int cmd_pack_refs(int argc, const char **argv, const char *prefix)
95
if (!cbdata.refs_file)
96
die("unable to create ref-pack file structure (%s)",
97
strerror(errno));
96
- iterate_ref(handle_one_ref, &cbdata);
98
+ for_each_ref(handle_one_ref, &cbdata);
99
fflush(cbdata.refs_file);
100
fsync(fd);
101
fclose(cbdata.refs_file);