From: Junio C Hamano Date: Fri, 24 Feb 2006 06:25:32 +0000 (-0800) Subject: Merge branches 'jc/fix-co-candy', 'jc/fix-rename-leak' and 'ar/fix-win' into maint X-Git-Tag: v1.2.4~9 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/7bd1527d2d8c80a6e9a0f8583082a5aee5428c68?ds=sidebyside;hp=-c Merge branches 'jc/fix-co-candy', 'jc/fix-rename-leak' and 'ar/fix-win' into maint * 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 --- 7bd1527d2d8c80a6e9a0f8583082a5aee5428c68 diff --combined git-clone.sh index d184ceb7a6,54c9e4ea4c,d184ceb7a6,be471d82b8..89c15d7a65 --- a/git-clone.sh +++ b/git-clone.sh @@@@@ -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 0d938724e5,4e0cdda08d,5580f15ba2,5580f15ba2..bb50a800d7 --- a/read-tree.c +++ b/read-tree.c @@@@@ -9,6 -9,8 -9,6 -9,6 +9,8 @@@@@ #include "object.h" #include "tree.h" + ++#include + ++#include 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 = { @@@@@ -276,8 -286,49 -276,8 -276,8 +286,49 @@@@@ .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); @@@@@ -289,6 -340,10 -289,6 -289,6 +340,10 @@@@@ 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. */