Merge branch 'maint-1.5.4' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 25 Apr 2008 04:50:48 +0000 (21:50 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 25 Apr 2008 04:50:48 +0000 (21:50 -0700)
* maint-1.5.4:
t5516: remove ambiguity test (1)
Linked glossary from cvs-migration page
write-tree: properly detect failure to write tree objects

1  2 
cache-tree.c
t/t5516-fetch-push.sh
diff --combined cache-tree.c
index 39da54d1e56b5905655eafed1aff0f51c2540a8e,cfe937b0f12896160e728f9bdec4d4594f13bd3a..73cb3407077275f82677839d2c9e794c12833c95
@@@ -320,13 -320,13 +320,13 @@@ static int update_one(struct cache_tre
                }
                else {
                        sha1 = ce->sha1;
 -                      mode = ntohl(ce->ce_mode);
 +                      mode = ce->ce_mode;
                        entlen = pathlen - baselen;
                }
                if (mode != S_IFGITLINK && !missing_ok && !has_sha1_file(sha1))
                        return error("invalid object %s", sha1_to_hex(sha1));
  
 -              if (!ce->ce_mode)
 +              if (ce->ce_flags & CE_REMOVE)
                        continue; /* entry being removed */
  
                strbuf_grow(&buffer, entlen + 100);
  
        if (dryrun)
                hash_sha1_file(buffer.buf, buffer.len, tree_type, it->sha1);
-       else
-               write_sha1_file(buffer.buf, buffer.len, tree_type, it->sha1);
+       else if (write_sha1_file(buffer.buf, buffer.len, tree_type, it->sha1)) {
+               strbuf_release(&buffer);
+               return -1;
+       }
        strbuf_release(&buffer);
        it->entry_count = i;
  #if DEBUG
@@@ -529,58 -532,3 +532,58 @@@ struct cache_tree *cache_tree_find(stru
        }
        return it;
  }
 +
 +int write_cache_as_tree(unsigned char *sha1, int missing_ok, const char *prefix)
 +{
 +      int entries, was_valid, newfd;
 +
 +      /*
 +       * We can't free this memory, it becomes part of a linked list
 +       * parsed atexit()
 +       */
 +      struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
 +
 +      newfd = hold_locked_index(lock_file, 1);
 +
 +      entries = read_cache();
 +      if (entries < 0)
 +              return WRITE_TREE_UNREADABLE_INDEX;
 +
 +      if (!active_cache_tree)
 +              active_cache_tree = cache_tree();
 +
 +      was_valid = cache_tree_fully_valid(active_cache_tree);
 +
 +      if (!was_valid) {
 +              if (cache_tree_update(active_cache_tree,
 +                                    active_cache, active_nr,
 +                                    missing_ok, 0) < 0)
 +                      return WRITE_TREE_UNMERGED_INDEX;
 +              if (0 <= newfd) {
 +                      if (!write_cache(newfd, active_cache, active_nr) &&
 +                          !commit_lock_file(lock_file))
 +                              newfd = -1;
 +              }
 +              /* Not being able to write is fine -- we are only interested
 +               * in updating the cache-tree part, and if the next caller
 +               * ends up using the old index with unupdated cache-tree part
 +               * it misses the work we did here, but that is just a
 +               * performance penalty and not a big deal.
 +               */
 +      }
 +
 +      if (prefix) {
 +              struct cache_tree *subtree =
 +                      cache_tree_find(active_cache_tree, prefix);
 +              if (!subtree)
 +                      return WRITE_TREE_PREFIX_ERROR;
 +              hashcpy(sha1, subtree->sha1);
 +      }
 +      else
 +              hashcpy(sha1, active_cache_tree->sha1);
 +
 +      if (0 <= newfd)
 +              rollback_lock_file(lock_file);
 +
 +      return 0;
 +}
diff --combined t/t5516-fetch-push.sh
index 6d7e7385483bda6223d8d222980bf33b2679f711,352e83bdc62b2971c89a12c42fb202836b36c744..f93a100f8732dcde2a8e52fc24ab5d54d4890b23
@@@ -100,23 -100,6 +100,23 @@@ test_expect_success 'fetch with wildcar
        )
  '
  
 +test_expect_success 'fetch with insteadOf' '
 +      mk_empty &&
 +      (
 +              TRASH=$(pwd)/ &&
 +              cd testrepo &&
 +              git config url.$TRASH.insteadOf trash/
 +              git config remote.up.url trash/. &&
 +              git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
 +              git fetch up &&
 +
 +              r=$(git show-ref -s --verify refs/remotes/origin/master) &&
 +              test "z$r" = "z$the_commit" &&
 +
 +              test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
 +      )
 +'
 +
  test_expect_success 'push without wildcard' '
        mk_empty &&
  
@@@ -143,20 -126,6 +143,20 @@@ test_expect_success 'push with wildcard
        )
  '
  
 +test_expect_success 'push with insteadOf' '
 +      mk_empty &&
 +      TRASH=$(pwd)/ &&
 +      git config url.$TRASH.insteadOf trash/ &&
 +      git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
 +      (
 +              cd testrepo &&
 +              r=$(git show-ref -s --verify refs/remotes/origin/master) &&
 +              test "z$r" = "z$the_commit" &&
 +
 +              test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
 +      )
 +'
 +
  test_expect_success 'push with matching heads' '
  
        mk_test heads/master &&
@@@ -209,19 -178,7 +209,7 @@@ test_expect_success 'push with weak amb
  
  '
  
- test_expect_success 'push with ambiguity (1)' '
-       mk_test remotes/origin/master remotes/frotz/master &&
-       if git push testrepo master:master
-       then
-               echo "Oops, should have failed"
-               false
-       else
-               check_push_result $the_first_commit remotes/origin/master remotes/frotz/master
-       fi
- '
- test_expect_success 'push with ambiguity (2)' '
+ test_expect_success 'push with ambiguity' '
  
        mk_test heads/frotz tags/frotz &&
        if git push testrepo master:frotz
@@@ -302,49 -259,6 +290,49 @@@ test_expect_success 'push with HEAD non
        check_push_result $the_commit heads/local
  '
  
 +test_expect_success 'push with +HEAD' '
 +
 +      mk_test heads/master &&
 +      git checkout master &&
 +      git branch -D local &&
 +      git checkout -b local &&
 +      git push testrepo master local &&
 +      check_push_result $the_commit heads/master &&
 +      check_push_result $the_commit heads/local &&
 +
 +      # Without force rewinding should fail
 +      git reset --hard HEAD^ &&
 +      ! git push testrepo HEAD &&
 +      check_push_result $the_commit heads/local &&
 +
 +      # With force rewinding should succeed
 +      git push testrepo +HEAD &&
 +      check_push_result $the_first_commit heads/local
 +
 +'
 +
 +test_expect_success 'push with config remote.*.push = HEAD' '
 +
 +      mk_test heads/local &&
 +      git checkout master &&
 +      git branch -f local $the_commit &&
 +      (
 +              cd testrepo &&
 +              git checkout local &&
 +              git reset --hard $the_first_commit
 +      ) &&
 +      git config remote.there.url testrepo &&
 +      git config remote.there.push HEAD &&
 +      git config branch.master.remote there &&
 +      git push &&
 +      check_push_result $the_commit heads/master &&
 +      check_push_result $the_first_commit heads/local
 +'
 +
 +# clean up the cruft left with the previous one
 +git config --remove-section remote.there
 +git config --remove-section branch.master
 +
  test_expect_success 'push with dry-run' '
  
        mk_test heads/master &&