Skip to content

Commit

Permalink
Merge branch 'rs/archive-tree-in-tip-simplify'
Browse files Browse the repository at this point in the history
By René Scharfe
* rs/archive-tree-in-tip-simplify:
  archive-tar: keep const in checksum calculation
  archive: simplify refname handling
  • Loading branch information
Junio C Hamano committed May 23, 2012
2 parents 8d19426 + bf38245 commit b83cfa5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
4 changes: 2 additions & 2 deletions archive-tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
char *p = (char *)header;
const char *p = (const char *)header;
unsigned int chksum = 0;
while (p < header->chksum)
chksum += *p++;
chksum += 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++;
return chksum;
}
Expand Down
17 changes: 5 additions & 12 deletions archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,18 +254,11 @@ static void parse_treeish_arg(const char **argv,
/* Remotes are only allowed to fetch actual refs */
if (remote) {
char *ref = NULL;
const char *refname, *colon = NULL;

colon = strchr(name, ':');
if (colon)
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);
const char *colon = strchr(name, ':');
int refnamelen = colon ? colon - name : strlen(name);

if (!dwim_ref(name, refnamelen, sha1, &ref))
die("no such ref: %.*s", refnamelen, name);
free(ref);
}

Expand Down

0 comments on commit b83cfa5

Please sign in to comment.