From: Junio C Hamano Date: Fri, 24 Feb 2006 06:27:03 +0000 (-0800) Subject: Merge fixes early for next maint series. X-Git-Tag: v1.3.0-rc1~152 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/816c02ce8ecddce065e83db9f4ecb78f6b0e23dc?ds=inline;hp=-c Merge fixes early for next maint series. --- 816c02ce8ecddce065e83db9f4ecb78f6b0e23dc diff --combined commit.c index c550a00d82,512b5d74d7..06d5439152 --- a/commit.c +++ b/commit.c @@@ -212,7 -212,8 +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 +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; @@@ -630,10 -631,7 +631,10 @@@ } 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; @@@ -650,12 -648,8 +651,12 @@@ * 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 index dc0ad552a3,89c15d7a65..4ed861d576 --- a/git-clone.sh +++ b/git-clone.sh @@@ -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" ;; @@@ -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 @@@ 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 index 4609fe54d5,c258ea78bc..7be9e81f1f --- a/git-merge.sh +++ b/git-merge.sh @@@ -13,10 -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 +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 @@@ -150,7 -146,7 +150,7 @@@ 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 index 52f06e312a,bb50a800d7..f39fe5ca65 --- a/read-tree.c +++ b/read-tree.c @@@ -9,6 -9,8 +9,8 @@@ #include "object.h" #include "tree.h" + #include + #include static int merge = 0; static int update = 0; @@@ -16,6 -18,8 +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 +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 +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 +340,10 @@@ checkout_entry(ce, &state); } } + if (total) { + fputc('\n', stderr); + signal(SIGALRM, SIG_IGN); + } } static int unpack_trees(merge_fn_t fn) @@@ -349,7 -404,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 -619,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 +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 +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 index 1fd5b797a5,aa09b4646a..a80d849f15 --- a/sha1_file.c +++ b/sha1_file.c @@@ -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 @@@ 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; @@@ -878,7 -878,7 +878,7 @@@ 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,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)); @@@ -1561,7 -1562,7 +1562,7 @@@ } 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));