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 <junkio@cox.net>
This commit is contained in:
Junio C Hamano 2005-10-13 18:57:40 -07:00
Родитель 5385f52da8
Коммит f6b42a81fd
3 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -176,6 +176,7 @@ if test "$tags"
then then
taglist=$(git-ls-remote --tags "$remote" | taglist=$(git-ls-remote --tags "$remote" |
sed -e ' sed -e '
/\^{}$/d
s/^[^ ]* // s/^[^ ]* //
s/.*/&:&/') s/.*/&:&/')
if test "$#" -gt 1 if test "$#" -gt 1

Просмотреть файл

@ -9,7 +9,14 @@ static FILE *info_ref_fp;
static int add_info_ref(const char *path, const unsigned char *sha1) static int add_info_ref(const char *path, const unsigned char *sha1)
{ {
struct object *o = parse_object(sha1);
fprintf(info_ref_fp, "%s %s\n", sha1_to_hex(sha1), path); fprintf(info_ref_fp, "%s %s\n", sha1_to_hex(sha1), path);
if (o->type == tag_type) {
o = deref_tag(o);
fprintf(info_ref_fp, "%s %s^{}\n",
sha1_to_hex(o->sha1), path);
}
return 0; return 0;
} }

Просмотреть файл

@ -1,6 +1,8 @@
#include "cache.h" #include "cache.h"
#include "refs.h" #include "refs.h"
#include "pkt-line.h" #include "pkt-line.h"
#include "tag.h"
#include "object.h"
static const char upload_pack_usage[] = "git-upload-pack <dir>"; static const char upload_pack_usage[] = "git-upload-pack <dir>";
@ -165,7 +167,13 @@ static int receive_needs(void)
static int send_ref(const char *refname, const unsigned char *sha1) static int send_ref(const char *refname, const unsigned char *sha1)
{ {
struct object *o = parse_object(sha1);
packet_write(1, "%s %s\n", sha1_to_hex(sha1), refname); packet_write(1, "%s %s\n", sha1_to_hex(sha1), refname);
if (o->type == tag_type) {
o = deref_tag(o);
packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname);
}
return 0; return 0;
} }