Code

Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Sat, 19 Jul 2008 18:28:06 +0000 (11:28 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 19 Jul 2008 18:28:06 +0000 (11:28 -0700)
* maint:
  GIT 1.5.6.4
  builtin-rm: fix index lock file path
  http-fetch: do not SEGV after fetching a bad pack idx file
  rev-list: honor --quiet option
  api-run-command.txt: typofix

1  2 
builtin-rev-list.c
builtin-rm.c
http-walker.c
t/t3600-rm.sh

diff --combined builtin-rev-list.c
index 8e1720c45bfa2ffc170b9880a6c90fcc3741bd46,39ec61c42858c0b1c5306025f0962b3ee3d7f910..893762c80f4910fadf2d6df414bd835cccb7faaa
@@@ -17,7 -17,7 +17,7 @@@
  #define COUNTED               (1u<<16)
  
  static const char rev_list_usage[] =
 -"git-rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
 +"git rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
  "  limiting output:\n"
  "    --max-count=nr\n"
  "    --max-age=epoch\n"
@@@ -37,7 -37,6 +37,7 @@@
  "    --reverse\n"
  "  formatting output:\n"
  "    --parents\n"
 +"    --children\n"
  "    --objects | --objects-edge\n"
  "    --unpacked\n"
  "    --header | --pretty\n"
@@@ -91,15 -90,6 +91,15 @@@ static void show_commit(struct commit *
                        parents = parents->next;
                }
        }
 +      if (revs.children.name) {
 +              struct commit_list *children;
 +
 +              children = lookup_decoration(&revs.children, &commit->object);
 +              while (children) {
 +                      printf(" %s", sha1_to_hex(children->item->object.sha1));
 +                      children = children->next;
 +              }
 +      }
        show_decorations(commit);
        if (revs.commit_format == CMIT_FMT_ONELINE)
                putchar(' ');
@@@ -575,6 -565,23 +575,6 @@@ static struct commit_list *find_bisecti
        return best;
  }
  
 -static void read_revisions_from_stdin(struct rev_info *revs)
 -{
 -      char line[1000];
 -
 -      while (fgets(line, sizeof(line), stdin) != NULL) {
 -              int len = strlen(line);
 -              if (len && line[len - 1] == '\n')
 -                      line[--len] = 0;
 -              if (!len)
 -                      break;
 -              if (line[0] == '-')
 -                      die("options not supported in --stdin mode");
 -              if (handle_revision_arg(line, revs, 0, 1))
 -                      die("bad revision '%s'", line);
 -      }
 -}
 -
  int cmd_rev_list(int argc, const char **argv, const char *prefix)
  {
        struct commit_list *list;
        revs.commit_format = CMIT_FMT_UNSPECIFIED;
        argc = setup_revisions(argc, argv, &revs, NULL);
  
+       quiet = DIFF_OPT_TST(&revs.diffopt, QUIET);
        for (i = 1 ; i < argc; i++) {
                const char *arg = argv[i];
  
                        read_revisions_from_stdin(&revs);
                        continue;
                }
-               if (!strcmp(arg, "--quiet")) {
-                       quiet = 1;
-                       continue;
-               }
                usage(rev_list_usage);
  
        }
diff --combined builtin-rm.c
index 56454ec8f4ed0612aa8932c4d5a3294da6a1f4cd,abdab7f001587e819aecb5c5f7e8dcbb10a5dd48..ee8247b08cd007f73d5dfffa560a9efe33d327b9
@@@ -11,7 -11,7 +11,7 @@@
  #include "parse-options.h"
  
  static const char * const builtin_rm_usage[] = {
 -      "git-rm [options] [--] <file>...",
 +      "git rm [options] [--] <file>...",
        NULL
  };
  
@@@ -146,11 -146,6 +146,6 @@@ int cmd_rm(int argc, const char **argv
  
        git_config(git_default_config, NULL);
  
-       newfd = hold_locked_index(&lock_file, 1);
-       if (read_cache() < 0)
-               die("index file corrupt");
        argc = parse_options(argc, argv, builtin_rm_options, builtin_rm_usage, 0);
        if (!argc)
                usage_with_options(builtin_rm_usage, builtin_rm_options);
        if (!index_only)
                setup_work_tree();
  
+       newfd = hold_locked_index(&lock_file, 1);
+       if (read_cache() < 0)
+               die("index file corrupt");
        pathspec = get_pathspec(prefix, argv);
        seen = NULL;
        for (i = 0; pathspec[i] ; i++)
diff --combined http-walker.c
index 51c18f2685aa1bdb7e4ed471d0ec5d31c6684fda,74033060c4e85b23a947ea5799d8ea96e6040da0..9dc6b27b457a2979a95018679a0b885e6fb62d9a
@@@ -442,6 -442,8 +442,8 @@@ static int setup_index(struct walker *w
                return -1;
  
        new_pack = parse_pack_index(sha1);
+       if (!new_pack)
+               return -1; /* parse_pack_index() already issued error message */
        new_pack->next = repo->packs;
        repo->packs = new_pack;
        return 0;
@@@ -795,7 -797,7 +797,7 @@@ static int fetch_pack(struct walker *wa
                lst = &((*lst)->next);
        *lst = (*lst)->next;
  
 -      if (verify_pack(target, 0))
 +      if (verify_pack(target))
                return -1;
        install_packed_git(target);
  
diff --combined t/t3600-rm.sh
index 316775ecd96208c07f3211a24de2e5ec2ee409ab,7893d8c40ea510595b0483432e71a74b11b24598..79c06adf1f035cf727771974b2f9713da9d2fb8c
@@@ -67,7 -67,7 +67,7 @@@ test_expect_success 
       echo "other content" > foo
       git add foo
       echo "yet another content" > foo
 -     ! git rm --cached foo
 +     test_must_fail git rm --cached foo
  '
  
  test_expect_success \
@@@ -82,7 -82,7 +82,7 @@@
  
  test_expect_success \
      'Post-check that foo exists but is not in index after git rm foo' \
 -    '[ -f foo ] && ! git ls-files --error-unmatch foo'
 +    '[ -f foo ] && test_must_fail git ls-files --error-unmatch foo'
  
  test_expect_success \
      'Pre-check that bar exists and is in index before "git rm bar"' \
@@@ -94,7 -94,7 +94,7 @@@ test_expect_success 
  
  test_expect_success \
      'Post-check that bar does not exist and is not in index after "git rm -f bar"' \
 -    '! [ -f bar ] && ! git ls-files --error-unmatch bar'
 +    '! [ -f bar ] && test_must_fail git ls-files --error-unmatch bar'
  
  test_expect_success \
      'Test that "git rm -- -q" succeeds (remove a file that looks like an option)' \
@@@ -109,7 -109,7 +109,7 @@@ if test "$test_failed_remove" = y; the
  chmod a-w .
  test_expect_success \
      'Test that "git rm -f" fails if its rm fails' \
 -    '! git rm -f baz'
 +    'test_must_fail git rm -f baz'
  chmod 775 .
  else
      test_expect_success 'skipping removal failure (perhaps running as root?)' :
@@@ -151,7 -151,7 +151,7 @@@ test_expect_success 'Re-add foo and baz
  
  test_expect_success 'Modify foo -- rm should refuse' '
        echo >>foo &&
 -      ! git rm foo baz &&
 +      test_must_fail git rm foo baz &&
        test -f foo &&
        test -f baz &&
        git ls-files --error-unmatch foo baz
@@@ -161,8 -161,8 +161,8 @@@ test_expect_success 'Modified foo -- r
        git rm -f foo baz &&
        test ! -f foo &&
        test ! -f baz &&
 -      ! git ls-files --error-unmatch foo &&
 -      ! git ls-files --error-unmatch bar
 +      test_must_fail git ls-files --error-unmatch foo &&
 +      test_must_fail git ls-files --error-unmatch bar
  '
  
  test_expect_success 'Re-add foo and baz for HEAD tests' '
  '
  
  test_expect_success 'foo is different in index from HEAD -- rm should refuse' '
 -      ! git rm foo baz &&
 +      test_must_fail git rm foo baz &&
        test -f foo &&
        test -f baz &&
        git ls-files --error-unmatch foo baz
@@@ -183,8 -183,8 +183,8 @@@ test_expect_success 'but with -f it sho
        git rm -f foo baz &&
        test ! -f foo &&
        test ! -f baz &&
 -      ! git ls-files --error-unmatch foo
 -      ! git ls-files --error-unmatch baz
 +      test_must_fail git ls-files --error-unmatch foo
 +      test_must_fail git ls-files --error-unmatch baz
  '
  
  test_expect_success 'Recursive test setup' '
  '
  
  test_expect_success 'Recursive without -r fails' '
 -      ! git rm frotz &&
 +      test_must_fail git rm frotz &&
        test -d frotz &&
        test -f frotz/nitfol
  '
  
  test_expect_success 'Recursive with -r but dirty' '
        echo qfwfq >>frotz/nitfol
 -      ! git rm -r frotz &&
 +      test_must_fail git rm -r frotz &&
        test -d frotz &&
        test -f frotz/nitfol
  '
@@@ -214,7 -214,19 +214,19 @@@ test_expect_success 'Recursive with -r 
  '
  
  test_expect_success 'Remove nonexistent file returns nonzero exit status' '
 -      ! git rm nonexistent
 +      test_must_fail git rm nonexistent
  '
  
+ test_expect_success 'Call "rm" from outside the work tree' '
+       mkdir repo &&
+       cd repo &&
+       git init &&
+       echo something > somefile &&
+       git add somefile &&
+       git commit -m "add a file" &&
+       (cd .. &&
+        git --git-dir=repo/.git --work-tree=repo rm somefile) &&
+       test_must_fail git ls-files --error-unmatch somefile
+ '
  test_done