Merge branches 'jc/sha1', 'jc/diff' and 'jc/ws'
authorJunio C Hamano <junkio@cox.net>
Sat, 4 Feb 2006 07:52:20 +0000 (23:52 -0800)
committerJunio C Hamano <junkio@cox.net>
Sat, 4 Feb 2006 07:52:20 +0000 (23:52 -0800)
* jc/sha1:
get_sha1_1: allow octopus^12 to be properly parsed.

* jc/diff:
combine-diff: finishing touches to git-diff-tree --cc

* jc/ws:
whitespace cleanup.

apply.c
combine-diff.c
daemon.c
git-merge.sh
http-fetch.c
diff --git a/apply.c b/apply.c
index 79e23a7fb930ba7b322a0c30dc87c5b394622e49..2ad47fbbb37b245a78abd8e8255d39b39a52f9a9 100644 (file)
--- 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;
index 216a77e08805d4cefce20ca0796b49b5fc65c330..210ffcbce38bf1155c6e9b054e0950ee07c979fe 100644 (file)
@@ -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);
        }
index bb014fa9c2cb8c02a3952d0fc521358222662da1..532bb0c325fd07e13360389297807a19a11ee33e 100644 (file)
--- 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);
index 92e5a65cae6ebe8d9f9eef71277240e3fbe72315..8c0a92c147f6e32a8870f24bd007204bcbc01064 100755 (executable)
@@ -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
index 97ce13c44c3bedcb13b55c4af885940831f1d12c..72edf28b0010ad107bae16a7330bad34f4bb5bca 100644 (file)
@@ -220,7 +220,6 @@ static void start_object_request(struct object_request *obj_req)
                free(obj_req->url);
                return;
        }
-       
 }
 
 static void finish_object_request(struct object_request *obj_req)
@@ -326,7 +325,7 @@ void fill_active_slots(void)
                        slot->curl = NULL;
                }
                slot = slot->next;
-       }                               
+       }
 }
 #endif
 
@@ -382,10 +381,10 @@ static int fetch_index(struct alt_base *repo, unsigned char *sha1)
 
        if (get_verbosely)
                fprintf(stderr, "Getting index for pack %s\n", hex);
-       
+
        url = xmalloc(strlen(repo->base) + 64);
        sprintf(url, "%s/objects/pack/pack-%s.idx", repo->base, hex);
-       
+
        filename = sha1_pack_index_name(sha1);
        snprintf(tmpfile, sizeof(tmpfile), "%s.temp", filename);
        indexfile = fopen(tmpfile, "a");
@@ -504,7 +503,7 @@ static void process_alternates_response(void *callback_data)
                        } else if (!memcmp(data + i, "../", 3)) {
                                i += 3;
                                serverlen = strlen(base);
-                               while (i + 2 < posn && 
+                               while (i + 2 < posn &&
                                       !memcmp(data + i, "../", 3)) {
                                        do {
                                                serverlen--;
@@ -513,7 +512,7 @@ static void process_alternates_response(void *callback_data)
                                        i += 3;
                                }
                                // If the server got removed, give up.
-                               okay = strchr(base, ':') - base + 3 < 
+                               okay = strchr(base, ':') - base + 3 <
                                        serverlen;
                        } else if (alt_req->http_specific) {
                                char *colon = strchr(data + i, ':');
@@ -531,7 +530,7 @@ static void process_alternates_response(void *callback_data)
                                        posn - i - 7);
                                target[serverlen + posn - i - 7] = '\0';
                                if (get_verbosely)
-                                       fprintf(stderr, 
+                                       fprintf(stderr,
                                                "Also look at %s\n", target);
                                newalt = xmalloc(sizeof(*newalt));
                                newalt->next = NULL;
@@ -580,7 +579,7 @@ static void fetch_alternates(char *base)
 
        if (get_verbosely)
                fprintf(stderr, "Getting alternates list for %s\n", base);
-       
+
        url = xmalloc(strlen(base) + 31);
        sprintf(url, "%s/objects/info/http-alternates", base);
 
@@ -630,7 +629,7 @@ static int fetch_indices(struct alt_base *repo)
 
        if (get_verbosely)
                fprintf(stderr, "Getting pack list for %s\n", repo->base);
-       
+
        url = xmalloc(strlen(repo->base) + 21);
        sprintf(url, "%s/objects/info/packs", repo->base);
 
@@ -844,7 +843,7 @@ int fetch(unsigned char *sha1)
                fetch_alternates(alt->base);
                altbase = altbase->next;
        }
-       return error("Unable to find %s under %s\n", sha1_to_hex(sha1), 
+       return error("Unable to find %s under %s\n", sha1_to_hex(sha1),
                     alt->base);
 }
 
@@ -905,7 +904,7 @@ int fetch_ref(char *ref, unsigned char *sha1)
         buffer.posn = 0;
         buffer.buffer = hex;
         hex[41] = '\0';
-        
+
        url = quote_ref_url(base, ref);
        slot = get_active_slot();
        slot->results = &results;