Merge branches 'jc/fix-co-candy', 'jc/fix-rename-leak' and 'ar/fix-win' into maint
authorJunio C Hamano <junkio@cox.net>
Fri, 24 Feb 2006 06:25:32 +0000 (22:25 -0800)
committerJunio C Hamano <junkio@cox.net>
Fri, 24 Feb 2006 06:25:32 +0000 (22:25 -0800)
* jc/fix-co-candy:
checkout - eye candy.

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

* ar/fix-win:
fix t5600-clone-fail-cleanup.sh on windows

1  2  3  4 
git-clone.sh
read-tree.c
diff --combined git-clone.sh
index d184ceb7a6f2a7d4ffc3a002b1a8846c46297f33,54c9e4ea4c5e486bf7dd4e2b19502d2400c4eb32,d184ceb7a6f2a7d4ffc3a002b1a8846c46297f33,be471d82b8f3d15407b599dcd5e89a7669502ff4..89c15d7a65bc7538ef2bfbc4a68a590d4add9cf8
@@@@@ -118,7 -118,7 -118,7 -118,7 +118,7 @@@@@ dir="$2
    [ -e "$dir" ] && echo "$dir already exists." && usage
    mkdir -p "$dir" &&
    D=$(cd "$dir" && pwd) &&
--- trap 'err=$?; rm -r $D; exit $err' exit
+++ trap 'err=$?; cd ..; rm -r "$D"; exit $err' exit
    case "$bare" in
    yes) GIT_DIR="$D" ;;
    *) GIT_DIR="$D/.git" ;;
@@@@@ -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 read-tree.c
index 0d938724e594b1bc3c573280cfb9affdd136f104,4e0cdda08d46f174cad07baa771844494ce32936,5580f15ba2c89f9fd1ed35de0b0183487d024bf8,5580f15ba2c89f9fd1ed35de0b0183487d024bf8..bb50a800d79dbfb7836b6cba1c62935d9a78577e
@@@@@ -9,6 -9,8 -9,6 -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 -18,8 -16,6 -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 -271,12 -267,6 -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)
@@@@@ -564,7 -619,7 -564,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 -671,7 -616,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 -735,11 -680,6 -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.
                 */