summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-05-23 13:35:22 -0700
committerJunio C Hamano <gitster@pobox.com>2012-05-23 13:35:22 -0700
commitb83cfa5949081c32a13b84e8aeea7d2cb7a96331 (patch)
treeab7d7cc080ea030b18f9110013f140cb3a656b14
parent8d19426f985afdf4cc34f88198226964566dcdc1 (diff)
parentbf38245be8f481ac1c08a98951b7fd00bbfc15ea (diff)
downloadgit-b83cfa5949081c32a13b84e8aeea7d2cb7a96331.tar.gz
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
-rw-r--r--archive-tar.c4
-rw-r--r--archive.c17
2 files changed, 7 insertions, 14 deletions
diff --git a/archive-tar.c b/archive-tar.c
index 93387ea336..dc91c6b50d 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -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;
}
diff --git a/archive.c b/archive.c
index cd083eaf9a..a4844330fb 100644
--- a/archive.c
+++ b/archive.c
@@ -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);
}