Merge fixes early for next maint series.
authorJunio C Hamano <junkio@cox.net>
Fri, 24 Feb 2006 06:27:03 +0000 (22:27 -0800)
committerJunio C Hamano <junkio@cox.net>
Fri, 24 Feb 2006 06:27:03 +0000 (22:27 -0800)
1  2 
commit.c
git-clone.sh
git-merge.sh
read-tree.c
sha1_file.c
diff --combined commit.c
index c550a00d8242f9a57e0bd008d952f24e1b91ad35,512b5d74d71dba46831192b740680243913166ba..06d5439152cd835e4de11552ef09438ce14b4d1d
+++ 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;
                }
                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
index dc0ad552a322d46f48bee2c8d324285a63a9b8c7,89c15d7a65bc7538ef2bfbc4a68a590d4add9cf8..4ed861d576bfaefa768f811a59d2ec53d233b5df
@@@ -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 4609fe54d52843f42d2c1d18a9dc2ff235b5c7ce,c258ea78bcd5dc944155b629ef429de247a6bac5..7be9e81f1f886c6e0b4c6be8758bd7ba25f5b04c
@@@ -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
  
        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 52f06e312ab5b8808401affed6291051d7a746d5,bb50a800d79dbfb7836b6cba1c62935d9a78577e..f39fe5ca653db7a4972cf99e790991c3d88495d0
@@@ -9,6 -9,8 +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 +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 = {
                .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 -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 1fd5b797a587dfd52a6662fc48c992a5e298f7f8,aa09b4646abff2f82d30c9968ae277d35db8c438..a80d849f15936c8fa7aa8f362bcb54b98a892f08
@@@ -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;
        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));
  
        }
        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));