aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apply.c25
-rw-r--r--combine-diff.c8
-rw-r--r--daemon.c2
-rwxr-xr-xgit-merge.sh2
-rw-r--r--sha1_name.c39
5 files changed, 26 insertions, 50 deletions
diff --git a/apply.c b/apply.c
index 79e23a7fb..2ad47fbbb 100644
--- a/apply.c
+++ b/apply.c
@@ -1564,24 +1564,6 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned
die("unable to add cache entry for %s", path);
}
-static void create_subdirectories(const char *path)
-{
- int len = strlen(path);
- char *buf = xmalloc(len + 1);
- const char *slash = path;
-
- while ((slash = strchr(slash+1, '/')) != NULL) {
- len = slash - path;
- memcpy(buf, path, len);
- buf[len] = 0;
- if (mkdir(buf, 0777) < 0) {
- if (errno != EEXIST)
- break;
- }
- }
- free(buf);
-}
-
static int try_create_file(const char *path, unsigned int mode, const char *buf, unsigned long size)
{
int fd;
@@ -1610,13 +1592,14 @@ static int try_create_file(const char *path, unsigned int mode, const char *buf,
* which is true 99% of the time anyway. If they don't,
* we create them and try again.
*/
-static void create_one_file(const char *path, unsigned mode, const char *buf, unsigned long size)
+static void create_one_file(char *path, unsigned mode, const char *buf, unsigned long size)
{
if (!try_create_file(path, mode, buf, size))
return;
if (errno == ENOENT) {
- create_subdirectories(path);
+ if (safe_create_leading_directories(path))
+ return;
if (!try_create_file(path, mode, buf, size))
return;
}
@@ -1643,7 +1626,7 @@ static void create_one_file(const char *path, unsigned mode, const char *buf, un
static void create_file(struct patch *patch)
{
- const char *path = patch->new_name;
+ char *path = patch->new_name;
unsigned mode = patch->new_mode;
unsigned long size = patch->resultsize;
char *buf = patch->result;
diff --git a/combine-diff.c b/combine-diff.c
index 216a77e08..210ffcbce 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -528,7 +528,7 @@ static void show_parent_lno(struct sline *sline, unsigned long l0, unsigned long
{
l0 = sline[l0].p_lno[n];
l1 = sline[l1].p_lno[n];
- printf("-%lu,%lu ", l0, l1-l0);
+ printf(" -%lu,%lu", l0, l1-l0);
}
static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent)
@@ -548,9 +548,9 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent)
if (!(sline[hunk_end].flag & mark))
break;
for (i = 0; i <= num_parent; i++) putchar(combine_marker);
- printf(" +%lu,%lu ", lno+1, hunk_end-lno);
for (i = 0; i < num_parent; i++)
show_parent_lno(sline, lno, hunk_end, cnt, i);
+ printf(" +%lu,%lu ", lno+1, hunk_end-lno);
for (i = 0; i <= num_parent; i++) putchar(combine_marker);
putchar('\n');
while (lno < hunk_end) {
@@ -714,11 +714,11 @@ int show_combined_diff(struct combine_diff_path *elem, int num_parent,
printf("index ");
for (i = 0; i < num_parent; i++) {
printf("%s%s",
- i ? ".." : "",
+ i ? "," : "",
find_unique_abbrev(elem->parent_sha1[i],
DEFAULT_ABBREV));
}
- printf("->%s\n",
+ printf("..%s\n",
find_unique_abbrev(elem->sha1, DEFAULT_ABBREV));
dump_sline(sline, cnt, num_parent);
}
diff --git a/daemon.c b/daemon.c
index bb014fa9c..532bb0c32 100644
--- a/daemon.c
+++ b/daemon.c
@@ -147,7 +147,7 @@ static char *path_ok(char *dir)
static char rpath[PATH_MAX];
if (*dir != '/') {
/* Forbid possible base-path evasion using ~paths. */
- logerror("'%s': Non-absolute path denied (base-path active)");
+ logerror("'%s': Non-absolute path denied (base-path active)", dir);
return NULL;
}
snprintf(rpath, PATH_MAX, "%s%s", base_path, dir);
diff --git a/git-merge.sh b/git-merge.sh
index 92e5a65ca..8c0a92c14 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -293,7 +293,7 @@ for remote
do
echo $remote
done >"$GIT_DIR/MERGE_HEAD"
-echo $merge_msg >"$GIT_DIR/MERGE_MSG"
+echo "$merge_msg" >"$GIT_DIR/MERGE_MSG"
if test "$merge_was_ok" = t
then
diff --git a/sha1_name.c b/sha1_name.c
index ba0747c84..fa85d8a88 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -388,43 +388,36 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)
static int get_sha1_1(const char *name, int len, unsigned char *sha1)
{
- int parent, ret;
+ int ret, has_suffix;
const char *cp;
- /* foo^[0-9] or foo^ (== foo^1); we do not do more than 9 parents. */
- if (len > 2 && name[len-2] == '^' &&
- name[len-1] >= '0' && name[len-1] <= '9') {
- parent = name[len-1] - '0';
- len -= 2;
- }
- else if (len > 1 && name[len-1] == '^') {
- parent = 1;
- len--;
- } else
- parent = -1;
-
- if (parent >= 0)
- return get_parent(name, len, sha1, parent);
-
/* "name~3" is "name^^^",
- * "name~12" is "name^^^^^^^^^^^^", and
* "name~" and "name~0" are name -- not "name^0"!
+ * "name^" is not "name^0"; it is "name^1".
*/
- parent = 0;
+ has_suffix = 0;
for (cp = name + len - 1; name <= cp; cp--) {
int ch = *cp;
if ('0' <= ch && ch <= '9')
continue;
- if (ch != '~')
- parent = -1;
+ if (ch == '~' || ch == '^')
+ has_suffix = ch;
break;
}
- if (!parent && *cp == '~') {
+
+ if (has_suffix) {
+ int num = 0;
int len1 = cp - name;
cp++;
while (cp < name + len)
- parent = parent * 10 + *cp++ - '0';
- return get_nth_ancestor(name, len1, sha1, parent);
+ num = num * 10 + *cp++ - '0';
+ if (has_suffix == '^') {
+ if (!num && len1 == len - 1)
+ num = 1;
+ return get_parent(name, len1, sha1, num);
+ }
+ /* else if (has_suffix == '~') -- goes without saying */
+ return get_nth_ancestor(name, len1, sha1, num);
}
ret = peel_onion(name, len, sha1);