Merge branch 'ab/i18n-fixup'
authorJunio C Hamano <gitster@pobox.com>
Mon, 2 May 2011 22:58:40 +0000 (15:58 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 2 May 2011 22:58:40 +0000 (15:58 -0700)
* ab/i18n-fixup: (24 commits)
i18n: use test_i18n{cmp,grep} in t7600, t7607, t7611 and t7811
i18n: use test_i18n{grep,cmp} in t7508
i18n: use test_i18ngrep in t7506
i18n: use test_i18ngrep and test_i18ncmp in t7502
i18n: use test_i18ngrep in t7501
i18n: use test_i18ncmp in t7500
i18n: use test_i18ngrep in t7201
i18n: use test_i18ncmp and test_i18ngrep in t7102 and t7110
i18n: use test_i18ncmp and test_i18ngrep in t5541, t6040, t6120, t7004, t7012 and t7060
i18n: use test_i18ncmp and test_i18ngrep in t3700, t4001 and t4014
i18n: use test_i18ncmp and test_i18ngrep in t3203, t3501 and t3507
i18n: use test_i18ngrep in t2020, t2204, t3030, and t3200
i18n: use test_i18ngrep in lib-httpd and t2019
i18n: do not overuse C_LOCALE_OUTPUT (grep)
i18n: use test_i18ncmp in t1200 and t2200
i18n: .git file is not a human readable message (t5601)
i18n: do not overuse C_LOCALE_OUTPUT
i18n: mark init-db messages for translation
i18n: mark checkout plural warning for translation
i18n: mark checkout --detach messages for translation
...

1  2 
builtin/merge.c
t/t0001-init.sh
t/t4001-diff-rename.sh
t/t7060-wtstatus.sh
t/test-lib.sh
diff --combined builtin/merge.c
index 0bdd19a13784590c107108443f449d37fd7509d8,08245b6d664b2e29637dfba6ad33a394a5c104cc..d171c63c52160f082bbc04c90ffebc9545090357
@@@ -822,7 -822,7 +822,7 @@@ static void read_merge_msg(void
  {
        strbuf_reset(&merge_msg);
        if (strbuf_read_file(&merge_msg, git_path("MERGE_MSG"), 0) < 0)
-               die_errno("Could not read from '%s'", git_path("MERGE_MSG"));
+               die_errno(_("Could not read from '%s'"), git_path("MERGE_MSG"));
  }
  
  static void run_prepare_commit_msg(void)
@@@ -962,16 -962,16 +962,16 @@@ static int setup_with_upstream(const ch
        const char **args;
  
        if (!branch)
-               die("No current branch.");
+               die(_("No current branch."));
        if (!branch->remote)
-               die("No remote for the current branch.");
+               die(_("No remote for the current branch."));
        if (!branch->merge_nr)
-               die("No default upstream defined for the current branch.");
+               die(_("No default upstream defined for the current branch."));
  
        args = xcalloc(branch->merge_nr + 1, sizeof(char *));
        for (i = 0; i < branch->merge_nr; i++) {
                if (!branch->merge[i]->dst)
-                       die("No remote tracking branch for %s from %s",
+                       die(_("No remote tracking branch for %s from %s"),
                            branch->merge[i]->src, branch->remote_name);
                args[i] = branch->merge[i]->dst;
        }
@@@ -1043,10 -1043,10 +1043,10 @@@ int cmd_merge(int argc, const char **ar
        }
        if (file_exists(git_path("CHERRY_PICK_HEAD"))) {
                if (advice_resolve_conflict)
-                       die("You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\n"
-                           "Please, commit your changes before you can merge.");
+                       die(_("You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\n"
+                           "Please, commit your changes before you can merge."));
                else
-                       die("You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).");
+                       die(_("You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists)."));
        }
        resolve_undo_clear();
  
        if (!allow_fast_forward && fast_forward_only)
                die(_("You cannot combine --no-ff with --ff-only."));
  
 -      if (!argc && !abort_current_merge && default_to_upstream)
 -              argc = setup_with_upstream(&argv);
 -
 +      if (!abort_current_merge) {
 +              if (!argc && default_to_upstream)
 +                      argc = setup_with_upstream(&argv);
 +              else if (argc == 1 && !strcmp(argv[0], "-"))
 +                      argv[0] = "@{-1}";
 +      }
        if (!argc)
                usage_with_options(builtin_merge_usage,
                        builtin_merge_options);
diff --combined t/t0001-init.sh
index 54520f6fa69bef682e200497c531c9cd7367b9ea,651e0982cf11380842d401c6b65e98a1e193f669..8106af8fba918b8de82857d40a7f693224c84e81
@@@ -180,7 -180,7 +180,7 @@@ test_expect_success 'GIT_DIR & GIT_WORK
        fi
  '
  
- test_expect_success C_LOCALE_OUTPUT 'reinit' '
+ test_expect_success 'reinit' '
  
        (
                sane_unset GIT_CONFIG GIT_WORK_TREE GIT_CONFIG &&
                git init >out1 2>err1 &&
                git init >out2 2>err2
        ) &&
-       grep "Initialized empty" again/out1 &&
-       grep "Reinitialized existing" again/out2 &&
+       test_i18ngrep "Initialized empty" again/out1 &&
+       test_i18ngrep "Reinitialized existing" again/out2 &&
        >again/empty &&
-       test_cmp again/empty again/err1 &&
-       test_cmp again/empty again/err2
+       test_i18ncmp again/empty again/err1 &&
+       test_i18ncmp again/empty again/err2
  '
  
  test_expect_success 'init with --template' '
@@@ -402,7 -402,7 +402,7 @@@ test_expect_success 're-init to move gi
        test -d realgitdir/refs
  '
  
 -test_expect_success 're-init to move gitdir symlink' '
 +test_expect_success SYMLINKS 're-init to move gitdir symlink' '
        rm -rf newdir realgitdir &&
        git init newdir &&
        (
diff --combined t/t4001-diff-rename.sh
index 3dadf9b31636b862b2ab7377ce7100ebebd397e2,9a16d1cd932c901570b4d8218469d74692e5341f..844277cfa605f51cccd5d78a48a83fb75c03af9b
@@@ -64,42 -64,17 +64,42 @@@ test_expect_success 
      'validate the output.' \
      'compare_diff_patch current expected'
  
- test_expect_success C_LOCALE_OUTPUT 'favour same basenames over different ones' '
+ test_expect_success 'favour same basenames over different ones' '
        cp path1 another-path &&
        git add another-path &&
        git commit -m 1 &&
        git rm path1 &&
        mkdir subdir &&
        git mv another-path subdir/path1 &&
-       git status | grep "renamed: .*path1 -> subdir/path1"'
+       git status | test_i18ngrep "renamed: .*path1 -> subdir/path1"'
  
- test_expect_success C_LOCALE_OUTPUT  'favour same basenames even with minor differences' '
+ test_expect_success 'favour same basenames even with minor differences' '
        git show HEAD:path1 | sed "s/15/16/" > subdir/path1 &&
-       git status | grep "renamed: .*path1 -> subdir/path1"'
+       git status | test_i18ngrep "renamed: .*path1 -> subdir/path1"'
  
 +test_expect_success 'setup for many rename source candidates' '
 +      git reset --hard &&
 +      for i in 0 1 2 3 4 5 6 7 8 9;
 +      do
 +              for j in 0 1 2 3 4 5 6 7 8 9;
 +              do
 +                      echo "$i$j" >"path$i$j"
 +              done
 +      done &&
 +      git add "path??" &&
 +      test_tick &&
 +      git commit -m "hundred" &&
 +      (cat path1; echo new) >new-path &&
 +      echo old >>path1 &&
 +      git add new-path path1 &&
 +      git diff -l 4 -C -C --cached --name-status >actual 2>actual.err &&
 +      sed -e "s/^\([CM]\)[0-9]*       /\1     /" actual >actual.munged &&
 +      cat >expect <<-EOF &&
 +      C       path1   new-path
 +      M       path1
 +      EOF
 +      test_cmp expect actual.munged &&
 +      grep warning actual.err
 +'
 +
  test_done
diff --combined t/t7060-wtstatus.sh
index 3a5d927f83730f53a67cfec76a0625008dfb71f2,da2a1f194cf5bd055bf48bb389f478da84168914..b8cb4906aa7de022543b594399b6fa9a83ffc847
@@@ -38,7 -38,7 +38,7 @@@ cat >expect <<EO
  no changes added to commit (use "git add" and/or "git commit -a")
  EOF
  
- test_expect_success C_LOCALE_OUTPUT 'M/D conflict does not segfault' '
+ test_expect_success 'M/D conflict does not segfault' '
        mkdir mdconflict &&
        (
                cd mdconflict &&
                git commit -m delete &&
                test_must_fail git merge master &&
                test_must_fail git commit --dry-run >../actual &&
-               test_cmp ../expect ../actual &&
+               test_i18ncmp ../expect ../actual &&
                git status >../actual &&
-               test_cmp ../expect ../actual
+               test_i18ncmp ../expect ../actual
        )
  '
  
 +test_expect_success 'rename & unmerged setup' '
 +      git rm -f -r . &&
 +      cat "$TEST_DIRECTORY/README" >ONE &&
 +      git add ONE &&
 +      test_tick &&
 +      git commit -m "One commit with ONE" &&
 +
 +      echo Modified >TWO &&
 +      cat ONE >>TWO &&
 +      cat ONE >>THREE &&
 +      git add TWO THREE &&
 +      sha1=$(git rev-parse :ONE) &&
 +      git rm --cached ONE &&
 +      (
 +              echo "100644 $sha1 1    ONE" &&
 +              echo "100644 $sha1 2    ONE" &&
 +              echo "100644 $sha1 3    ONE"
 +      ) | git update-index --index-info &&
 +      echo Further >>THREE
 +'
 +
 +test_expect_success 'rename & unmerged status' '
 +      git status -suno >actual &&
 +      cat >expect <<-EOF &&
 +      UU ONE
 +      AM THREE
 +      A  TWO
 +      EOF
 +      test_cmp expect actual
 +'
 +
 +test_expect_success 'git diff-index --cached shows 2 added + 1 unmerged' '
 +      cat >expected <<-EOF &&
 +      U       ONE
 +      A       THREE
 +      A       TWO
 +      EOF
 +      git diff-index --cached --name-status HEAD >actual &&
 +      test_cmp expected actual
 +'
 +
 +test_expect_success 'git diff-index --cached -M shows 2 added + 1 unmerged' '
 +      cat >expected <<-EOF &&
 +      U       ONE
 +      A       THREE
 +      A       TWO
 +      EOF
 +      git diff-index --cached --name-status HEAD >actual &&
 +      test_cmp expected actual
 +'
 +
 +test_expect_success 'git diff-index --cached -C shows 2 copies + 1 unmerged' '
 +      cat >expected <<-EOF &&
 +      U       ONE
 +      C       ONE     THREE
 +      C       ONE     TWO
 +      EOF
 +      git diff-index --cached -C --name-status HEAD |
 +      sed "s/^C[0-9]*/C/g" >actual &&
 +      test_cmp expected actual
 +'
 +
  test_done
diff --combined t/test-lib.sh
index aca03d2db0eaf2411c01f58554ec0075da491ea7,763b9c55a81796e11fcc3eaefd9ec362106c7c2a..c5b18e282a7ef4246fb7d725cf94bfc5e7e72dc3
@@@ -575,7 -575,7 +575,7 @@@ test_external () 
  test_external_without_stderr () {
        # The temporary file has no (and must have no) security
        # implications.
 -      tmp="$TMPDIR"; if [ -z "$tmp" ]; then tmp=/tmp; fi
 +      tmp=${TMPDIR:-/tmp}
        stderr="$tmp/git-external-stderr.$$.tmp"
        test_external "$@" 4> "$stderr"
        [ -f "$stderr" ] || error "Internal error: $stderr disappeared."
@@@ -801,14 -801,12 +801,14 @@@ test_done () 
                mkdir -p "$test_results_dir"
                test_results_path="$test_results_dir/${0%.sh}-$$.counts"
  
 -              echo "total $test_count" >> $test_results_path
 -              echo "success $test_success" >> $test_results_path
 -              echo "fixed $test_fixed" >> $test_results_path
 -              echo "broken $test_broken" >> $test_results_path
 -              echo "failed $test_failure" >> $test_results_path
 -              echo "" >> $test_results_path
 +              cat >>"$test_results_path" <<-EOF
 +              total $test_count
 +              success $test_success
 +              fixed $test_fixed
 +              broken $test_broken
 +              failed $test_failure
 +
 +              EOF
        fi
  
        if test "$test_fixed" != 0
        test_set_prereq C_LOCALE_OUTPUT
  fi
  
+ # Use this instead of test_cmp to compare files that contain expected and
+ # actual output from git commands that can be translated.  When running
+ # under GETTEXT_POISON this pretends that the command produced expected
+ # results.
+ test_i18ncmp () {
+       test -n "$GETTEXT_POISON" || test_cmp "$@"
+ }
+ # Use this instead of "grep expected-string actual" to see if the
+ # output from a git command that can be translated either contains an
+ # expected string, or does not contain an unwanted one.  When running
+ # under GETTEXT_POISON this pretends that the command produced expected
+ # results.
+ test_i18ngrep () {
+       if test -n "$GETTEXT_POISON"
+       then
+           : # pretend success
+       elif test "x!" = "x$1"
+       then
+               shift
+               ! grep "$@"
+       else
+               grep "$@"
+       fi
+ }
  # test whether the filesystem supports symbolic links
  ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
  rm -f y