コード例 #1
0
ファイル: describe.c プロジェクト: OpenSpan/git
static int replace_name(struct commit_name *e,
			       int prio,
			       const unsigned char *sha1,
			       struct tag **tag)
{
	if (!e || e->prio < prio)
		return 1;

	if (e->prio == 2 && prio == 2) {
		/* Multiple annotated tags point to the same commit.
		 * Select one to keep based upon their tagger date.
		 */
		struct tag *t;

		if (!e->tag) {
			t = lookup_tag(e->sha1);
			if (!t || parse_tag(t))
				return 1;
			e->tag = t;
		}

		t = lookup_tag(sha1);
		if (!t || parse_tag(t))
			return 0;
		*tag = t;

		if (e->tag->date < t->date)
			return 1;
	}

	return 0;
}
コード例 #2
0
ファイル: replace.c プロジェクト: PEPE-coin/git
static int check_one_mergetag(struct commit *commit,
			       struct commit_extra_header *extra,
			       void *data)
{
	struct check_mergetag_data *mergetag_data = (struct check_mergetag_data *)data;
	const char *ref = mergetag_data->argv[0];
	struct object_id tag_oid;
	struct tag *tag;
	int i;

	hash_object_file(extra->value, extra->len, type_name(OBJ_TAG), &tag_oid);
	tag = lookup_tag(&tag_oid);
	if (!tag)
		return error(_("bad mergetag in commit '%s'"), ref);
	if (parse_tag_buffer(tag, extra->value, extra->len))
		return error(_("malformed mergetag in commit '%s'"), ref);

	/* iterate over new parents */
	for (i = 1; i < mergetag_data->argc; i++) {
		struct object_id oid;
		if (get_oid(mergetag_data->argv[i], &oid) < 0)
			return error(_("Not a valid object name: '%s'"),
				     mergetag_data->argv[i]);
		if (!oidcmp(&tag->tagged->oid, &oid))
			return 0; /* found */
	}

	return error(_("original commit '%s' contains mergetag '%s' that is "
		       "discarded; use --edit instead of --graft"), ref,
		     oid_to_hex(&tag_oid));
}
コード例 #3
0
ファイル: codec_tags.c プロジェクト: agiz/mpv
void mp_set_codec_from_tag(struct sh_stream *sh)
{
    switch (sh->type) {
    case STREAM_VIDEO:
        sh->codec = lookup_tag(mp_video_codec_tags,
                               avformat_get_riff_video_tags(),
                               sh->format);
        break;
    case STREAM_AUDIO:
        sh->codec = lookup_tag(mp_audio_codec_tags,
                               avformat_get_riff_audio_tags(),
                               sh->format);
        break;
    default: ;
    }
}
コード例 #4
0
ファイル: object.c プロジェクト: ahappyforest/git
struct object *parse_object(unsigned char *sha1)
{
	unsigned long mapsize;
	void *map = map_sha1_file(sha1, &mapsize);
	if (map) {
		char type[100];
		unsigned long size;
		void *buffer = unpack_sha1_file(map, mapsize, type, &size);
		if (!buffer)
			return NULL;
		if (check_sha1_signature(sha1, buffer, size, type) < 0)
			printf("sha1 mismatch %s\n", sha1_to_hex(sha1));
		munmap(map, mapsize);
		if (!strcmp(type, "blob")) {
			struct blob *ret = lookup_blob(sha1);
			parse_blob(ret);
			return &ret->object;
		} else if (!strcmp(type, "tree")) {
			struct tree *ret = lookup_tree(sha1);
			parse_tree(ret);
			return &ret->object;
		} else if (!strcmp(type, "commit")) {
			struct commit *ret = lookup_commit(sha1);
			parse_commit(ret);
			return &ret->object;
		} else if (!strcmp(type, "tag")) {
			struct tag *ret = lookup_tag(sha1);
			parse_tag(ret);
			return &ret->object;
		} else {
			return NULL;
		}
	}
	return NULL;
}
コード例 #5
0
ファイル: tag.c プロジェクト: 0369/git
int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
{
	unsigned char sha1[20];
	char type[20];
	const char *bufptr = data;
	const char *tail = bufptr + size;
	const char *nl;

	if (item->object.parsed)
		return 0;
	item->object.parsed = 1;

	if (size < 64)
		return -1;
	if (memcmp("object ", bufptr, 7) || get_sha1_hex(bufptr + 7, sha1) || bufptr[47] != '\n')
		return -1;
	bufptr += 48; /* "object " + sha1 + "\n" */

	if (!starts_with(bufptr, "type "))
		return -1;
	bufptr += 5;
	nl = memchr(bufptr, '\n', tail - bufptr);
	if (!nl || sizeof(type) <= (nl - bufptr))
		return -1;
	memcpy(type, bufptr, nl - bufptr);
	type[nl - bufptr] = '\0';
	bufptr = nl + 1;

	if (!strcmp(type, blob_type)) {
		item->tagged = &lookup_blob(sha1)->object;
	} else if (!strcmp(type, tree_type)) {
		item->tagged = &lookup_tree(sha1)->object;
	} else if (!strcmp(type, commit_type)) {
		item->tagged = &lookup_commit(sha1)->object;
	} else if (!strcmp(type, tag_type)) {
		item->tagged = &lookup_tag(sha1)->object;
	} else {
		error("Unknown type %s", type);
		item->tagged = NULL;
	}

	if (bufptr + 4 < tail && starts_with(bufptr, "tag "))
		; 		/* good */
	else
		return -1;
	bufptr += 4;
	nl = memchr(bufptr, '\n', tail - bufptr);
	if (!nl)
		return -1;
	item->tag = xmemdupz(bufptr, nl - bufptr);
	bufptr = nl + 1;

	if (bufptr + 7 < tail && starts_with(bufptr, "tagger "))
		item->date = parse_tag_date(bufptr, tail);
	else
		item->date = 0;

	return 0;
}
コード例 #6
0
ファイル: tag.c プロジェクト: PEPE-coin/git
int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
{
	struct object_id oid;
	char type[20];
	const char *bufptr = data;
	const char *tail = bufptr + size;
	const char *nl;

	if (item->object.parsed)
		return 0;
	item->object.parsed = 1;

	if (size < GIT_SHA1_HEXSZ + 24)
		return -1;
	if (memcmp("object ", bufptr, 7) || parse_oid_hex(bufptr + 7, &oid, &bufptr) || *bufptr++ != '\n')
		return -1;

	if (!starts_with(bufptr, "type "))
		return -1;
	bufptr += 5;
	nl = memchr(bufptr, '\n', tail - bufptr);
	if (!nl || sizeof(type) <= (nl - bufptr))
		return -1;
	memcpy(type, bufptr, nl - bufptr);
	type[nl - bufptr] = '\0';
	bufptr = nl + 1;

	if (!strcmp(type, blob_type)) {
		item->tagged = (struct object *)lookup_blob(&oid);
	} else if (!strcmp(type, tree_type)) {
		item->tagged = (struct object *)lookup_tree(&oid);
	} else if (!strcmp(type, commit_type)) {
		item->tagged = (struct object *)lookup_commit(&oid);
	} else if (!strcmp(type, tag_type)) {
		item->tagged = (struct object *)lookup_tag(&oid);
	} else {
		error("Unknown type %s", type);
		item->tagged = NULL;
	}

	if (bufptr + 4 < tail && starts_with(bufptr, "tag "))
		; 		/* good */
	else
		return -1;
	bufptr += 4;
	nl = memchr(bufptr, '\n', tail - bufptr);
	if (!nl)
		return -1;
	item->tag = xmemdupz(bufptr, nl - bufptr);
	bufptr = nl + 1;

	if (bufptr + 7 < tail && starts_with(bufptr, "tagger "))
		item->date = parse_tag_date(bufptr, tail);
	else
		item->date = 0;

	return 0;
}
コード例 #7
0
ファイル: codec_tags.c プロジェクト: AoD314/mpv
void mp_set_codec_from_tag(struct sh_stream *sh)
{
    sh->codec = lookup_tag(sh->type, sh->format);

    if (sh->audio && sh->audio->bits_per_coded_sample) {
        const char *codec =
            map_audio_pcm_tag(sh->format, sh->audio->bits_per_coded_sample);
        if (codec)
            sh->codec = codec;
    }
}
コード例 #8
0
ファイル: nesc-attributes.c プロジェクト: HengeSense/nesc
/* Return a reference to attribute tag 
   (different from xref_tag because there is no implicit declaration) */
tag_ref lookup_attribute(word tag)
{
  tag_ref tref = newkind_tag_ref(parse_region, kind_attribute_ref,
				 tag->location, tag, NULL, NULL, FALSE);
  tag_declaration tdecl = lookup_tag(tref, FALSE);

  if (!tdecl)
    error_with_location(tag->location, "unknown attribute `%s'",
			tag->cstring.data);
  tref->tdecl = tdecl;

  return tref;
}
コード例 #9
0
ファイル: log-tree.c プロジェクト: Advael/git
static void show_one_mergetag(struct rev_info *opt,
			      struct commit_extra_header *extra,
			      struct commit *commit)
{
	unsigned char sha1[20];
	struct tag *tag;
	struct strbuf verify_message;
	int status, nth;
	size_t payload_size, gpg_message_offset;

	hash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), sha1);
	tag = lookup_tag(sha1);
	if (!tag)
		return; /* error message already given */

	strbuf_init(&verify_message, 256);
	if (parse_tag_buffer(tag, extra->value, extra->len))
		strbuf_addstr(&verify_message, "malformed mergetag\n");
	else if (is_common_merge(commit) &&
		 !hashcmp(tag->tagged->sha1,
			  commit->parents->next->item->object.sha1))
		strbuf_addf(&verify_message,
			    "merged tag '%s'\n", tag->tag);
	else if ((nth = which_parent(tag->tagged->sha1, commit)) < 0)
		strbuf_addf(&verify_message, "tag %s names a non-parent %s\n",
				    tag->tag, tag->tagged->sha1);
	else
		strbuf_addf(&verify_message,
			    "parent #%d, tagged '%s'\n", nth + 1, tag->tag);
	gpg_message_offset = verify_message.len;

	payload_size = parse_signature(extra->value, extra->len);
	if ((extra->len <= payload_size) ||
	    (verify_signed_buffer(extra->value, payload_size,
				  extra->value + payload_size,
				  extra->len - payload_size,
				  &verify_message) &&
	     verify_message.len <= gpg_message_offset)) {
		strbuf_addstr(&verify_message, "No signature\n");
		status = -1;
	}
	else if (strstr(verify_message.buf + gpg_message_offset,
			": Good signature from "))
		status = 0;
	else
		status = -1;

	show_sig_lines(opt, status, verify_message.buf);
	strbuf_release(&verify_message);
}
コード例 #10
0
ファイル: object.c プロジェクト: PEPE-coin/git
struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)
{
	struct object *obj;
	*eaten_p = 0;

	obj = NULL;
	if (type == OBJ_BLOB) {
		struct blob *blob = lookup_blob(oid);
		if (blob) {
			if (parse_blob_buffer(blob, buffer, size))
				return NULL;
			obj = &blob->object;
		}
	} else if (type == OBJ_TREE) {
		struct tree *tree = lookup_tree(oid);
		if (tree) {
			obj = &tree->object;
			if (!tree->buffer)
				tree->object.parsed = 0;
			if (!tree->object.parsed) {
				if (parse_tree_buffer(tree, buffer, size))
					return NULL;
				*eaten_p = 1;
			}
		}
	} else if (type == OBJ_COMMIT) {
		struct commit *commit = lookup_commit(oid);
		if (commit) {
			if (parse_commit_buffer(commit, buffer, size))
				return NULL;
			if (!get_cached_commit_buffer(commit, NULL)) {
				set_commit_buffer(commit, buffer, size);
				*eaten_p = 1;
			}
			obj = &commit->object;
		}
	} else if (type == OBJ_TAG) {
		struct tag *tag = lookup_tag(oid);
		if (tag) {
			if (parse_tag_buffer(tag, buffer, size))
			       return NULL;
			obj = &tag->object;
		}
	} else {
		warning("object %s has unknown type id %d", oid_to_hex(oid), type);
		obj = NULL;
	}
	return obj;
}
コード例 #11
0
ファイル: log-tree.c プロジェクト: Arti-Rakholiya/git
static void show_one_mergetag(struct commit *commit,
			      struct commit_extra_header *extra,
			      void *data)
{
	struct rev_info *opt = (struct rev_info *)data;
	unsigned char sha1[20];
	struct tag *tag;
	struct strbuf verify_message;
	int status, nth;
	size_t payload_size, gpg_message_offset;

	hash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), sha1);
	tag = lookup_tag(sha1);
	if (!tag)
		return; /* error message already given */

	strbuf_init(&verify_message, 256);
	if (parse_tag_buffer(tag, extra->value, extra->len))
		strbuf_addstr(&verify_message, "malformed mergetag\n");
	else if (is_common_merge(commit) &&
		 !oidcmp(&tag->tagged->oid,
			  &commit->parents->next->item->object.oid))
		strbuf_addf(&verify_message,
			    "merged tag '%s'\n", tag->tag);
	else if ((nth = which_parent(tag->tagged->oid.hash, commit)) < 0)
		strbuf_addf(&verify_message, "tag %s names a non-parent %s\n",
				    tag->tag, tag->tagged->oid.hash);
	else
		strbuf_addf(&verify_message,
			    "parent #%d, tagged '%s'\n", nth + 1, tag->tag);
	gpg_message_offset = verify_message.len;

	payload_size = parse_signature(extra->value, extra->len);
	status = -1;
	if (extra->len > payload_size) {
		/* could have a good signature */
		if (!verify_signed_buffer(extra->value, payload_size,
					  extra->value + payload_size,
					  extra->len - payload_size,
					  &verify_message, NULL))
			status = 0; /* good */
		else if (verify_message.len <= gpg_message_offset)
			strbuf_addstr(&verify_message, "No signature\n");
		/* otherwise we couldn't verify, which is shown as bad */
	}

	show_sig_lines(opt, status, verify_message.buf);
	strbuf_release(&verify_message);
}
コード例 #12
0
ファイル: builtin-describe.c プロジェクト: Pistos/git
static void display_name(struct commit_name *n)
{
	if (n->prio == 2 && !n->tag) {
		n->tag = lookup_tag(n->sha1);
		if (!n->tag || parse_tag(n->tag) || !n->tag->tag)
			die("annotated tag %s not available", n->path);
		if (strcmp(n->tag->tag, n->path))
			warning("tag '%s' is really '%s' here", n->tag->tag, n->path);
	}

	if (n->tag)
		printf("%s", n->tag->tag);
	else
		printf("%s", n->path);
}
コード例 #13
0
ファイル: ui-tag.c プロジェクト: metajack/cgit
void cgit_print_tag(char *revname)
{
    unsigned char sha1[20];
    struct object *obj;
    struct tag *tag;
    struct taginfo *info;

    if (get_sha1(revname, sha1)) {
        cgit_print_error(fmt("Bad tag reference: %s", revname));
        return;
    }
    obj = parse_object(sha1);
    if (!obj) {
        cgit_print_error(fmt("Bad object id: %s", sha1_to_hex(sha1)));
        return;
    }
    if (obj->type == OBJ_TAG) {
        tag = lookup_tag(sha1);
        if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) {
            cgit_print_error(fmt("Bad tag object: %s", revname));
            return;
        }
        html("<table class='commit-info'>\n");
        htmlf("<tr><td>Tag name</td><td>%s (%s)</td></tr>\n",
              revname, sha1_to_hex(sha1));
        if (info->tagger_date > 0) {
            html("<tr><td>Tag date</td><td>");
            cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time);
            html("</td></tr>\n");
        }
        if (info->tagger) {
            html("<tr><td>Tagged by</td><td>");
            html_txt(info->tagger);
            if (info->tagger_email) {
                html(" ");
                html_txt(info->tagger_email);
            }
            html("</td></tr>\n");
        }
        html("<tr><td>Tagged object</td><td>");
        cgit_object_link(tag->tagged);
        html("</td></tr>\n");
        html("</table>\n");
        print_tag_content(info->msg);
    }
    return;
}
コード例 #14
0
ファイル: describe.c プロジェクト: OpenSpan/git
static void display_name(struct commit_name *n)
{
	if (n->prio == 2 && !n->tag) {
		n->tag = lookup_tag(n->sha1);
		if (!n->tag || parse_tag(n->tag))
			die(_("annotated tag %s not available"), n->path);
	}
	if (n->tag && !n->name_checked) {
		if (!n->tag->tag)
			die(_("annotated tag %s has no embedded name"), n->path);
		if (strcmp(n->tag->tag, all ? n->path + 5 : n->path))
			warning(_("tag '%s' is really '%s' here"), n->tag->tag, n->path);
		n->name_checked = 1;
	}

	if (n->tag)
		printf("%s", n->tag->tag);
	else
		printf("%s", n->path);
}
コード例 #15
0
ファイル: yara.c プロジェクト: unixfreak0037/yara-dev
int callback(RULE* rule, void* data)
{
	TAG* tag;
    IDENTIFIER* identifier;
	STRING* string;
    META* meta;
	MATCH* match;
	
    int rule_match;
    int string_found;
	int show = TRUE;
		
	if (show_specified_tags)
	{
		show = FALSE;
		tag = specified_tags_list;
		
		while (tag != NULL)
		{
			if (lookup_tag(rule->tag_list_head, tag->identifier) != NULL)
			{
				show = TRUE;
				break;
			}
			
			tag = tag->next;
		}
	}
	
	if (show_specified_rules)
	{
		show = FALSE;
		identifier = specified_rules_list;
		
		while (identifier != NULL)
		{
            if (strcmp(identifier->name, rule->identifier) == 0)
            {
                show = TRUE;
                break;
            }
			
			identifier = identifier->next;
		}
	}
	
    rule_match = (rule->flags & RULE_FLAGS_MATCH);
	
    show = show && ((!negate && rule_match) || (negate && !rule_match));
	
	if (show)
	{
	    printf("%s ", rule->identifier);
	    
		if (show_tags)
		{			
			tag = rule->tag_list_head;
			
			printf("[");
						
			while(tag != NULL)
			{
				if (tag->next == NULL)
				{
					printf("%s", tag->identifier);
				}
				else
				{
					printf("%s,", tag->identifier);
				}
								
				tag = tag->next;
			}	
			
			printf("] ");
		}
		
		if (show_meta)
		{
            meta = rule->meta_list_head;
            
            printf("[");
           
    		while(meta != NULL)
    		{
    		    if (meta->type == META_TYPE_INTEGER)
    		    {
    		        printf("%s=%lu", meta->identifier, meta->integer);
    		    }
    		    else if (meta->type == META_TYPE_BOOLEAN)
    		    {
    		        printf("%s=%s", meta->identifier, (meta->boolean)?("true"):("false"));
    		    }
    		    else
    		    {
    		        printf("%s=\"%s\"", meta->identifier, meta->string);
    		    }
		    
    		    if (meta->next != NULL)
                    printf(",");
                						
    			meta = meta->next;
    		}
		
    		printf("] ");
    	}
		
		printf("%s\n", (char*) data);
		
		/* show matched strings */
		
		if (show_strings)
		{
			string = rule->string_list_head;

			while (string != NULL)
			{
                string_found = string->flags & STRING_FLAGS_FOUND;
			    
				if (string_found)
				{
					match = string->matches_head;

					while (match != NULL)
					{
						printf("0x%lx:%s: ", match->offset, string->identifier);
						
						if (IS_HEX(string))
						{
							print_hex_string(match->data, match->length);
						}
						else if (IS_WIDE(string))
						{
							print_string(match->data, match->length, TRUE);
						}
						else
						{
							print_string(match->data, match->length, FALSE);
						}
						
						match = match->next;
					}
				}

				string = string->next;
			}		
		}
	}
	
	if (rule_match)
        count++;
	
	if (limit != 0 && count >= limit)
        return CALLBACK_ABORT;
	
    return CALLBACK_CONTINUE;
}
コード例 #16
0
ファイル: ui-tag.c プロジェクト: formorer/pkg-cgit
void cgit_print_tag(char *revname)
{
	struct strbuf fullref = STRBUF_INIT;
	unsigned char sha1[20];
	struct object *obj;
	struct tag *tag;
	struct taginfo *info;

	if (!revname)
		revname = ctx.qry.head;

	strbuf_addf(&fullref, "refs/tags/%s", revname);
	if (get_sha1(fullref.buf, sha1)) {
		cgit_print_error_page(404, "Not found",
			"Bad tag reference: %s", revname);
		goto cleanup;
	}
	obj = parse_object(sha1);
	if (!obj) {
		cgit_print_error_page(500, "Internal server error",
			"Bad object id: %s", sha1_to_hex(sha1));
		goto cleanup;
	}
	if (obj->type == OBJ_TAG) {
		tag = lookup_tag(sha1);
		if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) {
			cgit_print_error_page(500, "Internal server error",
				"Bad tag object: %s", revname);
			goto cleanup;
		}
		cgit_print_layout_start();
		html("<table class='commit-info'>\n");
		htmlf("<tr><td>tag name</td><td>");
		html_txt(revname);
		htmlf(" (%s)</td></tr>\n", sha1_to_hex(sha1));
		if (info->tagger_date > 0) {
			html("<tr><td>tag date</td><td>");
			cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time);
			html("</td></tr>\n");
		}
		if (info->tagger) {
			html("<tr><td>tagged by</td><td>");
			cgit_open_filter(ctx.repo->email_filter, info->tagger_email, "tag");
			html_txt(info->tagger);
			if (info->tagger_email && !ctx.cfg.noplainemail) {
				html(" ");
				html_txt(info->tagger_email);
			}
			cgit_close_filter(ctx.repo->email_filter);
			html("</td></tr>\n");
		}
		html("<tr><td>tagged object</td><td class='sha1'>");
		cgit_object_link(tag->tagged);
		html("</td></tr>\n");
		if (ctx.repo->snapshots)
			print_download_links(revname);
		html("</table>\n");
		print_tag_content(info->msg);
		cgit_print_layout_end();
	} else {
		cgit_print_layout_start();
		html("<table class='commit-info'>\n");
		htmlf("<tr><td>tag name</td><td>");
		html_txt(revname);
		html("</td></tr>\n");
		html("<tr><td>Tagged object</td><td class='sha1'>");
		cgit_object_link(obj);
		html("</td></tr>\n");
		if (ctx.repo->snapshots)
			print_download_links(revname);
		html("</table>\n");
		cgit_print_layout_end();
	}

cleanup:
	strbuf_release(&fullref);
}
コード例 #17
0
ファイル: codec_tags.c プロジェクト: ArcherSeven/mpv
void mp_set_audio_codec_from_tag(struct sh_audio *sh)
{
    sh->gsh->codec = lookup_tag(mp_audio_codec_tags,
                                avformat_get_riff_audio_tags(),
                                sh->format);
}