strbuf: move strbuf_branchname to sha1_name.c
strbuf_branchname is a thin wrapper around interpret_branch_name from sha1_name.o. Most strbuf.o users do not need it. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
		
				
					committed by
					
						
						Junio C Hamano
					
				
			
			
				
	
			
			
			
						parent
						
							33f239365c
						
					
				
				
					commit
					6bab74e7fb
				
			
							
								
								
									
										18
									
								
								sha1_name.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								sha1_name.c
									
									
									
									
									
								
							@ -934,6 +934,24 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
 | 
			
		||||
	return len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int strbuf_branchname(struct strbuf *sb, const char *name)
 | 
			
		||||
{
 | 
			
		||||
	int len = strlen(name);
 | 
			
		||||
	if (interpret_branch_name(name, sb) == len)
 | 
			
		||||
		return 0;
 | 
			
		||||
	strbuf_add(sb, name, len);
 | 
			
		||||
	return len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
 | 
			
		||||
{
 | 
			
		||||
	strbuf_branchname(sb, name);
 | 
			
		||||
	if (name[0] == '-')
 | 
			
		||||
		return CHECK_REF_FORMAT_ERROR;
 | 
			
		||||
	strbuf_splice(sb, 0, 0, "refs/heads/", 11);
 | 
			
		||||
	return check_ref_format(sb->buf);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This is like "get_sha1_basic()", except it allows "sha1 expressions",
 | 
			
		||||
 * notably "xyz^" for "parent of xyz"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										18
									
								
								strbuf.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								strbuf.c
									
									
									
									
									
								
							@ -386,21 +386,3 @@ int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint)
 | 
			
		||||
 | 
			
		||||
	return len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int strbuf_branchname(struct strbuf *sb, const char *name)
 | 
			
		||||
{
 | 
			
		||||
	int len = strlen(name);
 | 
			
		||||
	if (interpret_branch_name(name, sb) == len)
 | 
			
		||||
		return 0;
 | 
			
		||||
	strbuf_add(sb, name, len);
 | 
			
		||||
	return len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
 | 
			
		||||
{
 | 
			
		||||
	strbuf_branchname(sb, name);
 | 
			
		||||
	if (name[0] == '-')
 | 
			
		||||
		return CHECK_REF_FORMAT_ERROR;
 | 
			
		||||
	strbuf_splice(sb, 0, 0, "refs/heads/", 11);
 | 
			
		||||
	return check_ref_format(sb->buf);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user