Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-09-04 20:25:23 +0300
committerJunio C Hamano <gitster@pobox.com>2015-09-04 20:25:23 +0300
commitf54cb059b18e704d8b51d0cd4736344422650d6f (patch)
tree324187d0682f989593a532d231acf8472d4d2f2b
parentfdf96a20acf96a6ac538df8113b2aafd6ed71d50 (diff)
parent78f23bdf68dae56d644892990484951583a64014 (diff)
Merge branch 'jk/long-paths' into maint-2.2
-rw-r--r--builtin/show-branch.c6
-rw-r--r--notes.c19
-rw-r--r--sha1_file.c9
-rw-r--r--unpack-trees.c17
4 files changed, 27 insertions, 24 deletions
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 270e39c6c1..9e60b12445 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -720,7 +720,6 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
if (reflog) {
unsigned char sha1[20];
- char nth_desc[256];
char *ref;
int base = 0;
unsigned int flags = 0;
@@ -759,6 +758,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
for (i = 0; i < reflog; i++) {
char *logmsg;
+ char *nth_desc;
const char *msg;
unsigned long timestamp;
int tz;
@@ -777,8 +777,10 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
show_date(timestamp, tz, 1),
msg);
free(logmsg);
- sprintf(nth_desc, "%s@{%d}", *av, base+i);
+
+ nth_desc = xstrfmt("%s@{%d}", *av, base+i);
append_ref(nth_desc, sha1, 1);
+ free(nth_desc);
}
free(ref);
}
diff --git a/notes.c b/notes.c
index 5fe691dbcd..6a9cc6295b 100644
--- a/notes.c
+++ b/notes.c
@@ -362,13 +362,14 @@ static int non_note_cmp(const struct non_note *a, const struct non_note *b)
return strcmp(a->path, b->path);
}
-static void add_non_note(struct notes_tree *t, const char *path,
+/* note: takes ownership of path string */
+static void add_non_note(struct notes_tree *t, char *path,
unsigned int mode, const unsigned char *sha1)
{
struct non_note *p = t->prev_non_note, *n;
n = (struct non_note *) xmalloc(sizeof(struct non_note));
n->next = NULL;
- n->path = xstrdup(path);
+ n->path = path;
n->mode = mode;
hashcpy(n->sha1, sha1);
t->prev_non_note = n;
@@ -482,17 +483,17 @@ handle_non_note:
* component.
*/
{
- char non_note_path[PATH_MAX];
- char *p = non_note_path;
+ struct strbuf non_note_path = STRBUF_INIT;
const char *q = sha1_to_hex(subtree->key_sha1);
int i;
for (i = 0; i < prefix_len; i++) {
- *p++ = *q++;
- *p++ = *q++;
- *p++ = '/';
+ strbuf_addch(&non_note_path, *q++);
+ strbuf_addch(&non_note_path, *q++);
+ strbuf_addch(&non_note_path, '/');
}
- strcpy(p, entry.path);
- add_non_note(t, non_note_path, entry.mode, entry.sha1);
+ strbuf_addstr(&non_note_path, entry.path);
+ add_non_note(t, strbuf_detach(&non_note_path, NULL),
+ entry.mode, entry.sha1);
}
}
free(buf);
diff --git a/sha1_file.c b/sha1_file.c
index d7f1838c13..b231b62784 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -377,15 +377,12 @@ void read_info_alternates(const char * relative_base, int depth)
char *map;
size_t mapsz;
struct stat st;
- const char alt_file_name[] = "info/alternates";
- /* Given that relative_base is no longer than PATH_MAX,
- ensure that "path" has enough space to append "/", the
- file name, "info/alternates", and a trailing NUL. */
- char path[PATH_MAX + 1 + sizeof alt_file_name];
+ char *path;
int fd;
- sprintf(path, "%s/%s", relative_base, alt_file_name);
+ path = xstrfmt("%s/info/alternates", relative_base);
fd = git_open_noatime(path);
+ free(path);
if (fd < 0)
return;
if (fstat(fd, &st) || (st.st_size == 0)) {
diff --git a/unpack-trees.c b/unpack-trees.c
index 256df47b35..4a6347899c 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1432,15 +1432,18 @@ static int verify_absent_1(const struct cache_entry *ce,
if (!len)
return 0;
else if (len > 0) {
- char path[PATH_MAX + 1];
- memcpy(path, ce->name, len);
- path[len] = 0;
+ char *path;
+ int ret;
+
+ path = xmemdupz(ce->name, len);
if (lstat(path, &st))
- return error("cannot stat '%s': %s", path,
+ ret = error("cannot stat '%s': %s", path,
strerror(errno));
-
- return check_ok_to_remove(path, len, DT_UNKNOWN, NULL, &st,
- error_type, o);
+ else
+ ret = check_ok_to_remove(path, len, DT_UNKNOWN, NULL,
+ &st, error_type, o);
+ free(path);
+ return ret;
} else if (lstat(ce->name, &st)) {
if (errno != ENOENT)
return error("cannot stat '%s': %s", ce->name,