Merge branch 'rs/archive-tree-in-tip-simplify'
By René Scharfe * rs/archive-tree-in-tip-simplify: archive-tar: keep const in checksum calculation archive: simplify refname handling
This commit is contained in:
@ -139,13 +139,13 @@ static void strbuf_append_ext_header(struct strbuf *sb, const char *keyword,
|
|||||||
|
|
||||||
static unsigned int ustar_header_chksum(const struct ustar_header *header)
|
static unsigned int ustar_header_chksum(const struct ustar_header *header)
|
||||||
{
|
{
|
||||||
char *p = (char *)header;
|
const char *p = (const char *)header;
|
||||||
unsigned int chksum = 0;
|
unsigned int chksum = 0;
|
||||||
while (p < header->chksum)
|
while (p < header->chksum)
|
||||||
chksum += *p++;
|
chksum += *p++;
|
||||||
chksum += sizeof(header->chksum) * ' ';
|
chksum += sizeof(header->chksum) * ' ';
|
||||||
p += sizeof(header->chksum);
|
p += sizeof(header->chksum);
|
||||||
while (p < (char *)header + sizeof(struct ustar_header))
|
while (p < (const char *)header + sizeof(struct ustar_header))
|
||||||
chksum += *p++;
|
chksum += *p++;
|
||||||
return chksum;
|
return chksum;
|
||||||
}
|
}
|
||||||
|
15
archive.c
15
archive.c
@ -254,18 +254,11 @@ static void parse_treeish_arg(const char **argv,
|
|||||||
/* Remotes are only allowed to fetch actual refs */
|
/* Remotes are only allowed to fetch actual refs */
|
||||||
if (remote) {
|
if (remote) {
|
||||||
char *ref = NULL;
|
char *ref = NULL;
|
||||||
const char *refname, *colon = NULL;
|
const char *colon = strchr(name, ':');
|
||||||
|
int refnamelen = colon ? colon - name : strlen(name);
|
||||||
|
|
||||||
colon = strchr(name, ':');
|
if (!dwim_ref(name, refnamelen, sha1, &ref))
|
||||||
if (colon)
|
die("no such ref: %.*s", refnamelen, name);
|
||||||
refname = xstrndup(name, colon - name);
|
|
||||||
else
|
|
||||||
refname = name;
|
|
||||||
|
|
||||||
if (!dwim_ref(refname, strlen(refname), sha1, &ref))
|
|
||||||
die("no such ref: %s", refname);
|
|
||||||
if (refname != name)
|
|
||||||
free((void *)refname);
|
|
||||||
free(ref);
|
free(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user