Merge branch 'master' of git://repo.or.cz/git/fastimport
authorJunio C Hamano <junkio@cox.net>
Tue, 13 Mar 2007 06:10:23 +0000 (23:10 -0700)
committerJunio C Hamano <junkio@cox.net>
Tue, 13 Mar 2007 06:10:23 +0000 (23:10 -0700)
* 'master' of git://repo.or.cz/git/fastimport:
Remove unnecessary casts from fast-import
New fast-import test case for valid tree sorting
fast-import: grow tree storage more aggressively

run-command.c
sha1_name.c
t/t5510-fetch.sh
index 03ff7bcac2a812bfa049255b499f25fdc14a0fd4..bef9775e0807200e07c9780c69e3e1bda0c6c874 100644 (file)
@@ -2,6 +2,12 @@
 #include "run-command.h"
 #include "exec_cmd.h"
 
+static inline void close_pair(int fd[2])
+{
+       close(fd[0]);
+       close(fd[1]);
+}
+
 int start_command(struct child_process *cmd)
 {
        int need_in = !cmd->no_stdin && cmd->in < 0;
@@ -16,10 +22,8 @@ int start_command(struct child_process *cmd)
 
        cmd->pid = fork();
        if (cmd->pid < 0) {
-               if (need_in) {
-                       close(fdin[0]);
-                       close(fdin[1]);
-               }
+               if (need_in)
+                       close_pair(fdin);
                return -ERR_RUN_COMMAND_FORK;
        }
 
@@ -30,8 +34,7 @@ int start_command(struct child_process *cmd)
                        close(fd);
                } else if (need_in) {
                        dup2(fdin[0], 0);
-                       close(fdin[0]);
-                       close(fdin[1]);
+                       close_pair(fdin);
                } else if (cmd->in) {
                        dup2(cmd->in, 0);
                        close(cmd->in);
index 6b8b67b4db3cbccc13d6ddda5dd3a1be11adabd1..bede0e5b0659db31a1dfdaab3d17627199150ea7 100644 (file)
@@ -602,10 +602,10 @@ static int handle_one_ref(const char *path,
  */
 
 #define ONELINE_SEEN (1u<<20)
-int get_sha1_oneline(const char *prefix, unsigned char *sha1)
+static int get_sha1_oneline(const char *prefix, unsigned char *sha1)
 {
        struct commit_list *list = NULL, *backup = NULL, *l;
-       struct commit *commit = NULL;
+       int retval = -1;
 
        if (prefix[0] == '!') {
                if (prefix[1] != '!')
@@ -619,22 +619,22 @@ int get_sha1_oneline(const char *prefix, unsigned char *sha1)
                commit_list_insert(l->item, &backup);
        while (list) {
                char *p;
+               struct commit *commit;
 
                commit = pop_most_recent_commit(&list, ONELINE_SEEN);
-               if (!commit)
-                       break;
                parse_object(commit->object.sha1);
                if (!commit->buffer || !(p = strstr(commit->buffer, "\n\n")))
                        continue;
                if (!prefixcmp(p + 2, prefix)) {
                        hashcpy(sha1, commit->object.sha1);
+                       retval = 0;
                        break;
                }
        }
        free_commit_list(list);
        for (l = backup; l; l = l->next)
                clear_commit_marks(l->item, ONELINE_SEEN);
-       return commit == NULL;
+       return retval;
 }
 
 /*
index ee3f397a9bf8d4a08c2f897f0ae094b8ea686344..426017e1d08aad5aa3a92f9473e02defc4b10aaf 100755 (executable)
@@ -134,7 +134,13 @@ test_expect_success 'bundle does not prerequisite objects' '
        git add file2 &&
        git commit -m add.file2 file2 &&
        git bundle create bundle3 -1 HEAD &&
-       sed "1,4d" < bundle3 > bundle.pack &&
+       (
+               while read x && test -n "$x"
+               do
+                       :;
+               done
+               cat
+       ) <bundle3 >bundle.pack &&
        git index-pack bundle.pack &&
        test 4 = $(git verify-pack -v bundle.pack | wc -l)
 '