Merge branches 'maint', 'jc/fix-co-candy' and 'jc/fix-rename-leak' into next
authorJunio C Hamano <junkio@cox.net>
Thu, 23 Feb 2006 03:46:59 +0000 (19:46 -0800)
committerJunio C Hamano <junkio@cox.net>
Thu, 23 Feb 2006 03:46:59 +0000 (19:46 -0800)
* maint:
  Give no terminating LF to error() function.

* jc/fix-co-candy:
  checkout - eye candy.

* jc/fix-rename-leak:
  diffcore-rename: plug memory leak.

1  2  3  4 
commit.c
git-clone.sh
git-merge.sh
read-tree.c
sha1_file.c

diff --combined commit.c
+++ b/commit.c
@@@@@ -212,7 -212,8 -212,7 -212,7 +212,8 @@@@@ int parse_commit_buffer(struct commit *
        if (memcmp(bufptr, "tree ", 5))
                return error("bogus commit object %s", sha1_to_hex(item->object.sha1));
        if (get_sha1_hex(bufptr + 5, parent) < 0)
- --            return error("bad tree pointer in commit %s\n", sha1_to_hex(item->object.sha1));
+ ++            return error("bad tree pointer in commit %s",
+ ++                         sha1_to_hex(item->object.sha1));
        item->tree = lookup_tree(parent);
        if (item->tree)
                n_refs++;
@@@@@ -571,7 -572,7 -571,7 -571,7 +572,7 @@@@@ int count_parents(struct commit * commi
    /*
     * Performs an in-place topological sort on the list supplied.
     */
 ---void sort_in_topological_order(struct commit_list ** list)
 +++void sort_in_topological_order(struct commit_list ** list, int lifo)
    {
        struct commit_list * next = *list;
        struct commit_list * work = NULL, **insert;
                }
                next=next->next;
        }
 +++
        /* process the list in topological order */
 +++    if (!lifo)
 +++            sort_by_date(&work);
        while (work) {
                struct commit * work_item = pop_commit(&work);
                struct sort_node * work_node = (struct sort_node *)work_item->object.util;
                                     * guaranteeing topological order.
                                     */
                                pn->indegree--;
 ---                            if (!pn->indegree) 
 ---                                    commit_list_insert(parent, &work);
 +++                            if (!pn->indegree) {
 +++                                    if (!lifo)
 +++                                            insert_by_date(parent, &work);
 +++                                    else
 +++                                            commit_list_insert(parent, &work);
 +++                            }
                        }
                        parents=parents->next;
                }
diff --combined git-clone.sh
@@@@@ -154,7 -154,7 -154,7 -154,7 +154,7 @@@@@ yes,yes
            fi &&
            rm -f "$GIT_DIR/objects/sample" &&
            cd "$repo" &&
 ---        find objects -depth -print | cpio -puamd$l "$GIT_DIR/" || exit 1
 +++        find objects -depth -print | cpio -pumd$l "$GIT_DIR/" || exit 1
            ;;
        yes)
            mkdir -p "$GIT_DIR/objects/info"
@@@@@ -253,7 -253,7 -253,7 -253,7 +253,7 @@@@@ Pull: $head_points_at:$origin" &
    
        case "$no_checkout" in
        '')
-- -            git checkout
++ +            git-read-tree -m -u -v HEAD HEAD
        esac
    fi
    
diff --combined git-merge.sh
@@@@@ -13,10 -13,6 -13,6 -13,6 +13,10 @@@@@ LF=
    all_strategies='recursive octopus resolve stupid ours'
    default_strategies='recursive'
    use_strategies=
 +++if test "@@NO_PYTHON@@"; then
 +++    all_strategies='resolve octopus stupid ours'
 +++    default_strategies='resolve'
 +++fi
    
    dropsave() {
        rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" \
@@@@@ -134,7 -130,7 -130,7 -130,7 +134,7 @@@@@ case "$#,$common,$no_commit" i
        echo "Updating from $head to $1."
        git-update-index --refresh 2>/dev/null
        new_head=$(git-rev-parse --verify "$1^0") &&
-- -    git-read-tree -u -m $head "$new_head" &&
++ +    git-read-tree -u -v -m $head "$new_head" &&
        finish "$new_head" "Fast forward"
        dropsave
        exit 0
    
        echo "Trying really trivial in-index merge..."
        git-update-index --refresh 2>/dev/null
-- -    if git-read-tree --trivial -m -u $common $head "$1" &&
++ +    if git-read-tree --trivial -m -u -v $common $head "$1" &&
           result_tree=$(git-write-tree)
        then
            echo "Wonderful."
diff --combined read-tree.c
@@@@@ -9,6 -9,6 -9,8 -9,6 +9,8 @@@@@
    
    #include "object.h"
    #include "tree.h"
++ +#include <sys/time.h>
++ +#include <signal.h>
    
    static int merge = 0;
    static int update = 0;
@@@@@ -16,6 -16,6 -18,8 -16,6 +18,8 @@@@@ static int index_only = 0
    static int nontrivial_merge = 0;
    static int trivial_merges_only = 0;
    static int aggressive = 0;
++ +static int verbose_update = 0;
++ +static volatile int progress_update = 0;
    
    static int head_idx = -1;
    static int merge_size = 0;
@@@@@ -267,6 -267,6 -271,12 -267,6 +271,12 @@@@@ static void unlink_entry(char *name
        }
    }
    
++ +static void progress_interval(int signum)
++ +{
++ +    signal(SIGALRM, progress_interval);
++ +    progress_update = 1;
++ +}
++ +
    static void check_updates(struct cache_entry **src, int nr)
    {
        static struct checkout state = {
                .refresh_cache = 1,
        };
        unsigned short mask = htons(CE_UPDATE);
++ +    unsigned last_percent = 200, cnt = 0, total = 0;
++ +
++ +    if (update && verbose_update) {
++ +            struct itimerval v;
++ +
++ +            for (total = cnt = 0; cnt < nr; cnt++) {
++ +                    struct cache_entry *ce = src[cnt];
++ +                    if (!ce->ce_mode || ce->ce_flags & mask)
++ +                            total++;
++ +            }
++ +
++ +            /* Don't bother doing this for very small updates */
++ +            if (total < 250)
++ +                    total = 0;
++ +
++ +            if (total) {
++ +                    v.it_interval.tv_sec = 1;
++ +                    v.it_interval.tv_usec = 0;
++ +                    v.it_value = v.it_interval;
++ +                    signal(SIGALRM, progress_interval);
++ +                    setitimer(ITIMER_REAL, &v, NULL);
++ +                    fprintf(stderr, "Checking files out...\n");
++ +                    progress_update = 1;
++ +            }
++ +            cnt = 0;
++ +    }
++ +
        while (nr--) {
                struct cache_entry *ce = *src++;
++ +
++ +            if (total) {
++ +                    if (!ce->ce_mode || ce->ce_flags & mask) {
++ +                            unsigned percent;
++ +                            cnt++;
++ +                            percent = (cnt * 100) / total;
++ +                            if (percent != last_percent ||
++ +                                progress_update) {
++ +                                    fprintf(stderr, "%4u%% (%u/%u) done\r",
++ +                                            percent, cnt, total);
++ +                                    last_percent = percent;
++ +                            }
++ +                    }
++ +            }
                if (!ce->ce_mode) {
                        if (update)
                                unlink_entry(ce->name);
                                checkout_entry(ce, &state);
                }
        }
++ +    if (total) {
++ +            fputc('\n', stderr);
++ +            signal(SIGALRM, SIG_IGN);
++ +    }
    }
    
    static int unpack_trees(merge_fn_t fn)
@@@@@ -349,7 -349,7 -404,7 -349,7 +404,7 @@@@@ static void verify_uptodate(struct cach
                return;
    
        if (!lstat(ce->name, &st)) {
 ---            unsigned changed = ce_match_stat(ce, &st);
 +++            unsigned changed = ce_match_stat(ce, &st, 1);
                if (!changed)
                        return;
                errno = 0;
@@@@@ -564,7 -564,7 -619,7 -564,7 +619,7 @@@@@ static int twoway_merge(struct cache_en
        struct cache_entry *oldtree = src[1], *newtree = src[2];
    
        if (merge_size != 2)
- --            return error("Cannot do a twoway merge of %d trees\n",
+ ++            return error("Cannot do a twoway merge of %d trees",
                             merge_size);
    
        if (current) {
@@@@@ -616,7 -616,7 -671,7 -616,7 +671,7 @@@@@ static int oneway_merge(struct cache_en
        struct cache_entry *a = src[1];
    
        if (merge_size != 1)
- --            return error("Cannot do a oneway merge of %d trees\n",
+ ++            return error("Cannot do a oneway merge of %d trees",
                             merge_size);
    
        if (!a)
@@@@@ -680,6 -680,6 -735,11 -680,6 +735,11 @@@@@ int main(int argc, char **argv
                        continue;
                }
    
++ +            if (!strcmp(arg, "-v")) {
++ +                    verbose_update = 1;
++ +                    continue;
++ +            }
++ +
                /* "-i" means "index only", meaning that a merge will
                 * not even look at the working tree.
                 */
diff --combined sha1_file.c
@@@@@ -564,7 -564,7 -564,7 -564,7 +564,7 @@@@@ static void prepare_packed_git_one(cha
        dir = opendir(path);
        if (!dir) {
                if (errno != ENOENT)
- --                    error("unable to open object pack directory: %s: %s\n",
+ ++                    error("unable to open object pack directory: %s: %s",
                              path, strerror(errno));
                return;
        }
@@@@@ -864,7 -864,7 -864,7 -864,7 +864,7 @@@@@ void packed_object_info_detail(struct p
                               char *type,
                               unsigned long *size,
                               unsigned long *store_size,
 ---                           int *delta_chain_length,
 +++                           unsigned int *delta_chain_length,
                               unsigned char *base_sha1)
    {
        struct packed_git *p = e->p;
        if (kind != OBJ_DELTA)
                *delta_chain_length = 0;
        else {
 ---            int chain_length = 0;
 +++            unsigned int chain_length = 0;
                memcpy(base_sha1, pack, 20);
                do {
                        struct pack_entry base_ent;
@@@@@ -1513,7 -1513,8 -1513,7 -1513,7 +1513,8 @@@@@ int write_sha1_from_fd(const unsigned c
    
        local = mkstemp(tmpfile);
        if (local < 0)
- --            return error("Couldn't open %s for %s\n", tmpfile, sha1_to_hex(sha1));
+ ++            return error("Couldn't open %s for %s",
+ ++                         tmpfile, sha1_to_hex(sha1));
    
        memset(&stream, 0, sizeof(stream));
    
        }
        if (memcmp(sha1, real_sha1, 20)) {
                unlink(tmpfile);
- --            return error("File %s has bad hash\n", sha1_to_hex(sha1));
+ ++            return error("File %s has bad hash", sha1_to_hex(sha1));
        }
    
        return move_temp_to_file(tmpfile, sha1_file_name(sha1));