Skip to content

Commit f6b42a8

Browse files
author
Junio C Hamano
committed
Show peeled onion from upload-pack and server-info.
This updates git-ls-remote to show SHA1 names of objects that are referred by tags, in the "ref^{}" notation. This would make git-findtags (without -t flag) almost trivial. git-peek-remote . | sed -ne "s:^$target "'refs/tags/\(.*\)^{}$:\1:p' Also Pasky could do: git-ls-remote --tags $remote | sed -ne 's:\( refs/tags/.*\)^{}$:\1:p' to find out what object each of the remote tags refers to, and if he has one locally, run "git-fetch $remote tag $tagname" to automatically catch up with the upstream tags. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5385f52 commit f6b42a8

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

git-fetch.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ if test "$tags"
176176
then
177177
taglist=$(git-ls-remote --tags "$remote" |
178178
sed -e '
179+
/\^{}$/d
179180
s/^[^ ]* //
180181
s/.*/&:&/')
181182
if test "$#" -gt 1

server-info.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ static FILE *info_ref_fp;
99

1010
static int add_info_ref(const char *path, const unsigned char *sha1)
1111
{
12+
struct object *o = parse_object(sha1);
13+
1214
fprintf(info_ref_fp, "%s %s\n", sha1_to_hex(sha1), path);
15+
if (o->type == tag_type) {
16+
o = deref_tag(o);
17+
fprintf(info_ref_fp, "%s %s^{}\n",
18+
sha1_to_hex(o->sha1), path);
19+
}
1320
return 0;
1421
}
1522

upload-pack.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "cache.h"
22
#include "refs.h"
33
#include "pkt-line.h"
4+
#include "tag.h"
5+
#include "object.h"
46

57
static const char upload_pack_usage[] = "git-upload-pack <dir>";
68

@@ -165,7 +167,13 @@ static int receive_needs(void)
165167

166168
static int send_ref(const char *refname, const unsigned char *sha1)
167169
{
170+
struct object *o = parse_object(sha1);
171+
168172
packet_write(1, "%s %s\n", sha1_to_hex(sha1), refname);
173+
if (o->type == tag_type) {
174+
o = deref_tag(o);
175+
packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname);
176+
}
169177
return 0;
170178
}
171179

0 commit comments

Comments
 (0)