Code

Merge branch 'mg/doc-revisions-txt'
authorJunio C Hamano <gitster@pobox.com>
Wed, 6 Apr 2011 17:37:56 +0000 (10:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Apr 2011 17:37:56 +0000 (10:37 -0700)
* mg/doc-revisions-txt:
  revisions.txt: language improvements
  revisions.txt: structure with a labelled list
  revisions.txt: consistent use of quotes

101 files changed:
.gitignore
Documentation/RelNotes/1.7.4.3.txt [new file with mode: 0644]
Documentation/RelNotes/1.7.4.4.txt [new file with mode: 0644]
Documentation/RelNotes/1.7.5.txt
Documentation/config.txt
Documentation/fetch-options.txt
Documentation/git-clone.txt
Documentation/git-fetch.txt
Documentation/git-filter-branch.txt
Documentation/git-grep.txt
Documentation/git-init.txt
Documentation/git-merge.txt
Documentation/git-pack-objects.txt
Documentation/git-pull.txt
Documentation/git-submodule.txt
Documentation/git.txt
Documentation/gitmodules.txt
Documentation/merge-config.txt
Documentation/rev-list-options.txt
Makefile
builtin/add.c
builtin/archive.c
builtin/branch.c
builtin/bundle.c
builtin/checkout.c
builtin/clean.c
builtin/clone.c
builtin/commit.c
builtin/describe.c
builtin/diff.c
builtin/fetch.c
builtin/gc.c
builtin/grep.c
builtin/index-pack.c
builtin/init-db.c
builtin/log.c
builtin/merge.c
builtin/mv.c
builtin/notes.c
builtin/push.c
builtin/receive-pack.c
builtin/reset.c
builtin/revert.c
builtin/rm.c
builtin/shortlog.c
builtin/tag.c
cache.h
contrib/emacs/git.el
csum-file.c
git-compat-util.h
git-pull.sh
git-submodule.sh
gitweb/static/gitweb.js
http-fetch.c
merge-recursive.c
pack-check.c
pkt-line.c
rerere.c
submodule.c
submodule.h
t/lib-httpd.sh
t/t0001-init.sh
t/t1200-tutorial.sh
t/t2019-checkout-ambiguous-ref.sh
t/t2200-add-update.sh
t/t2204-add-ignored.sh
t/t3030-merge-recursive.sh
t/t3200-branch.sh
t/t3203-branch-output.sh
t/t3501-revert-cherry-pick.sh
t/t3507-cherry-pick-conflict.sh
t/t3700-add.sh
t/t4001-diff-rename.sh
t/t4014-format-patch.sh
t/t5520-pull.sh
t/t5526-fetch-submodules.sh
t/t5541-http-push.sh
t/t5601-clone.sh
t/t6040-tracking-info.sh
t/t6120-describe.sh
t/t7004-tag.sh
t/t7012-skip-worktree-writing.sh
t/t7060-wtstatus.sh
t/t7102-reset.sh
t/t7110-reset-merge.sh
t/t7201-co.sh
t/t7300-clean.sh
t/t7403-submodule-sync.sh
t/t7405-submodule-merge.sh
t/t7406-submodule-update.sh
t/t7500-commit.sh
t/t7501-commit.sh
t/t7502-commit.sh
t/t7506-status-submodule.sh
t/t7508-status.sh
t/t7600-merge.sh
t/t7607-merge-overwrite.sh
t/t7611-merge-abort.sh
t/t7810-grep.sh
t/t7811-grep-open.sh
wt-status.c

index c460c66766ab590239e4ae9107bb55b9fd30fac6..2cf3ca5808b51be3921a0f25b5871f806ce447e1 100644 (file)
@@ -43,7 +43,6 @@
 /git-fast-export
 /git-fast-import
 /git-fetch
-/git-fetch--tool
 /git-fetch-pack
 /git-filter-branch
 /git-fmt-merge-msg
 /git-reflog
 /git-relink
 /git-remote
-/git-remote-curl
 /git-remote-http
 /git-remote-https
 /git-remote-ftp
diff --git a/Documentation/RelNotes/1.7.4.3.txt b/Documentation/RelNotes/1.7.4.3.txt
new file mode 100644 (file)
index 0000000..02a3d5b
--- /dev/null
@@ -0,0 +1,32 @@
+Git v1.7.4.3 Release Notes
+==========================
+
+Fixes since v1.7.4.2
+--------------------
+
+ * "git apply" used to confuse lines updated by previous hunks as lines
+   that existed before when applying a hunk, contributing misapplication
+   of patches with offsets.
+
+ * "git branch --track" (and "git checkout --track --branch") used to
+   allow setting up a random non-branch that does not make sense to follow
+   as the "upstream".  The command correctly diagnoses it as an error.
+
+ * "git checkout $other_branch" silently removed untracked symbolic links
+   in the working tree that are in the way in order to check out paths
+   under it from the named branch.
+
+ * "git cvsimport" did not bail out immediately when the cvs server cannot
+   be reached, spewing unnecessary error messages that complain about the
+   server response that it never got.
+
+ * "git diff --quiet" did not work very well with the "--diff-filter"
+   option.
+
+ * "git grep -n" lacked a long-hand synonym --line-number.
+
+ * "git stash apply" reported the result of its operation by running
+   "git status" from the top-level of the working tree; it should (and
+   now does) run it from the user's working directory.
+
+And other minor fixes and documentation updates.
diff --git a/Documentation/RelNotes/1.7.4.4.txt b/Documentation/RelNotes/1.7.4.4.txt
new file mode 100644 (file)
index 0000000..e914904
--- /dev/null
@@ -0,0 +1,37 @@
+Git v1.7.4.4 Release Notes
+==========================
+
+Fixes since v1.7.4.3
+--------------------
+
+ * Compilation of sha1_file.c on BSD platforms were broken due to our
+   recent use of getrlimit() without including <sys/resource.h>.
+
+ * "git config" did not diagnose incorrect configuration variable names.
+
+ * "git format-patch" did not wrap a long subject line that resulted from
+   rfc2047 encoding.
+
+ * "git instaweb" should work better again with plackup.
+
+ * "git log --max-count=4 -Sfoobar" now shows 4 commits that changes the
+   number of occurrences of string "foobar"; it used to scan only for 4
+   commits and then emitted only matching ones.
+
+ * "git log --first-parent --boundary $c^..$c" segfaulted on a merge.
+
+ * "git pull" into an empty branch should have behaved as if
+   fast-forwarding from emptiness to the version being pulled, with
+   the usual protection against overwriting untracked files.
+
+ * "git status" spent all the effort to notice racily-clean index entries
+   but didn't update the index file to help later operations go faster in
+   some cases.
+
+And other minor fixes and documentation updates.
+
+---
+exec >/var/tmp/1
+O=v1.7.4.3-22-g8c8674f
+echo O=$(git describe maint)
+git shortlog --no-merges $O..maint
index 648dbfd908d02d0c3a3c9a66330be02c0f4f7b32..9c72084ff928e76b7cd8ef8823bbff6e80ab8a18 100644 (file)
@@ -14,8 +14,9 @@ Updates since v1.7.4
 
  * Update to more modern HP-UX port.
 
- * The codebase is getting prepared for i18n/l10n; no translated/translatable
-   strings in the code yet.
+ * The codebase is getting prepared for i18n/l10n; no translated
+   strings nor translation mechanism in the code yet, but the strings
+   are being marked for l10n.
 
  * The bash completion script can now complete symmetric difference
    for "git diff" command, e.g. "git diff ...bra<TAB>".
@@ -27,10 +28,6 @@ Updates since v1.7.4
  * "git apply -v" reports offset lines when the patch does not apply at
    the exact location recorded in the diff output.
 
- * "git branch --track" (and "git checkout --track --branch") used to
-   allow setting up a random non-branch that does not make sense to follow
-   as the "upstream".  The command correctly diagnoses it as an error.
-
  * "git config" used to be also known as "git repo-config", but the old
    name is now officially deprecated.
 
@@ -63,6 +60,12 @@ Updates since v1.7.4
  * "git grep --no-index" did not honor pathspecs correctly, returning
    paths outside the specified area.
 
+ * "git init" learned the --separate-git-dir option to allow the git
+   directory for a new repository created elsewhere and linked via the
+   gitdir mechanism. This is primarily to help submodule support later
+   to switch between a branch of superproject that has the submodule
+   and another that does not.
+
  * "git log" type commands now understand globbing pathspecs.  You
    can say "git log -- '*.txt'" for example.
 
@@ -71,6 +74,10 @@ Updates since v1.7.4
    or highlighting equivalent changes that appear on both sides of a
    symmetric difference (e.g. "log --cherry A...B").
 
+ * A lazy "git merge" that didn't say what to merge used to be an error.
+   When run on a branch that has an upstream defined, however, the command
+   now merges from the configured upstream.
+
  * "git mergetool" learned how to drive "beyond compare 3" as well.
 
  * "git rerere forget" without pathspec used to forget all the saved
@@ -104,17 +111,6 @@ Fixes since v1.7.4
 All of the fixes in the v1.7.4.X maintenance series are included in this
 release, unless otherwise noted.
 
- * "git apply" used to confuse lines updated by previous hunks as lines
-   that existed before when applying a hunk, contributing misapplication
-   of patches with offsets.
-
- * "git checkout $other_branch" silently removed untracked symbolic links
-   in the working tree that are in the way in order to check out paths
-   under it from the named branch (js/checkout-untracked-symlink).
-
- * "git diff --quiet" did not work very well with the "--diff-filter"
-   option (jc/maint-diff-q-filter).
-
  * "git fetch" from a client that is mostly following the remote
    needlessly told all of its refs to the server for both sides to
    compute the set of objects that need to be transferred efficiently,
@@ -128,13 +124,13 @@ release, unless otherwise noted.
    reachable from the refs in their common alternate object store,
    causing it to fetch unnecessary objects (jc/maint-fetch-alt).
 
- * "git stash apply" reported the result of its operation by running
-   "git status" from the top-level of the working tree; it should (and
-   now does) run it from the user's working directory
-   (pk/stash-apply-status-relative).
+ * "git pull" into an empty branch should have behaved as if
+   fast-forwarding from emptiness to the version being pulled, with
+   the usual protection against overwriting untracked files (need to
+   cherry-pick 4b3ffe5).
 
 ---
 exec >/var/tmp/1
-O=v1.7.5-rc0
+O=v1.7.5-rc0-99-g8f84c95
 echo O=$(git describe 'master')
 git shortlog --no-merges ^maint ^$O master
index 52ffbf4efb8d17c22893112208c5864d4c19741d..750c86d4f51b256faac1b1b5eb26275384d87886 100644 (file)
@@ -320,7 +320,7 @@ core.worktree::
        Set the path to the root of the working tree.
        This can be overridden by the GIT_WORK_TREE environment
        variable and the '--work-tree' command line option.
-       The value can an absolute path or relative to the path to
+       The value can be an absolute path or relative to the path to
        the .git directory, which is either specified by --git-dir
        or GIT_DIR, or automatically discovered.
        If --git-dir or GIT_DIR is specified but none of
@@ -897,9 +897,13 @@ diff.wordRegex::
        characters are *ignorable* whitespace.
 
 fetch.recurseSubmodules::
-       A boolean value which changes the behavior for fetch and pull, the
-       default is to not recursively fetch populated submodules unless
-       configured otherwise.
+       This option can be either set to a boolean value or to 'on-demand'.
+       Setting it to a boolean changes the behavior of fetch and pull to
+       unconditionally recurse into submodules when set to true or to not
+       recurse at all when set to false. When set to 'on-demand' (the default
+       value), fetch and pull will only recurse into a populated submodule
+       when its superproject retrieves a commit that updates the submodule's
+       reference.
 
 fetch.unpackLimit::
        If the number of objects fetched over the git native
@@ -1098,6 +1102,12 @@ All gitcvs variables except for 'gitcvs.usecrlfattr' and
 is one of "ext" and "pserver") to make them apply only for the given
 access method.
 
+grep.lineNumber::
+       If set to true, enable '-n' option by default.
+
+grep.extendedRegexp::
+       If set to true, enable '--extended-regexp' option by default.
+
 gui.commitmsgwidth::
        Defines how wide the commit message window is in the
        linkgit:git-gui[1]. "75" is the default.
@@ -1817,7 +1827,7 @@ submodule.<name>.update::
        linkgit:git-submodule[1] and linkgit:gitmodules[5] for details.
 
 submodule.<name>.fetchRecurseSubmodules::
-       This option can be used to enable/disable recursive fetching of this
+       This option can be used to control recursive fetching of this
        submodule. It can be overridden by using the --[no-]recurse-submodules
        command line option to "git fetch" and "git pull".
        This setting will override that from in the linkgit:gitmodules[5]
index f37276e5add75583fd363af2cd0b7ba051771a97..39d326abc63af01d7cffe3d6f0c3df9279bc667e 100644 (file)
@@ -65,14 +65,33 @@ ifndef::git-pull[]
        specified with the remote.<name>.tagopt setting. See
        linkgit:git-config[1].
 
---[no-]recurse-submodules::
-       This option controls if new commits of all populated submodules should
-       be fetched too (see linkgit:git-config[1] and linkgit:gitmodules[5]).
+--recurse-submodules[=yes|on-demand|no]::
+       This option controls if and under what conditions new commits of
+       populated submodules should be fetched too. It can be used as a
+       boolean option to completely disable recursion when set to 'no' or to
+       unconditionally recurse into all populated submodules when set to
+       'yes', which is the default when this option is used without any
+       value. Use 'on-demand' to only recurse into a populated submodule
+       when the superproject retrieves a commit that updates the submodule's
+       reference to a commit that isn't already in the local submodule
+       clone.
+
+--no-recurse-submodules::
+       Disable recursive fetching of submodules (this has the same effect as
+       using the '--recurse-submodules=no' option).
 
 --submodule-prefix=<path>::
        Prepend <path> to paths printed in informative messages
        such as "Fetching submodule foo".  This option is used
        internally when recursing over submodules.
+
+--recurse-submodules-default=[yes|on-demand]::
+       This option is used internally to temporarily provide a
+       non-negative default value for the --recurse-submodules
+       option.  All other methods of configuring fetch's submodule
+       recursion (such as settings in linkgit:gitmodules[5] and
+       linkgit:git-config[1]) override this option, as does
+       specifying --[no-]recurse-submodules directly.
 endif::git-pull[]
 
 -u::
index 8577480074d84fe213cc6fd16486a1fa92c3e08a..86eb4c93682aa3d92fe001ae871913fc0dec8607 100644 (file)
@@ -12,6 +12,7 @@ SYNOPSIS
 'git clone' [--template=<template_directory>]
          [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
          [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]
+         [--separate-git-dir|-L <git dir>]
          [--depth <depth>] [--recursive|--recurse-submodules] [--] <repository>
          [<directory>]
 
@@ -176,6 +177,15 @@ objects from the source repository into a pack in the cloned repository.
        repository does not have a worktree/checkout (i.e. if any of
        `--no-checkout`/`-n`, `--bare`, or `--mirror` is given)
 
+-L=<git dir>::
+--separate-git-dir=<git dir>::
+       Instead of placing the cloned repository where it is supposed
+       to be, place the cloned repository at the specified directory,
+       then make a filesytem-agnostic git symbolic link to there.
+       The result is git repository can be separated from working
+       tree.
+
+
 <repository>::
        The (possibly remote) repository to clone from.  See the
        <<URLS,URLS>> section below for more information on specifying
index 7146f6ba0b3d531f788693cf78590565a0645144..67d221467d6dba14286f96e9ce1442cbfc1ee995 100644 (file)
@@ -76,6 +76,15 @@ The `pu` branch will be updated even if it is does not fast-forward,
 because it is prefixed with a plus sign; `tmp` will not be.
 
 
+BUGS
+----
+Using --recurse-submodules can only fetch new commits in already checked
+out submodules right now. When e.g. upstream added a new submodule in the
+just fetched commits of the superproject the submodule itself can not be
+fetched, making it impossible to check out that submodule later without
+having to do a fetch again. This is expected to be fixed in a future git
+version.
+
 SEE ALSO
 --------
 linkgit:git-pull[1]
index 03c76c717ac6c41edfaaed47fa9798344e5e8f94..9dc1f2a94708d40daf428a427dd2ea4256cc172a 100644 (file)
@@ -361,7 +361,7 @@ git filter-branch --index-filter \
        'git ls-files -s | sed "s-\t\"*-&newsubdir/-" |
                GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
                        git update-index --index-info &&
-        mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD
+        mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD
 ---------------------------------------------------------------
 
 
index 132505eb4f83fdc64778df8cf58b595ca6eadf1f..d7523b3e45ff06bd7a8abf4ff466fe619c8268e7 100644 (file)
@@ -31,6 +31,16 @@ Look for specified patterns in the tracked files in the work tree, blobs
 registered in the index file, or blobs in given tree objects.
 
 
+CONFIGURATION
+-------------
+
+grep.lineNumber::
+       If set to true, enable '-n' option by default.
+
+grep.extendedRegexp::
+       If set to true, enable '--extended-regexp' option by default.
+
+
 OPTIONS
 -------
 --cached::
index 593192555e3b407536c81e4cd7b1bcc0dbe8f519..58cd01145ab8605d30a9c670ee70391b9d974a32 100644 (file)
@@ -8,9 +8,32 @@ git-init - Create an empty git repository or reinitialize an existing one
 
 SYNOPSIS
 --------
-'git init' [-q | --quiet] [--bare] [--template=<template_directory>] [--shared[=<permissions>]] [directory]
+'git init' [-q | --quiet] [--bare] [--template=<template_directory>]
+         [--separate-git-dir|-L <git dir>]
+         [--shared[=<permissions>]] [directory]
 
 
+DESCRIPTION
+-----------
+
+This command creates an empty git repository - basically a `.git`
+directory with subdirectories for `objects`, `refs/heads`,
+`refs/tags`, and template files.  An initial `HEAD` file that
+references the HEAD of the master branch is also created.
+
+If the `$GIT_DIR` environment variable is set then it specifies a path
+to use instead of `./.git` for the base of the repository.
+
+If the object storage directory is specified via the
+`$GIT_OBJECT_DIRECTORY` environment variable then the sha1 directories
+are created underneath - otherwise the default `$GIT_DIR/objects`
+directory is used.
+
+Running 'git init' in an existing repository is safe. It will not
+overwrite things that are already there. The primary reason for
+rerunning 'git init' is to pick up newly added templates (or to move
+the repository to another place if --separate-git-dir is given).
+
 OPTIONS
 -------
 
@@ -31,6 +54,16 @@ current working directory.
 Specify the directory from which templates will be used.  (See the "TEMPLATE
 DIRECTORY" section below.)
 
+-L=<git dir>::
+--separate-git-dir=<git dir>::
+
+Instead of initializing the repository where it is supposed to be,
+place a filesytem-agnostic git symbolic link there, pointing to the
+specified git path, and initialize a git repository at the path. The
+result is git repository can be separated from working tree. If this
+is reinitialization, the repository will be moved to the specified
+path.
+
 --shared[=(false|true|umask|group|all|world|everybody|0xxx)]::
 
 Specify that the git repository is to be shared amongst several users.  This
@@ -74,32 +107,6 @@ line, the command is run inside the directory (possibly after creating it).
 --
 
 
-DESCRIPTION
------------
-This command creates an empty git repository - basically a `.git` directory
-with subdirectories for `objects`, `refs/heads`, `refs/tags`, and
-template files.
-An initial `HEAD` file that references the HEAD of the master branch
-is also created.
-
-If the `$GIT_DIR` environment variable is set then it specifies a path
-to use instead of `./.git` for the base of the repository.
-
-If the object storage directory is specified via the `$GIT_OBJECT_DIRECTORY`
-environment variable then the sha1 directories are created underneath -
-otherwise the default `$GIT_DIR/objects` directory is used.
-
-Running 'git init' in an existing repository is safe. It will not overwrite
-things that are already there. The primary reason for rerunning 'git init'
-is to pick up newly added templates.
-
-Note that 'git init' is the same as 'git init-db'.  The command
-was primarily meant to initialize the object database, but over
-time it has become responsible for setting up the other aspects
-of the repository, such as installing the default hooks and
-setting the configuration variables.  The old name is retained
-for backward compatibility reasons.
-
 TEMPLATE DIRECTORY
 ------------------
 
index fb4c05b83f2c5b27598938416ea092da77e5c81d..e2e6aba17e7bde2bacb7f29ec4c54e5f9587dac6 100644 (file)
@@ -11,7 +11,7 @@ SYNOPSIS
 [verse]
 'git merge' [-n] [--stat] [--no-commit] [--squash]
        [-s <strategy>] [-X <strategy-option>]
-       [--[no-]rerere-autoupdate] [-m <msg>] <commit>...
+       [--[no-]rerere-autoupdate] [-m <msg>] [<commit>...]
 'git merge' <msg> HEAD <commit>...
 'git merge' --abort
 
@@ -95,8 +95,13 @@ commit or stash your changes before running 'git merge'.
 
 <commit>...::
        Commits, usually other branch heads, to merge into our branch.
-       You need at least one <commit>.  Specifying more than one
-       <commit> obviously means you are trying an Octopus.
+       Specifying more than one commit will create a merge with
+       more than two parents (affectionately called an Octopus merge).
++
+If no commit is given from the command line, and if `merge.defaultToUpstream`
+configuration variable is set, merge the remote tracking branches
+that the current branch is configured to use as its upstream.
+See also the configuration section of this manual page.
 
 
 PRE-MERGE CHECKS
index 442018bcb8f14dbb7572ad87a3c1adb588444278..08c89d221cef9215806e4ef4dfda97898fe44942 100644 (file)
@@ -192,13 +192,18 @@ self-contained. Use `git index-pack --fix-thin`
 --delta-base-offset::
        A packed archive can express the base object of a delta as
        either a 20-byte object name or as an offset in the
-       stream, but older versions of git don't understand the
+       stream, but ancient versions of git don't understand the
        latter.  By default, 'git pack-objects' only uses the
        former format for better compatibility.  This option
        allows the command to use the latter format for
        compactness.  Depending on the average delta chain
        length, this option typically shrinks the resulting
        packfile by 3-5 per-cent.
++
+Note: Porcelain commands such as `git gc` (see linkgit:git-gc[1]),
+`git repack` (see linkgit:git-repack[1]) pass this option by default
+in modern git when they put objects in your repository into pack files.
+So does `git bundle` (see linkgit:git-bundle[1]) when it creates a bundle.
 
 --threads=<n>::
        Specifies the number of threads to spawn when searching for best
index c2a7f103ee5bf4495d39b3034752be564b119766..14609cbd4dc2f7f3c16f7b660e4aff76eca6065b 100644 (file)
@@ -84,7 +84,7 @@ must be given before the options meant for 'git fetch'.
 --verbose::
        Pass --verbose to git-fetch and git-merge.
 
---[no-]recurse-submodules::
+--[no-]recurse-submodules[=yes|on-demand|no]::
        This option controls if new commits of all populated submodules should
        be fetched too (see linkgit:git-config[1] and linkgit:gitmodules[5]).
        That might be necessary to get the data needed for merging submodule
@@ -220,6 +220,15 @@ If you tried a pull which resulted in a complex conflicts and
 would want to start over, you can recover with 'git reset'.
 
 
+BUGS
+----
+Using --recurse-submodules can only fetch new commits in already checked
+out submodules right now. When e.g. upstream added a new submodule in the
+just fetched commits of the superproject the submodule itself can not be
+fetched, making it impossible to check out that submodule later without
+having to do a fetch again. This is expected to be fixed in a future git
+version.
+
 SEE ALSO
 --------
 linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-config[1]
index 3a5aa01435e5fa1b19cd666e6cb357c85fd4df90..1a16ff60448a72bebcba2daff7dbabc5feed8a4c 100644 (file)
@@ -101,9 +101,10 @@ status::
        currently checked out commit for each submodule, along with the
        submodule path and the output of 'git describe' for the
        SHA-1. Each SHA-1 will be prefixed with `-` if the submodule is not
-       initialized and `+` if the currently checked out submodule commit
+       initialized, `+` if the currently checked out submodule commit
        does not match the SHA-1 found in the index of the containing
-       repository. This command is the default command for 'git submodule'.
+       repository and `U` if the submodule has merge conflicts.
+       This command is the default command for 'git submodule'.
 +
 If '--recursive' is specified, this command will recurse into nested
 submodules, and show their status as well.
index 5e57f6995a1039112c704565b380cedf9ff5b721..78499db81bd130fcf64a5a5e7adf85e1b522d230 100644 (file)
@@ -44,9 +44,11 @@ unreleased) version of git, that is available from 'master'
 branch of the `git.git` repository.
 Documentation for older releases are available here:
 
-* link:v1.7.4.1/git.html[documentation for release 1.7.4.1]
+* link:v1.7.4.3/git.html[documentation for release 1.7.4.3]
 
 * release notes for
+  link:RelNotes/1.7.4.3.txt[1.7.4.3],
+  link:RelNotes/1.7.4.2.txt[1.7.4.2],
   link:RelNotes/1.7.4.1.txt[1.7.4.1],
   link:RelNotes/1.7.4.txt[1.7.4].
 
index 15a218655970de61781e1b2793576a05b0fac7b2..4040941e55e88114b70d3d0ae7ecb644794fc8b3 100644 (file)
@@ -45,12 +45,12 @@ submodule.<name>.update::
        the '--merge' or '--rebase' options.
 
 submodule.<name>.fetchRecurseSubmodules::
-       This option can be used to enable/disable recursive fetching of this
+       This option can be used to control recursive fetching of this
        submodule. If this option is also present in the submodules entry in
        .git/config of the superproject, the setting there will override the
        one found in .gitmodules.
        Both settings can be overridden on the command line by using the
-       "--[no-]recurse-submodules" option to "git fetch" and "git pull"..
+       "--[no-]recurse-submodules" option to "git fetch" and "git pull".
 
 submodule.<name>.ignore::
        Defines under what circumstances "git status" and the diff family show
index 33bf74c334ead9ee5e44d81d15d544b0625f2894..8920258baa515b048555be3448edea0403ce05be 100644 (file)
@@ -6,6 +6,16 @@ merge.conflictstyle::
        a `>>>>>>>` marker.  An alternate style, "diff3", adds a `|||||||`
        marker and the original text before the `=======` marker.
 
+merge.defaultToUpstream::
+       If merge is called without any commit argument, merge the upstream
+       branches configured for the current branch by using their last
+       observed values stored in their remote tracking branches.
+       The values of the `branch.<current branch>.merge` that name the
+       branches at the remote named by `branch.<current branch>.remote`
+       are consulted, and then they are mapped via `remote.<remote>.fetch`
+       to their corresponding remote tracking branches, and the tips of
+       these tracking branches are merged.
+
 merge.log::
        In addition to branch names, populate the log message with at
        most the specified number of one-line descriptions from the
index ea5c6c49bd1b673aba48c057add1b5d15ae840a0..73111bb0512476cb1d1786d65c416b7f4efd94cf 100644 (file)
@@ -179,8 +179,8 @@ endif::git-rev-list[]
 +
 For example, if you have two branches, `A` and `B`, a usual way
 to list all commits on only one side of them is with
-`--left-right`, like the example above in the description of
-that option.  It however shows the commits that were cherry-picked
+`--left-right` (see the example below in the description of
+the `--left-right` option).  It however shows the commits that were cherry-picked
 from the other branch (for example, "3rd on b" may be cherry-picked
 from branch A).  With this option, such pairs of commits are
 excluded from the output.
index b0f155ab305d1795ada45060460c52594e7a366a..92c1c5e23b96f8bed1b1ac2dbff6c05580ecf678 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2162,7 +2162,7 @@ check-sha1:: test-sha1$X
 check: common-cmds.h
        if sparse; \
        then \
-               for i in *.c; \
+               for i in $(patsubst %.o, %.c, $(GIT_OBJS)); \
                do \
                        sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
                done; \
index e127d5a68b5c28497a3e640760e4c597fbaa59d5..d39a6ab930adf2e3cd716d3e9925350befed8947 100644 (file)
@@ -37,7 +37,7 @@ static void update_callback(struct diff_queue_struct *q,
                const char *path = p->one->path;
                switch (p->status) {
                default:
-                       die("unexpected diff status %c", p->status);
+                       die(_("unexpected diff status %c"), p->status);
                case DIFF_STATUS_UNMERGED:
                        /*
                         * ADD_CACHE_IGNORE_REMOVAL is unset if "git
@@ -63,7 +63,7 @@ static void update_callback(struct diff_queue_struct *q,
                case DIFF_STATUS_TYPE_CHANGED:
                        if (add_file_to_index(&the_index, path, data->flags)) {
                                if (!(data->flags & ADD_CACHE_IGNORE_ERRORS))
-                                       die("updating files failed");
+                                       die(_("updating files failed"));
                                data->add_errors++;
                        }
                        break;
@@ -73,7 +73,7 @@ static void update_callback(struct diff_queue_struct *q,
                        if (!(data->flags & ADD_CACHE_PRETEND))
                                remove_file_from_index(&the_index, path);
                        if (data->flags & (ADD_CACHE_PRETEND|ADD_CACHE_VERBOSE))
-                               printf("remove '%s'\n", path);
+                               printf(_("remove '%s'\n"), path);
                        break;
                }
        }
@@ -171,7 +171,7 @@ static void treat_gitlinks(const char **pathspec)
                                        /* strip trailing slash */
                                        pathspec[j] = xstrndup(ce->name, len);
                                else
-                                       die ("Path '%s' is in submodule '%.*s'",
+                                       die (_("Path '%s' is in submodule '%.*s'"),
                                                pathspec[j], len, ce->name);
                        }
                }
@@ -187,10 +187,10 @@ static void refresh(int verbose, const char **pathspec)
                /* nothing */;
        seen = xcalloc(specs, 1);
        refresh_index(&the_index, verbose ? REFRESH_IN_PORCELAIN : REFRESH_QUIET,
-                     pathspec, seen, "Unstaged changes after refreshing the index:");
+                     pathspec, seen, _("Unstaged changes after refreshing the index:"));
        for (i = 0; i < specs; i++) {
                if (!seen[i])
-                       die("pathspec '%s' did not match any files", pathspec[i]);
+                       die(_("pathspec '%s' did not match any files"), pathspec[i]);
        }
         free(seen);
 }
@@ -204,7 +204,7 @@ static const char **validate_pathspec(int argc, const char **argv, const char *p
                for (p = pathspec; *p; p++) {
                        if (has_symlink_leading_path(*p, strlen(*p))) {
                                int len = prefix ? strlen(prefix) : 0;
-                               die("'%s' is beyond a symbolic link", *p + len);
+                               die(_("'%s' is beyond a symbolic link"), *p + len);
                        }
                }
        }
@@ -271,7 +271,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
        git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
 
        if (read_cache() < 0)
-               die ("Could not read the index");
+               die (_("Could not read the index"));
 
        init_revisions(&rev, prefix);
        rev.diffopt.context = 7;
@@ -280,24 +280,24 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
        rev.diffopt.output_format = DIFF_FORMAT_PATCH;
        out = open(file, O_CREAT | O_WRONLY, 0644);
        if (out < 0)
-               die ("Could not open '%s' for writing.", file);
+               die (_("Could not open '%s' for writing."), file);
        rev.diffopt.file = xfdopen(out, "w");
        rev.diffopt.close_file = 1;
        if (run_diff_files(&rev, 0))
-               die ("Could not write patch");
+               die (_("Could not write patch"));
 
        launch_editor(file, NULL, NULL);
 
        if (stat(file, &st))
-               die_errno("Could not stat '%s'", file);
+               die_errno(_("Could not stat '%s'"), file);
        if (!st.st_size)
-               die("Empty patch. Aborted.");
+               die(_("Empty patch. Aborted."));
 
        memset(&child, 0, sizeof(child));
        child.git_cmd = 1;
        child.argv = apply_argv;
        if (run_command(&child))
-               die ("Could not apply '%s'", file);
+               die (_("Could not apply '%s'"), file);
 
        unlink(file);
        return 0;
@@ -306,7 +306,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
 static struct lock_file lock_file;
 
 static const char ignore_error[] =
-"The following paths are ignored by one of your .gitignore files:\n";
+N_("The following paths are ignored by one of your .gitignore files:\n");
 
 static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
 static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;
@@ -343,17 +343,17 @@ static int add_files(struct dir_struct *dir, int flags)
        int i, exit_status = 0;
 
        if (dir->ignored_nr) {
-               fprintf(stderr, ignore_error);
+               fprintf(stderr, _(ignore_error));
                for (i = 0; i < dir->ignored_nr; i++)
                        fprintf(stderr, "%s\n", dir->ignored[i]->name);
-               fprintf(stderr, "Use -f if you really want to add them.\n");
-               die("no files added");
+               fprintf(stderr, _("Use -f if you really want to add them.\n"));
+               die(_("no files added"));
        }
 
        for (i = 0; i < dir->nr; i++)
                if (add_file_to_cache(dir->entries[i]->name, flags)) {
                        if (!ignore_add_errors)
-                               die("adding files failed");
+                               die(_("adding files failed"));
                        exit_status = 1;
                }
        return exit_status;
@@ -385,9 +385,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
        argv++;
 
        if (addremove && take_worktree_changes)
-               die("-A and -u are mutually incompatible");
+               die(_("-A and -u are mutually incompatible"));
        if (!show_only && ignore_missing)
-               die("Option --ignore-missing can only be used together with --dry-run");
+               die(_("Option --ignore-missing can only be used together with --dry-run"));
        if ((addremove || take_worktree_changes) && !argc) {
                static const char *here[2] = { ".", NULL };
                argc = 1;
@@ -407,14 +407,14 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                  ? ADD_CACHE_IGNORE_REMOVAL : 0));
 
        if (require_pathspec && argc == 0) {
-               fprintf(stderr, "Nothing specified, nothing added.\n");
-               fprintf(stderr, "Maybe you wanted to say 'git add .'?\n");
+               fprintf(stderr, _("Nothing specified, nothing added.\n"));
+               fprintf(stderr, _("Maybe you wanted to say 'git add .'?\n"));
                return 0;
        }
        pathspec = validate_pathspec(argc, argv, prefix);
 
        if (read_cache() < 0)
-               die("index file corrupt");
+               die(_("index file corrupt"));
        treat_gitlinks(pathspec);
 
        if (add_new_files) {
@@ -450,7 +450,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                                        if (excluded(&dir, pathspec[i], &dtype))
                                                dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i]));
                                } else
-                                       die("pathspec '%s' did not match any files",
+                                       die(_("pathspec '%s' did not match any files"),
                                            pathspec[i]);
                        }
                }
@@ -466,7 +466,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
        if (active_cache_changed) {
                if (write_cache(newfd, active_cache, active_nr) ||
                    commit_locked_index(&lock_file))
-                       die("Unable to write new index file");
+                       die(_("Unable to write new index file"));
        }
 
        return exit_status;
index 6a887f5a9d785d23f1be76fd86fc17896b2b48d7..b14eaba1594bad060e0c881326368b9b2be3b158 100644 (file)
@@ -14,10 +14,10 @@ static void create_output_file(const char *output_file)
 {
        int output_fd = open(output_file, O_CREAT | O_WRONLY | O_TRUNC, 0666);
        if (output_fd < 0)
-               die_errno("could not create archive file '%s'", output_file);
+               die_errno(_("could not create archive file '%s'"), output_file);
        if (output_fd != 1) {
                if (dup2(output_fd, 1) < 0)
-                       die_errno("could not redirect output");
+                       die_errno(_("could not redirect output"));
                else
                        close(output_fd);
        }
@@ -33,7 +33,7 @@ static int run_remote_archiver(int argc, const char **argv,
 
        _remote = remote_get(remote);
        if (!_remote->url[0])
-               die("git archive: Remote with no URL");
+               die(_("git archive: Remote with no URL"));
        transport = transport_get(_remote, _remote->url[0]);
        transport_connect(transport, "git-upload-archive", exec, fd);
 
@@ -43,18 +43,18 @@ static int run_remote_archiver(int argc, const char **argv,
 
        len = packet_read_line(fd[0], buf, sizeof(buf));
        if (!len)
-               die("git archive: expected ACK/NAK, got EOF");
+               die(_("git archive: expected ACK/NAK, got EOF"));
        if (buf[len-1] == '\n')
                buf[--len] = 0;
        if (strcmp(buf, "ACK")) {
                if (len > 5 && !prefixcmp(buf, "NACK "))
-                       die("git archive: NACK %s", buf + 5);
-               die("git archive: protocol error");
+                       die(_("git archive: NACK %s"), buf + 5);
+               die(_("git archive: protocol error"));
        }
 
        len = packet_read_line(fd[0], buf, sizeof(buf));
        if (len)
-               die("git archive: expected a flush");
+               die(_("git archive: expected a flush"));
 
        /* Now, start reading from fd[0] and spit it out to stdout */
        rv = recv_sideband("archive", fd[0], 1);
index b9ba011f7b3f37a9448afae909d743249c3d8e1f..9cca1b9afc20caf6333d0269386249f41fa8746f 100644 (file)
@@ -133,12 +133,12 @@ static int branch_merged(int kind, const char *name,
        if ((head_rev != reference_rev) &&
            in_merge_bases(rev, &head_rev, 1) != merged) {
                if (merged)
-                       warning("deleting branch '%s' that has been merged to\n"
-                               "         '%s', but not yet been merged to HEAD.",
+                       warning(_("deleting branch '%s' that has been merged to\n"
+                               "         '%s', but not yet merged to HEAD."),
                                name, reference_name);
                else
-                       warning("not deleting branch '%s' that is not yet merged to\n"
-                               "         '%s', even though it is merged to HEAD.",
+                       warning(_("not deleting branch '%s' that is not yet merged to\n"
+                               "         '%s', even though it is merged to HEAD."),
                                name, reference_name);
        }
        return merged;
@@ -157,7 +157,8 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
        switch (kinds) {
        case REF_REMOTE_BRANCH:
                fmt = "refs/remotes/%s";
-               remote = "remote ";
+               /* TRANSLATORS: This is "remote " in "remote branch '%s' not found" */
+               remote = _("remote ");
                force = 1;
                break;
        case REF_LOCAL_BRANCH:
@@ -165,19 +166,19 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
                remote = "";
                break;
        default:
-               die("cannot use -a with -d");
+               die(_("cannot use -a with -d"));
        }
 
        if (!force) {
                head_rev = lookup_commit_reference(head_sha1);
                if (!head_rev)
-                       die("Couldn't look up commit object for HEAD");
+                       die(_("Couldn't look up commit object for HEAD"));
        }
        for (i = 0; i < argc; i++, strbuf_release(&bname)) {
                strbuf_branchname(&bname, argv[i]);
                if (kinds == REF_LOCAL_BRANCH && !strcmp(head, bname.buf)) {
-                       error("Cannot delete the branch '%s' "
-                             "which you are currently on.", bname.buf);
+                       error(_("Cannot delete the branch '%s' "
+                             "which you are currently on."), bname.buf);
                        ret = 1;
                        continue;
                }
@@ -186,7 +187,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 
                name = xstrdup(mkpath(fmt, bname.buf));
                if (!resolve_ref(name, sha1, 1, NULL)) {
-                       error("%sbranch '%s' not found.",
+                       error(_("%sbranch '%s' not found."),
                                        remote, bname.buf);
                        ret = 1;
                        continue;
@@ -194,31 +195,31 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 
                rev = lookup_commit_reference(sha1);
                if (!rev) {
-                       error("Couldn't look up commit object for '%s'", name);
+                       error(_("Couldn't look up commit object for '%s'"), name);
                        ret = 1;
                        continue;
                }
 
                if (!force && !branch_merged(kinds, bname.buf, rev, head_rev)) {
-                       error("The branch '%s' is not fully merged.\n"
+                       error(_("The branch '%s' is not fully merged.\n"
                              "If you are sure you want to delete it, "
-                             "run 'git branch -D %s'.", bname.buf, bname.buf);
+                             "run 'git branch -D %s'."), bname.buf, bname.buf);
                        ret = 1;
                        continue;
                }
 
                if (delete_ref(name, sha1, 0)) {
-                       error("Error deleting %sbranch '%s'", remote,
+                       error(_("Error deleting %sbranch '%s'"), remote,
                              bname.buf);
                        ret = 1;
                } else {
                        struct strbuf buf = STRBUF_INIT;
-                       printf("Deleted %sbranch %s (was %s).\n", remote,
+                       printf(_("Deleted %sbranch %s (was %s).\n"), remote,
                               bname.buf,
                               find_unique_abbrev(sha1, DEFAULT_ABBREV));
                        strbuf_addf(&buf, "branch.%s", bname.buf);
                        if (git_config_rename_section(buf.buf, NULL) < 0)
-                               warning("Update of config-file failed");
+                               warning(_("Update of config-file failed"));
                        strbuf_release(&buf);
                }
        }
@@ -300,7 +301,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
        if (ref_list->verbose || ref_list->with_commit || merge_filter != NO_FILTER) {
                commit = lookup_commit_reference_gently(sha1, 1);
                if (!commit) {
-                       cb->ret = error("branch '%s' does not point at a commit", refname);
+                       cb->ret = error(_("branch '%s' does not point at a commit"), refname);
                        return 0;
                }
 
@@ -372,11 +373,11 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
                strbuf_addf(stat, "%s: ",
                        shorten_unambiguous_ref(branch->merge[0]->dst, 0));
        if (!ours)
-               strbuf_addf(stat, "behind %d] ", theirs);
+               strbuf_addf(stat, _("behind %d] "), theirs);
        else if (!theirs)
-               strbuf_addf(stat, "ahead %d] ", ours);
+               strbuf_addf(stat, _("ahead %d] "), ours);
        else
-               strbuf_addf(stat, "ahead %d, behind %d] ", ours, theirs);
+               strbuf_addf(stat, _("ahead %d, behind %d] "), ours, theirs);
 }
 
 static int matches_merge_filter(struct commit *commit)
@@ -481,7 +482,7 @@ static void show_detached(struct ref_list *ref_list)
 
        if (head_commit && is_descendant_of(head_commit, ref_list->with_commit)) {
                struct ref_item item;
-               item.name = xstrdup("(no branch)");
+               item.name = xstrdup(_("(no branch)"));
                item.len = strlen(item.name);
                item.kind = REF_LOCAL_BRANCH;
                item.dest = NULL;
@@ -541,7 +542,7 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
        free_ref_list(&ref_list);
 
        if (cb.ret)
-               error("some refs could not be read");
+               error(_("some refs could not be read"));
 
        return cb.ret;
 }
@@ -554,7 +555,7 @@ static void rename_branch(const char *oldname, const char *newname, int force)
        int recovery = 0;
 
        if (!oldname)
-               die("cannot rename the current branch while not on any.");
+               die(_("cannot rename the current branch while not on any."));
 
        if (strbuf_check_branch_ref(&oldref, oldname)) {
                /*
@@ -564,35 +565,35 @@ static void rename_branch(const char *oldname, const char *newname, int force)
                if (resolve_ref(oldref.buf, sha1, 1, NULL))
                        recovery = 1;
                else
-                       die("Invalid branch name: '%s'", oldname);
+                       die(_("Invalid branch name: '%s'"), oldname);
        }
 
        if (strbuf_check_branch_ref(&newref, newname))
-               die("Invalid branch name: '%s'", newname);
+               die(_("Invalid branch name: '%s'"), newname);
 
        if (resolve_ref(newref.buf, sha1, 1, NULL) && !force)
-               die("A branch named '%s' already exists.", newref.buf + 11);
+               die(_("A branch named '%s' already exists."), newref.buf + 11);
 
        strbuf_addf(&logmsg, "Branch: renamed %s to %s",
                 oldref.buf, newref.buf);
 
        if (rename_ref(oldref.buf, newref.buf, logmsg.buf))
-               die("Branch rename failed");
+               die(_("Branch rename failed"));
        strbuf_release(&logmsg);
 
        if (recovery)
-               warning("Renamed a misnamed branch '%s' away", oldref.buf + 11);
+               warning(_("Renamed a misnamed branch '%s' away"), oldref.buf + 11);
 
        /* no need to pass logmsg here as HEAD didn't really move */
        if (!strcmp(oldname, head) && create_symref("HEAD", newref.buf, NULL))
-               die("Branch renamed to %s, but HEAD is not updated!", newname);
+               die(_("Branch renamed to %s, but HEAD is not updated!"), newname);
 
        strbuf_addf(&oldsection, "branch.%s", oldref.buf + 11);
        strbuf_release(&oldref);
        strbuf_addf(&newsection, "branch.%s", newref.buf + 11);
        strbuf_release(&newref);
        if (git_config_rename_section(oldsection.buf, newsection.buf) < 0)
-               die("Branch is renamed, but update of config-file failed");
+               die(_("Branch is renamed, but update of config-file failed"));
        strbuf_release(&oldsection);
        strbuf_release(&newsection);
 }
@@ -607,7 +608,7 @@ static int opt_parse_merge_filter(const struct option *opt, const char *arg, int
        if (!arg)
                arg = "HEAD";
        if (get_sha1(arg, merge_filter_ref))
-               die("malformed object name %s", arg);
+               die(_("malformed object name %s"), arg);
        return 0;
 }
 
@@ -681,13 +682,13 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 
        head = resolve_ref("HEAD", head_sha1, 0, NULL);
        if (!head)
-               die("Failed to resolve HEAD as a valid ref.");
+               die(_("Failed to resolve HEAD as a valid ref."));
        head = xstrdup(head);
        if (!strcmp(head, "HEAD")) {
                detached = 1;
        } else {
                if (prefixcmp(head, "refs/heads/"))
-                       die("HEAD not found below refs/heads!");
+                       die(_("HEAD not found below refs/heads!"));
                head += 11;
        }
        hashcpy(merge_filter_ref, head_sha1);
@@ -707,7 +708,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                rename_branch(argv[0], argv[1], rename > 1);
        else if (argc <= 2) {
                if (kinds != REF_LOCAL_BRANCH)
-                       die("-a and -r options to 'git branch' do not make sense with a branch name");
+                       die(_("-a and -r options to 'git branch' do not make sense with a branch name"));
                create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
                              force_create, reflog, track);
        } else
index 9b87fb9ac2505e746ae34db34740cdfb3cfde127..81046a9cb870aab59a56492e175a51c032ad96ce 100644 (file)
@@ -44,7 +44,7 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
                close(bundle_fd);
                if (verify_bundle(&header, 1))
                        return 1;
-               fprintf(stderr, "%s is okay\n", bundle_file);
+               fprintf(stderr, _("%s is okay\n"), bundle_file);
                return 0;
        }
        if (!strcmp(cmd, "list-heads")) {
@@ -53,11 +53,11 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
        }
        if (!strcmp(cmd, "create")) {
                if (!startup_info->have_repository)
-                       die("Need a repository to create a bundle.");
+                       die(_("Need a repository to create a bundle."));
                return !!create_bundle(&header, bundle_file, argc, argv);
        } else if (!strcmp(cmd, "unbundle")) {
                if (!startup_info->have_repository)
-                       die("Need a repository to unbundle.");
+                       die(_("Need a repository to unbundle."));
                return !!unbundle(&header, bundle_fd) ||
                        list_bundle_refs(&header, argc, argv);
        } else
index 686d0ffd300e3e23cfd31b12d4267b5930787317..eece5d6ac0f48ae76dc76c0f2ebda633cc0ded58 100644 (file)
@@ -104,9 +104,10 @@ static int check_stage(int stage, struct cache_entry *ce, int pos)
                        return 0;
                pos++;
        }
-       return error("path '%s' does not have %s version",
-                    ce->name,
-                    (stage == 2) ? "our" : "their");
+       if (stage == 2)
+               return error(_("path '%s' does not have our version"), ce->name);
+       else
+               return error(_("path '%s' does not have their version"), ce->name);
 }
 
 static int check_all_stages(struct cache_entry *ce, int pos)
@@ -117,7 +118,7 @@ static int check_all_stages(struct cache_entry *ce, int pos)
            ce_stage(active_cache[pos+1]) != 2 ||
            strcmp(active_cache[pos+2]->name, ce->name) ||
            ce_stage(active_cache[pos+2]) != 3)
-               return error("path '%s' does not have all three versions",
+               return error(_("path '%s' does not have all three versions"),
                             ce->name);
        return 0;
 }
@@ -131,9 +132,10 @@ static int checkout_stage(int stage, struct cache_entry *ce, int pos,
                        return checkout_entry(active_cache[pos], state, NULL);
                pos++;
        }
-       return error("path '%s' does not have %s version",
-                    ce->name,
-                    (stage == 2) ? "our" : "their");
+       if (stage == 2)
+               return error(_("path '%s' does not have our version"), ce->name);
+       else
+               return error(_("path '%s' does not have their version"), ce->name);
 }
 
 static int checkout_merged(int pos, struct checkout *state)
@@ -151,7 +153,7 @@ static int checkout_merged(int pos, struct checkout *state)
            ce_stage(active_cache[pos+1]) != 2 ||
            strcmp(active_cache[pos+2]->name, path) ||
            ce_stage(active_cache[pos+2]) != 3)
-               return error("path '%s' does not have all 3 versions", path);
+               return error(_("path '%s' does not have all 3 versions"), path);
 
        read_mmblob(&ancestor, active_cache[pos]->sha1);
        read_mmblob(&ours, active_cache[pos+1]->sha1);
@@ -168,7 +170,7 @@ static int checkout_merged(int pos, struct checkout *state)
        free(theirs.ptr);
        if (status < 0 || !result_buf.ptr) {
                free(result_buf.ptr);
-               return error("path '%s': cannot merge", path);
+               return error(_("path '%s': cannot merge"), path);
        }
 
        /*
@@ -185,12 +187,12 @@ static int checkout_merged(int pos, struct checkout *state)
         */
        if (write_sha1_file(result_buf.ptr, result_buf.size,
                            blob_type, sha1))
-               die("Unable to add merge result for '%s'", path);
+               die(_("Unable to add merge result for '%s'"), path);
        ce = make_cache_entry(create_ce_mode(active_cache[pos+1]->ce_mode),
                              sha1,
                              path, 2, 0);
        if (!ce)
-               die("make_cache_entry failed for path '%s'", path);
+               die(_("make_cache_entry failed for path '%s'"), path);
        status = checkout_entry(ce, state, NULL);
        return status;
 }
@@ -212,7 +214,7 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
 
        newfd = hold_locked_index(lock_file, 1);
        if (read_cache_preload(pathspec) < 0)
-               return error("corrupt index file");
+               return error(_("corrupt index file"));
 
        if (source_tree)
                read_tree_some(source_tree, pathspec);
@@ -240,14 +242,14 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
                        if (!ce_stage(ce))
                                continue;
                        if (opts->force) {
-                               warning("path '%s' is unmerged", ce->name);
+                               warning(_("path '%s' is unmerged"), ce->name);
                        } else if (stage) {
                                errs |= check_stage(stage, ce, pos);
                        } else if (opts->merge) {
                                errs |= check_all_stages(ce, pos);
                        } else {
                                errs = 1;
-                               error("path '%s' is unmerged", ce->name);
+                               error(_("path '%s' is unmerged"), ce->name);
                        }
                        pos = skip_same_name(ce, pos) - 1;
                }
@@ -276,7 +278,7 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
 
        if (write_cache(newfd, active_cache, active_nr) ||
            commit_locked_index(lock_file))
-               die("unable to write new index file");
+               die(_("unable to write new index file"));
 
        resolve_ref("HEAD", rev, 0, &flag);
        head = lookup_commit_reference_gently(rev, 1);
@@ -293,7 +295,7 @@ static void show_local_changes(struct object *head, struct diff_options *opts)
        rev.diffopt.flags = opts->flags;
        rev.diffopt.output_format |= DIFF_FORMAT_NAME_STATUS;
        if (diff_setup_done(&rev.diffopt) < 0)
-               die("diff_setup_done failed");
+               die(_("diff_setup_done failed"));
        add_pending_object(&rev, head, NULL);
        run_diff_index(&rev, 0);
 }
@@ -367,7 +369,7 @@ static int merge_working_tree(struct checkout_opts *opts,
        int newfd = hold_locked_index(lock_file, 1);
 
        if (read_cache_preload(NULL) < 0)
-               return error("corrupt index file");
+               return error(_("corrupt index file"));
 
        resolve_undo_clear();
        if (opts->force) {
@@ -389,7 +391,7 @@ static int merge_working_tree(struct checkout_opts *opts,
                refresh_cache(REFRESH_QUIET);
 
                if (unmerged_cache()) {
-                       error("you need to resolve your current index first");
+                       error(_("you need to resolve your current index first"));
                        return 1;
                }
 
@@ -471,7 +473,7 @@ static int merge_working_tree(struct checkout_opts *opts,
 
        if (write_cache(newfd, active_cache, active_nr) ||
            commit_locked_index(lock_file))
-               die("unable to write new index file");
+               die(_("unable to write new index file"));
 
        if (!opts->force && !opts->quiet)
                show_local_changes(&new->commit->object, &opts->diff_options);
@@ -520,7 +522,7 @@ static void update_refs_for_switch(struct checkout_opts *opts,
                                temp = log_all_ref_updates;
                                log_all_ref_updates = 1;
                                if (log_ref_setup(ref_name, log_file, sizeof(log_file))) {
-                                       fprintf(stderr, "Can not do reflog for '%s'\n",
+                                       fprintf(stderr, _("Can not do reflog for '%s'\n"),
                                            opts->new_orphan_branch);
                                        log_all_ref_updates = temp;
                                        return;
@@ -550,21 +552,23 @@ static void update_refs_for_switch(struct checkout_opts *opts,
                if (!opts->quiet) {
                        if (old->path && advice_detached_head)
                                detach_advice(old->path, new->name);
-                       describe_detached_head("HEAD is now at", new->commit);
+                       describe_detached_head(_("HEAD is now at"), new->commit);
                }
        } else if (new->path) { /* Switch branches. */
                create_symref("HEAD", new->path, msg.buf);
                if (!opts->quiet) {
-                       if (old->path && !strcmp(new->path, old->path))
-                               fprintf(stderr, "Already on '%s'\n",
-                                       new->name);
-                       else if (opts->new_branch)
-                               fprintf(stderr, "Switched to%s branch '%s'\n",
-                                       opts->branch_exists ? " and reset" : " a new",
+                       if (old->path && !strcmp(new->path, old->path)) {
+                               fprintf(stderr, _("Already on '%s'\n"),
                                        new->name);
-                       else
-                               fprintf(stderr, "Switched to branch '%s'\n",
+                       } else if (opts->new_branch) {
+                               if (opts->branch_exists)
+                                       fprintf(stderr, _("Switched to and reset branch '%s'\n"), new->name);
+                               else
+                                       fprintf(stderr, _("Switched to a new branch '%s'\n"), new->name);
+                       } else {
+                               fprintf(stderr, _("Switched to branch '%s'\n"),
                                        new->name);
+                       }
                }
                if (old->path && old->name) {
                        char log_file[PATH_MAX], ref_file[PATH_MAX];
@@ -680,13 +684,13 @@ static void orphaned_commit_warning(struct commit *commit)
 
        init_revisions(&revs, NULL);
        if (setup_revisions(args.argc - 1, args.argv, &revs, NULL) != 1)
-               die("internal error: only -- alone should have been left");
+               die(_("internal error: only -- alone should have been left"));
        if (prepare_revision_walk(&revs))
-               die("internal error in revision walk");
+               die(_("internal error in revision walk"));
        if (!(commit->object.flags & UNINTERESTING))
                suggest_reattach(commit, &revs);
        else
-               describe_detached_head("Previous HEAD position was", commit);
+               describe_detached_head(_("Previous HEAD position was"), commit);
 
        clear_commit_marks(commit, -1);
        for_each_ref(clear_commit_marks_from_one_ref, NULL);
@@ -711,7 +715,7 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
                new->name = "HEAD";
                new->commit = old.commit;
                if (!new->commit)
-                       die("You are on a branch yet to be born");
+                       die(_("You are on a branch yet to be born"));
                parse_commit(new->commit);
        }
 
@@ -839,7 +843,7 @@ static int parse_branchname_arg(int argc, const char **argv,
 
        if (get_sha1_mb(arg, rev)) {
                if (has_dash_dash)          /* case (1) */
-                       die("invalid reference: %s", arg);
+                       die(_("invalid reference: %s"), arg);
                if (dwim_new_local_branch_ok &&
                    !check_filename(NULL, arg) &&
                    argc == 1) {
@@ -878,7 +882,7 @@ static int parse_branchname_arg(int argc, const char **argv,
        }
 
        if (!*source_tree)                   /* case (1): want a tree */
-               die("reference is not a tree: %s", arg);
+               die(_("reference is not a tree: %s"), arg);
        if (!has_dash_dash) {/* case (3 -> 1) */
                /*
                 * Do not complain the most common case
@@ -945,7 +949,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 
        /* we can assume from now on new_branch = !new_branch_force */
        if (opts.new_branch && opts.new_branch_force)
-               die("-B cannot be used with -b");
+               die(_("-B cannot be used with -b"));
 
        /* copy -B over to -b, so that we can just check the latter */
        if (opts.new_branch_force)
@@ -954,7 +958,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
        if (patch_mode && (opts.track > 0 || opts.new_branch
                           || opts.new_branch_log || opts.merge || opts.force
                           || opts.force_detach))
-               die ("--patch is incompatible with all other options");
+               die (_("--patch is incompatible with all other options"));
 
        if (opts.force_detach && (opts.new_branch || opts.new_orphan_branch))
                die("--detach cannot be used with -b/-B/--orphan");
@@ -965,22 +969,22 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
        if (0 < opts.track && !opts.new_branch) {
                const char *argv0 = argv[0];
                if (!argc || !strcmp(argv0, "--"))
-                       die ("--track needs a branch name");
+                       die (_("--track needs a branch name"));
                if (!prefixcmp(argv0, "refs/"))
                        argv0 += 5;
                if (!prefixcmp(argv0, "remotes/"))
                        argv0 += 8;
                argv0 = strchr(argv0, '/');
                if (!argv0 || !argv0[1])
-                       die ("Missing branch name; try -b");
+                       die (_("Missing branch name; try -b"));
                opts.new_branch = argv0 + 1;
        }
 
        if (opts.new_orphan_branch) {
                if (opts.new_branch)
-                       die("--orphan and -b|-B are mutually exclusive");
+                       die(_("--orphan and -b|-B are mutually exclusive"));
                if (opts.track > 0)
-                       die("--orphan cannot be used with -t");
+                       die(_("--orphan cannot be used with -t"));
                opts.new_branch = opts.new_orphan_branch;
        }
 
@@ -990,7 +994,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
        }
 
        if (opts.force && opts.merge)
-               die("git checkout: -f and -m are incompatible");
+               die(_("git checkout: -f and -m are incompatible"));
 
        /*
         * Extract branch name from command line arguments, so
@@ -1024,7 +1028,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
                const char **pathspec = get_pathspec(prefix, argv);
 
                if (!pathspec)
-                       die("invalid path specification");
+                       die(_("invalid path specification"));
 
                if (patch_mode)
                        return interactive_checkout(new.name, pathspec, &opts);
@@ -1032,9 +1036,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
                /* Checkout paths */
                if (opts.new_branch) {
                        if (argc == 1) {
-                               die("git checkout: updating paths is incompatible with switching branches.\nDid you intend to checkout '%s' which can not be resolved as commit?", argv[0]);
+                               die(_("git checkout: updating paths is incompatible with switching branches.\nDid you intend to checkout '%s' which can not be resolved as commit?"), argv[0]);
                        } else {
-                               die("git checkout: updating paths is incompatible with switching branches.");
+                               die(_("git checkout: updating paths is incompatible with switching branches."));
                        }
                }
 
@@ -1042,7 +1046,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
                        die("git checkout: --detach does not take a path argument");
 
                if (1 < !!opts.writeout_stage + !!opts.force + !!opts.merge)
-                       die("git checkout: --ours/--theirs, --force and --merge are incompatible when\nchecking out of the index.");
+                       die(_("git checkout: --ours/--theirs, --force and --merge are incompatible when\nchecking out of the index."));
 
                return checkout_paths(source_tree, pathspec, &opts);
        }
@@ -1053,22 +1057,22 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
        if (opts.new_branch) {
                struct strbuf buf = STRBUF_INIT;
                if (strbuf_check_branch_ref(&buf, opts.new_branch))
-                       die("git checkout: we do not like '%s' as a branch name.",
+                       die(_("git checkout: we do not like '%s' as a branch name."),
                            opts.new_branch);
                if (!get_sha1(buf.buf, rev)) {
                        opts.branch_exists = 1;
                        if (!opts.new_branch_force)
-                               die("git checkout: branch %s already exists",
+                               die(_("git checkout: branch %s already exists"),
                                    opts.new_branch);
                }
                strbuf_release(&buf);
        }
 
        if (new.name && !new.commit) {
-               die("Cannot switch branch to a non-commit.");
+               die(_("Cannot switch branch to a non-commit."));
        }
        if (opts.writeout_stage)
-               die("--ours/--theirs is incompatible with switching branches.");
+               die(_("--ours/--theirs is incompatible with switching branches."));
 
        return switch_branches(&opts, &new);
 }
index 4a312abc6b3ecef5f174b2786ad31385ba058b44..75697f711116e42df1e21e608c21829f49549b08 100644 (file)
@@ -75,11 +75,16 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
                dir.flags |= DIR_SHOW_IGNORED;
 
        if (ignored && ignored_only)
-               die("-x and -X cannot be used together");
-
-       if (!show_only && !force)
-               die("clean.requireForce %s to true and neither -n nor -f given; "
-                   "refusing to clean", config_set ? "set" : "defaults");
+               die(_("-x and -X cannot be used together"));
+
+       if (!show_only && !force) {
+               if (config_set)
+                       die(_("clean.requireForce set to true and neither -n nor -f given; "
+                                 "refusing to clean"));
+               else
+                       die(_("clean.requireForce defaults to true and neither -n nor -f given; "
+                                 "refusing to clean"));
+       }
 
        if (force > 1)
                rm_flags = 0;
@@ -87,7 +92,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
        dir.flags |= DIR_SHOW_OTHER_DIRECTORIES;
 
        if (read_cache() < 0)
-               die("index file corrupt");
+               die(_("index file corrupt"));
 
        if (!ignored)
                setup_standard_excludes(&dir);
@@ -146,20 +151,20 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
                        qname = quote_path_relative(directory.buf, directory.len, &buf, prefix);
                        if (show_only && (remove_directories ||
                            (matches == MATCHED_EXACTLY))) {
-                               printf("Would remove %s\n", qname);
+                               printf(_("Would remove %s\n"), qname);
                        } else if (remove_directories ||
                                   (matches == MATCHED_EXACTLY)) {
                                if (!quiet)
-                                       printf("Removing %s\n", qname);
+                                       printf(_("Removing %s\n"), qname);
                                if (remove_dir_recursively(&directory,
                                                           rm_flags) != 0) {
-                                       warning("failed to remove %s", qname);
+                                       warning(_("failed to remove %s"), qname);
                                        errors++;
                                }
                        } else if (show_only) {
-                               printf("Would not remove %s\n", qname);
+                               printf(_("Would not remove %s\n"), qname);
                        } else {
-                               printf("Not removing %s\n", qname);
+                               printf(_("Not removing %s\n"), qname);
                        }
                        strbuf_reset(&directory);
                } else {
@@ -167,13 +172,13 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
                                continue;
                        qname = quote_path_relative(ent->name, -1, &buf, prefix);
                        if (show_only) {
-                               printf("Would remove %s\n", qname);
+                               printf(_("Would remove %s\n"), qname);
                                continue;
                        } else if (!quiet) {
-                               printf("Removing %s\n", qname);
+                               printf(_("Removing %s\n"), qname);
                        }
                        if (unlink(ent->name) != 0) {
-                               warning("failed to remove %s", qname);
+                               warning(_("failed to remove %s"), qname);
                                errors++;
                        }
                }
index c6e10bb9e916a21ad5c71018d6380ad85540dc65..4144bcf5ca320057b5ef1f5dac9c2df19aba250b 100644 (file)
@@ -42,6 +42,7 @@ static int option_local, option_no_hardlinks, option_shared, option_recursive;
 static char *option_template, *option_reference, *option_depth;
 static char *option_origin = NULL;
 static char *option_branch = NULL;
+static const char *real_git_dir;
 static char *option_upload_pack = "git-upload-pack";
 static int option_verbosity;
 static int option_progress;
@@ -80,6 +81,8 @@ static struct option builtin_clone_options[] = {
                   "path to git-upload-pack on the remote"),
        OPT_STRING(0, "depth", &option_depth, "depth",
                    "create a shallow clone of that depth"),
+       OPT_STRING('L', "separate-git-dir", &real_git_dir, "gitdir",
+                  "separate git dir from working tree"),
 
        OPT_END()
 };
@@ -208,7 +211,7 @@ static void setup_reference(const char *repo)
        if (is_directory(mkpath("%s/.git/objects", ref_git)))
                ref_git = mkpath("%s/.git", ref_git);
        else if (!is_directory(mkpath("%s/objects", ref_git)))
-               die("reference repository '%s' is not a local directory.",
+               die(_("reference repository '%s' is not a local directory."),
                    option_reference);
 
        ref_git_copy = xstrdup(ref_git);
@@ -235,15 +238,15 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 
        dir = opendir(src->buf);
        if (!dir)
-               die_errno("failed to open '%s'", src->buf);
+               die_errno(_("failed to open '%s'"), src->buf);
 
        if (mkdir(dest->buf, 0777)) {
                if (errno != EEXIST)
-                       die_errno("failed to create directory '%s'", dest->buf);
+                       die_errno(_("failed to create directory '%s'"), dest->buf);
                else if (stat(dest->buf, &buf))
-                       die_errno("failed to stat '%s'", dest->buf);
+                       die_errno(_("failed to stat '%s'"), dest->buf);
                else if (!S_ISDIR(buf.st_mode))
-                       die("%s exists and is not a directory", dest->buf);
+                       die(_("%s exists and is not a directory"), dest->buf);
        }
 
        strbuf_addch(src, '/');
@@ -257,7 +260,7 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
                strbuf_setlen(dest, dest_len);
                strbuf_addstr(dest, de->d_name);
                if (stat(src->buf, &buf)) {
-                       warning ("failed to stat %s\n", src->buf);
+                       warning (_("failed to stat %s\n"), src->buf);
                        continue;
                }
                if (S_ISDIR(buf.st_mode)) {
@@ -267,16 +270,16 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
                }
 
                if (unlink(dest->buf) && errno != ENOENT)
-                       die_errno("failed to unlink '%s'", dest->buf);
+                       die_errno(_("failed to unlink '%s'"), dest->buf);
                if (!option_no_hardlinks) {
                        if (!link(src->buf, dest->buf))
                                continue;
                        if (option_local)
-                               die_errno("failed to create link '%s'", dest->buf);
+                               die_errno(_("failed to create link '%s'"), dest->buf);
                        option_no_hardlinks = 1;
                }
                if (copy_file_with_time(dest->buf, src->buf, 0666))
-                       die_errno("failed to copy file to '%s'", dest->buf);
+                       die_errno(_("failed to copy file to '%s'"), dest->buf);
        }
        closedir(dir);
 }
@@ -305,7 +308,7 @@ static const struct ref *clone_local(const char *src_repo,
        ret = transport_get_remote_refs(transport);
        transport_disconnect(transport);
        if (0 <= option_verbosity)
-               printf("done.\n");
+               printf(_("done.\n"));
        return ret;
 }
 
@@ -388,11 +391,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                             builtin_clone_usage, 0);
 
        if (argc > 2)
-               usage_msg_opt("Too many arguments.",
+               usage_msg_opt(_("Too many arguments."),
                        builtin_clone_usage, builtin_clone_options);
 
        if (argc == 0)
-               usage_msg_opt("You must specify a repository to clone.",
+               usage_msg_opt(_("You must specify a repository to clone."),
                        builtin_clone_usage, builtin_clone_options);
 
        if (option_mirror)
@@ -400,7 +403,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
        if (option_bare) {
                if (option_origin)
-                       die("--bare and --origin %s options are incompatible.",
+                       die(_("--bare and --origin %s options are incompatible."),
                            option_origin);
                option_no_checkout = 1;
        }
@@ -419,7 +422,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                repo = repo_name;
        is_local = path && !is_bundle;
        if (is_local && option_depth)
-               warning("--depth is ignored in local clones; use file:// instead.");
+               warning(_("--depth is ignored in local clones; use file:// instead."));
 
        if (argc == 2)
                dir = xstrdup(argv[1]);
@@ -429,8 +432,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
        dest_exists = !stat(dir, &buf);
        if (dest_exists && !is_empty_dir(dir))
-               die("destination path '%s' already exists and is not "
-                       "an empty directory.", dir);
+               die(_("destination path '%s' already exists and is not "
+                       "an empty directory."), dir);
 
        strbuf_addf(&reflog_msg, "clone: from %s", repo);
 
@@ -439,7 +442,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        else {
                work_tree = getenv("GIT_WORK_TREE");
                if (work_tree && !stat(work_tree, &buf))
-                       die("working tree '%s' already exists.", work_tree);
+                       die(_("working tree '%s' already exists."), work_tree);
        }
 
        if (option_bare || work_tree)
@@ -452,10 +455,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        if (!option_bare) {
                junk_work_tree = work_tree;
                if (safe_create_leading_directories_const(work_tree) < 0)
-                       die_errno("could not create leading directories of '%s'",
+                       die_errno(_("could not create leading directories of '%s'"),
                                  work_tree);
                if (!dest_exists && mkdir(work_tree, 0755))
-                       die_errno("could not create work tree dir '%s'.",
+                       die_errno(_("could not create work tree dir '%s'."),
                                  work_tree);
                set_git_work_tree(work_tree);
        }
@@ -466,12 +469,18 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        setenv(CONFIG_ENVIRONMENT, mkpath("%s/config", git_dir), 1);
 
        if (safe_create_leading_directories_const(git_dir) < 0)
-               die("could not create leading directories of '%s'", git_dir);
-       set_git_dir(real_path(git_dir));
+               die(_("could not create leading directories of '%s'"), git_dir);
 
-       if (0 <= option_verbosity)
-               printf("Cloning into %s%s...\n",
-                      option_bare ? "bare repository " : "", dir);
+       set_git_dir_init(git_dir, real_git_dir, 0);
+       if (real_git_dir)
+               git_dir = real_git_dir;
+
+       if (0 <= option_verbosity) {
+               if (option_bare)
+                       printf(_("Cloning into bare repository %s...\n"), dir);
+               else
+                       printf(_("Cloning into %s...\n"), dir);
+       }
        init_db(option_template, INIT_DB_QUIET);
 
        /*
@@ -528,7 +537,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                transport = transport_get(remote, remote->url[0]);
 
                if (!transport->get_refs_list || !transport->fetch)
-                       die("Don't know how to clone %s", transport->url);
+                       die(_("Don't know how to clone %s"), transport->url);
 
                transport_set_option(transport, TRANS_OPT_KEEP, "yes");
 
@@ -567,8 +576,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                        strbuf_release(&head);
 
                        if (!our_head_points_at) {
-                               warning("Remote branch %s not found in "
-                                       "upstream %s, using HEAD instead",
+                               warning(_("Remote branch %s not found in "
+                                       "upstream %s, using HEAD instead"),
                                        option_branch, option_origin);
                                our_head_points_at = remote_head_points_at;
                        }
@@ -577,7 +586,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                        our_head_points_at = remote_head_points_at;
        }
        else {
-               warning("You appear to have cloned an empty repository.");
+               warning(_("You appear to have cloned an empty repository."));
                our_head_points_at = NULL;
                remote_head_points_at = NULL;
                remote_head = NULL;
@@ -619,8 +628,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        } else {
                /* Nothing to checkout out */
                if (!option_no_checkout)
-                       warning("remote HEAD refers to nonexistent ref, "
-                               "unable to checkout.\n");
+                       warning(_("remote HEAD refers to nonexistent ref, "
+                               "unable to checkout.\n"));
                option_no_checkout = 1;
        }
 
@@ -656,7 +665,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
                if (write_cache(fd, active_cache, active_nr) ||
                    commit_locked_index(lock_file))
-                       die("unable to write new index file");
+                       die(_("unable to write new index file"));
 
                err |= run_hook(NULL, "post-checkout", sha1_to_hex(null_sha1),
                                sha1_to_hex(our_head_points_at->old_sha1), "1",
index 54b20497b120bc2bf5ee6e4904eca0ca5d83ff4f..67757e999fba514b62767d3351031e9eb6ef8c10 100644 (file)
@@ -38,7 +38,7 @@ static const char * const builtin_status_usage[] = {
 };
 
 static const char implicit_ident_advice[] =
-"Your name and email address were configured automatically based\n"
+N_("Your name and email address were configured automatically based\n"
 "on your username and hostname. Please check that they are accurate.\n"
 "You can suppress this message by setting them explicitly:\n"
 "\n"
@@ -47,20 +47,20 @@ static const char implicit_ident_advice[] =
 "\n"
 "After doing this, you may fix the identity used for this commit with:\n"
 "\n"
-"    git commit --amend --reset-author\n";
+"    git commit --amend --reset-author\n");
 
 static const char empty_amend_advice[] =
-"You asked to amend the most recent commit, but doing so would make\n"
+N_("You asked to amend the most recent commit, but doing so would make\n"
 "it empty. You can repeat your command with --allow-empty, or you can\n"
-"remove the commit entirely with \"git reset HEAD^\".\n";
+"remove the commit entirely with \"git reset HEAD^\".\n");
 
 static const char empty_cherry_pick_advice[] =
-"The previous cherry-pick is now empty, possibly due to conflict resolution.\n"
+N_("The previous cherry-pick is now empty, possibly due to conflict resolution.\n"
 "If you wish to commit it anyway, use:\n"
 "\n"
 "    git commit --allow-empty\n"
 "\n"
-"Otherwise, please use 'git reset'\n";
+"Otherwise, please use 'git reset'\n");
 
 static unsigned char head_sha1[20];
 
@@ -287,7 +287,7 @@ static void add_remove_files(struct string_list *list)
 
                if (!lstat(p->string, &st)) {
                        if (add_to_cache(p->string, &st, 0))
-                               die("updating files failed");
+                               die(_("updating files failed"));
                } else
                        remove_file_from_cache(p->string);
        }
@@ -314,7 +314,7 @@ static void create_base_index(void)
        opts.fn = oneway_merge;
        tree = parse_tree_indirect(head_sha1);
        if (!tree)
-               die("failed to unpack HEAD tree object");
+               die(_("failed to unpack HEAD tree object"));
        parse_tree(tree);
        init_tree_desc(&t, tree->buffer, tree->size);
        if (unpack_trees(1, &t, &opts))
@@ -342,9 +342,9 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
                refresh_flags |= REFRESH_UNMERGED;
        if (interactive) {
                if (interactive_add(argc, argv, prefix) != 0)
-                       die("interactive add failed");
+                       die(_("interactive add failed"));
                if (read_cache_preload(NULL) < 0)
-                       die("index file corrupt");
+                       die(_("index file corrupt"));
                commit_style = COMMIT_AS_IS;
                return get_index_file();
        }
@@ -353,7 +353,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
                pathspec = get_pathspec(prefix, argv);
 
        if (read_cache_preload(pathspec) < 0)
-               die("index file corrupt");
+               die(_("index file corrupt"));
 
        /*
         * Non partial, non as-is commit.
@@ -373,7 +373,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
                refresh_cache_or_die(refresh_flags);
                if (write_cache(fd, active_cache, active_nr) ||
                    close_lock_file(&index_lock))
-                       die("unable to write new_index file");
+                       die(_("unable to write new_index file"));
                commit_style = COMMIT_NORMAL;
                return index_lock.filename;
        }
@@ -393,7 +393,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
                if (active_cache_changed) {
                        if (write_cache(fd, active_cache, active_nr) ||
                            commit_locked_index(&index_lock))
-                               die("unable to write new_index file");
+                               die(_("unable to write new_index file"));
                } else {
                        rollback_lock_file(&index_lock);
                }
@@ -423,7 +423,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
        commit_style = COMMIT_PARTIAL;
 
        if (whence != FROM_COMMIT)
-               die("cannot do a partial commit during a %s.", whence_s());
+               die(_("cannot do a partial commit during a %s."), whence_s());
 
        memset(&partial, 0, sizeof(partial));
        partial.strdup_strings = 1;
@@ -432,14 +432,14 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
 
        discard_cache();
        if (read_cache() < 0)
-               die("cannot read the index");
+               die(_("cannot read the index"));
 
        fd = hold_locked_index(&index_lock, 1);
        add_remove_files(&partial);
        refresh_cache(REFRESH_QUIET);
        if (write_cache(fd, active_cache, active_nr) ||
            close_lock_file(&index_lock))
-               die("unable to write new_index file");
+               die(_("unable to write new_index file"));
 
        fd = hold_lock_file_for_update(&false_lock,
                                       git_path("next-index-%"PRIuMAX,
@@ -452,7 +452,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
 
        if (write_cache(fd, active_cache, active_nr) ||
            close_lock_file(&false_lock))
-               die("unable to write temporary index file");
+               die(_("unable to write temporary index file"));
 
        discard_cache();
        read_cache_from(false_lock.filename);
@@ -499,7 +499,7 @@ static int is_a_merge(const unsigned char *sha1)
 {
        struct commit *commit = lookup_commit(sha1);
        if (!commit || parse_commit(commit))
-               die("could not parse HEAD commit");
+               die(_("could not parse HEAD commit"));
        return !!(commit->parents && commit->parents->next);
 }
 
@@ -518,13 +518,13 @@ static void determine_author_info(struct strbuf *author_ident)
 
                a = strstr(author_message_buffer, "\nauthor ");
                if (!a)
-                       die("invalid commit: %s", author_message);
+                       die(_("invalid commit: %s"), author_message);
 
                lb = strchrnul(a + strlen("\nauthor "), '<');
                rb = strchrnul(lb, '>');
                eol = strchrnul(rb, '\n');
                if (!*lb || !*rb || !*eol)
-                       die("invalid commit: %s", author_message);
+                       die(_("invalid commit: %s"), author_message);
 
                if (lb == a + strlen("\nauthor "))
                        /* \nauthor <foo@example.com> */
@@ -542,7 +542,7 @@ static void determine_author_info(struct strbuf *author_ident)
                const char *rb = strchr(force_author, '>');
 
                if (!lb || !rb)
-                       die("malformed --author parameter");
+                       die(_("malformed --author parameter"));
                name = xstrndup(force_author, lb - force_author);
                email = xstrndup(lb + 2, rb - (lb + 2));
        }
@@ -598,7 +598,7 @@ static char *cut_ident_timestamp_part(char *string)
 {
        char *ket = strrchr(string, '>');
        if (!ket || ket[1] != ' ')
-               die("Malformed ident string: '%s'", string);
+               die(_("Malformed ident string: '%s'"), string);
        *++ket = '\0';
        return ket;
 }
@@ -631,7 +631,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                        struct commit *c;
                        c = lookup_commit_reference_by_name(squash_message);
                        if (!c)
-                               die("could not lookup commit %s", squash_message);
+                               die(_("could not lookup commit %s"), squash_message);
                        ctx.output_encoding = get_commit_output_encoding();
                        format_commit_message(c, "squash! %s\n\n", &sb,
                                              &ctx);
@@ -643,19 +643,19 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                hook_arg1 = "message";
        } else if (logfile && !strcmp(logfile, "-")) {
                if (isatty(0))
-                       fprintf(stderr, "(reading log message from standard input)\n");
+                       fprintf(stderr, _("(reading log message from standard input)\n"));
                if (strbuf_read(&sb, 0, 0) < 0)
-                       die_errno("could not read log from standard input");
+                       die_errno(_("could not read log from standard input"));
                hook_arg1 = "message";
        } else if (logfile) {
                if (strbuf_read_file(&sb, logfile, 0) < 0)
-                       die_errno("could not read log file '%s'",
+                       die_errno(_("could not read log file '%s'"),
                                  logfile);
                hook_arg1 = "message";
        } else if (use_message) {
                buffer = strstr(use_message_buffer, "\n\n");
                if (!buffer || buffer[2] == '\0')
-                       die("commit has empty message");
+                       die(_("commit has empty message"));
                strbuf_add(&sb, buffer + 2, strlen(buffer + 2));
                hook_arg1 = "commit";
                hook_arg2 = use_message;
@@ -664,22 +664,22 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                struct commit *commit;
                commit = lookup_commit_reference_by_name(fixup_message);
                if (!commit)
-                       die("could not lookup commit %s", fixup_message);
+                       die(_("could not lookup commit %s"), fixup_message);
                ctx.output_encoding = get_commit_output_encoding();
                format_commit_message(commit, "fixup! %s\n\n",
                                      &sb, &ctx);
                hook_arg1 = "message";
        } else if (!stat(git_path("MERGE_MSG"), &statbuf)) {
                if (strbuf_read_file(&sb, git_path("MERGE_MSG"), 0) < 0)
-                       die_errno("could not read MERGE_MSG");
+                       die_errno(_("could not read MERGE_MSG"));
                hook_arg1 = "merge";
        } else if (!stat(git_path("SQUASH_MSG"), &statbuf)) {
                if (strbuf_read_file(&sb, git_path("SQUASH_MSG"), 0) < 0)
-                       die_errno("could not read SQUASH_MSG");
+                       die_errno(_("could not read SQUASH_MSG"));
                hook_arg1 = "squash";
        } else if (template_file) {
                if (strbuf_read_file(&sb, template_file, 0) < 0)
-                       die_errno("could not read '%s'", template_file);
+                       die_errno(_("could not read '%s'"), template_file);
                hook_arg1 = "template";
        }
 
@@ -706,7 +706,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 
        s->fp = fopen(git_path(commit_editmsg), "w");
        if (s->fp == NULL)
-               die_errno("could not open '%s'", git_path(commit_editmsg));
+               die_errno(_("could not open '%s'"), git_path(commit_editmsg));
 
        if (cleanup_mode != CLEANUP_NONE)
                stripspace(&sb, 0);
@@ -730,7 +730,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
        }
 
        if (fwrite(sb.buf, 1, sb.len, s->fp) < sb.len)
-               die_errno("could not write commit template");
+               die_errno(_("could not write commit template"));
 
        strbuf_release(&sb);
 
@@ -743,12 +743,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                char *ai_tmp, *ci_tmp;
                if (whence != FROM_COMMIT)
                        status_printf_ln(s, GIT_COLOR_NORMAL,
-                               "\n"
+                               _("\n"
                                "It looks like you may be committing a %s.\n"
                                "If this is not correct, please remove the file\n"
                                "       %s\n"
                                "and try again.\n"
-                               "",
+                               ""),
                                whence_s(),
                                git_path(whence == FROM_MERGE
                                         ? "MERGE_HEAD"
@@ -756,18 +756,18 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 
                fprintf(s->fp, "\n");
                status_printf(s, GIT_COLOR_NORMAL,
-                       "Please enter the commit message for your changes.");
+                       _("Please enter the commit message for your changes."));
                if (cleanup_mode == CLEANUP_ALL)
                        status_printf_more(s, GIT_COLOR_NORMAL,
-                               " Lines starting\n"
+                               _(" Lines starting\n"
                                "with '#' will be ignored, and an empty"
-                               " message aborts the commit.\n");
+                               " message aborts the commit.\n"));
                else /* CLEANUP_SPACE, that is. */
                        status_printf_more(s, GIT_COLOR_NORMAL,
-                               " Lines starting\n"
+                               _(" Lines starting\n"
                                "with '#' will be kept; you may remove them"
                                " yourself if you want to.\n"
-                               "An empty message aborts the commit.\n");
+                               "An empty message aborts the commit.\n"));
                if (only_include_assumed)
                        status_printf_ln(s, GIT_COLOR_NORMAL,
                                        "%s", only_include_assumed);
@@ -776,15 +776,15 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                ci_tmp = cut_ident_timestamp_part(committer_ident.buf);
                if (strcmp(author_ident->buf, committer_ident.buf))
                        status_printf_ln(s, GIT_COLOR_NORMAL,
-                               "%s"
-                               "Author:    %s",
+                               _("%s"
+                               "Author:    %s"),
                                ident_shown++ ? "" : "\n",
                                author_ident->buf);
 
                if (!user_ident_sufficiently_given())
                        status_printf_ln(s, GIT_COLOR_NORMAL,
-                               "%s"
-                               "Committer: %s",
+                               _("%s"
+                               "Committer: %s"),
                                ident_shown++ ? "" : "\n",
                                committer_ident.buf);
 
@@ -803,7 +803,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                const char *parent = "HEAD";
 
                if (!active_nr && read_cache() < 0)
-                       die("Cannot read index");
+                       die(_("Cannot read index"));
 
                if (amend)
                        parent = "HEAD^1";
@@ -826,9 +826,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
            !(amend && is_a_merge(head_sha1))) {
                run_status(stdout, index_file, prefix, 0, s);
                if (amend)
-                       fputs(empty_amend_advice, stderr);
+                       fputs(_(empty_amend_advice), stderr);
                else if (whence == FROM_CHERRY_PICK)
-                       fputs(empty_cherry_pick_advice, stderr);
+                       fputs(_(empty_cherry_pick_advice), stderr);
                return 0;
        }
 
@@ -843,7 +843,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                active_cache_tree = cache_tree();
        if (cache_tree_update(active_cache_tree,
                              active_cache, active_nr, 0, 0) < 0) {
-               error("Error building trees");
+               error(_("Error building trees"));
                return 0;
        }
 
@@ -858,7 +858,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
                if (launch_editor(git_path(commit_editmsg), NULL, env)) {
                        fprintf(stderr,
-                       "Please supply the message using either -m or -F option.\n");
+                       _("Please supply the message using either -m or -F option.\n"));
                        exit(1);
                }
        }
@@ -938,7 +938,7 @@ static const char *find_author_by_nickname(const char *name)
                format_commit_message(commit, "%an <%ae>", &buf, &ctx);
                return strbuf_detach(&buf, NULL);
        }
-       die("No existing author found with '%s'", name);
+       die(_("No existing author found with '%s'"), name);
 }
 
 
@@ -953,7 +953,7 @@ static void handle_untracked_files_arg(struct wt_status *s)
        else if (!strcmp(untracked_files_arg, "all"))
                s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
        else
-               die("Invalid untracked files mode '%s'", untracked_files_arg);
+               die(_("Invalid untracked files mode '%s'"), untracked_files_arg);
 }
 
 static const char *read_commit_message(const char *name)
@@ -963,7 +963,7 @@ static const char *read_commit_message(const char *name)
 
        commit = lookup_commit_reference_by_name(name);
        if (!commit)
-               die("could not lookup commit %s", name);
+               die(_("could not lookup commit %s"), name);
        out_enc = get_commit_output_encoding();
        out = logmsg_reencode(commit, out_enc);
 
@@ -992,7 +992,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
                force_author = find_author_by_nickname(force_author);
 
        if (force_author && renew_authorship)
-               die("Using both --reset-author and --author does not make sense");
+               die(_("Using both --reset-author and --author does not make sense"));
 
        if (logfile || message.len || use_message || fixup_message)
                use_editor = 0;
@@ -1006,11 +1006,11 @@ static int parse_and_validate_options(int argc, const char *argv[],
 
        /* Sanity check options */
        if (amend && initial_commit)
-               die("You have nothing to amend.");
+               die(_("You have nothing to amend."));
        if (amend && whence != FROM_COMMIT)
-               die("You are in the middle of a %s -- cannot amend.", whence_s());
+               die(_("You are in the middle of a %s -- cannot amend."), whence_s());
        if (fixup_message && squash_message)
-               die("Options --squash and --fixup cannot be used together");
+               die(_("Options --squash and --fixup cannot be used together"));
        if (use_message)
                f++;
        if (edit_message)
@@ -1020,15 +1020,15 @@ static int parse_and_validate_options(int argc, const char *argv[],
        if (logfile)
                f++;
        if (f > 1)
-               die("Only one of -c/-C/-F/--fixup can be used.");
+               die(_("Only one of -c/-C/-F/--fixup can be used."));
        if (message.len && f > 0)
-               die("Option -m cannot be combined with -c/-C/-F/--fixup.");
+               die((_("Option -m cannot be combined with -c/-C/-F/--fixup.")));
        if (edit_message)
                use_message = edit_message;
        if (amend && !use_message && !fixup_message)
                use_message = "HEAD";
        if (!use_message && whence != FROM_CHERRY_PICK && renew_authorship)
-               die("--reset-author can be used only with -C, -c or --amend.");
+               die(_("--reset-author can be used only with -C, -c or --amend."));
        if (use_message) {
                use_message_buffer = read_commit_message(use_message);
                if (!renew_authorship) {
@@ -1042,13 +1042,13 @@ static int parse_and_validate_options(int argc, const char *argv[],
        }
 
        if (!!also + !!only + !!all + !!interactive > 1)
-               die("Only one of --include/--only/--all/--interactive can be used.");
+               die(_("Only one of --include/--only/--all/--interactive can be used."));
        if (argc == 0 && (also || (only && !amend)))
-               die("No paths with --include/--only does not make sense.");
+               die(_("No paths with --include/--only does not make sense."));
        if (argc == 0 && only && amend)
-               only_include_assumed = "Clever... amending the last one with dirty index.";
+               only_include_assumed = _("Clever... amending the last one with dirty index.");
        if (argc > 0 && !also && !only)
-               only_include_assumed = "Explicit paths specified without -i nor -o; assuming --only paths...";
+               only_include_assumed = _("Explicit paths specified without -i nor -o; assuming --only paths...");
        if (!cleanup_arg || !strcmp(cleanup_arg, "default"))
                cleanup_mode = use_editor ? CLEANUP_ALL : CLEANUP_SPACE;
        else if (!strcmp(cleanup_arg, "verbatim"))
@@ -1058,14 +1058,14 @@ static int parse_and_validate_options(int argc, const char *argv[],
        else if (!strcmp(cleanup_arg, "strip"))
                cleanup_mode = CLEANUP_ALL;
        else
-               die("Invalid cleanup mode %s", cleanup_arg);
+               die(_("Invalid cleanup mode %s"), cleanup_arg);
 
        handle_untracked_files_arg(s);
 
        if (all && argc > 0)
-               die("Paths with -a does not make sense.");
+               die(_("Paths with -a does not make sense."));
        else if (interactive && argc > 0)
-               die("Paths with --interactive does not make sense.");
+               die(_("Paths with --interactive does not make sense."));
 
        if (null_termination && status_format == STATUS_FORMAT_LONG)
                status_format = STATUS_FORMAT_PORCELAIN;
@@ -1146,7 +1146,7 @@ static int git_status_config(const char *k, const char *v, void *cb)
                else if (!strcmp(v, "all"))
                        s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
                else
-                       return error("Invalid untracked files mode '%s'", v);
+                       return error(_("Invalid untracked files mode '%s'"), v);
                return 0;
        }
        return git_diff_ui_config(k, v, NULL);
@@ -1246,9 +1246,9 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
 
        commit = lookup_commit(sha1);
        if (!commit)
-               die("couldn't look up newly created commit");
+               die(_("couldn't look up newly created commit"));
        if (!commit || parse_commit(commit))
-               die("could not parse newly created commit");
+               die(_("could not parse newly created commit"));
 
        strbuf_addstr(&format, "format:%h] %s");
 
@@ -1263,7 +1263,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
                strbuf_addbuf_percentquote(&format, &committer_ident);
                if (advice_implicit_identity) {
                        strbuf_addch(&format, '\n');
-                       strbuf_addstr(&format, implicit_ident_advice);
+                       strbuf_addstr(&format, _(implicit_ident_advice));
                }
        }
        strbuf_release(&author_ident);
@@ -1288,9 +1288,9 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
                !prefixcmp(head, "refs/heads/") ?
                        head + 11 :
                        !strcmp(head, "HEAD") ?
-                               "detached HEAD" :
+                               _("detached HEAD") :
                                head,
-               initial_commit ? " (root-commit)" : "");
+               initial_commit ? _(" (root-commit)") : "");
 
        if (!log_tree_commit(&rev, commit)) {
                rev.always_show_header = 1;
@@ -1400,7 +1400,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                        reflog_msg = "commit (amend)";
                commit = lookup_commit(head_sha1);
                if (!commit || parse_commit(commit))
-                       die("could not parse HEAD commit");
+                       die(_("could not parse HEAD commit"));
 
                for (c = commit->parents; c; c = c->next)
                        pptr = &commit_list_insert(c->item, pptr)->next;
@@ -1413,19 +1413,19 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
                fp = fopen(git_path("MERGE_HEAD"), "r");
                if (fp == NULL)
-                       die_errno("could not open '%s' for reading",
+                       die_errno(_("could not open '%s' for reading"),
                                  git_path("MERGE_HEAD"));
                while (strbuf_getline(&m, fp, '\n') != EOF) {
                        unsigned char sha1[20];
                        if (get_sha1_hex(m.buf, sha1) < 0)
-                               die("Corrupt MERGE_HEAD file (%s)", m.buf);
+                               die(_("Corrupt MERGE_HEAD file (%s)"), m.buf);
                        pptr = &commit_list_insert(lookup_commit(sha1), pptr)->next;
                }
                fclose(fp);
                strbuf_release(&m);
                if (!stat(git_path("MERGE_MODE"), &statbuf)) {
                        if (strbuf_read_file(&sb, git_path("MERGE_MODE"), 0) < 0)
-                               die_errno("could not read MERGE_MODE");
+                               die_errno(_("could not read MERGE_MODE"));
                        if (!strcmp(sb.buf, "no-ff"))
                                allow_fast_forward = 0;
                }
@@ -1444,7 +1444,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
                int saved_errno = errno;
                rollback_index_files();
-               die("could not read commit message: %s", strerror(saved_errno));
+               die(_("could not read commit message: %s"), strerror(saved_errno));
        }
 
        /* Truncate the message just before the diff, if any. */
@@ -1458,14 +1458,14 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                stripspace(&sb, cleanup_mode == CLEANUP_ALL);
        if (message_is_empty(&sb) && !allow_empty_message) {
                rollback_index_files();
-               fprintf(stderr, "Aborting commit due to empty commit message.\n");
+               fprintf(stderr, _("Aborting commit due to empty commit message.\n"));
                exit(1);
        }
 
        if (commit_tree(sb.buf, active_cache_tree->sha1, parents, commit_sha1,
                        author_ident.buf)) {
                rollback_index_files();
-               die("failed to write commit object");
+               die(_("failed to write commit object"));
        }
        strbuf_release(&author_ident);
 
@@ -1483,11 +1483,11 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 
        if (!ref_lock) {
                rollback_index_files();
-               die("cannot lock HEAD ref");
+               die(_("cannot lock HEAD ref"));
        }
        if (write_ref_sha1(ref_lock, commit_sha1, sb.buf) < 0) {
                rollback_index_files();
-               die("cannot update HEAD ref");
+               die(_("cannot update HEAD ref"));
        }
 
        unlink(git_path("CHERRY_PICK_HEAD"));
@@ -1497,9 +1497,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        unlink(git_path("SQUASH_MSG"));
 
        if (commit_index_files())
-               die ("Repository has been updated, but unable to write\n"
+               die (_("Repository has been updated, but unable to write\n"
                     "new_index file. Check that disk is not full or quota is\n"
-                    "not exceeded, and then \"git reset HEAD\" to recover.");
+                    "not exceeded, and then \"git reset HEAD\" to recover."));
 
        rerere(0);
        run_hook(get_index_file(), "post-commit", NULL);
index 4afd1504a666d670ec71bdbd61b09bc0530ed04b..66fc291c8a81de71dee7b597c9ab0dc9d70e8e29 100644 (file)
@@ -231,13 +231,13 @@ static void display_name(struct commit_name *n)
        if (n->prio == 2 && !n->tag) {
                n->tag = lookup_tag(n->sha1);
                if (!n->tag || parse_tag(n->tag))
-                       die("annotated tag %s not available", n->path);
+                       die(_("annotated tag %s not available"), n->path);
        }
        if (n->tag && !n->name_checked) {
                if (!n->tag->tag)
-                       die("annotated tag %s has no embedded name", n->path);
+                       die(_("annotated tag %s has no embedded name"), n->path);
                if (strcmp(n->tag->tag, all ? n->path + 5 : n->path))
-                       warning("tag '%s' is really '%s' here", n->tag->tag, n->path);
+                       warning(_("tag '%s' is really '%s' here"), n->tag->tag, n->path);
                n->name_checked = 1;
        }
 
@@ -264,10 +264,10 @@ static void describe(const char *arg, int last_one)
        unsigned int unannotated_cnt = 0;
 
        if (get_sha1(arg, sha1))
-               die("Not a valid object name %s", arg);
+               die(_("Not a valid object name %s"), arg);
        cmit = lookup_commit_reference(sha1);
        if (!cmit)
-               die("%s is not a valid '%s' object", arg, commit_type);
+               die(_("%s is not a valid '%s' object"), arg, commit_type);
 
        n = find_commit_name(cmit->object.sha1);
        if (n && (tags || all || n->prio == 2)) {
@@ -284,9 +284,9 @@ static void describe(const char *arg, int last_one)
        }
 
        if (!max_candidates)
-               die("no tag exactly matches '%s'", sha1_to_hex(cmit->object.sha1));
+               die(_("no tag exactly matches '%s'"), sha1_to_hex(cmit->object.sha1));
        if (debug)
-               fprintf(stderr, "searching to describe %s\n", arg);
+               fprintf(stderr, _("searching to describe %s\n"), arg);
 
        if (!have_util) {
                for_each_hash(&names, set_util, NULL);
@@ -326,7 +326,7 @@ static void describe(const char *arg, int last_one)
                }
                if (annotated_cnt && !list) {
                        if (debug)
-                               fprintf(stderr, "finished search at %s\n",
+                               fprintf(stderr, _("finished search at %s\n"),
                                        sha1_to_hex(c->object.sha1));
                        break;
                }
@@ -350,12 +350,12 @@ static void describe(const char *arg, int last_one)
                        return;
                }
                if (unannotated_cnt)
-                       die("No annotated tags can describe '%s'.\n"
-                           "However, there were unannotated tags: try --tags.",
+                       die(_("No annotated tags can describe '%s'.\n"
+                           "However, there were unannotated tags: try --tags."),
                            sha1_to_hex(sha1));
                else
-                       die("No tags can describe '%s'.\n"
-                           "Try --always, or create some tags.",
+                       die(_("No tags can describe '%s'.\n"
+                           "Try --always, or create some tags."),
                            sha1_to_hex(sha1));
        }
 
@@ -375,11 +375,11 @@ static void describe(const char *arg, int last_one)
                                prio_names[t->name->prio],
                                t->depth, t->name->path);
                }
-               fprintf(stderr, "traversed %lu commits\n", seen_commits);
+               fprintf(stderr, _("traversed %lu commits\n"), seen_commits);
                if (gave_up_on) {
                        fprintf(stderr,
-                               "more than %i tags found; listed %i most recent\n"
-                               "gave up search at %s\n",
+                               _("more than %i tags found; listed %i most recent\n"
+                               "gave up search at %s\n"),
                                max_candidates, max_candidates,
                                sha1_to_hex(gave_up_on->object.sha1));
                }
@@ -433,7 +433,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
        save_commit_buffer = 0;
 
        if (longformat && abbrev == 0)
-               die("--long is incompatible with --abbrev=0");
+               die(_("--long is incompatible with --abbrev=0"));
 
        if (contains) {
                const char **args = xmalloc((7 + argc) * sizeof(char *));
@@ -459,14 +459,14 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
        init_hash(&names);
        for_each_rawref(get_name, NULL);
        if (!names.nr && !always)
-               die("No names found, cannot describe anything.");
+               die(_("No names found, cannot describe anything."));
 
        if (argc == 0) {
                if (dirty && !cmd_diff_index(ARRAY_SIZE(diff_index_args) - 1, diff_index_args, prefix))
                        dirty = NULL;
                describe("HEAD", 1);
        } else if (dirty) {
-               die("--dirty is incompatible with committishes");
+               die(_("--dirty is incompatible with committishes"));
        } else {
                while (argc-- > 0) {
                        describe(*argv++, argc == 0);
index 655a013ed05edd369225aa9ee9f39f347d687172..717fa1a3414e18cbdd4c6eb1e0785761687688d7 100644 (file)
@@ -71,9 +71,9 @@ static int builtin_diff_b_f(struct rev_info *revs,
                usage(builtin_diff_usage);
 
        if (lstat(path, &st))
-               die_errno("failed to stat '%s'", path);
+               die_errno(_("failed to stat '%s'"), path);
        if (!(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)))
-               die("'%s': not a regular file or symlink", path);
+               die(_("'%s': not a regular file or symlink"), path);
 
        diff_set_mnemonic_prefix(&revs->diffopt, "o/", "w/");
 
@@ -217,7 +217,7 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv
                else if (!strcmp(argv[1], "-h"))
                        usage(builtin_diff_usage);
                else
-                       return error("invalid option: %s", argv[1]);
+                       return error(_("invalid option: %s"), argv[1]);
                argv++; argc--;
        }
 
@@ -294,12 +294,12 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
        DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);
 
        if (nongit)
-               die("Not a git repository");
+               die(_("Not a git repository"));
        argc = setup_revisions(argc, argv, &rev, NULL);
        if (!rev.diffopt.output_format) {
                rev.diffopt.output_format = DIFF_FORMAT_PATCH;
                if (diff_setup_done(&rev.diffopt) < 0)
-                       die("diff_setup_done failed");
+                       die(_("diff_setup_done failed"));
        }
 
        DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
@@ -344,12 +344,12 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                        obj = parse_object(obj->sha1);
                obj = deref_tag(obj, NULL, 0);
                if (!obj)
-                       die("invalid object '%s' given.", name);
+                       die(_("invalid object '%s' given."), name);
                if (obj->type == OBJ_COMMIT)
                        obj = &((struct commit *)obj)->tree->object;
                if (obj->type == OBJ_TREE) {
                        if (ARRAY_SIZE(ent) <= ents)
-                               die("more than %d trees given: '%s'",
+                               die(_("more than %d trees given: '%s'"),
                                    (int) ARRAY_SIZE(ent), name);
                        obj->flags |= flags;
                        ent[ents].item = obj;
@@ -359,7 +359,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                }
                if (obj->type == OBJ_BLOB) {
                        if (2 <= blobs)
-                               die("more than two blobs given: '%s'", name);
+                               die(_("more than two blobs given: '%s'"), name);
                        hashcpy(blob[blobs].sha1, obj->sha1);
                        blob[blobs].name = name;
                        blob[blobs].mode = list->mode;
@@ -367,7 +367,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                        continue;
 
                }
-               die("unhandled object '%s' given.", name);
+               die(_("unhandled object '%s' given."), name);
        }
        if (rev.prune_data.nr) {
                if (!path)
index 1b6d4be00207576f612b8d2cf1f5979656a63da7..f9c41da475289b84fe849f7641406ebc94059630 100644 (file)
@@ -28,12 +28,6 @@ enum {
        TAGS_SET = 2
 };
 
-enum {
-       RECURSE_SUBMODULES_OFF = 0,
-       RECURSE_SUBMODULES_DEFAULT = 1,
-       RECURSE_SUBMODULES_ON = 2
-};
-
 static int all, append, dry_run, force, keep, multiple, prune, update_head_ok, verbosity;
 static int progress, recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
 static int tags = TAGS_DEFAULT;
@@ -42,6 +36,21 @@ static const char *upload_pack;
 static struct strbuf default_rla = STRBUF_INIT;
 static struct transport *transport;
 static const char *submodule_prefix = "";
+static const char *recurse_submodules_default;
+
+static int option_parse_recurse_submodules(const struct option *opt,
+                                  const char *arg, int unset)
+{
+       if (unset) {
+               recurse_submodules = RECURSE_SUBMODULES_OFF;
+       } else {
+               if (arg)
+                       recurse_submodules = parse_fetch_recurse_submodules_arg(opt->long_name, arg);
+               else
+                       recurse_submodules = RECURSE_SUBMODULES_ON;
+       }
+       return 0;
+}
 
 static struct option builtin_fetch_options[] = {
        OPT__VERBOSITY(&verbosity),
@@ -60,9 +69,9 @@ static struct option builtin_fetch_options[] = {
                    "do not fetch all tags (--no-tags)", TAGS_UNSET),
        OPT_BOOLEAN('p', "prune", &prune,
                    "prune remote-tracking branches no longer on remote"),
-       OPT_SET_INT(0, "recurse-submodules", &recurse_submodules,
+       { OPTION_CALLBACK, 0, "recurse-submodules", NULL, "on-demand",
                    "control recursive fetching of submodules",
-                   RECURSE_SUBMODULES_ON),
+                   PARSE_OPT_OPTARG, option_parse_recurse_submodules },
        OPT_BOOLEAN(0, "dry-run", &dry_run,
                    "dry run"),
        OPT_BOOLEAN('k', "keep", &keep, "keep downloaded pack"),
@@ -73,6 +82,9 @@ static struct option builtin_fetch_options[] = {
                   "deepen history of shallow clone"),
        { OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, "dir",
                   "prepend this to submodule path output", PARSE_OPT_HIDDEN },
+       { OPTION_STRING, 0, "recurse-submodules-default",
+                  &recurse_submodules_default, NULL,
+                  "default mode for recursion", PARSE_OPT_HIDDEN },
        OPT_END()
 };
 
@@ -184,7 +196,7 @@ static struct ref *get_ref_map(struct transport *transport,
                } else {
                        ref_map = get_remote_ref(remote_refs, "HEAD");
                        if (!ref_map)
-                               die("Couldn't find remote ref HEAD");
+                               die(_("Couldn't find remote ref HEAD"));
                        ref_map->merge = 1;
                        tail = &ref_map->next;
                }
@@ -237,12 +249,12 @@ static int update_local_ref(struct ref *ref,
        *display = 0;
        type = sha1_object_info(ref->new_sha1, NULL);
        if (type < 0)
-               die("object %s not found", sha1_to_hex(ref->new_sha1));
+               die(_("object %s not found"), sha1_to_hex(ref->new_sha1));
 
        if (!hashcmp(ref->old_sha1, ref->new_sha1)) {
                if (verbosity > 0)
                        sprintf(display, "= %-*s %-*s -> %s", TRANSPORT_SUMMARY_WIDTH,
-                               "[up to date]", REFCOL_WIDTH, remote,
+                               _("[up to date]"), REFCOL_WIDTH, remote,
                                pretty_ref);
                return 0;
        }
@@ -255,8 +267,8 @@ static int update_local_ref(struct ref *ref,
                 * If this is the head, and it's not okay to update
                 * the head, and the old value of the head isn't empty...
                 */
-               sprintf(display, "! %-*s %-*s -> %s  (can't fetch in current branch)",
-                       TRANSPORT_SUMMARY_WIDTH, "[rejected]", REFCOL_WIDTH, remote,
+               sprintf(display, _("! %-*s %-*s -> %s  (can't fetch in current branch)"),
+                       TRANSPORT_SUMMARY_WIDTH, _("[rejected]"), REFCOL_WIDTH, remote,
                        pretty_ref);
                return 1;
        }
@@ -266,8 +278,8 @@ static int update_local_ref(struct ref *ref,
                int r;
                r = s_update_ref("updating tag", ref, 0);
                sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : '-',
-                       TRANSPORT_SUMMARY_WIDTH, "[tag update]", REFCOL_WIDTH, remote,
-                       pretty_ref, r ? "  (unable to update local ref)" : "");
+                       TRANSPORT_SUMMARY_WIDTH, _("[tag update]"), REFCOL_WIDTH, remote,
+                       pretty_ref, r ? _("  (unable to update local ref)") : "");
                return r;
        }
 
@@ -279,17 +291,20 @@ static int update_local_ref(struct ref *ref,
                int r;
                if (!strncmp(ref->name, "refs/tags/", 10)) {
                        msg = "storing tag";
-                       what = "[new tag]";
+                       what = _("[new tag]");
                }
                else {
                        msg = "storing head";
-                       what = "[new branch]";
+                       what = _("[new branch]");
+                       if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
+                           (recurse_submodules != RECURSE_SUBMODULES_ON))
+                               check_for_new_submodule_commits(ref->new_sha1);
                }
 
                r = s_update_ref(msg, ref, 0);
                sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : '*',
                        TRANSPORT_SUMMARY_WIDTH, what, REFCOL_WIDTH, remote, pretty_ref,
-                       r ? "  (unable to update local ref)" : "");
+                       r ? _("  (unable to update local ref)") : "");
                return r;
        }
 
@@ -299,10 +314,13 @@ static int update_local_ref(struct ref *ref,
                strcpy(quickref, find_unique_abbrev(current->object.sha1, DEFAULT_ABBREV));
                strcat(quickref, "..");
                strcat(quickref, find_unique_abbrev(ref->new_sha1, DEFAULT_ABBREV));
+               if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
+                   (recurse_submodules != RECURSE_SUBMODULES_ON))
+                       check_for_new_submodule_commits(ref->new_sha1);
                r = s_update_ref("fast-forward", ref, 1);
                sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : ' ',
                        TRANSPORT_SUMMARY_WIDTH, quickref, REFCOL_WIDTH, remote,
-                       pretty_ref, r ? "  (unable to update local ref)" : "");
+                       pretty_ref, r ? _("  (unable to update local ref)") : "");
                return r;
        } else if (force || ref->force) {
                char quickref[84];
@@ -310,16 +328,19 @@ static int update_local_ref(struct ref *ref,
                strcpy(quickref, find_unique_abbrev(current->object.sha1, DEFAULT_ABBREV));
                strcat(quickref, "...");
                strcat(quickref, find_unique_abbrev(ref->new_sha1, DEFAULT_ABBREV));
+               if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
+                   (recurse_submodules != RECURSE_SUBMODULES_ON))
+                       check_for_new_submodule_commits(ref->new_sha1);
                r = s_update_ref("forced-update", ref, 1);
                sprintf(display, "%c %-*s %-*s -> %s  (%s)", r ? '!' : '+',
                        TRANSPORT_SUMMARY_WIDTH, quickref, REFCOL_WIDTH, remote,
                        pretty_ref,
-                       r ? "unable to update local ref" : "forced update");
+                       r ? _("unable to update local ref") : _("forced update"));
                return r;
        } else {
-               sprintf(display, "! %-*s %-*s -> %s  (non-fast-forward)",
-                       TRANSPORT_SUMMARY_WIDTH, "[rejected]", REFCOL_WIDTH, remote,
-                       pretty_ref);
+               sprintf(display, "! %-*s %-*s -> %s  %s",
+                       TRANSPORT_SUMMARY_WIDTH, _("[rejected]"), REFCOL_WIDTH, remote,
+                       pretty_ref, _("(non-fast-forward)"));
                return 1;
        }
 }
@@ -337,7 +358,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 
        fp = fopen(filename, "a");
        if (!fp)
-               return error("cannot open %s: %s\n", filename, strerror(errno));
+               return error(_("cannot open %s: %s\n"), filename, strerror(errno));
 
        if (raw_url)
                url = transport_anonymize_url(raw_url);
@@ -415,7 +436,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
                                 REFCOL_WIDTH, *what ? what : "HEAD");
                if (*note) {
                        if (verbosity >= 0 && !shown_url) {
-                               fprintf(stderr, "From %.*s\n",
+                               fprintf(stderr, _("From %.*s\n"),
                                                url_len, url);
                                shown_url = 1;
                        }
@@ -426,9 +447,9 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
        free(url);
        fclose(fp);
        if (rc & STORE_REF_ERROR_DF_CONFLICT)
-               error("some local refs could not be updated; try running\n"
+               error(_("some local refs could not be updated; try running\n"
                      " 'git remote prune %s' to remove any old, conflicting "
-                     "branches", remote_name);
+                     "branches"), remote_name);
        return rc;
 }
 
@@ -476,7 +497,7 @@ static int quickfetch(struct ref *ref_map)
 
        err = start_command(&revlist);
        if (err) {
-               error("could not run rev-list");
+               error(_("could not run rev-list"));
                return err;
        }
 
@@ -490,14 +511,14 @@ static int quickfetch(struct ref *ref_map)
                if (write_in_full(revlist.in, sha1_to_hex(ref->old_sha1), 40) < 0 ||
                    write_str_in_full(revlist.in, "\n") < 0) {
                        if (errno != EPIPE && errno != EINVAL)
-                               error("failed write to rev-list: %s", strerror(errno));
+                               error(_("failed write to rev-list: %s"), strerror(errno));
                        err = -1;
                        break;
                }
        }
 
        if (close(revlist.in)) {
-               error("failed to close rev-list's stdin: %s", strerror(errno));
+               error(_("failed to close rev-list's stdin: %s"), strerror(errno));
                err = -1;
        }
 
@@ -524,16 +545,16 @@ static int prune_refs(struct transport *transport, struct ref *ref_map)
        int result = 0;
        struct ref *ref, *stale_refs = get_stale_heads(transport->remote, ref_map);
        const char *dangling_msg = dry_run
-               ? "   (%s will become dangling)\n"
-               : "   (%s has become dangling)\n";
+               ? _("   (%s will become dangling)\n")
+               : _("   (%s has become dangling)\n");
 
        for (ref = stale_refs; ref; ref = ref->next) {
                if (!dry_run)
                        result |= delete_ref(ref->name, NULL, 0);
                if (verbosity >= 0) {
                        fprintf(stderr, " x %-*s %-*s -> %s\n",
-                               TRANSPORT_SUMMARY_WIDTH, "[deleted]",
-                               REFCOL_WIDTH, "(none)", prettify_refname(ref->name));
+                               TRANSPORT_SUMMARY_WIDTH, _("[deleted]"),
+                               REFCOL_WIDTH, _("(none)"), prettify_refname(ref->name));
                        warn_dangling_symref(stderr, dangling_msg, ref->name);
                }
        }
@@ -650,8 +671,8 @@ static void check_not_current_branch(struct ref *ref_map)
        for (; ref_map; ref_map = ref_map->next)
                if (ref_map->peer_ref && !strcmp(current_branch->refname,
                                        ref_map->peer_ref->name))
-                       die("Refusing to fetch into current branch %s "
-                           "of non-bare repository", current_branch->refname);
+                       die(_("Refusing to fetch into current branch %s "
+                           "of non-bare repository"), current_branch->refname);
 }
 
 static int truncate_fetch_head(void)
@@ -660,7 +681,7 @@ static int truncate_fetch_head(void)
        FILE *fp = fopen(filename, "w");
 
        if (!fp)
-               return error("cannot open %s: %s\n", filename, strerror(errno));
+               return error(_("cannot open %s: %s\n"), filename, strerror(errno));
        fclose(fp);
        return 0;
 }
@@ -684,7 +705,7 @@ static int do_fetch(struct transport *transport,
        }
 
        if (!transport->get_refs_list || !transport->fetch)
-               die("Don't know how to fetch from %s", transport->url);
+               die(_("Don't know how to fetch from %s"), transport->url);
 
        /* if not appending, truncate FETCH_HEAD */
        if (!append && !dry_run) {
@@ -738,10 +759,10 @@ static void set_option(const char *name, const char *value)
 {
        int r = transport_set_option(transport, name, value);
        if (r < 0)
-               die("Option \"%s\" value \"%s\" is not valid for %s",
+               die(_("Option \"%s\" value \"%s\" is not valid for %s"),
                        name, value, transport->url);
        if (r > 0)
-               warning("Option \"%s\" is ignored for %s\n",
+               warning(_("Option \"%s\" is ignored for %s\n"),
                        name, transport->url);
 }
 
@@ -810,6 +831,8 @@ static void add_options_to_argv(int *argc, const char **argv)
                argv[(*argc)++] = "--keep";
        if (recurse_submodules == RECURSE_SUBMODULES_ON)
                argv[(*argc)++] = "--recurse-submodules";
+       else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
+               argv[(*argc)++] = "--recurse-submodules=on-demand";
        if (verbosity >= 2)
                argv[(*argc)++] = "-v";
        if (verbosity >= 1)
@@ -838,9 +861,9 @@ static int fetch_multiple(struct string_list *list)
                argv[argc] = name;
                argv[argc + 1] = NULL;
                if (verbosity >= 0)
-                       printf("Fetching %s\n", name);
+                       printf(_("Fetching %s\n"), name);
                if (run_command_v_opt(argv, RUN_GIT_CMD)) {
-                       error("Could not fetch %s", name);
+                       error(_("Could not fetch %s"), name);
                        result = 1;
                }
        }
@@ -856,8 +879,8 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
        int exit_code;
 
        if (!remote)
-               die("No remote repository specified.  Please, specify either a URL or a\n"
-                   "remote name from which new revisions should be fetched.");
+               die(_("No remote repository specified.  Please, specify either a URL or a\n"
+                   "remote name from which new revisions should be fetched."));
 
        transport = transport_get(remote, NULL);
        transport_set_verbosity(transport, verbosity, progress);
@@ -876,7 +899,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
                                char *ref;
                                i++;
                                if (i >= argc)
-                                       die("You need to specify a tag name.");
+                                       die(_("You need to specify a tag name."));
                                ref = xmalloc(strlen(argv[i]) * 2 + 22);
                                strcpy(ref, "refs/tags/");
                                strcat(ref, argv[i]);
@@ -918,9 +941,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 
        if (all) {
                if (argc == 1)
-                       die("fetch --all does not take a repository argument");
+                       die(_("fetch --all does not take a repository argument"));
                else if (argc > 1)
-                       die("fetch --all does not make sense with refspecs");
+                       die(_("fetch --all does not make sense with refspecs"));
                (void) for_each_remote(get_one_remote_for_fetch, &list);
                result = fetch_multiple(&list);
        } else if (argc == 0) {
@@ -931,7 +954,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
                /* All arguments are assumed to be remotes or groups */
                for (i = 0; i < argc; i++)
                        if (!add_remote_or_group(argv[i], &list))
-                               die("No such remote or remote group: %s", argv[i]);
+                               die(_("No such remote or remote group: %s"), argv[i]);
                result = fetch_multiple(&list);
        } else {
                /* Single remote or group */
@@ -939,7 +962,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
                if (list.nr > 1) {
                        /* More than one remote */
                        if (argc > 1)
-                               die("Fetching a group and specifying refspecs does not make sense");
+                               die(_("Fetching a group and specifying refspecs does not make sense"));
                        result = fetch_multiple(&list);
                } else {
                        /* Zero or one remotes */
@@ -951,15 +974,16 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
        if (!result && (recurse_submodules != RECURSE_SUBMODULES_OFF)) {
                const char *options[10];
                int num_options = 0;
-               /* Set recursion as default when we already are recursing */
-               if (submodule_prefix[0])
-                       set_config_fetch_recurse_submodules(1);
+               if (recurse_submodules_default) {
+                       int arg = parse_fetch_recurse_submodules_arg("--recurse-submodules-default", recurse_submodules_default);
+                       set_config_fetch_recurse_submodules(arg);
+               }
                gitmodules_config();
                git_config(submodule_config, NULL);
                add_options_to_argv(&num_options, options);
                result = fetch_populated_submodules(num_options, options,
                                                    submodule_prefix,
-                                                   recurse_submodules == RECURSE_SUBMODULES_ON,
+                                                   recurse_submodules,
                                                    verbosity < 0);
        }
 
index 1a80702b3d1c86b55af24be3b3396f17e9d4a21c..ff5f73ba87b23fc7e361a1751c2d9a64e0267163 100644 (file)
@@ -60,7 +60,7 @@ static int gc_config(const char *var, const char *value, void *cb)
                if (value && strcmp(value, "now")) {
                        unsigned long now = approxidate("now");
                        if (approxidate(value) >= now)
-                               return error("Invalid %s: '%s'", var, value);
+                               return error(_("Invalid %s: '%s'"), var, value);
                }
                return git_config_string(&prune_expire, var, value);
        }
@@ -75,7 +75,7 @@ static void append_option(const char **cmd, const char *opt, int max_length)
                ;
 
        if (i + 2 >= max_length)
-               die("Too many options specified");
+               die(_("Too many options specified"));
        cmd[i++] = opt;
        cmd[i] = NULL;
 }
@@ -100,7 +100,7 @@ static int too_many_loose_objects(void)
                return 0;
 
        if (sizeof(path) <= snprintf(path, sizeof(path), "%s/17", objdir)) {
-               warning("insanely long object directory %.*s", 50, objdir);
+               warning(_("insanely long object directory %.*s"), 50, objdir);
                return 0;
        }
        dir = opendir(path);
@@ -219,13 +219,13 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
                 */
                if (!need_to_gc())
                        return 0;
-               fprintf(stderr,
-                       "Auto packing the repository for optimum performance.%s\n",
-                       quiet
-                       ? ""
-                       : (" You may also\n"
-                          "run \"git gc\" manually. See "
-                          "\"git help gc\" for more information."));
+               if (quiet)
+                       fprintf(stderr, _("Auto packing the repository for optimum performance.\n"));
+               else
+                       fprintf(stderr,
+                                       _("Auto packing the repository for optimum performance. You may also\n"
+                                       "run \"git gc\" manually. See "
+                                       "\"git help gc\" for more information."));
        } else
                append_option(argv_repack,
                              prune_expire && !strcmp(prune_expire, "now")
@@ -251,8 +251,8 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
                return error(FAILED_RUN, argv_rerere[0]);
 
        if (auto_gc && too_many_loose_objects())
-               warning("There are too many unreachable loose objects; "
-                       "run 'git prune' to remove them.");
+               warning(_("There are too many unreachable loose objects; "
+                       "run 'git prune' to remove them."));
 
        return 0;
 }
index 85e9583a1335330f8e852d7937abb10c97798bc0..10a1f65310f28f2014bab3f3295205abf6dc59ad 100644 (file)
@@ -244,7 +244,7 @@ static void start_threads(struct grep_opt *opt)
                err = pthread_create(&threads[i], NULL, run, o);
 
                if (err)
-                       die("grep: failed to create thread: %s",
+                       die(_("grep: failed to create thread: %s"),
                            strerror(err));
        }
 }
@@ -302,6 +302,19 @@ static int grep_config(const char *var, const char *value, void *cb)
        default: return 0;
        }
 
+       if (!strcmp(var, "grep.extendedregexp")) {
+               if (git_config_bool(var, value))
+                       opt->regflags |= REG_EXTENDED;
+               else
+                       opt->regflags &= ~REG_EXTENDED;
+               return 0;
+       }
+
+       if (!strcmp(var, "grep.linenumber")) {
+               opt->linenum = git_config_bool(var, value);
+               return 0;
+       }
+
        if (!strcmp(var, "color.grep"))
                opt->color = git_config_colorbool(var, value, -1);
        else if (!strcmp(var, "color.grep.context"))
@@ -349,7 +362,7 @@ static void *load_sha1(const unsigned char *sha1, unsigned long *size,
        void *data = lock_and_read_sha1_file(sha1, &type, size);
 
        if (!data)
-               error("'%s': unable to read %s", name, sha1_to_hex(sha1));
+               error(_("'%s': unable to read %s"), name, sha1_to_hex(sha1));
 
        return data;
 }
@@ -400,21 +413,21 @@ static void *load_file(const char *filename, size_t *sz)
        if (lstat(filename, &st) < 0) {
        err_ret:
                if (errno != ENOENT)
-                       error("'%s': %s", filename, strerror(errno));
-               return 0;
+                       error(_("'%s': %s"), filename, strerror(errno));
+               return NULL;
        }
        if (!S_ISREG(st.st_mode))
-               return 0;
+               return NULL;
        *sz = xsize_t(st.st_size);
        i = open(filename, O_RDONLY);
        if (i < 0)
                goto err_ret;
        data = xmalloc(*sz + 1);
        if (st.st_size != read_in_full(i, data, *sz)) {
-               error("'%s': short read %s", filename, strerror(errno));
+               error(_("'%s': short read %s"), filename, strerror(errno));
                close(i);
                free(data);
-               return 0;
+               return NULL;
        }
        close(i);
        data[*sz] = 0;
@@ -473,7 +486,7 @@ static void run_pager(struct grep_opt *opt, const char *prefix)
        argv[path_list->nr] = NULL;
 
        if (prefix && chdir(prefix))
-               die("Failed to chdir: %s", prefix);
+               die(_("Failed to chdir: %s"), prefix);
        status = run_command_v_opt(argv, RUN_USING_SHELL);
        if (status)
                exit(status);
@@ -548,7 +561,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
 
                        data = lock_and_read_sha1_file(entry.sha1, &type, &size);
                        if (!data)
-                               die("unable to read tree (%s)",
+                               die(_("unable to read tree (%s)"),
                                    sha1_to_hex(entry.sha1));
 
                        strbuf_addch(base, '/');
@@ -579,7 +592,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
                data = read_object_with_reference(obj->sha1, tree_type,
                                                  &size, NULL);
                if (!data)
-                       die("unable to read tree (%s)", sha1_to_hex(obj->sha1));
+                       die(_("unable to read tree (%s)"), sha1_to_hex(obj->sha1));
 
                len = name ? strlen(name) : 0;
                strbuf_init(&base, PATH_MAX + len + 1);
@@ -593,7 +606,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
                free(data);
                return hit;
        }
-       die("unable to grep from object of type %s", typename(obj->type));
+       die(_("unable to grep from object of type %s"), typename(obj->type));
 }
 
 static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
@@ -649,7 +662,7 @@ static int context_callback(const struct option *opt, const char *arg,
        }
        value = strtol(arg, (char **)&endp, 10);
        if (*endp) {
-               return error("switch `%c' expects a numerical value",
+               return error(_("switch `%c' expects a numerical value"),
                             opt->short_name);
        }
        grep_opt->pre_context = grep_opt->post_context = value;
@@ -666,7 +679,7 @@ static int file_callback(const struct option *opt, const char *arg, int unset)
 
        patterns = from_stdin ? stdin : fopen(arg, "r");
        if (!patterns)
-               die_errno("cannot open '%s'", arg);
+               die_errno(_("cannot open '%s'"), arg);
        while (strbuf_getline(&sb, patterns, '\n') == 0) {
                char *s;
                size_t len;
@@ -909,11 +922,11 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
        }
 
        if (!opt.pattern_list)
-               die("no pattern given.");
+               die(_("no pattern given."));
        if (!opt.fixed && opt.ignore_case)
                opt.regflags |= REG_ICASE;
        if ((opt.regflags != REG_NEWLINE) && opt.fixed)
-               die("cannot mix --fixed-strings and regexp");
+               die(_("cannot mix --fixed-strings and regexp"));
 
 #ifndef NO_PTHREADS
        if (online_cpus() == 1 || !grep_threads_ok(&opt))
@@ -938,7 +951,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                if (!get_sha1(arg, sha1)) {
                        struct object *object = parse_object(sha1);
                        if (!object)
-                               die("bad object %s", arg);
+                               die(_("bad object %s"), arg);
                        add_object_array(object, arg, &list);
                        continue;
                }
@@ -968,7 +981,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
        pathspec.recursive = 1;
 
        if (show_in_pager && (cached || list.nr))
-               die("--open-files-in-pager only works on the worktree");
+               die(_("--open-files-in-pager only works on the worktree"));
 
        if (show_in_pager && opt.pattern_list && !opt.pattern_list->next) {
                const char *pager = path_list.items[0].string;
@@ -993,9 +1006,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 
        if (!use_index) {
                if (cached)
-                       die("--cached cannot be used with --no-index.");
+                       die(_("--cached cannot be used with --no-index."));
                if (list.nr)
-                       die("--no-index cannot be used with revs.");
+                       die(_("--no-index cannot be used with revs."));
                hit = grep_directory(&opt, &pathspec);
        } else if (!list.nr) {
                if (!cached)
@@ -1004,7 +1017,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                hit = grep_cache(&opt, &pathspec, cached);
        } else {
                if (cached)
-                       die("both --cached and trees are given.");
+                       die(_("both --cached and trees are given."));
                hit = grep_objects(&opt, &pathspec, &list);
        }
 
index 5a67c8181e5273ab0e79b8cb704dadc87cde1a37..31f001f1059ec533ee62d6bd951b068d7f924f50 100644 (file)
@@ -294,7 +294,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
        void *data;
 
        obj->idx.offset = consumed_bytes;
-       input_crc32 = crc32(0, Z_NULL, 0);
+       input_crc32 = crc32(0, NULL, 0);
 
        p = fill(1);
        c = *p;
index 8f5cfd712243975dacd08cb51c69c2e174e470b1..b7370d9bb8f235f1cf39b1ffa768498ca1e88654 100644 (file)
@@ -21,6 +21,7 @@
 static int init_is_bare_repository = 0;
 static int init_shared_repository = -1;
 static const char *init_db_template_dir;
+static const char *git_link;
 
 static void safe_create_dir(const char *dir, int share)
 {
@@ -31,7 +32,7 @@ static void safe_create_dir(const char *dir, int share)
                }
        }
        else if (share && adjust_shared_perm(dir))
-               die("Could not make %s writable by group", dir);
+               die(_("Could not make %s writable by group"), dir);
 }
 
 static void copy_templates_1(char *path, int baselen,
@@ -58,25 +59,25 @@ static void copy_templates_1(char *path, int baselen,
                namelen = strlen(de->d_name);
                if ((PATH_MAX <= baselen + namelen) ||
                    (PATH_MAX <= template_baselen + namelen))
-                       die("insanely long template name %s", de->d_name);
+                       die(_("insanely long template name %s"), de->d_name);
                memcpy(path + baselen, de->d_name, namelen+1);
                memcpy(template + template_baselen, de->d_name, namelen+1);
                if (lstat(path, &st_git)) {
                        if (errno != ENOENT)
-                               die_errno("cannot stat '%s'", path);
+                               die_errno(_("cannot stat '%s'"), path);
                }
                else
                        exists = 1;
 
                if (lstat(template, &st_template))
-                       die_errno("cannot stat template '%s'", template);
+                       die_errno(_("cannot stat template '%s'"), template);
 
                if (S_ISDIR(st_template.st_mode)) {
                        DIR *subdir = opendir(template);
                        int baselen_sub = baselen + namelen;
                        int template_baselen_sub = template_baselen + namelen;
                        if (!subdir)
-                               die_errno("cannot opendir '%s'", template);
+                               die_errno(_("cannot opendir '%s'"), template);
                        path[baselen_sub++] =
                                template[template_baselen_sub++] = '/';
                        path[baselen_sub] =
@@ -93,20 +94,20 @@ static void copy_templates_1(char *path, int baselen,
                        int len;
                        len = readlink(template, lnk, sizeof(lnk));
                        if (len < 0)
-                               die_errno("cannot readlink '%s'", template);
+                               die_errno(_("cannot readlink '%s'"), template);
                        if (sizeof(lnk) <= len)
-                               die("insanely long symlink %s", template);
+                               die(_("insanely long symlink %s"), template);
                        lnk[len] = 0;
                        if (symlink(lnk, path))
-                               die_errno("cannot symlink '%s' '%s'", lnk, path);
+                               die_errno(_("cannot symlink '%s' '%s'"), lnk, path);
                }
                else if (S_ISREG(st_template.st_mode)) {
                        if (copy_file(path, template, st_template.st_mode))
-                               die_errno("cannot copy '%s' to '%s'", template,
+                               die_errno(_("cannot copy '%s' to '%s'"), template,
                                          path);
                }
                else
-                       error("ignoring template %s", template);
+                       error(_("ignoring template %s"), template);
        }
 }
 
@@ -129,7 +130,7 @@ static void copy_templates(const char *template_dir)
                return;
        template_len = strlen(template_dir);
        if (PATH_MAX <= (template_len+strlen("/config")))
-               die("insanely long template path %s", template_dir);
+               die(_("insanely long template path %s"), template_dir);
        strcpy(template_path, template_dir);
        if (template_path[template_len-1] != '/') {
                template_path[template_len++] = '/';
@@ -137,7 +138,7 @@ static void copy_templates(const char *template_dir)
        }
        dir = opendir(template_path);
        if (!dir) {
-               warning("templates not found %s", template_dir);
+               warning(_("templates not found %s"), template_dir);
                return;
        }
 
@@ -150,8 +151,8 @@ static void copy_templates(const char *template_dir)
 
        if (repository_format_version &&
            repository_format_version != GIT_REPO_VERSION) {
-               warning("not copying templates of "
-                       "a wrong format version %d from '%s'",
+               warning(_("not copying templates of "
+                       "a wrong format version %d from '%s'"),
                        repository_format_version,
                        template_dir);
                closedir(dir);
@@ -188,7 +189,7 @@ static int create_default_files(const char *template_path)
        int filemode;
 
        if (len > sizeof(path)-50)
-               die("insane git directory %s", git_dir);
+               die(_("insane git directory %s"), git_dir);
        memcpy(path, git_dir, len);
 
        if (len && path[len-1] != '/')
@@ -311,11 +312,67 @@ static void create_object_directory(void)
        free(path);
 }
 
+int set_git_dir_init(const char *git_dir, const char *real_git_dir,
+                    int exist_ok)
+{
+       if (real_git_dir) {
+               struct stat st;
+
+               if (!exist_ok && !stat(git_dir, &st))
+                       die("%s already exists", git_dir);
+
+               if (!exist_ok && !stat(real_git_dir, &st))
+                       die("%s already exists", real_git_dir);
+
+               /*
+                * make sure symlinks are resolved because we'll be
+                * moving the target repo later on in separate_git_dir()
+                */
+               git_link = xstrdup(real_path(git_dir));
+       }
+       else {
+               real_git_dir = real_path(git_dir);
+               git_link = NULL;
+       }
+       set_git_dir(real_path(real_git_dir));
+       return 0;
+}
+
+static void separate_git_dir(const char *git_dir)
+{
+       struct stat st;
+       FILE *fp;
+
+       if (!stat(git_link, &st)) {
+               const char *src;
+
+               if (S_ISREG(st.st_mode))
+                       src = read_gitfile_gently(git_link);
+               else if (S_ISDIR(st.st_mode))
+                       src = git_link;
+               else
+                       die("unable to handle file type %d", st.st_mode);
+
+               if (rename(src, git_dir))
+                       die_errno("unable to move %s to %s", src, git_dir);
+       }
+
+       fp = fopen(git_link, "w");
+       if (!fp)
+               die("Could not create git link %s", git_link);
+       fprintf(fp, "gitdir: %s\n", git_dir);
+       fclose(fp);
+}
+
 int init_db(const char *template_dir, unsigned int flags)
 {
        int reinit;
+       const char *git_dir = get_git_dir();
+
+       if (git_link)
+               separate_git_dir(git_dir);
 
-       safe_create_dir(get_git_dir(), 0);
+       safe_create_dir(git_dir, 0);
 
        init_is_bare_repository = is_bare_repository();
 
@@ -352,11 +409,16 @@ int init_db(const char *template_dir, unsigned int flags)
        }
 
        if (!(flags & INIT_DB_QUIET)) {
-               const char *git_dir = get_git_dir();
                int len = strlen(git_dir);
-               printf("%s%s Git repository in %s%s\n",
-                      reinit ? "Reinitialized existing" : "Initialized empty",
-                      shared_repository ? " shared" : "",
+
+               /*
+                * TRANSLATORS: The first '%s' is either "Reinitialized
+                * existing" or "Initialized empty", the second " shared" or
+                * "", and the last '%s%s' is the verbatim directory name.
+                */
+               printf(_("%s%s Git repository in %s%s\n"),
+                      reinit ? _("Reinitialized existing") : _("Initialized empty"),
+                      shared_repository ? _(" shared") : "",
                       git_dir, len && git_dir[len-1] != '/' ? "/" : "");
        }
 
@@ -375,7 +437,7 @@ static int guess_repository_type(const char *git_dir)
        if (!strcmp(".", git_dir))
                return 1;
        if (!getcwd(cwd, sizeof(cwd)))
-               die_errno("cannot tell cwd");
+               die_errno(_("cannot tell cwd"));
        if (!strcmp(git_dir, cwd))
                return 1;
        /*
@@ -414,6 +476,7 @@ static const char *const init_db_usage[] = {
 int cmd_init_db(int argc, const char **argv, const char *prefix)
 {
        const char *git_dir;
+       const char *real_git_dir = NULL;
        const char *work_tree;
        const char *template_dir = NULL;
        unsigned int flags = 0;
@@ -427,11 +490,16 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
                        "specify that the git repository is to be shared amongst several users",
                        PARSE_OPT_OPTARG | PARSE_OPT_NONEG, shared_callback, 0},
                OPT_BIT('q', "quiet", &flags, "be quiet", INIT_DB_QUIET),
+               OPT_STRING('L', "separate-git-dir", &real_git_dir, "gitdir",
+                          "separate git dir from working tree"),
                OPT_END()
        };
 
        argc = parse_options(argc, argv, prefix, init_db_options, init_db_usage, 0);
 
+       if (real_git_dir && !is_absolute_path(real_git_dir))
+               real_git_dir = xstrdup(real_path(real_git_dir));
+
        if (argc == 1) {
                int mkdir_tried = 0;
        retry:
@@ -450,18 +518,18 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
                                        errno = EEXIST;
                                        /* fallthru */
                                case -1:
-                                       die_errno("cannot mkdir %s", argv[0]);
+                                       die_errno(_("cannot mkdir %s"), argv[0]);
                                        break;
                                default:
                                        break;
                                }
                                shared_repository = saved;
                                if (mkdir(argv[0], 0777) < 0)
-                                       die_errno("cannot mkdir %s", argv[0]);
+                                       die_errno(_("cannot mkdir %s"), argv[0]);
                                mkdir_tried = 1;
                                goto retry;
                        }
-                       die_errno("cannot chdir to %s", argv[0]);
+                       die_errno(_("cannot chdir to %s"), argv[0]);
                }
        } else if (0 < argc) {
                usage(init_db_usage[0]);
@@ -483,8 +551,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
        git_dir = getenv(GIT_DIR_ENVIRONMENT);
        work_tree = getenv(GIT_WORK_TREE_ENVIRONMENT);
        if ((!git_dir || is_bare_repository_cfg == 1) && work_tree)
-               die("%s (or --work-tree=<directory>) not allowed without "
-                   "specifying %s (or --git-dir=<directory>)",
+               die(_("%s (or --work-tree=<directory>) not allowed without "
+                         "specifying %s (or --git-dir=<directory>)"),
                    GIT_WORK_TREE_ENVIRONMENT,
                    GIT_DIR_ENVIRONMENT);
 
@@ -507,14 +575,14 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
                if (!git_work_tree_cfg) {
                        git_work_tree_cfg = xcalloc(PATH_MAX, 1);
                        if (!getcwd(git_work_tree_cfg, PATH_MAX))
-                               die_errno ("Cannot access current working directory");
+                               die_errno (_("Cannot access current working directory"));
                }
                if (work_tree)
                        set_git_work_tree(real_path(work_tree));
                else
                        set_git_work_tree(git_work_tree_cfg);
                if (access(get_git_work_tree(), X_OK))
-                       die_errno ("Cannot access work tree '%s'",
+                       die_errno (_("Cannot access work tree '%s'"),
                                   get_git_work_tree());
        }
        else {
@@ -522,7 +590,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
                        set_git_work_tree(real_path(work_tree));
        }
 
-       set_git_dir(real_path(git_dir));
+       set_git_dir_init(git_dir, real_git_dir, 1);
 
        return init_db(template_dir, flags);
 }
index 4a0f78dc7139ac529e60e7e1099834ff7efe1163..9db43edb063bbcb4da3b213d92d14b5c92aa4cfb 100644 (file)
@@ -101,7 +101,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
                        const char *v = skip_prefix(arg, "--decorate=");
                        decoration_style = parse_decoration_style(arg, v);
                        if (decoration_style < 0)
-                               die("invalid --decorate option: %s", arg);
+                               die(_("invalid --decorate option: %s"), arg);
                        decoration_given = 1;
                } else if (!strcmp(arg, "--no-decorate")) {
                        decoration_style = 0;
@@ -110,7 +110,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
                } else if (!strcmp(arg, "-h")) {
                        usage(builtin_log_usage);
                } else
-                       die("unrecognized argument: %s", arg);
+                       die(_("unrecognized argument: %s"), arg);
        }
 
        /*
@@ -153,7 +153,7 @@ static void show_early_header(struct rev_info *rev, const char *stage, int nr)
                if (rev->commit_format != CMIT_FMT_ONELINE)
                        putchar(rev->diffopt.line_termination);
        }
-       printf("Final output: %d %s\n", nr, stage);
+       printf(_("Final output: %d %s\n"), nr, stage);
 }
 
 static struct itimerval early_output_timer;
@@ -252,7 +252,7 @@ static int cmd_log_walk(struct rev_info *rev)
                setup_early_output(rev);
 
        if (prepare_revision_walk(rev))
-               die("revision walk setup failed");
+               die(_("revision walk setup failed"));
 
        if (rev->early_output)
                finish_early_output(rev);
@@ -349,7 +349,7 @@ static int show_object(const unsigned char *sha1, int show_tag_object,
        int offset = 0;
 
        if (!buf)
-               return error("Could not read object %s", sha1_to_hex(sha1));
+               return error(_("Could not read object %s"), sha1_to_hex(sha1));
 
        if (show_tag_object)
                while (offset < size && buf[offset] != '\n') {
@@ -436,7 +436,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
                                break;
                        o = parse_object(t->tagged->sha1);
                        if (!o)
-                               ret = error("Could not read object %s",
+                               ret = error(_("Could not read object %s"),
                                            sha1_to_hex(t->tagged->sha1));
                        objects[i].item = o;
                        i--;
@@ -460,7 +460,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
                        ret = cmd_log_walk(&rev);
                        break;
                default:
-                       ret = error("Unknown type: %d", o->type);
+                       ret = error(_("Unknown type: %d"), o->type);
                }
        }
        free(objects);
@@ -560,7 +560,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
 {
        if (!strcmp(var, "format.headers")) {
                if (!value)
-                       die("format.headers without value");
+                       die(_("format.headers without value"));
                add_header(value);
                return 0;
        }
@@ -632,7 +632,7 @@ static int reopen_stdout(struct commit *commit, struct rev_info *rev)
                strbuf_addstr(&filename, output_directory);
                if (filename.len >=
                    PATH_MAX - FORMAT_PATCH_NAME_MAX - suffix_len)
-                       return error("name of output directory is too long");
+                       return error(_("name of output directory is too long"));
                if (filename.buf[filename.len - 1] != '/')
                        strbuf_addch(&filename, '/');
        }
@@ -643,7 +643,7 @@ static int reopen_stdout(struct commit *commit, struct rev_info *rev)
                fprintf(realstdout, "%s\n", filename.buf + outdir_offset);
 
        if (freopen(filename.buf, "w", stdout) == NULL)
-               return error("Cannot open patch file %s", filename.buf);
+               return error(_("Cannot open patch file %s"), filename.buf);
 
        strbuf_release(&filename);
        return 0;
@@ -657,7 +657,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha
        unsigned flags1, flags2;
 
        if (rev->pending.nr != 2)
-               die("Need exactly one range.");
+               die(_("Need exactly one range."));
 
        o1 = rev->pending.objects[0].item;
        flags1 = o1->flags;
@@ -665,7 +665,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha
        flags2 = o2->flags;
 
        if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))
-               die("Not a range.");
+               die(_("Not a range."));
 
        init_patch_ids(ids);
 
@@ -676,7 +676,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha
        add_pending_object(&check_rev, o1, "o1");
        add_pending_object(&check_rev, o2, "o2");
        if (prepare_revision_walk(&check_rev))
-               die("revision walk setup failed");
+               die(_("revision walk setup failed"));
 
        while ((commit = get_revision(&check_rev)) != NULL) {
                /* ignore merges */
@@ -702,7 +702,7 @@ static void gen_message_id(struct rev_info *info, char *base)
        const char *email_end = strrchr(committer, '>');
        struct strbuf buf = STRBUF_INIT;
        if (!email_start || !email_end || email_start > email_end - 1)
-               die("Could not extract email from committer identity.");
+               die(_("Could not extract email from committer identity."));
        strbuf_addf(&buf, "%s.%lu.git.%.*s", base,
                    (unsigned long) time(NULL),
                    (int)(email_end - email_start - 1), email_start + 1);
@@ -734,7 +734,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
        struct commit *commit = NULL;
 
        if (rev->commit_format != CMIT_FMT_EMAIL)
-               die("Cover letter needs email format");
+               die(_("Cover letter needs email format"));
 
        committer = git_committer_info(0);
 
@@ -827,7 +827,7 @@ static const char *clean_message_id(const char *msg_id)
                m++;
        }
        if (!z)
-               die("insane in-reply-to: %s", msg_id);
+               die(_("insane in-reply-to: %s"), msg_id);
        if (++z == m)
                return a;
        return xmemdupz(a, z - a);
@@ -900,7 +900,7 @@ static int output_directory_callback(const struct option *opt, const char *arg,
 {
        const char **dir = (const char **)opt->value;
        if (*dir)
-               die("Two output directories?");
+               die(_("Two output directories?"));
        *dir = arg;
        return 0;
 }
@@ -1088,7 +1088,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                committer = git_committer_info(IDENT_ERROR_ON_NO_NAME);
                endpos = strchr(committer, '>');
                if (!endpos)
-                       die("bogus committer info %s", committer);
+                       die(_("bogus committer info %s"), committer);
                add_signoff = xmemdupz(committer, endpos - committer + 1);
        }
 
@@ -1133,20 +1133,20 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                numbered = 0;
 
        if (numbered && keep_subject)
-               die ("-n and -k are mutually exclusive.");
+               die (_("-n and -k are mutually exclusive."));
        if (keep_subject && subject_prefix)
-               die ("--subject-prefix and -k are mutually exclusive.");
+               die (_("--subject-prefix and -k are mutually exclusive."));
 
        argc = setup_revisions(argc, argv, &rev, &s_r_opt);
        if (argc > 1)
-               die ("unrecognized argument: %s", argv[1]);
+               die (_("unrecognized argument: %s"), argv[1]);
 
        if (rev.diffopt.output_format & DIFF_FORMAT_NAME)
-               die("--name-only does not make sense");
+               die(_("--name-only does not make sense"));
        if (rev.diffopt.output_format & DIFF_FORMAT_NAME_STATUS)
-               die("--name-status does not make sense");
+               die(_("--name-status does not make sense"));
        if (rev.diffopt.output_format & DIFF_FORMAT_CHECKDIFF)
-               die("--check does not make sense");
+               die(_("--check does not make sense"));
 
        if (!use_patch_format &&
                (!rev.diffopt.output_format ||
@@ -1169,9 +1169,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 
        if (output_directory) {
                if (use_stdout)
-                       die("standard output, or directory, which one?");
+                       die(_("standard output, or directory, which one?"));
                if (mkdir(output_directory, 0777) < 0 && errno != EEXIST)
-                       die_errno("Could not create directory '%s'",
+                       die_errno(_("Could not create directory '%s'"),
                                  output_directory);
        }
 
@@ -1225,7 +1225,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                realstdout = xfdopen(xdup(1), "w");
 
        if (prepare_revision_walk(&rev))
-               die("revision walk setup failed");
+               die(_("revision walk setup failed"));
        rev.boundary = 1;
        while ((commit = get_revision(&rev)) != NULL) {
                if (commit->object.flags & BOUNDARY) {
@@ -1306,7 +1306,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 
                if (!use_stdout && reopen_stdout(numbered_files ? NULL : commit,
                                                 &rev))
-                       die("Failed to create output files");
+                       die(_("Failed to create output files"));
                shown = log_tree_commit(&rev, commit);
                free(commit->buffer);
                commit->buffer = NULL;
@@ -1410,9 +1410,9 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
                if (!current_branch || !current_branch->merge
                                        || !current_branch->merge[0]
                                        || !current_branch->merge[0]->dst) {
-                       fprintf(stderr, "Could not find a tracked"
+                       fprintf(stderr, _("Could not find a tracked"
                                        " remote branch, please"
-                                       " specify <upstream> manually.\n");
+                                       " specify <upstream> manually.\n"));
                        usage_with_options(cherry_usage, options);
                }
 
@@ -1426,9 +1426,9 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
        DIFF_OPT_SET(&revs.diffopt, RECURSIVE);
 
        if (add_pending_commit(head, &revs, 0))
-               die("Unknown commit %s", head);
+               die(_("Unknown commit %s"), head);
        if (add_pending_commit(upstream, &revs, UNINTERESTING))
-               die("Unknown commit %s", upstream);
+               die(_("Unknown commit %s"), upstream);
 
        /* Don't say anything if head and upstream are the same. */
        if (revs.pending.nr == 2) {
@@ -1440,11 +1440,11 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
        get_patch_ids(&revs, &ids, prefix);
 
        if (limit && add_pending_commit(limit, &revs, UNINTERESTING))
-               die("Unknown commit %s", limit);
+               die(_("Unknown commit %s"), limit);
 
        /* reverse the list of commits */
        if (prepare_revision_walk(&revs))
-               die("revision walk setup failed");
+               die(_("revision walk setup failed"));
        while ((commit = get_revision(&revs)) != NULL) {
                /* ignore merges */
                if (commit->parents && commit->parents->next)
index aa3453c5e1c99c02d802bc77632ecedec4451c43..d54e7ddbb12286beb4f9622864f2eeaa79453d32 100644 (file)
@@ -25,6 +25,7 @@
 #include "help.h"
 #include "merge-recursive.h"
 #include "resolve-undo.h"
+#include "remote.h"
 
 #define DEFAULT_TWOHEAD (1<<0)
 #define DEFAULT_OCTOPUS (1<<1)
@@ -37,8 +38,9 @@ struct strategy {
 };
 
 static const char * const builtin_merge_usage[] = {
-       "git merge [options] <remote>...",
-       "git merge [options] <msg> HEAD <remote>",
+       "git merge [options] [<commit>...]",
+       "git merge [options] <msg> HEAD <commit>",
+       "git merge --abort",
        NULL
 };
 
@@ -59,6 +61,7 @@ static int verbosity;
 static int allow_rerere_auto;
 static int abort_current_merge;
 static int show_progress = -1;
+static int default_to_upstream;
 
 static struct strategy all_strategy[] = {
        { "recursive",  DEFAULT_TWOHEAD | NO_TRIVIAL },
@@ -81,7 +84,7 @@ static int option_parse_message(const struct option *opt,
                strbuf_addf(buf, "%s%s", buf->len ? "\n\n" : "", arg);
                have_message = 1;
        } else
-               return error("switch `m' requires a value");
+               return error(_("switch `m' requires a value"));
        return 0;
 }
 
@@ -118,13 +121,13 @@ static struct strategy *get_strategy(const char *name)
                exclude_cmds(&main_cmds, &not_strategies);
        }
        if (!is_in_cmdlist(&main_cmds, name) && !is_in_cmdlist(&other_cmds, name)) {
-               fprintf(stderr, "Could not find merge strategy '%s'.\n", name);
-               fprintf(stderr, "Available strategies are:");
+               fprintf(stderr, _("Could not find merge strategy '%s'.\n"), name);
+               fprintf(stderr, _("Available strategies are:"));
                for (i = 0; i < main_cmds.cnt; i++)
                        fprintf(stderr, " %s", main_cmds.names[i]->name);
                fprintf(stderr, ".\n");
                if (other_cmds.cnt) {
-                       fprintf(stderr, "Available custom strategies are:");
+                       fprintf(stderr, _("Available custom strategies are:"));
                        for (i = 0; i < other_cmds.cnt; i++)
                                fprintf(stderr, " %s", other_cmds.names[i]->name);
                        fprintf(stderr, ".\n");
@@ -226,17 +229,17 @@ static void save_state(void)
        cp.git_cmd = 1;
 
        if (start_command(&cp))
-               die("could not run stash.");
+               die(_("could not run stash."));
        len = strbuf_read(&buffer, cp.out, 1024);
        close(cp.out);
 
        if (finish_command(&cp) || len < 0)
-               die("stash failed");
+               die(_("stash failed"));
        else if (!len)
                return;
        strbuf_setlen(&buffer, buffer.len-1);
        if (get_sha1(buffer.buf, stash))
-               die("not a valid object: %s", buffer.buf);
+               die(_("not a valid object: %s"), buffer.buf);
 }
 
 static void read_empty(unsigned const char *sha1, int verbose)
@@ -254,7 +257,7 @@ static void read_empty(unsigned const char *sha1, int verbose)
        args[i] = NULL;
 
        if (run_command_v_opt(args, RUN_GIT_CMD))
-               die("read-tree failed");
+               die(_("read-tree failed"));
 }
 
 static void reset_hard(unsigned const char *sha1, int verbose)
@@ -271,7 +274,7 @@ static void reset_hard(unsigned const char *sha1, int verbose)
        args[i] = NULL;
 
        if (run_command_v_opt(args, RUN_GIT_CMD))
-               die("read-tree failed");
+               die(_("read-tree failed"));
 }
 
 static void restore_state(void)
@@ -300,7 +303,7 @@ static void restore_state(void)
 static void finish_up_to_date(const char *msg)
 {
        if (verbosity >= 0)
-               printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
+               printf("%s%s\n", squash ? _(" (nothing to squash)") : "", msg);
        drop_save();
 }
 
@@ -313,10 +316,10 @@ static void squash_message(void)
        int fd;
        struct pretty_print_context ctx = {0};
 
-       printf("Squash commit -- not updating HEAD\n");
+       printf(_("Squash commit -- not updating HEAD\n"));
        fd = open(git_path("SQUASH_MSG"), O_WRONLY | O_CREAT, 0666);
        if (fd < 0)
-               die_errno("Could not write to '%s'", git_path("SQUASH_MSG"));
+               die_errno(_("Could not write to '%s'"), git_path("SQUASH_MSG"));
 
        init_revisions(&rev, NULL);
        rev.ignore_merges = 1;
@@ -331,7 +334,7 @@ static void squash_message(void)
 
        setup_revisions(0, NULL, &rev, NULL);
        if (prepare_revision_walk(&rev))
-               die("revision walk setup failed");
+               die(_("revision walk setup failed"));
 
        ctx.abbrev = rev.abbrev;
        ctx.date_mode = rev.date_mode;
@@ -344,9 +347,9 @@ static void squash_message(void)
                pretty_print_commit(rev.commit_format, commit, &out, &ctx);
        }
        if (write(fd, out.buf, out.len) < 0)
-               die_errno("Writing SQUASH_MSG");
+               die_errno(_("Writing SQUASH_MSG"));
        if (close(fd))
-               die_errno("Finishing SQUASH_MSG");
+               die_errno(_("Finishing SQUASH_MSG"));
        strbuf_release(&out);
 }
 
@@ -366,7 +369,7 @@ static void finish(const unsigned char *new_head, const char *msg)
                squash_message();
        } else {
                if (verbosity >= 0 && !merge_msg.len)
-                       printf("No merge message -- not updating HEAD\n");
+                       printf(_("No merge message -- not updating HEAD\n"));
                else {
                        const char *argv_gc_auto[] = { "gc", "--auto", NULL };
                        update_ref(reflog_message.buf, "HEAD",
@@ -388,7 +391,7 @@ static void finish(const unsigned char *new_head, const char *msg)
                if (diff_use_color_default > 0)
                        DIFF_OPT_SET(&opts, COLOR_DIFF);
                if (diff_setup_done(&opts) < 0)
-                       die("diff_setup_done failed");
+                       die(_("diff_setup_done failed"));
                diff_tree_sha1(head, new_head, "", &opts);
                diffcore_std(&opts);
                diff_flush(&opts);
@@ -417,7 +420,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
        memset(branch_head, 0, sizeof(branch_head));
        remote_head = peel_to_type(remote, 0, NULL, OBJ_COMMIT);
        if (!remote_head)
-               die("'%s' does not point to a commit", remote);
+               die(_("'%s' does not point to a commit"), remote);
 
        if (dwim_ref(remote, strlen(remote), branch_head, &found_ref) > 0) {
                if (!prefixcmp(found_ref, "refs/heads/")) {
@@ -482,7 +485,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
 
                fp = fopen(git_path("FETCH_HEAD"), "r");
                if (!fp)
-                       die_errno("could not open '%s' for reading",
+                       die_errno(_("could not open '%s' for reading"),
                                  git_path("FETCH_HEAD"));
                strbuf_getline(&line, fp, '\n');
                fclose(fp);
@@ -512,7 +515,7 @@ static int git_merge_config(const char *k, const char *v, void *cb)
                buf = xstrdup(v);
                argc = split_cmdline(buf, &argv);
                if (argc < 0)
-                       die("Bad branch.%s.mergeoptions string: %s", branch,
+                       die(_("Bad branch.%s.mergeoptions string: %s"), branch,
                            split_cmdline_strerror(argc));
                argv = xrealloc(argv, sizeof(*argv) * (argc + 2));
                memmove(argv + 1, argv, sizeof(*argv) * (argc + 1));
@@ -534,10 +537,13 @@ static int git_merge_config(const char *k, const char *v, void *cb)
                int is_bool;
                shortlog_len = git_config_bool_or_int(k, v, &is_bool);
                if (!is_bool && shortlog_len < 0)
-                       return error("%s: negative length %s", k, v);
+                       return error(_("%s: negative length %s"), k, v);
                if (is_bool && shortlog_len)
                        shortlog_len = DEFAULT_MERGE_LOG_LEN;
                return 0;
+       } else if (!strcmp(k, "merge.defaulttoupstream")) {
+               default_to_upstream = git_config_bool(k, v);
+               return 0;
        }
        return git_diff_ui_config(k, v, cb);
 }
@@ -581,7 +587,7 @@ static int read_tree_trivial(unsigned char *common, unsigned char *head,
 static void write_tree_trivial(unsigned char *sha1)
 {
        if (write_cache_as_tree(sha1, 0, NULL))
-               die("git write-tree failed to write a tree");
+               die(_("git write-tree failed to write a tree"));
 }
 
 int try_merge_command(const char *strategy, size_t xopts_nr,
@@ -623,7 +629,7 @@ int try_merge_command(const char *strategy, size_t xopts_nr,
        free(args);
        discard_cache();
        if (read_cache() < 0)
-               die("failed to read the cache");
+               die(_("failed to read the cache"));
        resolve_undo_clear();
 
        return ret;
@@ -640,7 +646,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
        if (active_cache_changed &&
                        (write_cache(index_fd, active_cache, active_nr) ||
                         commit_locked_index(lock)))
-               return error("Unable to write index.");
+               return error(_("Unable to write index."));
        rollback_lock_file(lock);
 
        if (!strcmp(strategy, "recursive") || !strcmp(strategy, "subtree")) {
@@ -653,7 +659,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
                struct commit_list *j;
 
                if (remoteheads->next) {
-                       error("Not handling anything other than two heads merge.");
+                       error(_("Not handling anything other than two heads merge."));
                        return 2;
                }
 
@@ -667,7 +673,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
 
                for (x = 0; x < xopts_nr; x++)
                        if (parse_merge_opt(&o, xopts[x]))
-                               die("Unknown option for merge-recursive: -X%s", xopts[x]);
+                               die(_("Unknown option for merge-recursive: -X%s"), xopts[x]);
 
                o.branch1 = head_arg;
                o.branch2 = remoteheads->item->util;
@@ -681,7 +687,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
                if (active_cache_changed &&
                                (write_cache(index_fd, active_cache, active_nr) ||
                                 commit_locked_index(lock)))
-                       die ("unable to write %s", get_index_file());
+                       die (_("unable to write %s"), get_index_file());
                rollback_lock_file(lock);
                return clean ? 0 : 1;
        } else {
@@ -753,7 +759,7 @@ int checkout_fast_forward(const unsigned char *head, const unsigned char *remote
                return -1;
        if (write_cache(fd, active_cache, active_nr) ||
                commit_locked_index(lock_file))
-               die("unable to write new index file");
+               die(_("unable to write new index file"));
        return 0;
 }
 
@@ -805,10 +811,10 @@ static void write_merge_msg(void)
 {
        int fd = open(git_path("MERGE_MSG"), O_WRONLY | O_CREAT, 0666);
        if (fd < 0)
-               die_errno("Could not open '%s' for writing",
+               die_errno(_("Could not open '%s' for writing"),
                          git_path("MERGE_MSG"));
        if (write_in_full(fd, merge_msg.buf, merge_msg.len) != merge_msg.len)
-               die_errno("Could not write to '%s'", git_path("MERGE_MSG"));
+               die_errno(_("Could not write to '%s'"), git_path("MERGE_MSG"));
        close(fd);
 }
 
@@ -833,7 +839,7 @@ static int merge_trivial(void)
        struct commit_list *parent = xmalloc(sizeof(*parent));
 
        write_tree_trivial(result_tree);
-       printf("Wonderful.\n");
+       printf(_("Wonderful.\n"));
        parent->item = lookup_commit(head);
        parent->next = xmalloc(sizeof(*parent->next));
        parent->next->item = remoteheads->item;
@@ -884,7 +890,7 @@ static int suggest_conflicts(int renormalizing)
 
        fp = fopen(git_path("MERGE_MSG"), "a");
        if (!fp)
-               die_errno("Could not open '%s' for writing",
+               die_errno(_("Could not open '%s' for writing"),
                          git_path("MERGE_MSG"));
        fprintf(fp, "\nConflicts:\n");
        for (pos = 0; pos < active_nr; pos++) {
@@ -900,8 +906,8 @@ static int suggest_conflicts(int renormalizing)
        }
        fclose(fp);
        rerere(allow_rerere_auto);
-       printf("Automatic merge failed; "
-                       "fix conflicts and then commit the result.\n");
+       printf(_("Automatic merge failed; "
+                       "fix conflicts and then commit the result.\n"));
        return 1;
 }
 
@@ -915,7 +921,7 @@ static struct commit *is_old_style_invocation(int argc, const char **argv)
                        return NULL;
                second_token = lookup_commit_reference_gently(second_sha1, 0);
                if (!second_token)
-                       die("'%s' is not a commit", argv[1]);
+                       die(_("'%s' is not a commit"), argv[1]);
                if (hashcmp(second_token->object.sha1, head))
                        return NULL;
        }
@@ -945,6 +951,35 @@ static int evaluate_result(void)
        return cnt;
 }
 
+/*
+ * Pretend as if the user told us to merge with the tracking
+ * branch we have for the upstream of the current branch
+ */
+static int setup_with_upstream(const char ***argv)
+{
+       struct branch *branch = branch_get(NULL);
+       int i;
+       const char **args;
+
+       if (!branch)
+               die("No current branch.");
+       if (!branch->remote)
+               die("No remote for the current branch.");
+       if (!branch->merge_nr)
+               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",
+                           branch->merge[i]->src, branch->remote_name);
+               args[i] = branch->merge[i]->dst;
+       }
+       args[i] = NULL;
+       *argv = args;
+       return i;
+}
+
 int cmd_merge(int argc, const char **argv, const char *prefix)
 {
        unsigned char result_tree[20];
@@ -986,7 +1021,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                const char *nargv[] = {"reset", "--merge", NULL};
 
                if (!file_exists(git_path("MERGE_HEAD")))
-                       die("There is no merge to abort (MERGE_HEAD missing).");
+                       die(_("There is no merge to abort (MERGE_HEAD missing)."));
 
                /* Invoke 'git reset --merge' */
                return cmd_reset(nargc, nargv, prefix);
@@ -1001,10 +1036,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                 * add/rm <file>', just 'git commit'.
                 */
                if (advice_resolve_conflict)
-                       die("You have not concluded your merge (MERGE_HEAD exists).\n"
-                           "Please, commit your changes before you can merge.");
+                       die(_("You have not concluded your merge (MERGE_HEAD exists).\n"
+                                 "Please, commit your changes before you can merge."));
                else
-                       die("You have not concluded your merge (MERGE_HEAD exists).");
+                       die(_("You have not concluded your merge (MERGE_HEAD exists)."));
        }
        if (file_exists(git_path("CHERRY_PICK_HEAD"))) {
                if (advice_resolve_conflict)
@@ -1020,12 +1055,15 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 
        if (squash) {
                if (!allow_fast_forward)
-                       die("You cannot combine --squash with --no-ff.");
+                       die(_("You cannot combine --squash with --no-ff."));
                option_commit = 0;
        }
 
        if (!allow_fast_forward && fast_forward_only)
-               die("You cannot combine --no-ff with --ff-only.");
+               die(_("You cannot combine --no-ff with --ff-only."));
+
+       if (!argc && !abort_current_merge && default_to_upstream)
+               argc = setup_with_upstream(&argv);
 
        if (!argc)
                usage_with_options(builtin_merge_usage,
@@ -1053,19 +1091,19 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                 * We do the same for "git pull".
                 */
                if (argc != 1)
-                       die("Can merge only exactly one commit into "
-                               "empty head");
+                       die(_("Can merge only exactly one commit into "
+                               "empty head"));
                if (squash)
-                       die("Squash commit into empty head not supported yet");
+                       die(_("Squash commit into empty head not supported yet"));
                if (!allow_fast_forward)
-                       die("Non-fast-forward commit does not make sense into "
-                           "an empty head");
+                       die(_("Non-fast-forward commit does not make sense into "
+                           "an empty head"));
                remote_head = peel_to_type(argv[0], 0, NULL, OBJ_COMMIT);
                if (!remote_head)
-                       die("%s - not something we can merge", argv[0]);
+                       die(_("%s - not something we can merge"), argv[0]);
+               read_empty(remote_head->sha1, 0);
                update_ref("initial pull", "HEAD", remote_head->sha1, NULL, 0,
                                DIE_ON_ERR);
-               read_empty(remote_head->sha1, 0);
                return 0;
        } else {
                struct strbuf merge_names = STRBUF_INIT;
@@ -1108,7 +1146,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 
                o = peel_to_type(argv[i], 0, NULL, OBJ_COMMIT);
                if (!o)
-                       die("%s - not something we can merge", argv[i]);
+                       die(_("%s - not something we can merge"), argv[i]);
                commit = lookup_commit(o->sha1);
                commit->util = (void *)argv[i];
                remotes = &commit_list_insert(commit, remotes)->next;
@@ -1166,7 +1204,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                strcpy(hex, find_unique_abbrev(head, DEFAULT_ABBREV));
 
                if (verbosity >= 0)
-                       printf("Updating %s..%s\n",
+                       printf(_("Updating %s..%s\n"),
                                hex,
                                find_unique_abbrev(remoteheads->item->object.sha1,
                                DEFAULT_ABBREV));
@@ -1200,11 +1238,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                if (allow_trivial && !fast_forward_only) {
                        /* See if it is really trivial. */
                        git_committer_info(IDENT_ERROR_ON_NO_NAME);
-                       printf("Trying really trivial in-index merge...\n");
+                       printf(_("Trying really trivial in-index merge...\n"));
                        if (!read_tree_trivial(common->item->object.sha1,
                                        head, remoteheads->item->object.sha1))
                                return merge_trivial();
-                       printf("Nope.\n");
+                       printf(_("Nope.\n"));
                }
        } else {
                /*
@@ -1237,7 +1275,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
        }
 
        if (fast_forward_only)
-               die("Not possible to fast-forward, aborting.");
+               die(_("Not possible to fast-forward, aborting."));
 
        /* We are going to make a new commit. */
        git_committer_info(IDENT_ERROR_ON_NO_NAME);
@@ -1263,11 +1301,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
        for (i = 0; i < use_strategies_nr; i++) {
                int ret;
                if (i) {
-                       printf("Rewinding the tree to pristine...\n");
+                       printf(_("Rewinding the tree to pristine...\n"));
                        restore_state();
                }
                if (use_strategies_nr != 1)
-                       printf("Trying merge strategy %s...\n",
+                       printf(_("Trying merge strategy %s...\n"),
                                use_strategies[i]->name);
                /*
                 * Remember which strategy left the state in the working
@@ -1328,17 +1366,17 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                restore_state();
                if (use_strategies_nr > 1)
                        fprintf(stderr,
-                               "No merge strategy handled the merge.\n");
+                               _("No merge strategy handled the merge.\n"));
                else
-                       fprintf(stderr, "Merge with strategy %s failed.\n",
+                       fprintf(stderr, _("Merge with strategy %s failed.\n"),
                                use_strategies[0]->name);
                return 2;
        } else if (best_strategy == wt_strategy)
                ; /* We already have its result in the working tree. */
        else {
-               printf("Rewinding the tree to pristine...\n");
+               printf(_("Rewinding the tree to pristine...\n"));
                restore_state();
-               printf("Using the %s to prepare resolving by hand.\n",
+               printf(_("Using the %s to prepare resolving by hand.\n"),
                        best_strategy);
                try_merge_strategy(best_strategy, common, head_arg);
        }
@@ -1354,28 +1392,28 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                                sha1_to_hex(j->item->object.sha1));
                fd = open(git_path("MERGE_HEAD"), O_WRONLY | O_CREAT, 0666);
                if (fd < 0)
-                       die_errno("Could not open '%s' for writing",
+                       die_errno(_("Could not open '%s' for writing"),
                                  git_path("MERGE_HEAD"));
                if (write_in_full(fd, buf.buf, buf.len) != buf.len)
-                       die_errno("Could not write to '%s'", git_path("MERGE_HEAD"));
+                       die_errno(_("Could not write to '%s'"), git_path("MERGE_HEAD"));
                close(fd);
                strbuf_addch(&merge_msg, '\n');
                write_merge_msg();
                fd = open(git_path("MERGE_MODE"), O_WRONLY | O_CREAT | O_TRUNC, 0666);
                if (fd < 0)
-                       die_errno("Could not open '%s' for writing",
+                       die_errno(_("Could not open '%s' for writing"),
                                  git_path("MERGE_MODE"));
                strbuf_reset(&buf);
                if (!allow_fast_forward)
                        strbuf_addf(&buf, "no-ff");
                if (write_in_full(fd, buf.buf, buf.len) != buf.len)
-                       die_errno("Could not write to '%s'", git_path("MERGE_MODE"));
+                       die_errno(_("Could not write to '%s'"), git_path("MERGE_MODE"));
                close(fd);
        }
 
        if (merge_was_ok) {
-               fprintf(stderr, "Automatic merge went well; "
-                       "stopped before committing as requested\n");
+               fprintf(stderr, _("Automatic merge went well; "
+                       "stopped before committing as requested\n"));
                return 0;
        } else
                return suggest_conflicts(option_renormalize);
index 93e8995d9e704faa041f97f92ba72dabe7839d81..40f33ca4d0e6d0bb1733e0544029c6f588d09b59 100644 (file)
@@ -74,7 +74,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 
        newfd = hold_locked_index(&lock_file, 1);
        if (read_cache() < 0)
-               die("index file corrupt");
+               die(_("index file corrupt"));
 
        source = copy_pathspec(prefix, argv, argc, 0);
        modes = xcalloc(argc, sizeof(enum update_mode));
@@ -100,17 +100,17 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                const char *bad = NULL;
 
                if (show_only)
-                       printf("Checking rename of '%s' to '%s'\n", src, dst);
+                       printf(_("Checking rename of '%s' to '%s'\n"), src, dst);
 
                length = strlen(src);
                if (lstat(src, &st) < 0)
-                       bad = "bad source";
+                       bad = _("bad source");
                else if (!strncmp(src, dst, length) &&
                                (dst[length] == 0 || dst[length] == '/')) {
-                       bad = "can not move directory into itself";
+                       bad = _("can not move directory into itself");
                } else if ((src_is_dir = S_ISDIR(st.st_mode))
                                && lstat(dst, &st) == 0)
-                       bad = "cannot move directory over file";
+                       bad = _("cannot move directory over file");
                else if (src_is_dir) {
                        const char *src_w_slash = add_slash(src);
                        int len_w_slash = length + 1;
@@ -120,7 +120,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 
                        first = cache_name_pos(src_w_slash, len_w_slash);
                        if (first >= 0)
-                               die ("Huh? %.*s is in index?",
+                               die (_("Huh? %.*s is in index?"),
                                                len_w_slash, src_w_slash);
 
                        first = -1 - first;
@@ -132,7 +132,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                        free((char *)src_w_slash);
 
                        if (last - first < 1)
-                               bad = "source directory is empty";
+                               bad = _("source directory is empty");
                        else {
                                int j, dst_len;
 
@@ -163,22 +163,22 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                                argc += last - first;
                        }
                } else if (cache_name_pos(src, length) < 0)
-                       bad = "not under version control";
+                       bad = _("not under version control");
                else if (lstat(dst, &st) == 0) {
-                       bad = "destination exists";
+                       bad = _("destination exists");
                        if (force) {
                                /*
                                 * only files can overwrite each other:
                                 * check both source and destination
                                 */
                                if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
-                                       warning("%s; will overwrite!", bad);
+                                       warning(_("%s; will overwrite!"), bad);
                                        bad = NULL;
                                } else
-                                       bad = "Cannot overwrite";
+                                       bad = _("Cannot overwrite");
                        }
                } else if (string_list_has_string(&src_for_dst, dst))
-                       bad = "multiple sources for the same target";
+                       bad = _("multiple sources for the same target");
                else
                        string_list_insert(&src_for_dst, dst);
 
@@ -193,7 +193,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                                        i--;
                                }
                        } else
-                               die ("%s, source=%s, destination=%s",
+                               die (_("%s, source=%s, destination=%s"),
                                     bad, src, dst);
                }
        }
@@ -203,10 +203,10 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                enum update_mode mode = modes[i];
                int pos;
                if (show_only || verbose)
-                       printf("Renaming %s to %s\n", src, dst);
+                       printf(_("Renaming %s to %s\n"), src, dst);
                if (!show_only && mode != INDEX &&
                                rename(src, dst) < 0 && !ignore_errors)
-                       die_errno ("renaming '%s' failed", src);
+                       die_errno (_("renaming '%s' failed"), src);
 
                if (mode == WORKING_DIRECTORY)
                        continue;
@@ -220,7 +220,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
        if (active_cache_changed) {
                if (write_cache(newfd, active_cache, active_nr) ||
                    commit_locked_index(&lock_file))
-                       die("Unable to write new index file");
+                       die(_("Unable to write new index file"));
        }
 
        return 0;
index a0f310b72956dcb00d2a0899d39ddfb9f7811fa4..d6dcfcb0149ab6dc45f4a71e21cf77d13b494e18 100644 (file)
@@ -146,13 +146,13 @@ static void write_commented_object(int fd, const unsigned char *object)
        show.err = 0;
        show.git_cmd = 1;
        if (start_command(&show))
-               die("unable to start 'show' for object '%s'",
+               die(_("unable to start 'show' for object '%s'"),
                    sha1_to_hex(object));
 
        /* Open the output as FILE* so strbuf_getline() can be used. */
        show_out = xfdopen(show.out, "r");
        if (show_out == NULL)
-               die_errno("can't fdopen 'show' output fd");
+               die_errno(_("can't fdopen 'show' output fd"));
 
        /* Prepend "# " to each output line and write result to 'fd' */
        while (strbuf_getline(&buf, show_out, '\n') != EOF) {
@@ -162,10 +162,10 @@ static void write_commented_object(int fd, const unsigned char *object)
        }
        strbuf_release(&buf);
        if (fclose(show_out))
-               die_errno("failed to close pipe to 'show' for object '%s'",
+               die_errno(_("failed to close pipe to 'show' for object '%s'"),
                          sha1_to_hex(object));
        if (finish_command(&show))
-               die("failed to finish 'show' for object '%s'",
+               die(_("failed to finish 'show' for object '%s'"),
                    sha1_to_hex(object));
 }
 
@@ -182,7 +182,7 @@ static void create_note(const unsigned char *object, struct msg_arg *msg,
                path = git_pathdup("NOTES_EDITMSG");
                fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
                if (fd < 0)
-                       die_errno("could not create file '%s'", path);
+                       die_errno(_("could not create file '%s'"), path);
 
                if (msg->given)
                        write_or_die(fd, msg->buf.buf, msg->buf.len);
@@ -196,8 +196,8 @@ static void create_note(const unsigned char *object, struct msg_arg *msg,
                strbuf_reset(&(msg->buf));
 
                if (launch_editor(path, &(msg->buf), NULL)) {
-                       die("Please supply the note contents using either -m" \
-                           " or -F option");
+                       die(_("Please supply the note contents using either -m" \
+                           " or -F option"));
                }
                stripspace(&(msg->buf), 1);
        }
@@ -217,14 +217,14 @@ static void create_note(const unsigned char *object, struct msg_arg *msg,
        }
 
        if (!msg->buf.len) {
-               fprintf(stderr, "Removing note for object %s\n",
+               fprintf(stderr, _("Removing note for object %s\n"),
                        sha1_to_hex(object));
                hashclr(result);
        } else {
                if (write_sha1_file(msg->buf.buf, msg->buf.len, blob_type, result)) {
-                       error("unable to write note object");
+                       error(_("unable to write note object"));
                        if (path)
-                               error("The note contents has been left in %s",
+                               error(_("The note contents has been left in %s"),
                                      path);
                        exit(128);
                }
@@ -258,9 +258,9 @@ static int parse_file_arg(const struct option *opt, const char *arg, int unset)
                strbuf_addch(&(msg->buf), '\n');
        if (!strcmp(arg, "-")) {
                if (strbuf_read(&(msg->buf), 0, 1024) < 0)
-                       die_errno("cannot read '%s'", arg);
+                       die_errno(_("cannot read '%s'"), arg);
        } else if (strbuf_read_file(&(msg->buf), arg, 1024) < 0)
-               die_errno("could not open or read '%s'", arg);
+               die_errno(_("could not open or read '%s'"), arg);
        stripspace(&(msg->buf), 0);
 
        msg->given = 1;
@@ -279,10 +279,10 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
                strbuf_addch(&(msg->buf), '\n');
 
        if (get_sha1(arg, object))
-               die("Failed to resolve '%s' as a valid ref.", arg);
+               die(_("Failed to resolve '%s' as a valid ref."), arg);
        if (!(buf = read_sha1_file(object, &type, &len)) || !len) {
                free(buf);
-               die("Failed to read object '%s'.", arg);;
+               die(_("Failed to read object '%s'."), arg);;
        }
        strbuf_add(&(msg->buf), buf, len);
        free(buf);
@@ -306,7 +306,7 @@ void commit_notes(struct notes_tree *t, const char *msg)
        if (!t)
                t = &default_notes_tree;
        if (!t->initialized || !t->ref || !*t->ref)
-               die("Cannot commit uninitialized/unreferenced notes tree");
+               die(_("Cannot commit uninitialized/unreferenced notes tree"));
        if (!t->dirty)
                return; /* don't have to commit an unchanged tree */
 
@@ -347,7 +347,7 @@ static int notes_rewrite_config(const char *k, const char *v, void *cb)
                        config_error_nonbool(k);
                c->combine = parse_combine_notes_fn(v);
                if (!c->combine) {
-                       error("Bad notes.rewriteMode value: '%s'", v);
+                       error(_("Bad notes.rewriteMode value: '%s'"), v);
                        return 1;
                }
                return 0;
@@ -357,8 +357,8 @@ static int notes_rewrite_config(const char *k, const char *v, void *cb)
                if (!prefixcmp(v, "refs/notes/"))
                        string_list_add_refs_by_glob(c->refs, v);
                else
-                       warning("Refusing to rewrite notes in %s"
-                               " (outside of refs/notes/)", v);
+                       warning(_("Refusing to rewrite notes in %s"
+                               " (outside of refs/notes/)"), v);
                return 0;
        }
 
@@ -382,8 +382,10 @@ struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd)
                c->mode_from_env = 1;
                c->combine = parse_combine_notes_fn(rewrite_mode_env);
                if (!c->combine)
-                       error("Bad " GIT_NOTES_REWRITE_MODE_ENVIRONMENT
-                             " value: '%s'", rewrite_mode_env);
+                       /* TRANSLATORS: The first %s is the name of the
+                          environment variable, the second %s is its value */
+                       error(_("Bad %s value: '%s'"), GIT_NOTES_REWRITE_MODE_ENVIRONMENT,
+                                       rewrite_mode_env);
        }
        if (rewrite_refs_env) {
                c->refs_from_env = 1;
@@ -446,13 +448,13 @@ static int notes_copy_from_stdin(int force, const char *rewrite_cmd)
 
                split = strbuf_split(&buf, ' ');
                if (!split[0] || !split[1])
-                       die("Malformed input line: '%s'.", buf.buf);
+                       die(_("Malformed input line: '%s'."), buf.buf);
                strbuf_rtrim(split[0]);
                strbuf_rtrim(split[1]);
                if (get_sha1(split[0]->buf, from_obj))
-                       die("Failed to resolve '%s' as a valid ref.", split[0]->buf);
+                       die(_("Failed to resolve '%s' as a valid ref."), split[0]->buf);
                if (get_sha1(split[1]->buf, to_obj))
-                       die("Failed to resolve '%s' as a valid ref.", split[1]->buf);
+                       die(_("Failed to resolve '%s' as a valid ref."), split[1]->buf);
 
                if (rewrite_cmd)
                        err = copy_note_for_rewrite(c, from_obj, to_obj);
@@ -461,7 +463,7 @@ static int notes_copy_from_stdin(int force, const char *rewrite_cmd)
                                        combine_notes_overwrite);
 
                if (err) {
-                       error("Failed to copy notes from '%s' to '%s'",
+                       error(_("Failed to copy notes from '%s' to '%s'"),
                              split[0]->buf, split[1]->buf);
                        ret = 1;
                }
@@ -505,20 +507,20 @@ static int list(int argc, const char **argv, const char *prefix)
                                     git_notes_list_usage, 0);
 
        if (1 < argc) {
-               error("too many parameters");
+               error(_("too many parameters"));
                usage_with_options(git_notes_list_usage, options);
        }
 
        t = init_notes_check("list");
        if (argc) {
                if (get_sha1(argv[0], object))
-                       die("Failed to resolve '%s' as a valid ref.", argv[0]);
+                       die(_("Failed to resolve '%s' as a valid ref."), argv[0]);
                note = get_note(t, object);
                if (note) {
                        puts(sha1_to_hex(note));
                        retval = 0;
                } else
-                       retval = error("No note found for object %s.",
+                       retval = error(_("No note found for object %s."),
                                       sha1_to_hex(object));
        } else
                retval = for_each_note(t, 0, list_each_note, NULL);
@@ -557,26 +559,26 @@ static int add(int argc, const char **argv, const char *prefix)
                             0);
 
        if (1 < argc) {
-               error("too many parameters");
+               error(_("too many parameters"));
                usage_with_options(git_notes_add_usage, options);
        }
 
        object_ref = argc ? argv[0] : "HEAD";
 
        if (get_sha1(object_ref, object))
-               die("Failed to resolve '%s' as a valid ref.", object_ref);
+               die(_("Failed to resolve '%s' as a valid ref."), object_ref);
 
        t = init_notes_check("add");
        note = get_note(t, object);
 
        if (note) {
                if (!force) {
-                       retval = error("Cannot add notes. Found existing notes "
+                       retval = error(_("Cannot add notes. Found existing notes "
                                       "for object %s. Use '-f' to overwrite "
-                                      "existing notes", sha1_to_hex(object));
+                                      "existing notes"), sha1_to_hex(object));
                        goto out;
                }
-               fprintf(stderr, "Overwriting existing notes for object %s\n",
+               fprintf(stderr, _("Overwriting existing notes for object %s\n"),
                        sha1_to_hex(object));
        }
 
@@ -618,7 +620,7 @@ static int copy(int argc, const char **argv, const char *prefix)
 
        if (from_stdin || rewrite_cmd) {
                if (argc) {
-                       error("too many parameters");
+                       error(_("too many parameters"));
                        usage_with_options(git_notes_copy_usage, options);
                } else {
                        return notes_copy_from_stdin(force, rewrite_cmd);
@@ -626,41 +628,41 @@ static int copy(int argc, const char **argv, const char *prefix)
        }
 
        if (argc < 2) {
-               error("too few parameters");
+               error(_("too few parameters"));
                usage_with_options(git_notes_copy_usage, options);
        }
        if (2 < argc) {
-               error("too many parameters");
+               error(_("too many parameters"));
                usage_with_options(git_notes_copy_usage, options);
        }
 
        if (get_sha1(argv[0], from_obj))
-               die("Failed to resolve '%s' as a valid ref.", argv[0]);
+               die(_("Failed to resolve '%s' as a valid ref."), argv[0]);
 
        object_ref = 1 < argc ? argv[1] : "HEAD";
 
        if (get_sha1(object_ref, object))
-               die("Failed to resolve '%s' as a valid ref.", object_ref);
+               die(_("Failed to resolve '%s' as a valid ref."), object_ref);
 
        t = init_notes_check("copy");
        note = get_note(t, object);
 
        if (note) {
                if (!force) {
-                       retval = error("Cannot copy notes. Found existing "
+                       retval = error(_("Cannot copy notes. Found existing "
                                       "notes for object %s. Use '-f' to "
-                                      "overwrite existing notes",
+                                      "overwrite existing notes"),
                                       sha1_to_hex(object));
                        goto out;
                }
-               fprintf(stderr, "Overwriting existing notes for object %s\n",
+               fprintf(stderr, _("Overwriting existing notes for object %s\n"),
                        sha1_to_hex(object));
        }
 
        from_note = get_note(t, from_obj);
        if (!from_note) {
-               retval = error("Missing notes on source object %s. Cannot "
-                              "copy.", sha1_to_hex(from_obj));
+               retval = error(_("Missing notes on source object %s. Cannot "
+                              "copy."), sha1_to_hex(from_obj));
                goto out;
        }
 
@@ -703,19 +705,19 @@ static int append_edit(int argc, const char **argv, const char *prefix)
                             PARSE_OPT_KEEP_ARGV0);
 
        if (2 < argc) {
-               error("too many parameters");
+               error(_("too many parameters"));
                usage_with_options(usage, options);
        }
 
        if (msg.given && edit)
-               fprintf(stderr, "The -m/-F/-c/-C options have been deprecated "
+               fprintf(stderr, _("The -m/-F/-c/-C options have been deprecated "
                        "for the 'edit' subcommand.\n"
-                       "Please use 'git notes add -f -m/-F/-c/-C' instead.\n");
+                       "Please use 'git notes add -f -m/-F/-c/-C' instead.\n"));
 
        object_ref = 1 < argc ? argv[1] : "HEAD";
 
        if (get_sha1(object_ref, object))
-               die("Failed to resolve '%s' as a valid ref.", object_ref);
+               die(_("Failed to resolve '%s' as a valid ref."), object_ref);
 
        t = init_notes_check(argv[0]);
        note = get_note(t, object);
@@ -750,20 +752,20 @@ static int show(int argc, const char **argv, const char *prefix)
                             0);
 
        if (1 < argc) {
-               error("too many parameters");
+               error(_("too many parameters"));
                usage_with_options(git_notes_show_usage, options);
        }
 
        object_ref = argc ? argv[0] : "HEAD";
 
        if (get_sha1(object_ref, object))
-               die("Failed to resolve '%s' as a valid ref.", object_ref);
+               die(_("Failed to resolve '%s' as a valid ref."), object_ref);
 
        t = init_notes_check("show");
        note = get_note(t, object);
 
        if (!note)
-               retval = error("No note found for object %s.",
+               retval = error(_("No note found for object %s."),
                               sha1_to_hex(object));
        else {
                const char *show_args[3] = {"show", sha1_to_hex(note), NULL};
@@ -961,22 +963,22 @@ static int remove_cmd(int argc, const char **argv, const char *prefix)
                             git_notes_remove_usage, 0);
 
        if (1 < argc) {
-               error("too many parameters");
+               error(_("too many parameters"));
                usage_with_options(git_notes_remove_usage, options);
        }
 
        object_ref = argc ? argv[0] : "HEAD";
 
        if (get_sha1(object_ref, object))
-               die("Failed to resolve '%s' as a valid ref.", object_ref);
+               die(_("Failed to resolve '%s' as a valid ref."), object_ref);
 
        t = init_notes_check("remove");
 
        retval = remove_note(t, object);
        if (retval)
-               fprintf(stderr, "Object %s has no note\n", sha1_to_hex(object));
+               fprintf(stderr, _("Object %s has no note\n"), sha1_to_hex(object));
        else {
-               fprintf(stderr, "Removing note for object %s\n",
+               fprintf(stderr, _("Removing note for object %s\n"),
                        sha1_to_hex(object));
 
                commit_notes(t, "Notes removed by 'git notes remove'");
@@ -999,7 +1001,7 @@ static int prune(int argc, const char **argv, const char *prefix)
                             0);
 
        if (argc) {
-               error("too many parameters");
+               error(_("too many parameters"));
                usage_with_options(git_notes_prune_usage, options);
        }
 
@@ -1069,7 +1071,7 @@ int cmd_notes(int argc, const char **argv, const char *prefix)
        else if (!strcmp(argv[0], "get-ref"))
                result = get_ref(argc, argv, prefix);
        else {
-               result = error("Unknown subcommand: %s", argv[0]);
+               result = error(_("Unknown subcommand: %s"), argv[0]);
                usage_with_options(git_notes_usage, options);
        }
 
index 6f6a66f9862d5ee5eaf4a4ce07934832569eacf9..9cebf9ea234d968eab638f7dcdc65370f77c0047 100644 (file)
@@ -40,7 +40,7 @@ static void set_refspecs(const char **refs, int nr)
                        char *tag;
                        int len;
                        if (nr <= ++i)
-                               die("tag shorthand without <tag>");
+                               die(_("tag shorthand without <tag>"));
                        len = strlen(refs[i]) + 11;
                        if (deleterefs) {
                                tag = xmalloc(len+1);
@@ -59,7 +59,7 @@ static void set_refspecs(const char **refs, int nr)
                        strcat(delref, ref);
                        ref = delref;
                } else if (deleterefs)
-                       die("--delete only accepts plain target ref names");
+                       die(_("--delete only accepts plain target ref names"));
                add_refspec(ref);
        }
 }
@@ -69,23 +69,23 @@ static void setup_push_upstream(struct remote *remote)
        struct strbuf refspec = STRBUF_INIT;
        struct branch *branch = branch_get(NULL);
        if (!branch)
-               die("You are not currently on a branch.\n"
+               die(_("You are not currently on a branch.\n"
                    "To push the history leading to the current (detached HEAD)\n"
                    "state now, use\n"
                    "\n"
-                   "    git push %s HEAD:<name-of-remote-branch>\n",
+                   "    git push %s HEAD:<name-of-remote-branch>\n"),
                    remote->name);
        if (!branch->merge_nr || !branch->merge)
-               die("The current branch %s has no upstream branch.\n"
+               die(_("The current branch %s has no upstream branch.\n"
                    "To push the current branch and set the remote as upstream, use\n"
                    "\n"
-                   "    git push --set-upstream %s %s\n",
+                   "    git push --set-upstream %s %s\n"),
                    branch->name,
                    remote->name,
                    branch->name);
        if (branch->merge_nr != 1)
-               die("The current branch %s has multiple upstream branches, "
-                   "refusing to push.", branch->name);
+               die(_("The current branch %s has multiple upstream branches, "
+                   "refusing to push."), branch->name);
        strbuf_addf(&refspec, "%s:%s", branch->name, branch->merge[0]->src);
        add_refspec(refspec.buf);
 }
@@ -107,8 +107,8 @@ static void setup_default_push_refspecs(struct remote *remote)
                break;
 
        case PUSH_DEFAULT_NOTHING:
-               die("You didn't specify any refspecs to push, and "
-                   "push.default is \"nothing\".");
+               die(_("You didn't specify any refspecs to push, and "
+                   "push.default is \"nothing\"."));
                break;
        }
 }
@@ -127,11 +127,11 @@ static int push_with_options(struct transport *transport, int flags)
                transport_set_option(transport, TRANS_OPT_THIN, "yes");
 
        if (verbosity > 0)
-               fprintf(stderr, "Pushing to %s\n", transport->url);
+               fprintf(stderr, _("Pushing to %s\n"), transport->url);
        err = transport_push(transport, refspec_nr, refspec, flags,
                             &nonfastforward);
        if (err != 0)
-               error("failed to push some refs to '%s'", transport->url);
+               error(_("failed to push some refs to '%s'"), transport->url);
 
        err |= transport_disconnect(transport);
 
@@ -139,9 +139,9 @@ static int push_with_options(struct transport *transport, int flags)
                return 0;
 
        if (nonfastforward && advice_push_nonfastforward) {
-               fprintf(stderr, "To prevent you from losing history, non-fast-forward updates were rejected\n"
+               fprintf(stderr, _("To prevent you from losing history, non-fast-forward updates were rejected\n"
                                "Merge the remote changes (e.g. 'git pull') before pushing again.  See the\n"
-                               "'Note about fast-forwards' section of 'git push --help' for details.\n");
+                               "'Note about fast-forwards' section of 'git push --help' for details.\n"));
        }
 
        return 1;
@@ -156,15 +156,15 @@ static int do_push(const char *repo, int flags)
 
        if (!remote) {
                if (repo)
-                       die("bad repository '%s'", repo);
-               die("No configured push destination.\n"
+                       die(_("bad repository '%s'"), repo);
+               die(_("No configured push destination.\n"
                    "Either specify the URL from the command-line or configure a remote repository using\n"
                    "\n"
                    "    git remote add <name> <url>\n"
                    "\n"
                    "and then push using the remote name\n"
                    "\n"
-                   "    git push <name>\n");
+                   "    git push <name>\n"));
        }
 
        if (remote->mirror)
@@ -172,19 +172,19 @@ static int do_push(const char *repo, int flags)
 
        if ((flags & TRANSPORT_PUSH_ALL) && refspec) {
                if (!strcmp(*refspec, "refs/tags/*"))
-                       return error("--all and --tags are incompatible");
-               return error("--all can't be combined with refspecs");
+                       return error(_("--all and --tags are incompatible"));
+               return error(_("--all can't be combined with refspecs"));
        }
 
        if ((flags & TRANSPORT_PUSH_MIRROR) && refspec) {
                if (!strcmp(*refspec, "refs/tags/*"))
-                       return error("--mirror and --tags are incompatible");
-               return error("--mirror can't be combined with refspecs");
+                       return error(_("--mirror and --tags are incompatible"));
+               return error(_("--mirror can't be combined with refspecs"));
        }
 
        if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
                                (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {
-               return error("--all and --mirror are incompatible");
+               return error(_("--all and --mirror are incompatible"));
        }
 
        if (!refspec && !(flags & TRANSPORT_PUSH_ALL)) {
@@ -250,9 +250,9 @@ int cmd_push(int argc, const char **argv, const char *prefix)
        argc = parse_options(argc, argv, prefix, options, push_usage, 0);
 
        if (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))
-               die("--delete is incompatible with --all, --mirror and --tags");
+               die(_("--delete is incompatible with --all, --mirror and --tags"));
        if (deleterefs && argc < 2)
-               die("--delete doesn't make sense without any refs");
+               die(_("--delete doesn't make sense without any refs"));
 
        if (tags)
                add_refspec("refs/tags/*");
index 27050e7c1627ed2899963fb3fdb81a7ba95d06df..e1ba4dc697abd1b2582713744c5a1892ef4a4882 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
 #include "pack.h"
 #include "refs.h"
 #include "pkt-line.h"
index eb5f98c16320cd4eded3c842ec1d019e75c5b9c3..98bca044c1267fa63cb084a45aaf621e85f7d9b6 100644 (file)
@@ -30,7 +30,7 @@ static const char * const git_reset_usage[] = {
 
 enum reset_type { MIXED, SOFT, HARD, MERGE, KEEP, NONE };
 static const char *reset_type_names[] = {
-       "mixed", "soft", "hard", "merge", "keep", NULL
+       N_("mixed"), N_("soft"), N_("hard"), N_("merge"), N_("keep"), NULL
 };
 
 static char *args_to_str(const char **argv)
@@ -92,20 +92,20 @@ static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet
        if (reset_type == KEEP) {
                unsigned char head_sha1[20];
                if (get_sha1("HEAD", head_sha1))
-                       return error("You do not have a valid HEAD.");
+                       return error(_("You do not have a valid HEAD."));
                if (!fill_tree_descriptor(desc, head_sha1))
-                       return error("Failed to find tree of HEAD.");
+                       return error(_("Failed to find tree of HEAD."));
                nr++;
                opts.fn = twoway_merge;
        }
 
        if (!fill_tree_descriptor(desc + nr - 1, sha1))
-               return error("Failed to find tree of %s.", sha1_to_hex(sha1));
+               return error(_("Failed to find tree of %s."), sha1_to_hex(sha1));
        if (unpack_trees(nr, desc, &opts))
                return -1;
        if (write_cache(newfd, active_cache, active_nr) ||
            commit_locked_index(lock))
-               return error("Could not write new index file.");
+               return error(_("Could not write new index file."));
 
        return 0;
 }
@@ -115,7 +115,7 @@ static void print_new_head_line(struct commit *commit)
        const char *hex, *body;
 
        hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
-       printf("HEAD is now at %s", hex);
+       printf(_("HEAD is now at %s"), hex);
        body = strstr(commit->buffer, "\n\n");
        if (body) {
                const char *eol;
@@ -139,10 +139,10 @@ static int update_index_refresh(int fd, struct lock_file *index_lock, int flags)
        }
 
        if (read_cache() < 0)
-               return error("Could not read index");
+               return error(_("Could not read index"));
 
        result = refresh_index(&the_index, (flags), NULL, NULL,
-                              "Unstaged changes after reset:") ? 1 : 0;
+                              _("Unstaged changes after reset:")) ? 1 : 0;
        if (write_cache(fd, active_cache, active_nr) ||
                        commit_locked_index(index_lock))
                return error ("Could not refresh index");
@@ -167,7 +167,7 @@ static void update_index_from_diff(struct diff_queue_struct *q,
                        ce = make_cache_entry(one->mode, one->sha1, one->path,
                                0, 0);
                        if (!ce)
-                               die("make_cache_entry failed for path '%s'",
+                               die(_("make_cache_entry failed for path '%s'"),
                                    one->path);
                        add_cache_entry(ce, ADD_CACHE_OK_TO_ADD |
                                ADD_CACHE_OK_TO_REPLACE);
@@ -222,14 +222,14 @@ static void prepend_reflog_action(const char *action, char *buf, size_t size)
        if (!rla)
                rla = sep = "";
        if (snprintf(buf, size, "%s%s%s", rla, sep, action) >= size)
-               warning("Reflog action message too long: %.*s...", 50, buf);
+               warning(_("Reflog action message too long: %.*s..."), 50, buf);
 }
 
 static void die_if_unmerged_cache(int reset_type)
 {
        if (is_merge() || read_cache() < 0 || unmerged_cache())
-               die("Cannot do a %s reset in the middle of a merge.",
-                   reset_type_names[reset_type]);
+               die(_("Cannot do a %s reset in the middle of a merge."),
+                   _(reset_type_names[reset_type]));
 
 }
 
@@ -300,16 +300,16 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
        }
 
        if (get_sha1(rev, sha1))
-               die("Failed to resolve '%s' as a valid ref.", rev);
+               die(_("Failed to resolve '%s' as a valid ref."), rev);
 
        commit = lookup_commit_reference(sha1);
        if (!commit)
-               die("Could not parse object '%s'.", rev);
+               die(_("Could not parse object '%s'."), rev);
        hashcpy(sha1, commit->object.sha1);
 
        if (patch_mode) {
                if (reset_type != NONE)
-                       die("--patch is incompatible with --{hard,mixed,soft}");
+                       die(_("--patch is incompatible with --{hard,mixed,soft}"));
                return interactive_reset(rev, argv + i, prefix);
        }
 
@@ -318,10 +318,10 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
         * affecting the working tree nor HEAD. */
        if (i < argc) {
                if (reset_type == MIXED)
-                       warning("--mixed with paths is deprecated; use 'git reset -- <paths>' instead.");
+                       warning(_("--mixed with paths is deprecated; use 'git reset -- <paths>' instead."));
                else if (reset_type != NONE)
-                       die("Cannot do %s reset with paths.",
-                                       reset_type_names[reset_type]);
+                       die(_("Cannot do %s reset with paths."),
+                                       _(reset_type_names[reset_type]));
                return read_from_tree(prefix, argv + i, sha1,
                                quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN);
        }
@@ -332,8 +332,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
                setup_work_tree();
 
        if (reset_type == MIXED && is_bare_repository())
-               die("%s reset is not allowed in a bare repository",
-                   reset_type_names[reset_type]);
+               die(_("%s reset is not allowed in a bare repository"),
+                   _(reset_type_names[reset_type]));
 
        /* Soft reset does not touch the index file nor the working tree
         * at all, but requires them in a good order.  Other resets reset
@@ -348,7 +348,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
                if (reset_type == KEEP)
                        err = err || reset_index_file(sha1, MIXED, quiet);
                if (err)
-                       die("Could not reset index file to revision '%s'.", rev);
+                       die(_("Could not reset index file to revision '%s'."), rev);
        }
 
        /* Any resets update HEAD to the head being switched to,
index c57b872fe114145ec82bf33717c2a8d7f0982204..2bb13ebb1de48e793e01d18ced29a468aa273b34 100644 (file)
@@ -95,7 +95,7 @@ static void parse_args(int argc, const char **argv)
                        OPT_END(),
                };
                if (parse_options_concat(options, ARRAY_SIZE(options), cp_extra))
-                       die("program error");
+                       die(_("program error"));
        }
 
        commit_argc = parse_options(argc, argv, NULL, options, usage_str,
@@ -167,7 +167,7 @@ static char *get_encoding(const char *message)
        const char *p = message, *eol;
 
        if (!p)
-               die ("Could not read commit message of %s",
+               die (_("Could not read commit message of %s"),
                                sha1_to_hex(commit->object.sha1));
        while (*p && *p != '\n') {
                for (eol = p + 1; *eol && *eol != '\n'; eol++)
@@ -206,10 +206,10 @@ static void write_cherry_pick_head(void)
 
        fd = open(git_path("CHERRY_PICK_HEAD"), O_WRONLY | O_CREAT, 0666);
        if (fd < 0)
-               die_errno("Could not open '%s' for writing",
+               die_errno(_("Could not open '%s' for writing"),
                          git_path("CHERRY_PICK_HEAD"));
        if (write_in_full(fd, buf.buf, buf.len) != buf.len || close(fd))
-               die_errno("Could not write to '%s'", git_path("CHERRY_PICK_HEAD"));
+               die_errno(_("Could not write to '%s'"), git_path("CHERRY_PICK_HEAD"));
        strbuf_release(&buf);
 }
 
@@ -249,10 +249,10 @@ static void write_message(struct strbuf *msgbuf, const char *filename)
        int msg_fd = hold_lock_file_for_update(&msg_file, filename,
                                               LOCK_DIE_ON_ERROR);
        if (write_in_full(msg_fd, msgbuf->buf, msgbuf->len) < 0)
-               die_errno("Could not write to %s.", filename);
+               die_errno(_("Could not write to %s."), filename);
        strbuf_release(msgbuf);
        if (commit_lock_file(&msg_file) < 0)
-               die("Error wrapping up %s", filename);
+               die(_("Error wrapping up %s"), filename);
 }
 
 static struct tree *empty_tree(void)
@@ -270,11 +270,19 @@ static NORETURN void die_dirty_index(const char *me)
        if (read_cache_unmerged()) {
                die_resolve_conflict(me);
        } else {
-               if (advice_commit_before_merge)
-                       die("Your local changes would be overwritten by %s.\n"
-                           "Please, commit your changes or stash them to proceed.", me);
-               else
-                       die("Your local changes would be overwritten by %s.\n", me);
+               if (advice_commit_before_merge) {
+                       if (action == REVERT)
+                               die(_("Your local changes would be overwritten by revert.\n"
+                                         "Please, commit your changes or stash them to proceed."));
+                       else
+                               die(_("Your local changes would be overwritten by cherry-pick.\n"
+                                         "Please, commit your changes or stash them to proceed."));
+               } else {
+                       if (action == REVERT)
+                               die(_("Your local changes would be overwritten by revert.\n"));
+                       else
+                               die(_("Your local changes would be overwritten by cherry-pick.\n"));
+               }
        }
 }
 
@@ -322,7 +330,8 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
        if (active_cache_changed &&
            (write_cache(index_fd, active_cache, active_nr) ||
             commit_locked_index(&index_lock)))
-               die("%s: Unable to write new index file", me);
+               /* TRANSLATORS: %s will be "revert" or "cherry-pick" */
+               die(_("%s: Unable to write new index file"), me);
        rollback_lock_file(&index_lock);
 
        if (!clean) {
@@ -388,10 +397,10 @@ static int do_pick_commit(void)
                 * to work on.
                 */
                if (write_cache_as_tree(head, 0, NULL))
-                       die ("Your index file is unmerged.");
+                       die (_("Your index file is unmerged."));
        } else {
                if (get_sha1("HEAD", head))
-                       die ("You do not have a valid HEAD");
+                       die (_("You do not have a valid HEAD"));
                if (index_differs_from("HEAD", 0))
                        die_dirty_index(me);
        }
@@ -399,7 +408,7 @@ static int do_pick_commit(void)
 
        if (!commit->parents) {
                if (action == REVERT)
-                       die ("Cannot revert a root commit");
+                       die (_("Cannot revert a root commit"));
                parent = NULL;
        }
        else if (commit->parents->next) {
@@ -408,7 +417,7 @@ static int do_pick_commit(void)
                struct commit_list *p;
 
                if (!mainline)
-                       die("Commit %s is a merge but no -m option was given.",
+                       die(_("Commit %s is a merge but no -m option was given."),
                            sha1_to_hex(commit->object.sha1));
 
                for (cnt = 1, p = commit->parents;
@@ -416,11 +425,11 @@ static int do_pick_commit(void)
                     cnt++)
                        p = p->next;
                if (cnt != mainline || !p)
-                       die("Commit %s does not have parent %d",
+                       die(_("Commit %s does not have parent %d"),
                            sha1_to_hex(commit->object.sha1), mainline);
                parent = p->item;
        } else if (0 < mainline)
-               die("Mainline was specified but commit %s is not a merge.",
+               die(_("Mainline was specified but commit %s is not a merge."),
                    sha1_to_hex(commit->object.sha1));
        else
                parent = commit->parents->item;
@@ -429,11 +438,13 @@ static int do_pick_commit(void)
                return fast_forward_to(commit->object.sha1, head);
 
        if (parent && parse_commit(parent) < 0)
-               die("%s: cannot parse parent commit %s",
+               /* TRANSLATORS: The first %s will be "revert" or
+                  "cherry-pick", the second %s a SHA1 */
+               die(_("%s: cannot parse parent commit %s"),
                    me, sha1_to_hex(parent->object.sha1));
 
        if (get_message(commit->buffer, &msg) != 0)
-               die("Cannot get commit message for %s",
+               die(_("Cannot get commit message for %s"),
                                sha1_to_hex(commit->object.sha1));
 
        /*
@@ -494,8 +505,9 @@ static int do_pick_commit(void)
        }
 
        if (res) {
-               error("could not %s %s... %s",
-                     action == REVERT ? "revert" : "apply",
+               error(action == REVERT
+                     ? _("could not revert %s... %s")
+                     : _("could not apply %s... %s"),
                      find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV),
                      msg.subject);
                print_advice();
@@ -525,10 +537,10 @@ static void prepare_revs(struct rev_info *revs)
                usage(*revert_or_cherry_pick_usage());
 
        if (prepare_revision_walk(revs))
-               die("revision walk setup failed");
+               die(_("revision walk setup failed"));
 
        if (!revs->commits)
-               die("empty commit set passed");
+               die(_("empty commit set passed"));
 }
 
 static void read_and_refresh_cache(const char *me)
@@ -536,12 +548,12 @@ static void read_and_refresh_cache(const char *me)
        static struct lock_file index_lock;
        int index_fd = hold_locked_index(&index_lock, 0);
        if (read_index_preload(&the_index, NULL) < 0)
-               die("git %s: failed to read the index", me);
+               die(_("git %s: failed to read the index"), me);
        refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL, NULL);
        if (the_index.cache_changed) {
                if (write_index(&the_index, index_fd) ||
                    commit_locked_index(&index_lock))
-                       die("git %s: failed to refresh the index", me);
+                       die(_("git %s: failed to refresh the index"), me);
        }
        rollback_lock_file(&index_lock);
 }
@@ -557,13 +569,13 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 
        if (allow_ff) {
                if (signoff)
-                       die("cherry-pick --ff cannot be used with --signoff");
+                       die(_("cherry-pick --ff cannot be used with --signoff"));
                if (no_commit)
-                       die("cherry-pick --ff cannot be used with --no-commit");
+                       die(_("cherry-pick --ff cannot be used with --no-commit"));
                if (no_replay)
-                       die("cherry-pick --ff cannot be used with -x");
+                       die(_("cherry-pick --ff cannot be used with -x"));
                if (edit)
-                       die("cherry-pick --ff cannot be used with --edit");
+                       die(_("cherry-pick --ff cannot be used with --edit"));
        }
 
        read_and_refresh_cache(me);
index ff491d77612ffb3c906c5e1ffa232f4410e4b661..90c8a5047c26cd7bdb939d150b842823f595333c 100644 (file)
@@ -106,19 +106,19 @@ static int check_local_mod(unsigned char *head, int index_only)
                 */
                if (local_changes && staged_changes) {
                        if (!index_only || !(ce->ce_flags & CE_INTENT_TO_ADD))
-                               errs = error("'%s' has staged content different "
+                               errs = error(_("'%s' has staged content different "
                                             "from both the file and the HEAD\n"
-                                            "(use -f to force removal)", name);
+                                            "(use -f to force removal)"), name);
                }
                else if (!index_only) {
                        if (staged_changes)
-                               errs = error("'%s' has changes staged in the index\n"
+                               errs = error(_("'%s' has changes staged in the index\n"
                                             "(use --cached to keep the file, "
-                                            "or -f to force removal)", name);
+                                            "or -f to force removal)"), name);
                        if (local_changes)
-                               errs = error("'%s' has local modifications\n"
+                               errs = error(_("'%s' has local modifications\n"
                                             "(use --cached to keep the file, "
-                                            "or -f to force removal)", name);
+                                            "or -f to force removal)"), name);
                }
        }
        return errs;
@@ -159,7 +159,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
        newfd = hold_locked_index(&lock_file, 1);
 
        if (read_cache() < 0)
-               die("index file corrupt");
+               die(_("index file corrupt"));
 
        pathspec = get_pathspec(prefix, argv);
        refresh_index(&the_index, REFRESH_QUIET, pathspec, NULL, NULL);
@@ -183,7 +183,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
                for (i = 0; (match = pathspec[i]) != NULL ; i++) {
                        if (!seen[i]) {
                                if (!ignore_unmatch) {
-                                       die("pathspec '%s' did not match any files",
+                                       die(_("pathspec '%s' did not match any files"),
                                            match);
                                }
                        }
@@ -191,7 +191,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
                                seen_any = 1;
                        }
                        if (!recursive && seen[i] == MATCHED_RECURSIVELY)
-                               die("not removing '%s' recursively without -r",
+                               die(_("not removing '%s' recursively without -r"),
                                    *match ? match : ".");
                }
 
@@ -227,7 +227,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
                        printf("rm '%s'\n", path);
 
                if (remove_file_from_cache(path))
-                       die("git rm: unable to remove %s", path);
+                       die(_("git rm: unable to remove %s"), path);
        }
 
        if (show_only)
@@ -257,7 +257,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
        if (active_cache_changed) {
                if (write_cache(newfd, active_cache, active_nr) ||
                    commit_locked_index(&lock_file))
-                       die("Unable to write new index file");
+                       die(_("Unable to write new index file"));
        }
 
        return 0;
index 1a21e4b0538565f7a64488ed7b3a5c317e559699..f5efc67c9cad24fe54d5c6ab7257d38a4b1727ac 100644 (file)
@@ -158,7 +158,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
                buffer = eol;
        }
        if (!author)
-               die("Missing author: %s",
+               die(_("Missing author: %s"),
                    sha1_to_hex(commit->object.sha1));
        if (log->user_format) {
                struct pretty_print_context ctx = {0};
@@ -181,7 +181,7 @@ static void get_from_rev(struct rev_info *rev, struct shortlog *log)
        struct commit *commit;
 
        if (prepare_revision_walk(rev))
-               die("revision walk setup failed");
+               die(_("revision walk setup failed"));
        while ((commit = get_revision(rev)) != NULL)
                shortlog_add_commit(log, commit);
 }
@@ -284,7 +284,7 @@ parse_done:
        argc = parse_options_end(&ctx);
 
        if (setup_revisions(argc, argv, &rev, NULL) != 1) {
-               error("unrecognized argument: %s", argv[1]);
+               error(_("unrecognized argument: %s"), argv[1]);
                usage_with_options(shortlog_usage, options);
        }
 
@@ -296,7 +296,7 @@ parse_done:
                add_head_to_pending(&rev);
        if (rev.pending.nr == 0) {
                if (isatty(0))
-                       fprintf(stderr, "(reading log message from standard input)\n");
+                       fprintf(stderr, _("(reading log message from standard input)\n"));
                read_from_stdin(&log);
        }
        else
index 7cf48abca857f049243dfab7c95fea70d216ea93..b66b34a1820b3c258ddd85180442df865becee15 100644 (file)
@@ -118,12 +118,12 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn)
        for (p = argv; *p; p++) {
                if (snprintf(ref, sizeof(ref), "refs/tags/%s", *p)
                                        >= sizeof(ref)) {
-                       error("tag name too long: %.*s...", 50, *p);
+                       error(_("tag name too long: %.*s..."), 50, *p);
                        had_error = 1;
                        continue;
                }
                if (!resolve_ref(ref, sha1, 1, NULL)) {
-                       error("tag '%s' not found.", *p);
+                       error(_("tag '%s' not found."), *p);
                        had_error = 1;
                        continue;
                }
@@ -138,7 +138,7 @@ static int delete_tag(const char *name, const char *ref,
 {
        if (delete_ref(ref, sha1, 0))
                return 1;
-       printf("Deleted tag '%s' (was %s)\n", name, find_unique_abbrev(sha1, DEFAULT_ABBREV));
+       printf(_("Deleted tag '%s' (was %s)\n"), name, find_unique_abbrev(sha1, DEFAULT_ABBREV));
        return 0;
 }
 
@@ -150,7 +150,7 @@ static int verify_tag(const char *name, const char *ref,
        argv_verify_tag[2] = sha1_to_hex(sha1);
 
        if (run_command_v_opt(argv_verify_tag, RUN_GIT_CMD))
-               return error("could not verify the tag '%s'", name);
+               return error(_("could not verify the tag '%s'"), name);
        return 0;
 }
 
@@ -165,7 +165,7 @@ static int do_sign(struct strbuf *buffer)
        if (!*signingkey) {
                if (strlcpy(signingkey, git_committer_info(IDENT_ERROR_ON_NO_NAME),
                                sizeof(signingkey)) > sizeof(signingkey) - 1)
-                       return error("committer info too long.");
+                       return error(_("committer info too long."));
                bracket = strchr(signingkey, '>');
                if (bracket)
                        bracket[1] = '\0';
@@ -185,20 +185,20 @@ static int do_sign(struct strbuf *buffer)
        args[3] = NULL;
 
        if (start_command(&gpg))
-               return error("could not run gpg.");
+               return error(_("could not run gpg."));
 
        if (write_in_full(gpg.in, buffer->buf, buffer->len) != buffer->len) {
                close(gpg.in);
                close(gpg.out);
                finish_command(&gpg);
-               return error("gpg did not accept the tag data");
+               return error(_("gpg did not accept the tag data"));
        }
        close(gpg.in);
        len = strbuf_read(buffer, gpg.out, 1024);
        close(gpg.out);
 
        if (finish_command(&gpg) || !len || len < 0)
-               return error("gpg failed to sign the tag");
+               return error(_("gpg failed to sign the tag"));
 
        /* Strip CR from the line endings, in case we are on Windows. */
        for (i = j = 0; i < buffer->len; i++)
@@ -213,15 +213,15 @@ static int do_sign(struct strbuf *buffer)
 }
 
 static const char tag_template[] =
-       "\n"
+       N_("\n"
        "#\n"
        "# Write a tag message\n"
-       "#\n";
+       "#\n");
 
 static void set_signingkey(const char *value)
 {
        if (strlcpy(signingkey, value, sizeof(signingkey)) >= sizeof(signingkey))
-               die("signing key value too long (%.10s...)", value);
+               die(_("signing key value too long (%.10s...)"), value);
 }
 
 static int git_tag_config(const char *var, const char *value, void *cb)
@@ -261,9 +261,9 @@ static void write_tag_body(int fd, const unsigned char *sha1)
 static int build_tag_object(struct strbuf *buf, int sign, unsigned char *result)
 {
        if (sign && do_sign(buf) < 0)
-               return error("unable to sign the tag");
+               return error(_("unable to sign the tag"));
        if (write_sha1_file(buf->buf, buf->len, tag_type, result) < 0)
-               return error("unable to write tag file");
+               return error(_("unable to write tag file"));
        return 0;
 }
 
@@ -278,7 +278,7 @@ static void create_tag(const unsigned char *object, const char *tag,
 
        type = sha1_object_info(object, NULL);
        if (type <= OBJ_NONE)
-           die("bad object type.");
+           die(_("bad object type."));
 
        header_len = snprintf(header_buf, sizeof(header_buf),
                          "object %s\n"
@@ -291,7 +291,7 @@ static void create_tag(const unsigned char *object, const char *tag,
                          git_committer_info(IDENT_ERROR_ON_NO_NAME));
 
        if (header_len > sizeof(header_buf) - 1)
-               die("tag header too big.");
+               die(_("tag header too big."));
 
        if (!message) {
                int fd;
@@ -300,17 +300,17 @@ static void create_tag(const unsigned char *object, const char *tag,
                path = git_pathdup("TAG_EDITMSG");
                fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
                if (fd < 0)
-                       die_errno("could not create file '%s'", path);
+                       die_errno(_("could not create file '%s'"), path);
 
                if (!is_null_sha1(prev))
                        write_tag_body(fd, prev);
                else
-                       write_or_die(fd, tag_template, strlen(tag_template));
+                       write_or_die(fd, _(tag_template), strlen(_(tag_template)));
                close(fd);
 
                if (launch_editor(path, buf, NULL)) {
                        fprintf(stderr,
-                       "Please supply the message using either -m or -F option.\n");
+                       _("Please supply the message using either -m or -F option.\n"));
                        exit(1);
                }
        }
@@ -318,13 +318,13 @@ static void create_tag(const unsigned char *object, const char *tag,
        stripspace(buf, 1);
 
        if (!message && !buf->len)
-               die("no tag message?");
+               die(_("no tag message?"));
 
        strbuf_insert(buf, 0, header_buf, header_len);
 
        if (build_tag_object(buf, sign, result) < 0) {
                if (path)
-                       fprintf(stderr, "The tag message has been left in %s\n",
+                       fprintf(stderr, _("The tag message has been left in %s\n"),
                                path);
                exit(128);
        }
@@ -417,9 +417,9 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
                return list_tags(argv[0], lines == -1 ? 0 : lines,
                                 with_commit);
        if (lines != -1)
-               die("-n option is only allowed with -l.");
+               die(_("-n option is only allowed with -l."));
        if (with_commit)
-               die("--contains option is only allowed with -l.");
+               die(_("--contains option is only allowed with -l."));
        if (delete)
                return for_each_tag_name(argv, delete_tag);
        if (verify)
@@ -427,17 +427,17 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 
        if (msg.given || msgfile) {
                if (msg.given && msgfile)
-                       die("only one -F or -m option is allowed.");
+                       die(_("only one -F or -m option is allowed."));
                annotate = 1;
                if (msg.given)
                        strbuf_addbuf(&buf, &(msg.buf));
                else {
                        if (!strcmp(msgfile, "-")) {
                                if (strbuf_read(&buf, 0, 1024) < 0)
-                                       die_errno("cannot read '%s'", msgfile);
+                                       die_errno(_("cannot read '%s'"), msgfile);
                        } else {
                                if (strbuf_read_file(&buf, msgfile, 1024) < 0)
-                                       die_errno("could not open or read '%s'",
+                                       die_errno(_("could not open or read '%s'"),
                                                msgfile);
                        }
                }
@@ -447,20 +447,20 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 
        object_ref = argc == 2 ? argv[1] : "HEAD";
        if (argc > 2)
-               die("too many params");
+               die(_("too many params"));
 
        if (get_sha1(object_ref, object))
-               die("Failed to resolve '%s' as a valid ref.", object_ref);
+               die(_("Failed to resolve '%s' as a valid ref."), object_ref);
 
        if (snprintf(ref, sizeof(ref), "refs/tags/%s", tag) > sizeof(ref) - 1)
-               die("tag name too long: %.*s...", 50, tag);
+               die(_("tag name too long: %.*s..."), 50, tag);
        if (check_ref_format(ref))
-               die("'%s' is not a valid tag name.", tag);
+               die(_("'%s' is not a valid tag name."), tag);
 
        if (!resolve_ref(ref, prev, 1, NULL))
                hashclr(prev);
        else if (!force)
-               die("tag '%s' already exists", tag);
+               die(_("tag '%s' already exists"), tag);
 
        if (annotate)
                create_tag(object, tag, &buf, msg.given || msgfile,
@@ -468,11 +468,11 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 
        lock = lock_any_ref_for_update(ref, prev, 0);
        if (!lock)
-               die("%s: cannot lock the ref", ref);
+               die(_("%s: cannot lock the ref"), ref);
        if (write_ref_sha1(lock, object, NULL) < 0)
-               die("%s: cannot update the ref", ref);
+               die(_("%s: cannot update the ref"), ref);
        if (force && hashcmp(prev, object))
-               printf("Updated tag '%s' (was %s)\n", tag, find_unique_abbrev(prev, DEFAULT_ABBREV));
+               printf(_("Updated tag '%s' (was %s)\n"), tag, find_unique_abbrev(prev, DEFAULT_ABBREV));
 
        strbuf_release(&buf);
        return 0;
diff --git a/cache.h b/cache.h
index 9f06d215790ef98c2138ab26c1a9b4ddafd33c55..2674f4cf5a74aaa8e6137985d552d7b6123a432c 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -437,6 +437,7 @@ extern void verify_non_filename(const char *prefix, const char *name);
 
 #define INIT_DB_QUIET 0x0001
 
+extern int set_git_dir_init(const char *git_dir, const char *real_git_dir, int);
 extern int init_db(const char *template_dir, unsigned int flags);
 
 #define alloc_nr(x) (((x)+16)*3/2)
index 214930a021e6ab18f855b0b4ff4bd7d53912d06b..65c95d9d5a6e00e376a75bdad2194ec9d6539667 100644 (file)
@@ -1310,6 +1310,13 @@ The FILES list must be sorted."
       (when sign-off (git-append-sign-off committer-name committer-email)))
     buffer))
 
+(define-derived-mode git-log-edit-mode log-edit-mode "Git-Log-Edit"
+  "Major mode for editing git log messages.
+
+Set up git-specific `font-lock-keywords' for `log-edit-mode'."
+  (set (make-local-variable 'font-lock-defaults)
+       '(git-log-edit-font-lock-keywords t t)))
+
 (defun git-commit-file ()
   "Commit the marked file(s), asking for a commit message."
   (interactive)
@@ -1335,9 +1342,9 @@ The FILES list must be sorted."
         (git-setup-log-buffer buffer (git-get-merge-heads) author-name author-email subject date))
       (if (boundp 'log-edit-diff-function)
          (log-edit 'git-do-commit nil '((log-edit-listfun . git-log-edit-files)
-                                        (log-edit-diff-function . git-log-edit-diff)) buffer)
-       (log-edit 'git-do-commit nil 'git-log-edit-files buffer))
-      (setq font-lock-keywords (font-lock-compile-keywords git-log-edit-font-lock-keywords))
+                                        (log-edit-diff-function . git-log-edit-diff)) buffer 'git-log-edit-mode)
+       (log-edit 'git-do-commit nil 'git-log-edit-files buffer
+                  'git-log-edit-mode))
       (setq paragraph-separate (concat (regexp-quote git-log-msg-separator) "$\\|Author: \\|Date: \\|Merge: \\|Signed-off-by: \\|\f\\|[        ]*$"))
       (setq buffer-file-coding-system coding-system)
       (re-search-forward (regexp-quote (concat git-log-msg-separator "\n")) nil t))))
index 4d50cc5ce18c24a1dc853d3050062b864fe0b943..be49d5fcf900cb47cb14d8c85a69112b26532b93 100644 (file)
@@ -116,7 +116,7 @@ struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp
 
 void crc32_begin(struct sha1file *f)
 {
-       f->crc32 = crc32(0, Z_NULL, 0);
+       f->crc32 = crc32(0, NULL, 0);
        f->do_crc = 1;
 }
 
index 49b50eec86828066c90b6165c35ec21cb51e85ce..40498b33c9f09ef9cac1f7340a9a1ceb2ffcd50d 100644 (file)
 #endif
 #ifndef __MINGW32__
 #include <sys/wait.h>
+#include <sys/resource.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <termios.h>
index 63b063a7b284bac5b10a9bd6fe879e5717bee2f3..4e9e0e49ecf2532ac8af1bfd46033e68c6f1042d 100755 (executable)
@@ -110,6 +110,9 @@ do
        --recurse-submodules)
                recurse_submodules=--recurse-submodules
                ;;
+       --recurse-submodules=*)
+               recurse_submodules="$1"
+               ;;
        --no-recurse-submodules)
                recurse_submodules=--no-recurse-submodules
                ;;
@@ -274,7 +277,7 @@ esac
 if test -z "$orig_head"
 then
        git update-ref -m "initial pull" HEAD $merge_head "$curr_head" &&
-       git read-tree --reset -u HEAD || exit 1
+       git read-tree -m -u HEAD || exit 1
        exit
 fi
 
index 3a13397e057edf88d2c810490ec3d7d755be2009..b010a673097a9cfcf009b307114669b6221d066c 100755 (executable)
@@ -72,7 +72,24 @@ resolve_relative_url ()
 #
 module_list()
 {
-       git ls-files --error-unmatch --stage -- "$@" | sane_grep '^160000 '
+       git ls-files --error-unmatch --stage -- "$@" |
+       perl -e '
+       my %unmerged = ();
+       my ($null_sha1) = ("0" x 40);
+       while (<STDIN>) {
+               chomp;
+               my ($mode, $sha1, $stage, $path) =
+                       /^([0-7]+) ([0-9a-f]{40}) ([0-3])\t(.*)$/;
+               next unless $mode eq "160000";
+               if ($stage ne "0") {
+                       if (!$unmerged{$path}++) {
+                               print "$mode $null_sha1 U\t$path\n";
+                       }
+                       next;
+               }
+               print "$_\n";
+       }
+       '
 }
 
 #
@@ -427,6 +444,11 @@ cmd_update()
        module_list "$@" |
        while read mode sha1 stage path
        do
+               if test "$stage" = U
+               then
+                       echo >&2 "Skipping unmerged submodule $path"
+                       continue
+               fi
                name=$(module_name "$path") || exit
                url=$(git config submodule."$name".url)
                update_module=$(git config submodule."$name".update)
@@ -466,8 +488,11 @@ cmd_update()
 
                        if test -z "$nofetch"
                        then
+                               # Run fetch only if $sha1 isn't present or it
+                               # is not reachable from a ref.
                                (clear_local_git_env; cd "$path" &&
-                                       git-fetch) ||
+                                       ((rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&
+                                        test -z "$rev") || git-fetch)) ||
                                die "Unable to fetch in submodule path '$path'"
                        fi
 
@@ -770,6 +795,11 @@ cmd_status()
                name=$(module_name "$path") || exit
                url=$(git config submodule."$name".url)
                displaypath="$prefix$path"
+               if test "$stage" = U
+               then
+                       say "U$sha1 $displaypath"
+                       continue
+               fi
                if test -z "$url" || ! test -d "$path"/.git -o -f "$path"/.git
                then
                        say "-$sha1 $displaypath"
index 9c66928c4af8cf37b9c13a6a40936523e16fcc6f..40ec08440b047718bece8efa469683e4b768b68d 100644 (file)
@@ -399,7 +399,24 @@ function fixColorsAndGroups() {
  * used to extract hours and minutes from timezone info, e.g '-0900'
  * @constant
  */
-var tzRe = /^([+-][0-9][0-9])([0-9][0-9])$/;
+var tzRe = /^([+-])([0-9][0-9])([0-9][0-9])$/;
+
+/**
+ * convert numeric timezone +/-ZZZZ to offset from UTC in seconds
+ *
+ * @param {String} timezoneInfo: numeric timezone '(+|-)HHMM'
+ * @returns {Number} offset from UTC in seconds for timezone
+ *
+ * @globals tzRe
+ */
+function timezoneOffset(timezoneInfo) {
+       var match = tzRe.exec(timezoneInfo);
+       var tz_sign = (match[1] === '-' ? -1 : +1);
+       var tz_hour = parseInt(match[2],10);
+       var tz_min  = parseInt(match[3],10);
+
+       return tz_sign*(((tz_hour*60) + tz_min)*60);
+}
 
 /**
  * return date in local time formatted in iso-8601 like format
@@ -408,14 +425,11 @@ var tzRe = /^([+-][0-9][0-9])([0-9][0-9])$/;
  * @param {Number} epoch: seconds since '00:00:00 1970-01-01 UTC'
  * @param {String} timezoneInfo: numeric timezone '(+|-)HHMM'
  * @returns {String} date in local time in iso-8601 like format
- *
- * @globals tzRe
  */
 function formatDateISOLocal(epoch, timezoneInfo) {
-       var match = tzRe.exec(timezoneInfo);
        // date corrected by timezone
        var localDate = new Date(1000 * (epoch +
-               (parseInt(match[1],10)*3600 + parseInt(match[2],10)*60)));
+               timezoneOffset(timezoneInfo)));
        var localDateStr = // e.g. '2005-08-07'
                localDate.getUTCFullYear()                 + '-' +
                padLeft(localDate.getUTCMonth()+1, 2, '0') + '-' +
index 923904f97f9274d09a0a0b08543492f78a141f79..3af4c71bd0fb8370c6f08b0e3d43adc722cac2f4 100644 (file)
@@ -8,7 +8,6 @@ static const char http_fetch_usage[] = "git http-fetch "
 
 int main(int argc, const char **argv)
 {
-       const char *prefix;
        struct walker *walker;
        int commits_on_stdin = 0;
        int commits;
@@ -60,7 +59,7 @@ int main(int argc, const char **argv)
        if (argv[arg])
                str_end_url_with_slash(argv[arg], &url);
 
-       prefix = setup_git_directory();
+       setup_git_directory();
 
        git_config(git_default_config, NULL);
 
index 8e82a8b1a5ab8a2f5af00910a8febda93b9e420d..af131508ec7ffa3ac7b1b1b1cadfcda0040becf2 100644 (file)
@@ -356,7 +356,6 @@ static void make_room_for_directories_of_df_conflicts(struct merge_options *o,
         */
        const char *last_file = NULL;
        int last_len = 0;
-       struct stage_data *last_e;
        int i;
 
        for (i = 0; i < entries->nr; i++) {
@@ -386,7 +385,6 @@ static void make_room_for_directories_of_df_conflicts(struct merge_options *o,
                if (S_ISREG(e->stages[2].mode) || S_ISLNK(e->stages[2].mode)) {
                        last_file = path;
                        last_len = len;
-                       last_e = e;
                } else {
                        last_file = NULL;
                }
@@ -961,7 +959,6 @@ static int process_renames(struct merge_options *o,
        }
 
        for (i = 0, j = 0; i < a_renames->nr || j < b_renames->nr;) {
-               char *src;
                struct string_list *renames1, *renames2Dst;
                struct rename *ren1 = NULL, *ren2 = NULL;
                const char *branch1, *branch2;
@@ -996,7 +993,6 @@ static int process_renames(struct merge_options *o,
                        ren2 = ren1;
                        ren1 = tmp;
                }
-               src = ren1->pair->one->path;
 
                ren1->dst_entry->processed = 1;
                ren1->src_entry->processed = 1;
index c3bf21dbcb4b79fdc815ef80ae5c970aafd02bbf..a1a521648deee8e7e82c4e2cb7fe8fe03605dc06 100644 (file)
@@ -23,7 +23,7 @@ int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,
                   off_t offset, off_t len, unsigned int nr)
 {
        const uint32_t *index_crc;
-       uint32_t data_crc = crc32(0, Z_NULL, 0);
+       uint32_t data_crc = crc32(0, NULL, 0);
 
        do {
                unsigned int avail;
index cd1bd264139bf15cca06f900b7921f0956c6458b..5a04984ea31744528de30269add2754ed2dcd105 100644 (file)
@@ -1,7 +1,7 @@
 #include "cache.h"
 #include "pkt-line.h"
 
-const char *packet_trace_prefix = "git";
+static const char *packet_trace_prefix = "git";
 static const char trace_key[] = "GIT_TRACE_PACKET";
 
 void packet_trace_identity(const char *prog)
index 3d00a71ff9730ed4a10114185f4360de698c1fbf..22dfc843da1528ffd0466d496c50c56702e55a24 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -438,7 +438,7 @@ static int merge(const char *name, const char *path)
                ret = 1;
                goto out;
        }
-       ret = ll_merge(&result, path, &base, NULL, &cur, "", &other, "", 0);
+       ret = ll_merge(&result, path, &base, NULL, &cur, "", &other, "", NULL);
        if (!ret) {
                FILE *f;
 
index 0cb6d1829944b8a6d0f1a7ed1c228b61c31c7e0d..5294cef641ef74ec525d8d747c82faf0bef7352a 100644 (file)
@@ -12,7 +12,8 @@
 static struct string_list config_name_for_path;
 static struct string_list config_fetch_recurse_submodules_for_name;
 static struct string_list config_ignore_for_name;
-static int config_fetch_recurse_submodules;
+static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND;
+static struct string_list changed_submodule_paths;
 
 static int add_submodule_odb(const char *path)
 {
@@ -70,7 +71,7 @@ int submodule_config(const char *var, const char *value, void *cb)
        if (!prefixcmp(var, "submodule."))
                return parse_submodule_config_option(var, value);
        else if (!strcmp(var, "fetch.recursesubmodules")) {
-               config_fetch_recurse_submodules = git_config_bool(var, value);
+               config_fetch_recurse_submodules = parse_fetch_recurse_submodules_arg(var, value);
                return 0;
        }
        return 0;
@@ -112,7 +113,7 @@ int parse_submodule_config_option(const char *var, const char *value)
                if (!config)
                        config = string_list_append(&config_fetch_recurse_submodules_for_name,
                                                    strbuf_detach(&submodname, NULL));
-               config->util = git_config_bool(var, value) ? (void *)1 : NULL;
+               config->util = (void *)(intptr_t)parse_fetch_recurse_submodules_arg(var, value);
                strbuf_release(&submodname);
        } else if ((len > 7) && !strcmp(var + len - 7, ".ignore")) {
                if (strcmp(value, "untracked") && strcmp(value, "dirty") &&
@@ -206,6 +207,20 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
        strbuf_release(&sb);
 }
 
+int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
+{
+       switch (git_config_maybe_bool(opt, arg)) {
+       case 1:
+               return RECURSE_SUBMODULES_ON;
+       case 0:
+               return RECURSE_SUBMODULES_OFF;
+       default:
+               if (!strcmp(arg, "on-demand"))
+                       return RECURSE_SUBMODULES_ON_DEMAND;
+               die("bad %s argument: %s", opt, arg);
+       }
+}
+
 void show_submodule_summary(FILE *f, const char *path,
                unsigned char one[20], unsigned char two[20],
                unsigned dirty_submodule,
@@ -267,27 +282,122 @@ void set_config_fetch_recurse_submodules(int value)
        config_fetch_recurse_submodules = value;
 }
 
+static int is_submodule_commit_present(const char *path, unsigned char sha1[20])
+{
+       int is_present = 0;
+       if (!add_submodule_odb(path) && lookup_commit_reference(sha1)) {
+               /* Even if the submodule is checked out and the commit is
+                * present, make sure it is reachable from a ref. */
+               struct child_process cp;
+               const char *argv[] = {"rev-list", "-n", "1", NULL, "--not", "--all", NULL};
+               struct strbuf buf = STRBUF_INIT;
+
+               argv[3] = sha1_to_hex(sha1);
+               memset(&cp, 0, sizeof(cp));
+               cp.argv = argv;
+               cp.env = local_repo_env;
+               cp.git_cmd = 1;
+               cp.no_stdin = 1;
+               cp.out = -1;
+               cp.dir = path;
+               if (!run_command(&cp) && !strbuf_read(&buf, cp.out, 1024))
+                       is_present = 1;
+
+               close(cp.out);
+               strbuf_release(&buf);
+       }
+       return is_present;
+}
+
+static void submodule_collect_changed_cb(struct diff_queue_struct *q,
+                                        struct diff_options *options,
+                                        void *data)
+{
+       int i;
+       for (i = 0; i < q->nr; i++) {
+               struct diff_filepair *p = q->queue[i];
+               if (!S_ISGITLINK(p->two->mode))
+                       continue;
+
+               if (S_ISGITLINK(p->one->mode)) {
+                       /* NEEDSWORK: We should honor the name configured in
+                        * the .gitmodules file of the commit we are examining
+                        * here to be able to correctly follow submodules
+                        * being moved around. */
+                       struct string_list_item *path;
+                       path = unsorted_string_list_lookup(&changed_submodule_paths, p->two->path);
+                       if (!path && !is_submodule_commit_present(p->two->path, p->two->sha1))
+                               string_list_append(&changed_submodule_paths, xstrdup(p->two->path));
+               } else {
+                       /* Submodule is new or was moved here */
+                       /* NEEDSWORK: When the .git directories of submodules
+                        * live inside the superprojects .git directory some
+                        * day we should fetch new submodules directly into
+                        * that location too when config or options request
+                        * that so they can be checked out from there. */
+                       continue;
+               }
+       }
+}
+
+void check_for_new_submodule_commits(unsigned char new_sha1[20])
+{
+       struct rev_info rev;
+       struct commit *commit;
+       const char *argv[] = {NULL, NULL, "--not", "--all", NULL};
+       int argc = ARRAY_SIZE(argv) - 1;
+
+       init_revisions(&rev, NULL);
+       argv[1] = xstrdup(sha1_to_hex(new_sha1));
+       setup_revisions(argc, argv, &rev, NULL);
+       if (prepare_revision_walk(&rev))
+               die("revision walk setup failed");
+
+       /*
+        * Collect all submodules (whether checked out or not) for which new
+        * commits have been recorded upstream in "changed_submodule_paths".
+        */
+       while ((commit = get_revision(&rev))) {
+               struct commit_list *parent = commit->parents;
+               while (parent) {
+                       struct diff_options diff_opts;
+                       diff_setup(&diff_opts);
+                       diff_opts.output_format |= DIFF_FORMAT_CALLBACK;
+                       diff_opts.format_callback = submodule_collect_changed_cb;
+                       if (diff_setup_done(&diff_opts) < 0)
+                               die("diff_setup_done failed");
+                       diff_tree_sha1(parent->item->object.sha1, commit->object.sha1, "", &diff_opts);
+                       diffcore_std(&diff_opts);
+                       diff_flush(&diff_opts);
+                       parent = parent->next;
+               }
+       }
+       free((char *)argv[1]);
+}
+
 int fetch_populated_submodules(int num_options, const char **options,
-                              const char *prefix, int ignore_config,
+                              const char *prefix, int command_line_option,
                               int quiet)
 {
-       int i, result = 0, argc = 0;
+       int i, result = 0, argc = 0, default_argc;
        struct child_process cp;
        const char **argv;
        struct string_list_item *name_for_path;
        const char *work_tree = get_git_work_tree();
        if (!work_tree)
-               return 0;
+               goto out;
 
        if (!the_index.initialized)
                if (read_cache() < 0)
                        die("index file corrupt");
 
-       /* 4: "fetch" (options) "--submodule-prefix" prefix NULL */
-       argv = xcalloc(num_options + 4, sizeof(const char *));
+       /* 6: "fetch" (options) --recurse-submodules-default default "--submodule-prefix" prefix NULL */
+       argv = xcalloc(num_options + 6, sizeof(const char *));
        argv[argc++] = "fetch";
        for (i = 0; i < num_options; i++)
                argv[argc++] = options[i];
+       argv[argc++] = "--recurse-submodules-default";
+       default_argc = argc++;
        argv[argc++] = "--submodule-prefix";
 
        memset(&cp, 0, sizeof(cp));
@@ -301,7 +411,7 @@ int fetch_populated_submodules(int num_options, const char **options,
                struct strbuf submodule_git_dir = STRBUF_INIT;
                struct strbuf submodule_prefix = STRBUF_INIT;
                struct cache_entry *ce = active_cache[i];
-               const char *git_dir, *name;
+               const char *git_dir, *name, *default_argv;
 
                if (!S_ISGITLINK(ce->ce_mode))
                        continue;
@@ -311,16 +421,31 @@ int fetch_populated_submodules(int num_options, const char **options,
                if (name_for_path)
                        name = name_for_path->util;
 
-               if (!ignore_config) {
+               default_argv = "yes";
+               if (command_line_option == RECURSE_SUBMODULES_DEFAULT) {
                        struct string_list_item *fetch_recurse_submodules_option;
                        fetch_recurse_submodules_option = unsorted_string_list_lookup(&config_fetch_recurse_submodules_for_name, name);
                        if (fetch_recurse_submodules_option) {
-                               if (!fetch_recurse_submodules_option->util)
+                               if ((intptr_t)fetch_recurse_submodules_option->util == RECURSE_SUBMODULES_OFF)
                                        continue;
+                               if ((intptr_t)fetch_recurse_submodules_option->util == RECURSE_SUBMODULES_ON_DEMAND) {
+                                       if (!unsorted_string_list_lookup(&changed_submodule_paths, ce->name))
+                                               continue;
+                                       default_argv = "on-demand";
+                               }
                        } else {
-                               if (!config_fetch_recurse_submodules)
+                               if (config_fetch_recurse_submodules == RECURSE_SUBMODULES_OFF)
                                        continue;
+                               if (config_fetch_recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) {
+                                       if (!unsorted_string_list_lookup(&changed_submodule_paths, ce->name))
+                                               continue;
+                                       default_argv = "on-demand";
+                               }
                        }
+               } else if (command_line_option == RECURSE_SUBMODULES_ON_DEMAND) {
+                       if (!unsorted_string_list_lookup(&changed_submodule_paths, ce->name))
+                               continue;
+                       default_argv = "on-demand";
                }
 
                strbuf_addf(&submodule_path, "%s/%s", work_tree, ce->name);
@@ -333,6 +458,7 @@ int fetch_populated_submodules(int num_options, const char **options,
                        if (!quiet)
                                printf("Fetching submodule %s%s\n", prefix, ce->name);
                        cp.dir = submodule_path.buf;
+                       argv[default_argc] = default_argv;
                        argv[argc] = submodule_prefix.buf;
                        if (run_command(&cp))
                                result = 1;
@@ -342,6 +468,8 @@ int fetch_populated_submodules(int num_options, const char **options,
                strbuf_release(&submodule_prefix);
        }
        free(argv);
+out:
+       string_list_clear(&changed_submodule_paths, 1);
        return result;
 }
 
index 4729023aa5bbd7d7c95981b995c379407ba6423d..5350b0d5a0d16e12e96b983e6510cb1d4098f962 100644 (file)
@@ -3,19 +3,28 @@
 
 struct diff_options;
 
+enum {
+       RECURSE_SUBMODULES_ON_DEMAND = -1,
+       RECURSE_SUBMODULES_OFF = 0,
+       RECURSE_SUBMODULES_DEFAULT = 1,
+       RECURSE_SUBMODULES_ON = 2
+};
+
 void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,
                const char *path);
 int submodule_config(const char *var, const char *value, void *cb);
 void gitmodules_config();
 int parse_submodule_config_option(const char *var, const char *value);
 void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *);
+int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
 void show_submodule_summary(FILE *f, const char *path,
                unsigned char one[20], unsigned char two[20],
                unsigned dirty_submodule,
                const char *del, const char *add, const char *reset);
 void set_config_fetch_recurse_submodules(int value);
+void check_for_new_submodule_commits(unsigned char new_sha1[20]);
 int fetch_populated_submodules(int num_options, const char **options,
-                              const char *prefix, int ignore_config,
+                              const char *prefix, int command_line_option,
                               int quiet);
 unsigned is_submodule_modified(const char *path, int ignore_untracked);
 int merge_submodule(unsigned char result[20], const char *path, const unsigned char base[20],
index 3f24384371bf227126e38da61f3b7efd3961ede8..d3829b8d0a18d15590f4cbde4606d130a9293ead 100644 (file)
@@ -157,7 +157,7 @@ test_http_push_nonff() {
                grep "^ ! \[rejected\][ ]*$BRANCH -> $BRANCH (non-fast-forward)$" output
        '
 
-       test_expect_success 'non-fast-forward push shows help message' '
+       test_expect_success C_LOCALE_OUTPUT 'non-fast-forward push shows help message' '
                grep "To prevent you from losing history, non-fast-forward updates were rejected" \
                        output
        '
index ce4ba1379ef05066cc697cdc7fdf53f8c40f58ee..a5816d0e4f3744f8ba30666d8bb5828abf6cda51 100755 (executable)
@@ -180,7 +180,7 @@ test_expect_success 'GIT_DIR & GIT_WORK_TREE (2)' '
        fi
 '
 
-test_expect_success 'reinit' '
+test_expect_success C_LOCALE_OUTPUT 'reinit' '
 
        (
                sane_unset GIT_CONFIG GIT_WORK_TREE GIT_CONFIG &&
@@ -371,4 +371,50 @@ test_expect_success 'init prefers command line to GIT_DIR' '
        ! test -d otherdir/refs
 '
 
+test_expect_success 'init with separate gitdir' '
+       rm -rf newdir &&
+       git init --separate-git-dir realgitdir newdir &&
+       echo "gitdir: `pwd`/realgitdir" >expected &&
+       test_cmp expected newdir/.git &&
+       test -d realgitdir/refs
+'
+
+test_expect_success 're-init to update git link' '
+       (
+       cd newdir &&
+       git init --separate-git-dir ../surrealgitdir
+       ) &&
+       echo "gitdir: `pwd`/surrealgitdir" >expected &&
+       test_cmp expected newdir/.git &&
+       test -d surrealgitdir/refs &&
+       ! test -d realgitdir/refs
+'
+
+test_expect_success 're-init to move gitdir' '
+       rm -rf newdir realgitdir surrealgitdir &&
+       git init newdir &&
+       (
+       cd newdir &&
+       git init --separate-git-dir ../realgitdir
+       ) &&
+       echo "gitdir: `pwd`/realgitdir" >expected &&
+       test_cmp expected newdir/.git &&
+       test -d realgitdir/refs
+'
+
+test_expect_success 're-init to move gitdir symlink' '
+       rm -rf newdir realgitdir &&
+       git init newdir &&
+       (
+       cd newdir &&
+       mv .git here &&
+       ln -s here .git &&
+       git init -L ../realgitdir
+       ) &&
+       echo "gitdir: `pwd`/realgitdir" >expected &&
+       test_cmp expected newdir/.git &&
+       test -d realgitdir/refs &&
+       ! test -d newdir/here
+'
+
 test_done
index bfa2c2190d0368eba533a8411df739eee77fa1be..3264fefbad8b941bd90b243948f618b65fe4929f 100755 (executable)
@@ -163,7 +163,10 @@ test_expect_success 'git resolve' '
        git checkout mybranch &&
        git merge -m "Merge upstream changes." master |
                sed -e "1s/[0-9a-f]\{7\}/VARIABLE/g" \
-               -e "s/^Fast[- ]forward /FASTFORWARD /" >resolve.output &&
+               -e "s/^Fast[- ]forward /FASTFORWARD /" >resolve.output
+'
+
+test_expect_success C_LOCALE_OUTPUT 'git resolve output' '
        test_cmp resolve.expect resolve.output
 '
 
index 943541d40d7ea331dd0ae85624a33b9f2258246c..cc34e5535bc5ab7441ba375540e5feec2dfb2d6b 100755 (executable)
@@ -29,7 +29,7 @@ test_expect_success 'checkout chooses branch over tag' '
        test_cmp expect file
 '
 
-test_expect_success 'checkout reports switch to branch' '
+test_expect_success C_LOCALE_OUTPUT 'checkout reports switch to branch' '
        grep "Switched to branch" stderr &&
        ! grep "^HEAD is now at" stderr
 '
@@ -51,7 +51,7 @@ test_expect_success VAGUENESS_SUCCESS 'checkout chooses branch over tag' '
        test_cmp expect file
 '
 
-test_expect_success VAGUENESS_SUCCESS 'checkout reports switch to branch' '
+test_expect_success VAGUENESS_SUCCESS,C_LOCALE_OUTPUT 'checkout reports switch to branch' '
        grep "Switched to branch" stderr &&
        ! grep "^HEAD is now at" stderr
 '
index 0692427cb69c62327da52061de6238ca8e12169d..856e7da1f2d3aba299d30aca9a1a6d5a288d2d91 100755 (executable)
@@ -111,7 +111,7 @@ test_expect_success 'touch and then add explicitly' '
 
 '
 
-test_expect_success 'add -n -u should not add but just report' '
+test_expect_success C_LOCALE_OUTPUT 'add -n -u should not add but just report' '
 
        (
                echo "add '\''check'\''" &&
index 24afdabab7e30feaf583079a75a756d267181bb9..49753362f0974627f1b5e5e11144484238875494 100755 (executable)
@@ -31,18 +31,21 @@ do
                rm -f .git/index &&
                test_must_fail git add "$i" 2>err &&
                git ls-files "$i" >out &&
-               ! test -s out &&
-               grep -e "Use -f if" err &&
-               cat err
+               ! test -s out
+       '
+
+       test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i output" '
+               grep -e "Use -f if" err
        '
 
        test_expect_success "complaints for ignored $i with unignored file" '
                rm -f .git/index &&
                test_must_fail git add "$i" file 2>err &&
                git ls-files "$i" >out &&
-               ! test -s out &&
-               grep -e "Use -f if" err &&
-               cat err
+               ! test -s out
+       '
+       test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i with unignored file output" '
+               grep -e "Use -f if" err
        '
 done
 
@@ -54,9 +57,14 @@ do
                        cd dir &&
                        test_must_fail git add "$i" 2>err &&
                        git ls-files "$i" >out &&
-                       ! test -s out &&
-                       grep -e "Use -f if" err &&
-                       cat err
+                       ! test -s out
+               )
+       '
+
+       test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i in dir output" '
+               (
+                       cd dir &&
+                       grep -e "Use -f if" err
                )
        '
 done
@@ -69,9 +77,14 @@ do
                        cd sub &&
                        test_must_fail git add "$i" 2>err &&
                        git ls-files "$i" >out &&
-                       ! test -s out &&
-                       grep -e "Use -f if" err &&
-                       cat err
+                       ! test -s out
+               )
+       '
+
+       test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i in sub output" '
+               (
+                       cd sub &&
+                       grep -e "Use -f if" err
                )
        '
 done
index 34794f8a70e1c9b71384363e022d08da4ac8872e..806fdccce1db994899509cb3dd9d7801b84c48ba 100755 (executable)
@@ -312,7 +312,7 @@ test_expect_success 'merge-recursive result' '
 
 '
 
-test_expect_success 'fail if the index has unresolved entries' '
+test_expect_success C_LOCALE_OUTPUT 'fail if the index has unresolved entries' '
 
        rm -fr [abcd] &&
        git checkout -f "$c1" &&
index 78ce09f9d788203ebea280cc94c8098c9043311f..286a2a68692dd7a70e34851f75098506a1fc783a 100755 (executable)
@@ -203,7 +203,7 @@ test_expect_success 'test deleting branch deletes branch config' \
      test -z "$(git config branch.my7.remote)" &&
      test -z "$(git config branch.my7.merge)"'
 
-test_expect_success 'test deleting branch without config' \
+test_expect_success C_LOCALE_OUTPUT 'test deleting branch without config' \
     'git branch my7 s &&
      sha1=$(git rev-parse my7 | cut -c 1-7) &&
      test "$(git branch -d my7 2>&1)" = "Deleted branch my7 (was $sha1)."'
index 6028748c6cecaedb087c35182de172ca0e93fe08..4ef7d09115678ff97717a5f6a3027a87490dac79 100755 (executable)
@@ -72,7 +72,7 @@ cat >expect <<'EOF'
   branch-two
   master
 EOF
-test_expect_success 'git branch shows detached HEAD properly' '
+test_expect_success C_LOCALE_OUTPUT 'git branch shows detached HEAD properly' '
        git checkout HEAD^0 &&
        git branch >actual &&
        test_cmp expect actual
index 043954422c82d9afbb318bcb7d1aa5685a391c85..753a6c972cda61d2da3d2ecf7bd9c231004d6ad0 100755 (executable)
@@ -91,7 +91,7 @@ test_expect_success 'cherry-pick on stat-dirty working tree' '
        )
 '
 
-test_expect_success 'revert forbidden on dirty working tree' '
+test_expect_success C_LOCALE_OUTPUT 'revert forbidden on dirty working tree' '
 
        echo content >extra_file &&
        git add extra_file &&
index 95741801b0007b6ecbf22f665c4dcf3c744d5221..c0c8330c20e80f26d51b62c8999533c5692094de 100755 (executable)
@@ -44,7 +44,7 @@ test_expect_success 'failed cherry-pick does not advance HEAD' '
        test "$head" = "$newhead"
 '
 
-test_expect_success 'advice from failed cherry-pick' "
+test_expect_success C_LOCALE_OUTPUT 'advice from failed cherry-pick' "
        pristine_detach initial &&
 
        picked=\$(git rev-parse --short picked) &&
index ec7108358e7b7f54f0b5e7530c8368e4a56576af..7de42faf4887c6e8137c2498a96b41a4afe4e672 100755 (executable)
@@ -268,8 +268,12 @@ test_expect_success 'git add --dry-run of existing changed file' "
 
 test_expect_success 'git add --dry-run of non-existing file' "
        echo ignored-file >>.gitignore &&
-       test_must_fail git add --dry-run track-this ignored-file >actual 2>&1 &&
-       echo \"fatal: pathspec 'ignored-file' did not match any files\" | test_cmp - actual
+       test_must_fail git add --dry-run track-this ignored-file >actual 2>&1
+"
+
+test_expect_success C_LOCALE_OUTPUT 'git add --dry-run of an existing file output' "
+       echo \"fatal: pathspec 'ignored-file' did not match any files\" >expect &&
+       test_cmp expect actual
 "
 
 cat >expect.err <<\EOF
@@ -283,7 +287,10 @@ add 'track-this'
 EOF
 
 test_expect_success 'git add --dry-run --ignore-missing of non-existing file' '
-       test_must_fail git add --dry-run --ignore-missing track-this ignored-file >actual.out 2>actual.err &&
+       test_must_fail git add --dry-run --ignore-missing track-this ignored-file >actual.out 2>actual.err
+'
+
+test_expect_success C_LOCALE_OUTPUT 'git add --dry-run --ignore-missing of non-existing file output' '
        test_cmp expect.out actual.out &&
        test_cmp expect.err actual.err
 '
index 71bac83dd5e42a19e3b1a7e869df0e7143371c99..cad85450b78891a98a0b60af1422c62c7288265c 100755 (executable)
@@ -64,7 +64,7 @@ test_expect_success \
     'validate the output.' \
     'compare_diff_patch current expected'
 
-test_expect_success 'favour same basenames over different ones' '
+test_expect_success C_LOCALE_OUTPUT 'favour same basenames over different ones' '
        cp path1 another-path &&
        git add another-path &&
        git commit -m 1 &&
@@ -73,7 +73,7 @@ test_expect_success 'favour same basenames over different ones' '
        git mv another-path subdir/path1 &&
        git status | grep "renamed: .*path1 -> subdir/path1"'
 
-test_expect_success  'favour same basenames even with minor differences' '
+test_expect_success C_LOCALE_OUTPUT  'favour same basenames even with minor differences' '
        git show HEAD:path1 | sed "s/15/16/" > subdir/path1 &&
        git status | grep "renamed: .*path1 -> subdir/path1"'
 
index 9c663677df0887cc09ce2c8277ec300e8de4eaaa..c3cdb5205350985f3362268b0cd63bc59bee2444 100755 (executable)
@@ -614,7 +614,7 @@ echo "fatal: --name-only does not make sense" > expect.name-only
 echo "fatal: --name-status does not make sense" > expect.name-status
 echo "fatal: --check does not make sense" > expect.check
 
-test_expect_success 'options no longer allowed for format-patch' '
+test_expect_success C_LOCALE_OUTPUT 'options no longer allowed for format-patch' '
        test_must_fail git format-patch --name-only 2> output &&
        test_cmp expect.name-only output &&
        test_must_fail git format-patch --name-status 2> output &&
index 0470a81be0edaf883788d313778ef6865ed34c6f..0e5eb678ce6b2f4fad79c39947455e5284313ba4 100755 (executable)
@@ -46,6 +46,17 @@ test_expect_success 'pulling into void using master:master' '
        test_cmp file cloned-uho/file
 '
 
+test_expect_success 'pulling into void does not overwrite untracked files' '
+       git init cloned-untracked &&
+       (
+               cd cloned-untracked &&
+               echo untracked >file &&
+               test_must_fail git pull .. master &&
+               echo untracked >expect &&
+               test_cmp expect file
+       )
+'
+
 test_expect_success 'test . as a remote' '
 
        git branch copy master &&
index a5f458533fd071c13550a72bf251e2e10c109637..af78e21ba913b465e7bf2e4149549d32de9d4240 100755 (executable)
@@ -66,7 +66,10 @@ test_expect_success "fetch --recurse-submodules recurses into submodules" '
        (
                cd downstream &&
                git fetch --recurse-submodules >../actual.out 2>../actual.err
-       ) &&
+       )
+'
+
+test_expect_success C_LOCALE_OUTPUT "fetch --recurse-submodules recurses into submodules: output" '
        test_cmp expect.out actual.out &&
        test_cmp expect.err actual.err
 '
@@ -95,7 +98,10 @@ test_expect_success "using fetchRecurseSubmodules=true in .gitmodules recurses i
                cd downstream &&
                git config -f .gitmodules submodule.submodule.fetchRecurseSubmodules true &&
                git fetch >../actual.out 2>../actual.err
-       ) &&
+       )
+'
+
+test_expect_success C_LOCALE_OUTPUT "using fetchRecurseSubmodules=true in .gitmodules recurses into submodules" '
        test_cmp expect.out actual.out &&
        test_cmp expect.err actual.err
 '
@@ -126,7 +132,10 @@ test_expect_success "--recurse-submodules overrides fetchRecurseSubmodules setti
                git fetch --recurse-submodules >../actual.out 2>../actual.err &&
                git config --unset -f .gitmodules submodule.submodule.fetchRecurseSubmodules &&
                git config --unset submodule.submodule.fetchRecurseSubmodules
-       ) &&
+       )
+'
+
+test_expect_success C_LOCALE_OUTPUT "--recurse-submodules overrides fetchRecurseSubmodules setting from .git/config: output" '
        test_cmp expect.out actual.out &&
        test_cmp expect.err actual.err
 '
@@ -145,13 +154,22 @@ test_expect_success "--dry-run propagates to submodules" '
        (
                cd downstream &&
                git fetch --recurse-submodules --dry-run >../actual.out 2>../actual.err
-       ) &&
+       )
+'
+
+test_expect_success C_LOCALE_OUTPUT "--dry-run propagates to submodules: output" '
        test_cmp expect.out actual.out &&
-       test_cmp expect.err actual.err &&
+       test_cmp expect.err actual.err
+'
+
+test_expect_success "Without --dry-run propagates to submodules" '
        (
                cd downstream &&
                git fetch --recurse-submodules >../actual.out 2>../actual.err
-       ) &&
+       )
+'
+
+test_expect_success C_LOCALE_OUTPUT "Without --dry-run propagates to submodules: output" '
        test_cmp expect.out actual.out &&
        test_cmp expect.err actual.err
 '
@@ -162,7 +180,10 @@ test_expect_success "recurseSubmodules=true propagates into submodules" '
                cd downstream &&
                git config fetch.recurseSubmodules true
                git fetch >../actual.out 2>../actual.err
-       ) &&
+       )
+'
+
+test_expect_success C_LOCALE_OUTPUT "recurseSubmodules=true propagates into submodules: output" '
        test_cmp expect.out actual.out &&
        test_cmp expect.err actual.err
 '
@@ -176,7 +197,10 @@ test_expect_success "--recurse-submodules overrides config in submodule" '
                        git config fetch.recurseSubmodules false
                ) &&
                git fetch --recurse-submodules >../actual.out 2>../actual.err
-       ) &&
+       )
+'
+
+test_expect_success C_LOCALE_OUTPUT "--recurse-submodules overrides config in submodule: output" '
        test_cmp expect.out actual.out &&
        test_cmp expect.err actual.err
 '
@@ -192,4 +216,259 @@ test_expect_success "--no-recurse-submodules overrides config setting" '
        ! test -s actual.err
 '
 
+test_expect_success "Recursion doesn't happen when no new commits are fetched in the superproject" '
+       (
+               cd downstream &&
+               (
+                       cd submodule &&
+                       git config --unset fetch.recurseSubmodules
+               ) &&
+               git config --unset fetch.recurseSubmodules
+               git fetch >../actual.out 2>../actual.err
+       ) &&
+       ! test -s actual.out &&
+       ! test -s actual.err
+'
+
+test_expect_success "Recursion stops when no new submodule commits are fetched" '
+       head1=$(git rev-parse --short HEAD) &&
+       git add submodule &&
+       git commit -m "new submodule" &&
+       head2=$(git rev-parse --short HEAD) &&
+       echo "Fetching submodule submodule" > expect.out.sub &&
+       echo "From $pwd/." > expect.err.sub &&
+       echo "   $head1..$head2  master     -> origin/master" >> expect.err.sub
+       head -2 expect.err >> expect.err.sub &&
+       (
+               cd downstream &&
+               git fetch >../actual.out 2>../actual.err
+       ) &&
+       test_cmp expect.err.sub actual.err &&
+       test_cmp expect.out.sub actual.out
+'
+
+test_expect_success "Recursion doesn't happen when new superproject commits don't change any submodules" '
+       add_upstream_commit &&
+       head1=$(git rev-parse --short HEAD) &&
+       echo a > file &&
+       git add file &&
+       git commit -m "new file" &&
+       head2=$(git rev-parse --short HEAD) &&
+       echo "From $pwd/." > expect.err.file &&
+       echo "   $head1..$head2  master     -> origin/master" >> expect.err.file &&
+       (
+               cd downstream &&
+               git fetch >../actual.out 2>../actual.err
+       ) &&
+       ! test -s actual.out &&
+       test_cmp expect.err.file actual.err
+'
+
+test_expect_success "Recursion picks up config in submodule" '
+       (
+               cd downstream &&
+               git fetch --recurse-submodules &&
+               (
+                       cd submodule &&
+                       git config fetch.recurseSubmodules true
+               )
+       ) &&
+       add_upstream_commit &&
+       head1=$(git rev-parse --short HEAD) &&
+       git add submodule &&
+       git commit -m "new submodule" &&
+       head2=$(git rev-parse --short HEAD) &&
+       echo "From $pwd/." > expect.err.sub &&
+       echo "   $head1..$head2  master     -> origin/master" >> expect.err.sub &&
+       cat expect.err >> expect.err.sub &&
+       (
+               cd downstream &&
+               git fetch >../actual.out 2>../actual.err &&
+               (
+                       cd submodule &&
+                       git config --unset fetch.recurseSubmodules
+               )
+       ) &&
+       test_cmp expect.err.sub actual.err &&
+       test_cmp expect.out actual.out
+'
+
+test_expect_success "Recursion picks up all submodules when necessary" '
+       add_upstream_commit &&
+       (
+               cd submodule &&
+               (
+                       cd deepsubmodule &&
+                       git fetch &&
+                       git checkout -q FETCH_HEAD
+               ) &&
+               head1=$(git rev-parse --short HEAD^) &&
+               git add deepsubmodule &&
+               git commit -m "new deepsubmodule"
+               head2=$(git rev-parse --short HEAD) &&
+               echo "From $pwd/submodule" > ../expect.err.sub &&
+               echo "   $head1..$head2  master     -> origin/master" >> ../expect.err.sub
+       ) &&
+       head1=$(git rev-parse --short HEAD) &&
+       git add submodule &&
+       git commit -m "new submodule" &&
+       head2=$(git rev-parse --short HEAD) &&
+       echo "From $pwd/." > expect.err.2 &&
+       echo "   $head1..$head2  master     -> origin/master" >> expect.err.2 &&
+       cat expect.err.sub >> expect.err.2 &&
+       tail -2 expect.err >> expect.err.2 &&
+       (
+               cd downstream &&
+               git fetch >../actual.out 2>../actual.err
+       ) &&
+       test_cmp expect.err.2 actual.err &&
+       test_cmp expect.out actual.out
+'
+
+test_expect_success "'--recurse-submodules=on-demand' doesn't recurse when no new commits are fetched in the superproject (and ignores config)" '
+       add_upstream_commit &&
+       (
+               cd submodule &&
+               (
+                       cd deepsubmodule &&
+                       git fetch &&
+                       git checkout -q FETCH_HEAD
+               ) &&
+               head1=$(git rev-parse --short HEAD^) &&
+               git add deepsubmodule &&
+               git commit -m "new deepsubmodule"
+               head2=$(git rev-parse --short HEAD) &&
+               echo "From $pwd/submodule" > ../expect.err.sub &&
+               echo "   $head1..$head2  master     -> origin/master" >> ../expect.err.sub
+       ) &&
+       (
+               cd downstream &&
+               git config fetch.recurseSubmodules true &&
+               git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err &&
+               git config --unset fetch.recurseSubmodules
+       ) &&
+       ! test -s actual.out &&
+       ! test -s actual.err
+'
+
+test_expect_success "'--recurse-submodules=on-demand' recurses as deep as necessary (and ignores config)" '
+       head1=$(git rev-parse --short HEAD) &&
+       git add submodule &&
+       git commit -m "new submodule" &&
+       head2=$(git rev-parse --short HEAD) &&
+       tail -2 expect.err > expect.err.deepsub &&
+       echo "From $pwd/." > expect.err &&
+       echo "   $head1..$head2  master     -> origin/master" >> expect.err
+       cat expect.err.sub >> expect.err &&
+       cat expect.err.deepsub >> expect.err &&
+       (
+               cd downstream &&
+               git config fetch.recurseSubmodules false &&
+               (
+                       cd submodule &&
+                       git config -f .gitmodules submodule.deepsubmodule.fetchRecursive false
+               ) &&
+               git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err &&
+               git config --unset fetch.recurseSubmodules
+               (
+                       cd submodule &&
+                       git config --unset -f .gitmodules submodule.deepsubmodule.fetchRecursive
+               )
+       ) &&
+       test_cmp expect.out actual.out &&
+       test_cmp expect.err actual.err
+'
+
+test_expect_success "'--recurse-submodules=on-demand' stops when no new submodule commits are found in the superproject (and ignores config)" '
+       add_upstream_commit &&
+       head1=$(git rev-parse --short HEAD) &&
+       echo a >> file &&
+       git add file &&
+       git commit -m "new file" &&
+       head2=$(git rev-parse --short HEAD) &&
+       echo "From $pwd/." > expect.err.file &&
+       echo "   $head1..$head2  master     -> origin/master" >> expect.err.file &&
+       (
+               cd downstream &&
+               git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err
+       ) &&
+       ! test -s actual.out &&
+       test_cmp expect.err.file actual.err
+'
+
+test_expect_success "'fetch.recurseSubmodules=on-demand' overrides global config" '
+       (
+               cd downstream &&
+               git fetch --recurse-submodules
+       ) &&
+       add_upstream_commit &&
+       git config --global fetch.recurseSubmodules false &&
+       head1=$(git rev-parse --short HEAD) &&
+       git add submodule &&
+       git commit -m "new submodule" &&
+       head2=$(git rev-parse --short HEAD) &&
+       echo "From $pwd/." > expect.err.2 &&
+       echo "   $head1..$head2  master     -> origin/master" >> expect.err.2
+       head -2 expect.err >> expect.err.2 &&
+       (
+               cd downstream &&
+               git config fetch.recurseSubmodules on-demand &&
+               git fetch >../actual.out 2>../actual.err
+       ) &&
+       git config --global --unset fetch.recurseSubmodules &&
+       (
+               cd downstream &&
+               git config --unset fetch.recurseSubmodules
+       ) &&
+       test_cmp expect.out.sub actual.out &&
+       test_cmp expect.err.2 actual.err
+'
+
+test_expect_success "'submodule.<sub>.fetchRecurseSubmodules=on-demand' overrides fetch.recurseSubmodules" '
+       (
+               cd downstream &&
+               git fetch --recurse-submodules
+       ) &&
+       add_upstream_commit &&
+       git config fetch.recurseSubmodules false &&
+       head1=$(git rev-parse --short HEAD) &&
+       git add submodule &&
+       git commit -m "new submodule" &&
+       head2=$(git rev-parse --short HEAD) &&
+       echo "From $pwd/." > expect.err.2 &&
+       echo "   $head1..$head2  master     -> origin/master" >> expect.err.2
+       head -2 expect.err >> expect.err.2 &&
+       (
+               cd downstream &&
+               git config submodule.submodule.fetchRecurseSubmodules on-demand &&
+               git fetch >../actual.out 2>../actual.err
+       ) &&
+       git config --unset fetch.recurseSubmodules &&
+       (
+               cd downstream &&
+               git config --unset submodule.submodule.fetchRecurseSubmodules
+       ) &&
+       test_cmp expect.out.sub actual.out &&
+       test_cmp expect.err.2 actual.err
+'
+
+test_expect_success "don't fetch submodule when newly recorded commits are already present" '
+       (
+               cd submodule &&
+               git checkout -q HEAD^^
+       ) &&
+       head1=$(git rev-parse --short HEAD) &&
+       git add submodule &&
+       git commit -m "submodule rewound" &&
+       head2=$(git rev-parse --short HEAD) &&
+       echo "From $pwd/." > expect.err &&
+       echo "   $head1..$head2  master     -> origin/master" >> expect.err &&
+       (
+               cd downstream &&
+               git fetch >../actual.out 2>../actual.err
+       ) &&
+       ! test -s actual.out &&
+       test_cmp expect.err actual.err
+'
+
 test_done
index b0c2a2c3aea811ec023423bdb486de5412fa79c5..0492877d516b8f33a8fd1555ec77a2aa3b34352c 100755 (executable)
@@ -128,11 +128,14 @@ test_expect_success 'push fails for non-fast-forward refs unmatched by remote he
 
        # push master too; this ensures there is at least one '"'push'"' command to
        # the remote helper and triggers interaction with the helper.
-       test_must_fail git push -v origin +master master:retsam >output 2>&1 &&
+       test_must_fail git push -v origin +master master:retsam >output 2>&1'
 
+test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper: remote output' '
        grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *master -> master (forced update)$" output &&
-       grep "^ ! \[rejected\] *master -> retsam (non-fast-forward)$" output &&
+       grep "^ ! \[rejected\] *master -> retsam (non-fast-forward)$" output
+'
 
+test_expect_success C_LOCALE_OUTPUT 'push fails for non-fast-forward refs unmatched by remote helper: our output' '
        grep "To prevent you from losing history, non-fast-forward updates were rejected" \
                output
 '
index 3ca275cc671502febd8397e1828c612f575c5b89..5a068b21e4aeac79863df657d6388ec4c2732d55 100755 (executable)
@@ -31,7 +31,7 @@ test_expect_success 'clone with excess parameters (2)' '
 
 '
 
-test_expect_success 'output from clone' '
+test_expect_success C_LOCALE_OUTPUT 'output from clone' '
        rm -fr dst &&
        git clone -n "file://$(pwd)/src" dst >output &&
        test $(grep Clon output | wc -l) = 1
@@ -191,4 +191,17 @@ test_expect_success 'do not respect url-encoding of non-url path' '
        git clone x+y xy-regular
 '
 
+test_expect_success 'clone separate gitdir' '
+       rm -rf dst &&
+       git clone --separate-git-dir realgitdir src dst &&
+       echo "gitdir: `pwd`/realgitdir" >expected &&
+       test_cmp expected dst/.git &&
+       test -d realgitdir/refs
+'
+
+test_expect_success 'clone separate gitdir where target already exists' '
+       rm -rf dst &&
+       test_must_fail git clone --separate-git-dir realgitdir src dst
+'
+
 test_done
index cb851326425be7a552a0624a5d7483244625a7ed..6c3719141aa567b97de1228f53a6c49eaf139e8e 100755 (executable)
@@ -42,7 +42,7 @@ b3 behind 1
 b4 ahead 2
 EOF
 
-test_expect_success 'branch -v' '
+test_expect_success C_LOCALE_OUTPUT 'branch -v' '
        (
                cd test &&
                git branch -v
index 876d1ab7430c2054ddc69bd3712ff769de52e774..18269962458248034598d2bb15315f0d2a121027 100755 (executable)
@@ -123,7 +123,7 @@ cat - >err.expect <<EOF
 warning: tag 'A' is really 'Q' here
 EOF
 check_describe A-* HEAD
-test_expect_success 'warning was displayed for Q' '
+test_expect_success C_LOCALE_OUTPUT 'warning was displayed for Q' '
        test_cmp err.expect err.actual
 '
 test_expect_success 'rename tag Q back to A' '
index 3e7baaf89f9bada46fc084e568544ce9df833594..1dedfd0c836c06eb3d2f66aa8e4e7eac54368508 100755 (executable)
@@ -1121,6 +1121,7 @@ test_expect_success \
 '
 
 test_expect_success \
+       C_LOCALE_OUTPUT \
        'message in editor has initial comment: first line' '
        # check the first line --- should be empty
        echo >first.expect &&
index 582d0b54f1f1a32459727e59932e95c4b466951f..14fcb1c7f5d8366827bc6e3256f118a757d2e996 100755 (executable)
@@ -124,13 +124,13 @@ cat >expected <<EOF
 Would remove expected
 Would remove result
 EOF
-test_expect_success 'git-clean, absent case' '
+test_expect_success C_LOCALE_OUTPUT 'git-clean, absent case' '
        setup_absent &&
        git clean -n > result &&
        test_cmp expected result
 '
 
-test_expect_success 'git-clean, dirty case' '
+test_expect_success C_LOCALE_OUTPUT 'git-clean, dirty case' '
        setup_dirty &&
        git clean -n > result &&
        test_cmp expected result
index fcac4725982096af98414c5d40df2d4c14be9454..b4fcc86a10f15178da25da159e160b38d717f318 100755 (executable)
@@ -38,7 +38,7 @@ cat >expect <<EOF
 no changes added to commit (use "git add" and/or "git commit -a")
 EOF
 
-test_expect_success 'M/D conflict does not segfault' '
+test_expect_success C_LOCALE_OUTPUT 'M/D conflict does not segfault' '
        mkdir mdconflict &&
        (
                cd mdconflict &&
index b8cf2603a195af406d3606712e45fd1195c1588f..7be2ff38fc92088d4caff9ea13b1d78a1b040b40 100755 (executable)
@@ -423,7 +423,7 @@ Unstaged changes after reset:
 M      file2
 EOF
 
-test_expect_success '--mixed refreshes the index' '
+test_expect_success C_LOCALE_OUTPUT '--mixed refreshes the index' '
        echo 123 >> file2 &&
        git reset --mixed HEAD > output &&
        test_cmp expect output
index 70cdd8e618c648f7ee6550997d68c40d912c8db9..b42820ad6976590fe195637d5e85d1b4db963cda 100755 (executable)
@@ -233,7 +233,7 @@ test_expect_success '"reset --merge HEAD^" is ok with pending merge' '
 #           working index HEAD target         working index HEAD
 #           ----------------------------------------------------
 # file1:     X       U     B    C     --keep   (disallowed)
-test_expect_success '"reset --keep HEAD^" fails with pending merge' '
+test_expect_success C_LOCALE_OUTPUT '"reset --keep HEAD^" fails with pending merge' '
     git reset --hard third &&
     test_must_fail git merge branch1 &&
     test_must_fail git reset --keep HEAD^ 2>err.log &&
@@ -259,7 +259,7 @@ test_expect_success '"reset --merge HEAD" is ok with pending merge' '
 #           working index HEAD target         working index HEAD
 #           ----------------------------------------------------
 # file1:     X       U     B    B     --keep   (disallowed)
-test_expect_success '"reset --keep HEAD" fails with pending merge' '
+test_expect_success C_LOCALE_OUTPUT '"reset --keep HEAD" fails with pending merge' '
     git reset --hard third &&
     test_must_fail git merge branch1 &&
     test_must_fail git reset --keep HEAD 2>err.log &&
@@ -280,7 +280,7 @@ test_expect_success '--merge is ok with added/deleted merge' '
     git diff --exit-code --cached
 '
 
-test_expect_success '--keep fails with added/deleted merge' '
+test_expect_success C_LOCALE_OUTPUT '--keep fails with added/deleted merge' '
     git reset --hard third &&
     rm -f file2 &&
     test_must_fail git merge branch3 &&
index 0c002ab6951752bbf1d466ff5d0a4668835ca57c..37ed0931d9499791a6b3336efb97385356df6157 100755 (executable)
@@ -223,7 +223,7 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' '
        test_cmp two expect
 '
 
-test_expect_success 'checkout to detach HEAD (with advice declined)' '
+test_expect_success C_LOCALE_OUTPUT 'checkout to detach HEAD (with advice declined)' '
 
        git config advice.detachedHead false &&
        git checkout -f renamer && git clean -f &&
@@ -242,7 +242,7 @@ test_expect_success 'checkout to detach HEAD (with advice declined)' '
        fi
 '
 
-test_expect_success 'checkout to detach HEAD' '
+test_expect_success C_LOCALE_OUTPUT 'checkout to detach HEAD' '
        git config advice.detachedHead true &&
        git checkout -f renamer && git clean -f &&
        git checkout renamer^ 2>messages &&
@@ -260,7 +260,7 @@ test_expect_success 'checkout to detach HEAD' '
        fi
 '
 
-test_expect_success 'checkout to detach HEAD with branchname^' '
+test_expect_success C_LOCALE_OUTPUT 'checkout to detach HEAD with branchname^' '
 
        git checkout -f master && git clean -f &&
        git checkout renamer^ &&
@@ -276,7 +276,7 @@ test_expect_success 'checkout to detach HEAD with branchname^' '
        fi
 '
 
-test_expect_success 'checkout to detach HEAD with :/message' '
+test_expect_success C_LOCALE_OUTPUT 'checkout to detach HEAD with :/message' '
 
        git checkout -f master && git clean -f &&
        git checkout ":/Initial" &&
@@ -292,7 +292,7 @@ test_expect_success 'checkout to detach HEAD with :/message' '
        fi
 '
 
-test_expect_success 'checkout to detach HEAD with HEAD^0' '
+test_expect_success C_LOCALE_OUTPUT 'checkout to detach HEAD with HEAD^0' '
 
        git checkout -f master && git clean -f &&
        git checkout HEAD^0 &&
index 02f67b73b762850f3c7f0faf0886bf4011f57308..7e1be444027621e1ea94b0b9ed0e129fce922b02 100755 (executable)
@@ -110,7 +110,7 @@ test_expect_success 'git clean with prefix' '
 
 '
 
-test_expect_success 'git clean with relative prefix' '
+test_expect_success C_LOCALE_OUTPUT 'git clean with relative prefix' '
 
        mkdir -p build docs &&
        touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
@@ -125,7 +125,7 @@ test_expect_success 'git clean with relative prefix' '
        }
 '
 
-test_expect_success 'git clean with absolute path' '
+test_expect_success C_LOCALE_OUTPUT 'git clean with absolute path' '
 
        mkdir -p build docs &&
        touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
@@ -377,7 +377,7 @@ test_expect_success 'clean.requireForce and -f' '
 
 '
 
-test_expect_success 'core.excludesfile' '
+test_expect_success C_LOCALE_OUTPUT 'core.excludesfile' '
 
        echo excludes >excludes &&
        echo included >included &&
index e5b19538b0192e5ab5f9081b0c10ac0dc8497cb6..d600583cef8aa4a19d98ffa63b2cc4f76f698c9e 100755 (executable)
@@ -52,7 +52,7 @@ test_expect_success 'change submodule url' '
 
 test_expect_success '"git submodule sync" should update submodule URLs' '
        (cd super-clone &&
-        git pull &&
+        git pull --no-recurse-submodules &&
         git submodule sync
        ) &&
        test -d "$(git config -f super-clone/submodule/.git/config \
index 7e2e258950772c91dfc04aff72ed74e95b5df884..a8fb30b7921dd17f910d48e82fbb2374fcb45ac3 100755 (executable)
@@ -56,11 +56,11 @@ test_expect_success setup '
 
 # History setup
 #
-#      b
-#    /   \
-#   a     d
-#    \   /
-#      c
+#             b
+#           /   \
+#  init -- a     d
+#    \      \   /
+#     g       c
 #
 # a in the main repository records to sub-a in the submodule and
 # analogous b and c. d should be automatically found by merging c into
@@ -76,6 +76,8 @@ test_expect_success 'setup for merge search' '
         git add file-a &&
         git commit -m "sub-a" &&
         git branch sub-a) &&
+       git commit --allow-empty -m init &&
+       git branch init &&
        git add sub &&
        git commit -m "a" &&
        git branch a &&
@@ -101,7 +103,13 @@ test_expect_success 'setup for merge search' '
         git checkout -b sub-d sub-b &&
         git merge sub-c) &&
        git commit -a -m "d" &&
-       git branch test b)
+       git branch test b &&
+
+       git checkout -b g init &&
+       (cd sub &&
+        git checkout -b sub-g sub-c) &&
+       git add sub &&
+       git commit -a -m "g")
 '
 
 test_expect_success 'merge with one side as a fast-forward of the other' '
@@ -176,6 +184,44 @@ test_expect_success 'merging should fail for changes that are backwards' '
        test_must_fail git merge f)
 '
 
+
+# Check that the conflicting submodule is detected when it is
+# in the common ancestor. status should be 'U00...00"
+test_expect_success 'git submodule status should display the merge conflict properly with merge base' '
+       (cd merge-search &&
+       cat >.gitmodules <<EOF &&
+[submodule "sub"]
+       path = sub
+       url = $TRASH_DIRECTORY/sub
+EOF
+       cat >expect <<EOF &&
+U0000000000000000000000000000000000000000 sub
+EOF
+       git submodule status > actual &&
+       test_cmp expect actual &&
+       git reset --hard)
+'
+
+# Check that the conflicting submodule is detected when it is
+# not in the common ancestor. status should be 'U00...00"
+test_expect_success 'git submodule status should display the merge conflict properly without merge-base' '
+       (cd merge-search &&
+       git checkout -b test-no-merge-base g &&
+       test_must_fail git merge b &&
+       cat >.gitmodules <<EOF &&
+[submodule "sub"]
+       path = sub
+       url = $TRASH_DIRECTORY/sub
+EOF
+       cat >expect <<EOF &&
+U0000000000000000000000000000000000000000 sub
+EOF
+       git submodule status > actual &&
+       test_cmp expect actual &&
+       git reset --hard)
+'
+
+
 test_expect_success 'merging with a modify/modify conflict between merge bases' '
        git reset --hard HEAD &&
        git checkout -b test2 c &&
index fa9d23aa31302f53cc1c39473492cf545ca5ae87..bf7c788735d6e3e0ecf56e7a2f82826701ee1789 100755 (executable)
@@ -74,6 +74,26 @@ test_expect_success 'submodule update detaching the HEAD ' '
        )
 '
 
+apos="'";
+test_expect_success 'submodule update does not fetch already present commits' '
+       (cd submodule &&
+         echo line3 >> file &&
+         git add file &&
+         test_tick &&
+         git commit -m "upstream line3"
+       ) &&
+       (cd super/submodule &&
+         head=$(git rev-parse --verify HEAD) &&
+         echo "Submodule path ${apos}submodule$apos: checked out $apos$head$apos" > ../../expected &&
+         git reset --hard HEAD~1
+       ) &&
+       (cd super &&
+         git submodule update > ../actual 2> ../actual.err
+       ) &&
+       test_cmp expected actual &&
+       ! test -s actual.err
+'
+
 test_expect_success 'submodule update --rebase staying on master' '
        (cd super/submodule &&
          git checkout master
index 5976f598fc7bf48120865eca3ceef74a151e717a..bcdf0847d0970f544e96afa0036ec12800422fd8 100755 (executable)
@@ -72,7 +72,7 @@ test_expect_success 'adding comments to a template should not commit' '
        )
 '
 
-test_expect_success 'adding real content to a template should commit' '
+test_expect_success C_LOCALE_OUTPUT 'adding real content to a template should commit' '
        (
                test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
                git commit --template "$TEMPLATE"
@@ -80,7 +80,7 @@ test_expect_success 'adding real content to a template should commit' '
        commit_msg_is "template linecommit message"
 '
 
-test_expect_success '-t option should be short for --template' '
+test_expect_success C_LOCALE_OUTPUT '-t option should be short for --template' '
        echo "short template" > "$TEMPLATE" &&
        echo "new content" >> foo &&
        git add foo &&
@@ -91,7 +91,7 @@ test_expect_success '-t option should be short for --template' '
        commit_msg_is "short templatecommit message"
 '
 
-test_expect_success 'config-specified template should commit' '
+test_expect_success C_LOCALE_OUTPUT 'config-specified template should commit' '
        echo "new template" > "$TEMPLATE" &&
        git config commit.template "$TEMPLATE" &&
        echo "more content" >> foo &&
@@ -290,7 +290,7 @@ test_expect_success 'commit --squash works with -c for same commit' '
        commit_msg_is "squash! edited commit"
 '
 
-test_expect_success 'commit --squash works with editor' '
+test_expect_success C_LOCALE_OUTPUT 'commit --squash works with editor' '
        commit_for_rebase_autosquash_setup &&
        test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
        git commit --squash HEAD~1 &&
index 8980738c7540b79eaa566d6054f3e76b202bd27e..a76c47419590ed16c53b8d4d82c2d92c11853154 100755 (executable)
@@ -14,8 +14,11 @@ test_tick
 test_expect_success \
        "initial status" \
        "echo 'bongo bongo' >file &&
-        git add file && \
-        git status | grep 'Initial commit'"
+        git add file"
+
+test_expect_success C_LOCALE_OUTPUT \
+       "Constructing initial commit" \
+       "git status | grep 'Initial commit'"
 
 test_expect_success \
        "fail initial amend" \
index 50da034cd3934d0509e67a6f20e514a18e5659d4..cfb569eaba657501cf0361bee8c3f7c172ed1c06 100755 (executable)
@@ -22,7 +22,10 @@ check_summary_oneline() {
        SUMMARY_POSTFIX="$(git log -1 --pretty='format:%h')"
        echo "[$SUMMARY_PREFIX $SUMMARY_POSTFIX] $2" >exp &&
 
-       test_cmp exp act
+       if test_have_prereq C_LOCALE_OUTPUT
+       then
+               test_cmp exp act
+       fi
 }
 
 test_expect_success 'output summary format' '
@@ -32,7 +35,10 @@ test_expect_success 'output summary format' '
        check_summary_oneline "root-commit" "initial" &&
 
        echo change >>file1 &&
-       git add file1 &&
+       git add file1
+'
+
+test_expect_success 'output summary format: root-commit' '
        check_summary_oneline "" "a change"
 '
 
@@ -215,30 +221,35 @@ test_expect_success 'cleanup commit messages (strip,-F)' '
 
 '
 
-echo "sample
-
-# Please enter the commit message for your changes. Lines starting
-# with '#' will be ignored, and an empty message aborts the commit." >expect
-
 test_expect_success 'cleanup commit messages (strip,-F,-e)' '
 
        echo >>negative &&
        { echo;echo sample;echo; } >text &&
        git commit -e -F text -a &&
-       head -n 4 .git/COMMIT_EDITMSG >actual &&
-       test_cmp expect actual
+       head -n 4 .git/COMMIT_EDITMSG >actual
+'
+
+echo "sample
+
+# Please enter the commit message for your changes. Lines starting
+# with '#' will be ignored, and an empty message aborts the commit." >expect
 
+test_expect_success C_LOCALE_OUTPUT 'cleanup commit messages (strip,-F,-e): output' '
+       test_cmp expect actual
 '
 
 echo "#
 # Author:    $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 #" >> expect
 
-test_expect_success 'author different from committer' '
+test_expect_success C_LOCALE_OUTPUT 'author different from committer' '
 
        echo >>negative &&
        git commit -e -m "sample"
-       head -n 7 .git/COMMIT_EDITMSG >actual &&
+       head -n 7 .git/COMMIT_EDITMSG >actual
+'
+
+test_expect_success C_LOCALE_OUTPUT 'author different from committer: output' '
        test_cmp expect actual
 '
 
@@ -248,7 +259,7 @@ rm -f expect.tmp
 echo "# Committer:
 #" >> expect
 
-test_expect_success 'committer is automatic' '
+test_expect_success C_LOCALE_OUTPUT 'committer is automatic' '
 
        echo >>negative &&
        (
@@ -258,7 +269,10 @@ test_expect_success 'committer is automatic' '
                test_must_fail git commit -e -m "sample"
        ) &&
        head -n 8 .git/COMMIT_EDITMSG | \
-       sed "s/^# Committer: .*/# Committer:/" >actual &&
+       sed "s/^# Committer: .*/# Committer:/" >actual
+'
+
+test_expect_success C_LOCALE_OUTPUT 'committer is automatic: output' '
        test_cmp expect actual
 '
 
@@ -370,66 +384,66 @@ try_commit () {
 
 try_commit_status_combo () {
 
-       test_expect_success 'commit' '
+       test_expect_success C_LOCALE_OUTPUT 'commit' '
                clear_config commit.status &&
                try_commit "" &&
                grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
 
-       test_expect_success 'commit' '
+       test_expect_success C_LOCALE_OUTPUT 'commit' '
                clear_config commit.status &&
                try_commit "" &&
                grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
 
-       test_expect_success 'commit --status' '
+       test_expect_success C_LOCALE_OUTPUT 'commit --status' '
                clear_config commit.status &&
                try_commit --status &&
                grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
 
-       test_expect_success 'commit --no-status' '
+       test_expect_success C_LOCALE_OUTPUT 'commit --no-status' '
                clear_config commit.status &&
                try_commit --no-status &&
                ! grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
 
-       test_expect_success 'commit with commit.status = yes' '
+       test_expect_success C_LOCALE_OUTPUT 'commit with commit.status = yes' '
                clear_config commit.status &&
                git config commit.status yes &&
                try_commit "" &&
                grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
 
-       test_expect_success 'commit with commit.status = no' '
+       test_expect_success C_LOCALE_OUTPUT 'commit with commit.status = no' '
                clear_config commit.status &&
                git config commit.status no &&
                try_commit "" &&
                ! grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
 
-       test_expect_success 'commit --status with commit.status = yes' '
+       test_expect_success C_LOCALE_OUTPUT 'commit --status with commit.status = yes' '
                clear_config commit.status &&
                git config commit.status yes &&
                try_commit --status &&
                grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
 
-       test_expect_success 'commit --no-status with commit.status = yes' '
+       test_expect_success C_LOCALE_OUTPUT 'commit --no-status with commit.status = yes' '
                clear_config commit.status &&
                git config commit.status yes &&
                try_commit --no-status &&
                ! grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
 
-       test_expect_success 'commit --status with commit.status = no' '
+       test_expect_success C_LOCALE_OUTPUT 'commit --status with commit.status = no' '
                clear_config commit.status &&
                git config commit.status no &&
                try_commit --status &&
                grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
 
-       test_expect_success 'commit --no-status with commit.status = no' '
+       test_expect_success C_LOCALE_OUTPUT 'commit --no-status with commit.status = no' '
                clear_config commit.status &&
                git config commit.status no &&
                try_commit --no-status &&
index 3d4f85d74f6f378d76bde77e581273af010ba452..c56733253fe335af9cbd12d19e776e35bd335994 100755 (executable)
@@ -20,17 +20,17 @@ test_expect_success 'setup' '
        git commit -m "Add submodule sub"
 '
 
-test_expect_success 'status clean' '
+test_expect_success C_LOCALE_OUTPUT 'status clean' '
        git status >output &&
        grep "nothing to commit" output
 '
 
-test_expect_success 'commit --dry-run -a clean' '
+test_expect_success C_LOCALE_OUTPUT 'commit --dry-run -a clean' '
        test_must_fail git commit --dry-run -a >output &&
        grep "nothing to commit" output
 '
 
-test_expect_success 'status with modified file in submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with modified file in submodule' '
        (cd sub && git reset --hard) &&
        echo "changed" >sub/foo &&
        git status >output &&
@@ -46,7 +46,7 @@ test_expect_success 'status with modified file in submodule (porcelain)' '
        EOF
 '
 
-test_expect_success 'status with added file in submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with added file in submodule' '
        (cd sub && git reset --hard && echo >foo && git add foo) &&
        git status >output &&
        grep "modified:   sub (modified content)" output
@@ -60,14 +60,14 @@ test_expect_success 'status with added file in submodule (porcelain)' '
        EOF
 '
 
-test_expect_success 'status with untracked file in submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with untracked file in submodule' '
        (cd sub && git reset --hard) &&
        echo "content" >sub/new-file &&
        git status >output &&
        grep "modified:   sub (untracked content)" output
 '
 
-test_expect_success 'status -uno with untracked file in submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status -uno with untracked file in submodule' '
        git status -uno >output &&
        grep "^nothing to commit" output
 '
@@ -79,7 +79,7 @@ test_expect_success 'status with untracked file in submodule (porcelain)' '
        EOF
 '
 
-test_expect_success 'status with added and untracked file in submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with added and untracked file in submodule' '
        (cd sub && git reset --hard && echo >foo && git add foo) &&
        echo "content" >sub/new-file &&
        git status >output &&
@@ -95,7 +95,7 @@ test_expect_success 'status with added and untracked file in submodule (porcelai
        EOF
 '
 
-test_expect_success 'status with modified file in modified submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with modified file in modified submodule' '
        (cd sub && git reset --hard) &&
        rm sub/new-file &&
        (cd sub && echo "next change" >foo && git commit -m "next change" foo) &&
@@ -113,7 +113,7 @@ test_expect_success 'status with modified file in modified submodule (porcelain)
        EOF
 '
 
-test_expect_success 'status with added file in modified submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with added file in modified submodule' '
        (cd sub && git reset --hard && echo >foo && git add foo) &&
        git status >output &&
        grep "modified:   sub (new commits, modified content)" output
@@ -127,7 +127,7 @@ test_expect_success 'status with added file in modified submodule (porcelain)' '
        EOF
 '
 
-test_expect_success 'status with untracked file in modified submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with untracked file in modified submodule' '
        (cd sub && git reset --hard) &&
        echo "content" >sub/new-file &&
        git status >output &&
@@ -141,7 +141,7 @@ test_expect_success 'status with untracked file in modified submodule (porcelain
        EOF
 '
 
-test_expect_success 'status with added and untracked file in modified submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with added and untracked file in modified submodule' '
        (cd sub && git reset --hard && echo >foo && git add foo) &&
        echo "content" >sub/new-file &&
        git status >output &&
@@ -167,7 +167,7 @@ test_expect_success 'setup .git file for sub' '
         git commit -m "added .real to .gitignore" .gitignore
 '
 
-test_expect_success 'status with added file in modified submodule with .git file' '
+test_expect_success C_LOCALE_OUTPUT 'status with added file in modified submodule with .git file' '
        (cd sub && git reset --hard && echo >foo && git add foo) &&
        git status >output &&
        grep "modified:   sub (new commits, modified content)" output
@@ -177,12 +177,12 @@ test_expect_success 'rm submodule contents' '
        rm -rf sub/* sub/.git
 '
 
-test_expect_success 'status clean (empty submodule dir)' '
+test_expect_success C_LOCALE_OUTPUT 'status clean (empty submodule dir)' '
        git status >output &&
        grep "nothing to commit" output
 '
 
-test_expect_success 'status -a clean (empty submodule dir)' '
+test_expect_success C_LOCALE_OUTPUT 'status -a clean (empty submodule dir)' '
        test_must_fail git commit --dry-run -a >output &&
        grep "nothing to commit" output
 '
index f1dc5c3b6a36507e664e624bf9cebb1634bce335..a93e70fac446f0b062abe9109658d54b7c321819 100755 (executable)
@@ -55,7 +55,7 @@ test_expect_success 'setup' '
        git add dir2/added
 '
 
-test_expect_success 'status (1)' '
+test_expect_success C_LOCALE_OUTPUT 'status (1)' '
 
        grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
 
@@ -85,7 +85,7 @@ cat >expect <<\EOF
 #      untracked
 EOF
 
-test_expect_success 'status (2)' '
+test_expect_success C_LOCALE_OUTPUT 'status (2)' '
 
        git status >output &&
        test_cmp expect output
@@ -111,7 +111,7 @@ EOF
 
 git config advice.statusHints false
 
-test_expect_success 'status (advice.statusHints false)' '
+test_expect_success C_LOCALE_OUTPUT 'status (advice.statusHints false)' '
 
        git status >output &&
        test_cmp expect output
@@ -157,6 +157,12 @@ test_expect_success 'status -s -b' '
 
 '
 
+test_expect_success 'setup dir3' '
+       mkdir dir3 &&
+       : >dir3/untracked1 &&
+       : >dir3/untracked2
+'
+
 cat >expect <<EOF
 # On branch master
 # Changes to be committed:
@@ -172,16 +178,14 @@ cat >expect <<EOF
 #
 # Untracked files not listed (use -u option to show untracked files)
 EOF
-test_expect_success 'status -uno' '
-       mkdir dir3 &&
-       : >dir3/untracked1 &&
-       : >dir3/untracked2 &&
+test_expect_success C_LOCALE_OUTPUT 'status -uno' '
        git status -uno >output &&
        test_cmp expect output
 '
 
-test_expect_success 'status (status.showUntrackedFiles no)' '
+test_expect_success C_LOCALE_OUTPUT 'status (status.showUntrackedFiles no)' '
        git config status.showuntrackedfiles no
+       test_when_finished "git config --unset status.showuntrackedfiles" &&
        git status >output &&
        test_cmp expect output
 '
@@ -197,7 +201,7 @@ cat >expect <<EOF
 # Untracked files not listed
 EOF
 git config advice.statusHints false
-test_expect_success 'status -uno (advice.statusHints false)' '
+test_expect_success C_LOCALE_OUTPUT 'status -uno (advice.statusHints false)' '
        git status -uno >output &&
        test_cmp expect output
 '
@@ -208,7 +212,6 @@ cat >expect << EOF
 A  dir2/added
 EOF
 test_expect_success 'status -s -uno' '
-       git config --unset status.showuntrackedfiles
        git status -s -uno >output &&
        test_cmp expect output
 '
@@ -243,13 +246,14 @@ cat >expect <<EOF
 #      output
 #      untracked
 EOF
-test_expect_success 'status -unormal' '
+test_expect_success C_LOCALE_OUTPUT 'status -unormal' '
        git status -unormal >output &&
        test_cmp expect output
 '
 
-test_expect_success 'status (status.showUntrackedFiles normal)' '
+test_expect_success C_LOCALE_OUTPUT 'status (status.showUntrackedFiles normal)' '
        git config status.showuntrackedfiles normal
+       test_when_finished "git config --unset status.showuntrackedfiles" &&
        git status >output &&
        test_cmp expect output
 '
@@ -266,7 +270,6 @@ A  dir2/added
 ?? untracked
 EOF
 test_expect_success 'status -s -unormal' '
-       git config --unset status.showuntrackedfiles
        git status -s -unormal >output &&
        test_cmp expect output
 '
@@ -302,18 +305,21 @@ cat >expect <<EOF
 #      output
 #      untracked
 EOF
-test_expect_success 'status -uall' '
+test_expect_success C_LOCALE_OUTPUT 'status -uall' '
        git status -uall >output &&
        test_cmp expect output
 '
-test_expect_success 'status (status.showUntrackedFiles all)' '
+test_expect_success C_LOCALE_OUTPUT 'status (status.showUntrackedFiles all)' '
        git config status.showuntrackedfiles all
+       test_when_finished "git config --unset status.showuntrackedfiles" &&
        git status >output &&
-       rm -rf dir3 &&
-       git config --unset status.showuntrackedfiles &&
        test_cmp expect output
 '
 
+test_expect_success 'teardown dir3' '
+       rm -rf dir3
+'
+
 cat >expect <<EOF
  M dir1/modified
 A  dir2/added
@@ -361,7 +367,7 @@ cat >expect <<\EOF
 #      ../untracked
 EOF
 
-test_expect_success 'status with relative paths' '
+test_expect_success C_LOCALE_OUTPUT 'status with relative paths' '
 
        (cd dir1 && git status) >output &&
        test_cmp expect output
@@ -434,18 +440,19 @@ cat >expect <<\EOF
 #      <BLUE>untracked<RESET>
 EOF
 
-test_expect_success 'status with color.ui' '
+test_expect_success C_LOCALE_OUTPUT 'status with color.ui' '
 
        git config color.ui always &&
+       test_when_finished "git config --unset color.ui" &&
        git status | test_decode_color >output &&
        test_cmp expect output
 
 '
 
-test_expect_success 'status with color.status' '
+test_expect_success C_LOCALE_OUTPUT 'status with color.status' '
 
-       git config --unset color.ui &&
        git config color.status always &&
+       test_when_finished "git config --unset color.status" &&
        git status | test_decode_color >output &&
        test_cmp expect output
 
@@ -464,7 +471,6 @@ EOF
 
 test_expect_success 'status -s with color.ui' '
 
-       git config --unset color.status &&
        git config color.ui always &&
        git status -s | test_decode_color >output &&
        test_cmp expect output
@@ -564,9 +570,10 @@ cat >expect <<\EOF
 EOF
 
 
-test_expect_success 'status without relative paths' '
+test_expect_success C_LOCALE_OUTPUT 'status without relative paths' '
 
-       git config status.relativePaths false
+       git config status.relativePaths false &&
+       test_when_finished "git config --unset status.relativePaths" &&
        (cd dir1 && git status) >output &&
        test_cmp expect output
 
@@ -585,6 +592,8 @@ EOF
 
 test_expect_success 'status -s without relative paths' '
 
+       git config status.relativePaths false &&
+       test_when_finished "git config --unset status.relativePaths" &&
        (cd dir1 && git status -s) >output &&
        test_cmp expect output
 
@@ -607,7 +616,10 @@ cat <<EOF >expect
 #      untracked
 EOF
 test_expect_success 'dry-run of partial commit excluding new file in index' '
-       git commit --dry-run dir1/modified >output &&
+       git commit --dry-run dir1/modified >output
+'
+
+test_expect_success C_LOCALE_OUTPUT 'dry-run of partial commit excluding new file in index: output' '
        test_cmp expect output
 '
 
@@ -655,13 +667,13 @@ cat >expect <<EOF
 #      output
 #      untracked
 EOF
-test_expect_success 'status submodule summary is disabled by default' '
+test_expect_success C_LOCALE_OUTPUT 'status submodule summary is disabled by default' '
        git status >output &&
        test_cmp expect output
 '
 
 # we expect the same as the previous test
-test_expect_success 'status --untracked-files=all does not show submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status --untracked-files=all does not show submodule' '
        git status --untracked-files=all >output &&
        test_cmp expect output
 '
@@ -719,7 +731,7 @@ cat >expect <<EOF
 #      output
 #      untracked
 EOF
-test_expect_success 'status submodule summary' '
+test_expect_success C_LOCALE_OUTPUT 'status submodule summary' '
        git config status.submodulesummary 10 &&
        git status >output &&
        test_cmp expect output
@@ -760,8 +772,11 @@ cat >expect <<EOF
 #      untracked
 no changes added to commit (use "git add" and/or "git commit -a")
 EOF
-test_expect_success 'status submodule summary (clean submodule)' '
-       git commit -m "commit submodule" &&
+test_expect_success 'status submodule summary (clean submodule): commit' '
+       git commit -m "commit submodule"
+'
+
+test_expect_success C_LOCALE_OUTPUT 'status submodule summary (clean submodule): output' '
        git config status.submodulesummary 10 &&
        test_must_fail git commit --dry-run >output &&
        test_cmp expect output &&
@@ -812,7 +827,7 @@ cat >expect <<EOF
 #      output
 #      untracked
 EOF
-test_expect_success 'commit --dry-run submodule summary (--amend)' '
+test_expect_success C_LOCALE_OUTPUT 'commit --dry-run submodule summary (--amend)' '
        git config status.submodulesummary 10 &&
        git commit --dry-run --amend >output &&
        test_cmp expect output
@@ -867,13 +882,13 @@ cat > expect << EOF
 #      untracked
 EOF
 
-test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '--ignore-submodules=untracked suppresses submodules with untracked content' '
        echo modified > sm/untracked &&
        git status --ignore-submodules=untracked > output &&
        test_cmp expect output
 '
 
-test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '.gitmodules ignore=untracked suppresses submodules with untracked content' '
        git config diff.ignoreSubmodules dirty &&
        git status >output &&
        test_cmp expect output &&
@@ -885,7 +900,7 @@ test_expect_success '.gitmodules ignore=untracked suppresses submodules with unt
        git config --unset diff.ignoreSubmodules
 '
 
-test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '.git/config ignore=untracked suppresses submodules with untracked content' '
        git config --add -f .gitmodules submodule.subname.ignore none &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git config --add submodule.subname.ignore untracked &&
@@ -896,12 +911,12 @@ test_expect_success '.git/config ignore=untracked suppresses submodules with unt
        git config --remove-section -f .gitmodules submodule.subname
 '
 
-test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '--ignore-submodules=dirty suppresses submodules with untracked content' '
        git status --ignore-submodules=dirty > output &&
        test_cmp expect output
 '
 
-test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '.gitmodules ignore=dirty suppresses submodules with untracked content' '
        git config diff.ignoreSubmodules dirty &&
        git status >output &&
        ! test -s actual &&
@@ -913,7 +928,7 @@ test_expect_success '.gitmodules ignore=dirty suppresses submodules with untrack
        git config --unset diff.ignoreSubmodules
 '
 
-test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '.git/config ignore=dirty suppresses submodules with untracked content' '
        git config --add -f .gitmodules submodule.subname.ignore none &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git config --add submodule.subname.ignore dirty &&
@@ -924,13 +939,13 @@ test_expect_success '.git/config ignore=dirty suppresses submodules with untrack
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
-test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
+test_expect_success C_LOCALE_OUTPUT '--ignore-submodules=dirty suppresses submodules with modified content' '
        echo modified > sm/foo &&
        git status --ignore-submodules=dirty > output &&
        test_cmp expect output
 '
 
-test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
+test_expect_success C_LOCALE_OUTPUT '.gitmodules ignore=dirty suppresses submodules with modified content' '
        git config --add -f .gitmodules submodule.subname.ignore dirty &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git status > output &&
@@ -938,7 +953,7 @@ test_expect_success '.gitmodules ignore=dirty suppresses submodules with modifie
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
-test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
+test_expect_success C_LOCALE_OUTPUT '.git/config ignore=dirty suppresses submodules with modified content' '
        git config --add -f .gitmodules submodule.subname.ignore none &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git config --add submodule.subname.ignore dirty &&
@@ -981,12 +996,12 @@ cat > expect << EOF
 #      untracked
 EOF
 
-test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
+test_expect_success C_LOCALE_OUTPUT "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
        git status --ignore-submodules=untracked > output &&
        test_cmp expect output
 '
 
-test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
+test_expect_success C_LOCALE_OUTPUT ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
        git config --add -f .gitmodules submodule.subname.ignore untracked &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git status > output &&
@@ -994,7 +1009,7 @@ test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules wi
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
-test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
+test_expect_success C_LOCALE_OUTPUT ".git/config ignore=untracked doesn't suppress submodules with modified content" '
        git config --add -f .gitmodules submodule.subname.ignore none &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git config --add submodule.subname.ignore untracked &&
@@ -1043,12 +1058,12 @@ cat > expect << EOF
 #      untracked
 EOF
 
-test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT "--ignore-submodules=untracked doesn't suppress submodule summary" '
        git status --ignore-submodules=untracked > output &&
        test_cmp expect output
 '
 
-test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT ".gitmodules ignore=untracked doesn't suppress submodule summary" '
        git config --add -f .gitmodules submodule.subname.ignore untracked &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git status > output &&
@@ -1056,7 +1071,7 @@ test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule sum
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
-test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT ".git/config ignore=untracked doesn't suppress submodule summary" '
        git config --add -f .gitmodules submodule.subname.ignore none &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git config --add submodule.subname.ignore untracked &&
@@ -1067,11 +1082,11 @@ test_expect_success ".git/config ignore=untracked doesn't suppress submodule sum
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
-test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT "--ignore-submodules=dirty doesn't suppress submodule summary" '
        git status --ignore-submodules=dirty > output &&
        test_cmp expect output
 '
-test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT ".gitmodules ignore=dirty doesn't suppress submodule summary" '
        git config --add -f .gitmodules submodule.subname.ignore dirty &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git status > output &&
@@ -1079,7 +1094,7 @@ test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
-test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT ".git/config ignore=dirty doesn't suppress submodule summary" '
        git config --add -f .gitmodules submodule.subname.ignore none &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git config --add submodule.subname.ignore dirty &&
@@ -1111,7 +1126,7 @@ cat > expect << EOF
 no changes added to commit (use "git add" and/or "git commit -a")
 EOF
 
-test_expect_success "--ignore-submodules=all suppresses submodule summary" '
+test_expect_success C_LOCALE_OUTPUT "--ignore-submodules=all suppresses submodule summary" '
        git status --ignore-submodules=all > output &&
        test_cmp expect output
 '
index b147a1bd69e96e48d3808028a3775a609471639a..87d5d788cb1884fdfe218ec30582f5d3da8b5d7d 100755 (executable)
@@ -495,7 +495,7 @@ test_expect_success 'merge fast-forward in a dirty tree' '
 
 test_debug 'git log --graph --decorate --oneline --all'
 
-test_expect_success 'in-index merge' '
+test_expect_success C_LOCALE_OUTPUT 'in-index merge' '
        git reset --hard c0 &&
        git merge --no-ff -s resolve c1 >out &&
        grep "Wonderful." out &&
index c86e298d082316ff5a4de6f07c0faba85c65d4e1..ef84f04102ed067768c66ea9608b98d47851eb8b 100755 (executable)
@@ -150,13 +150,23 @@ test_expect_success 'will not overwrite untracked file on unborn branch' '
        git rm -fr . &&
        git checkout --orphan new &&
        cp important c0.c &&
+       test_must_fail git merge c0 2>out
+'
+
+test_expect_success C_LOCALE_OUTPUT 'will not overwrite untracked file on unborn branch: output' '
+       test_cmp out expect
+'
+
+test_expect_success 'will not overwrite untracked file on unborn branch .git/MERGE_HEAD sanity etc.' '
        test_when_finished "rm c0.c" &&
-       test_must_fail git merge c0 2>out &&
-       test_cmp out expect &&
        test_path_is_missing .git/MERGE_HEAD &&
        test_cmp important c0.c
 '
 
+test_expect_success 'failed merge leaves unborn branch in the womb' '
+       test_must_fail git rev-parse --verify HEAD
+'
+
 test_expect_success 'set up unborn branch and content' '
        git symbolic-ref HEAD refs/heads/unborn &&
        rm -f .git/index &&
index 61890bc892d9fd37032f9ca05eab87de0e0dda03..cdb3f444cd4a5970df6f375382f5cea82ccaee06 100755 (executable)
@@ -46,8 +46,14 @@ test_expect_success 'setup' '
 pre_merge_head="$(git rev-parse HEAD)"
 
 test_expect_success 'fails without MERGE_HEAD (unstarted merge)' '
-       test_must_fail git merge --abort 2>output &&
-       grep -q MERGE_HEAD output &&
+       test_must_fail git merge --abort 2>output
+'
+
+test_expect_success C_LOCALE_OUTPUT 'fails without MERGE_HEAD (unstarted merge): fatal output' '
+       grep -q MERGE_HEAD output
+'
+
+test_expect_success 'fails without MERGE_HEAD (unstarted merge): .git/MERGE_HEAD sanity' '
        test ! -f .git/MERGE_HEAD &&
        test "$pre_merge_head" = "$(git rev-parse HEAD)"
 '
@@ -57,8 +63,14 @@ test_expect_success 'fails without MERGE_HEAD (completed merge)' '
        test ! -f .git/MERGE_HEAD &&
        # Merge successfully completed
        post_merge_head="$(git rev-parse HEAD)" &&
-       test_must_fail git merge --abort 2>output &&
-       grep -q MERGE_HEAD output &&
+       test_must_fail git merge --abort 2>output
+'
+
+test_expect_success C_LOCALE_OUTPUT 'fails without MERGE_HEAD (completed merge): output' '
+       grep -q MERGE_HEAD output
+'
+
+test_expect_success 'fails without MERGE_HEAD (completed merge): .git/MERGE_HEAD sanity' '
        test ! -f .git/MERGE_HEAD &&
        test "$post_merge_head" = "$(git rev-parse HEAD)"
 '
index dbc6cd8a775a43efbd8fdf433958ccd090b6e3ab..8184c264cf942bcd8e6c2f75b5526ddfdc5a11e9 100755 (executable)
@@ -59,7 +59,29 @@ do
                        echo ${HC}file:4:foo mmap bar_mmap
                        echo ${HC}file:5:foo_mmap bar mmap baz
                } >expected &&
-               git grep -n -w -e mmap $H >actual &&
+               git -c grep.linenumber=false grep -n -w -e mmap $H >actual &&
+               test_cmp expected actual
+       '
+
+       test_expect_success "grep -w $L" '
+               {
+                       echo ${HC}file:1:foo mmap bar
+                       echo ${HC}file:3:foo_mmap bar mmap
+                       echo ${HC}file:4:foo mmap bar_mmap
+                       echo ${HC}file:5:foo_mmap bar mmap baz
+               } >expected &&
+               git -c grep.linenumber=true grep -w -e mmap $H >actual &&
+               test_cmp expected actual
+       '
+
+       test_expect_success "grep -w $L" '
+               {
+                       echo ${HC}file:foo mmap bar
+                       echo ${HC}file:foo_mmap bar mmap
+                       echo ${HC}file:foo mmap bar_mmap
+                       echo ${HC}file:foo_mmap bar mmap baz
+               } >expected &&
+               git -c grep.linenumber=true grep --no-line-number -w -e mmap $H >actual &&
                test_cmp expected actual
        '
 
index 568a6f2b69ab5003c00f206806c3fe6289f63a98..aedf484feeb9da05054f18ab2f4913865048fe35 100755 (executable)
@@ -61,7 +61,7 @@ test_expect_success SIMPLEPAGER 'git grep -O' '
        test_cmp empty out
 '
 
-test_expect_success 'git grep -O --cached' '
+test_expect_success C_LOCALE_OUTPUT 'git grep -O --cached' '
        test_must_fail git grep --cached -O GREP_PATTERN >out 2>msg &&
        grep open-files-in-pager msg
 '
index 53558d7e5f517479af478e375076718189c2d2d5..9f4e0ba9c17120ca2903b30b95b6d8fbcc62cd9c 100644 (file)
@@ -131,16 +131,16 @@ static void wt_status_print_unmerged_header(struct wt_status *s)
 {
        const char *c = color(WT_STATUS_HEADER, s);
 
-       status_printf_ln(s, c, "Unmerged paths:");
+       status_printf_ln(s, c, _("Unmerged paths:"));
        if (!advice_status_hints)
                return;
        if (s->whence != FROM_COMMIT)
                ;
        else if (!s->is_initial)
-               status_printf_ln(s, c, "  (use \"git reset %s <file>...\" to unstage)", s->reference);
+               status_printf_ln(s, c, _("  (use \"git reset %s <file>...\" to unstage)"), s->reference);
        else
-               status_printf_ln(s, c, "  (use \"git rm --cached <file>...\" to unstage)");
-       status_printf_ln(s, c, "  (use \"git add/rm <file>...\" as appropriate to mark resolution)");
+               status_printf_ln(s, c, _("  (use \"git rm --cached <file>...\" to unstage)"));
+       status_printf_ln(s, c, _("  (use \"git add/rm <file>...\" as appropriate to mark resolution)"));
        status_printf_ln(s, c, "");
 }
 
@@ -148,15 +148,15 @@ static void wt_status_print_cached_header(struct wt_status *s)
 {
        const char *c = color(WT_STATUS_HEADER, s);
 
-       status_printf_ln(s, c, "Changes to be committed:");
+       status_printf_ln(s, c, _("Changes to be committed:"));
        if (!advice_status_hints)
                return;
        if (s->whence != FROM_COMMIT)
                ; /* NEEDSWORK: use "git reset --unresolve"??? */
        else if (!s->is_initial)
-               status_printf_ln(s, c, "  (use \"git reset %s <file>...\" to unstage)", s->reference);
+               status_printf_ln(s, c, _("  (use \"git reset %s <file>...\" to unstage)"), s->reference);
        else
-               status_printf_ln(s, c, "  (use \"git rm --cached <file>...\" to unstage)");
+               status_printf_ln(s, c, _("  (use \"git rm --cached <file>...\" to unstage)"));
        status_printf_ln(s, c, "");
 }
 
@@ -166,16 +166,16 @@ static void wt_status_print_dirty_header(struct wt_status *s,
 {
        const char *c = color(WT_STATUS_HEADER, s);
 
-       status_printf_ln(s, c, "Changes not staged for commit:");
+       status_printf_ln(s, c, _("Changes not staged for commit:"));
        if (!advice_status_hints)
                return;
        if (!has_deleted)
-               status_printf_ln(s, c, "  (use \"git add <file>...\" to update what will be committed)");
+               status_printf_ln(s, c, _("  (use \"git add <file>...\" to update what will be committed)"));
        else
-               status_printf_ln(s, c, "  (use \"git add/rm <file>...\" to update what will be committed)");
-       status_printf_ln(s, c, "  (use \"git checkout -- <file>...\" to discard changes in working directory)");
+               status_printf_ln(s, c, _("  (use \"git add/rm <file>...\" to update what will be committed)"));
+       status_printf_ln(s, c, _("  (use \"git checkout -- <file>...\" to discard changes in working directory)"));
        if (has_dirty_submodules)
-               status_printf_ln(s, c, "  (commit or discard the untracked or modified content in submodules)");
+               status_printf_ln(s, c, _("  (commit or discard the untracked or modified content in submodules)"));
        status_printf_ln(s, c, "");
 }
 
@@ -184,10 +184,10 @@ static void wt_status_print_other_header(struct wt_status *s,
                                         const char *how)
 {
        const char *c = color(WT_STATUS_HEADER, s);
-       status_printf_ln(s, c, "%s files:", what);
+       status_printf_ln(s, c, _("%s files:"), what);
        if (!advice_status_hints)
                return;
-       status_printf_ln(s, c, "  (use \"git %s <file>...\" to include in what will be committed)", how);
+       status_printf_ln(s, c, _("  (use \"git %s <file>...\" to include in what will be committed)"), how);
        status_printf_ln(s, c, "");
 }
 
@@ -204,18 +204,18 @@ static void wt_status_print_unmerged_data(struct wt_status *s,
        const char *c = color(WT_STATUS_UNMERGED, s);
        struct wt_status_change_data *d = it->util;
        struct strbuf onebuf = STRBUF_INIT;
-       const char *one, *how = "bug";
+       const char *one, *how = _("bug");
 
        one = quote_path(it->string, -1, &onebuf, s->prefix);
        status_printf(s, color(WT_STATUS_HEADER, s), "\t");
        switch (d->stagemask) {
-       case 1: how = "both deleted:"; break;
-       case 2: how = "added by us:"; break;
-       case 3: how = "deleted by them:"; break;
-       case 4: how = "added by them:"; break;
-       case 5: how = "deleted by us:"; break;
-       case 6: how = "both added:"; break;
-       case 7: how = "both modified:"; break;
+       case 1: how = _("both deleted:"); break;
+       case 2: how = _("added by us:"); break;
+       case 3: how = _("deleted by them:"); break;
+       case 4: how = _("added by them:"); break;
+       case 5: how = _("deleted by us:"); break;
+       case 6: how = _("both added:"); break;
+       case 7: how = _("both modified:"); break;
        }
        status_printf_more(s, c, "%-20s%s\n", how, one);
        strbuf_release(&onebuf);
@@ -245,11 +245,11 @@ static void wt_status_print_change_data(struct wt_status *s,
                if (d->new_submodule_commits || d->dirty_submodule) {
                        strbuf_addstr(&extra, " (");
                        if (d->new_submodule_commits)
-                               strbuf_addf(&extra, "new commits, ");
+                               strbuf_addf(&extra, _("new commits, "));
                        if (d->dirty_submodule & DIRTY_SUBMODULE_MODIFIED)
-                               strbuf_addf(&extra, "modified content, ");
+                               strbuf_addf(&extra, _("modified content, "));
                        if (d->dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
-                               strbuf_addf(&extra, "untracked content, ");
+                               strbuf_addf(&extra, _("untracked content, "));
                        strbuf_setlen(&extra, extra.len - 2);
                        strbuf_addch(&extra, ')');
                }
@@ -263,31 +263,31 @@ static void wt_status_print_change_data(struct wt_status *s,
        status_printf(s, color(WT_STATUS_HEADER, s), "\t");
        switch (status) {
        case DIFF_STATUS_ADDED:
-               status_printf_more(s, c, "new file:   %s", one);
+               status_printf_more(s, c, _("new file:   %s"), one);
                break;
        case DIFF_STATUS_COPIED:
-               status_printf_more(s, c, "copied:     %s -> %s", one, two);
+               status_printf_more(s, c, _("copied:     %s -> %s"), one, two);
                break;
        case DIFF_STATUS_DELETED:
-               status_printf_more(s, c, "deleted:    %s", one);
+               status_printf_more(s, c, _("deleted:    %s"), one);
                break;
        case DIFF_STATUS_MODIFIED:
-               status_printf_more(s, c, "modified:   %s", one);
+               status_printf_more(s, c, _("modified:   %s"), one);
                break;
        case DIFF_STATUS_RENAMED:
-               status_printf_more(s, c, "renamed:    %s -> %s", one, two);
+               status_printf_more(s, c, _("renamed:    %s -> %s"), one, two);
                break;
        case DIFF_STATUS_TYPE_CHANGED:
-               status_printf_more(s, c, "typechange: %s", one);
+               status_printf_more(s, c, _("typechange: %s"), one);
                break;
        case DIFF_STATUS_UNKNOWN:
-               status_printf_more(s, c, "unknown:    %s", one);
+               status_printf_more(s, c, _("unknown:    %s"), one);
                break;
        case DIFF_STATUS_UNMERGED:
-               status_printf_more(s, c, "unmerged:   %s", one);
+               status_printf_more(s, c, _("unmerged:   %s"), one);
                break;
        default:
-               die("bug: unhandled diff status %c", status);
+               die(_("bug: unhandled diff status %c"), status);
        }
        if (extra.len) {
                status_printf_more(s, color(WT_STATUS_HEADER, s), "%s", extra.buf);
@@ -710,14 +710,14 @@ void wt_status_print(struct wt_status *s)
        const char *branch_status_color = color(WT_STATUS_HEADER, s);
 
        if (s->branch) {
-               const char *on_what = "On branch ";
+               const char *on_what = _("On branch ");
                const char *branch_name = s->branch;
                if (!prefixcmp(branch_name, "refs/heads/"))
                        branch_name += 11;
                else if (!strcmp(branch_name, "HEAD")) {
                        branch_name = "";
                        branch_status_color = color(WT_STATUS_NOBRANCH, s);
-                       on_what = "Not currently on any branch.";
+                       on_what = _("Not currently on any branch.");
                }
                status_printf(s, color(WT_STATUS_HEADER, s), "");
                status_printf_more(s, branch_status_color, "%s", on_what);
@@ -728,7 +728,7 @@ void wt_status_print(struct wt_status *s)
 
        if (s->is_initial) {
                status_printf_ln(s, color(WT_STATUS_HEADER, s), "");
-               status_printf_ln(s, color(WT_STATUS_HEADER, s), "Initial commit");
+               status_printf_ln(s, color(WT_STATUS_HEADER, s), _("Initial commit"));
                status_printf_ln(s, color(WT_STATUS_HEADER, s), "");
        }
 
@@ -742,38 +742,38 @@ void wt_status_print(struct wt_status *s)
                wt_status_print_submodule_summary(s, 1);  /* unstaged */
        }
        if (s->show_untracked_files) {
-               wt_status_print_other(s, &s->untracked, "Untracked", "add");
+               wt_status_print_other(s, &s->untracked, _("Untracked"), "add");
                if (s->show_ignored_files)
-                       wt_status_print_other(s, &s->ignored, "Ignored", "add -f");
+                       wt_status_print_other(s, &s->ignored, _("Ignored"), "add -f");
        } else if (s->commitable)
-               status_printf_ln(s, GIT_COLOR_NORMAL, "Untracked files not listed%s",
+               status_printf_ln(s, GIT_COLOR_NORMAL, _("Untracked files not listed%s"),
                        advice_status_hints
-                       ? " (use -u option to show untracked files)" : "");
+                       ? _(" (use -u option to show untracked files)") : "");
 
        if (s->verbose)
                wt_status_print_verbose(s);
        if (!s->commitable) {
                if (s->amend)
-                       status_printf_ln(s, GIT_COLOR_NORMAL, "No changes");
+                       status_printf_ln(s, GIT_COLOR_NORMAL, _("No changes"));
                else if (s->nowarn)
                        ; /* nothing */
                else if (s->workdir_dirty)
-                       printf("no changes added to commit%s\n",
+                       printf(_("no changes added to commit%s\n"),
                                advice_status_hints
-                               ? " (use \"git add\" and/or \"git commit -a\")" : "");
+                               ? _(" (use \"git add\" and/or \"git commit -a\")") : "");
                else if (s->untracked.nr)
-                       printf("nothing added to commit but untracked files present%s\n",
+                       printf(_("nothing added to commit but untracked files present%s\n"),
                                advice_status_hints
-                               ? " (use \"git add\" to track)" : "");
+                               ? _(" (use \"git add\" to track)") : "");
                else if (s->is_initial)
-                       printf("nothing to commit%s\n", advice_status_hints
-                               ? " (create/copy files and use \"git add\" to track)" : "");
+                       printf(_("nothing to commit%s\n"), advice_status_hints
+                               ? _(" (create/copy files and use \"git add\" to track)") : "");
                else if (!s->show_untracked_files)
-                       printf("nothing to commit%s\n", advice_status_hints
-                               ? " (use -u to show untracked files)" : "");
+                       printf(_("nothing to commit%s\n"), advice_status_hints
+                               ? _(" (use -u to show untracked files)") : "");
                else
-                       printf("nothing to commit%s\n", advice_status_hints
-                               ? " (working directory clean)" : "");
+                       printf(_("nothing to commit%s\n"), advice_status_hints
+                               ? _(" (working directory clean)") : "");
        }
 }
 
@@ -881,13 +881,13 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
        if (!prefixcmp(branch_name, "refs/heads/"))
                branch_name += 11;
        else if (!strcmp(branch_name, "HEAD")) {
-               branch_name = "HEAD (no branch)";
+               branch_name = _("HEAD (no branch)");
                branch_color_local = color(WT_STATUS_NOBRANCH, s);
        }
 
        branch = branch_get(s->branch + 11);
        if (s->is_initial)
-               color_fprintf(s->fp, header_color, "Initial commit on ");
+               color_fprintf(s->fp, header_color, _("Initial commit on "));
        if (!stat_tracking_info(branch, &num_ours, &num_theirs)) {
                color_fprintf_ln(s->fp, branch_color_local,
                        "%s", branch_name);
@@ -902,15 +902,15 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
 
        color_fprintf(s->fp, header_color, " [");
        if (!num_ours) {
-               color_fprintf(s->fp, header_color, "behind ");
+               color_fprintf(s->fp, header_color, _("behind "));
                color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
        } else if (!num_theirs) {
-               color_fprintf(s->fp, header_color, "ahead ");
+               color_fprintf(s->fp, header_color, _("ahead "));
                color_fprintf(s->fp, branch_color_local, "%d", num_ours);
        } else {
-               color_fprintf(s->fp, header_color, "ahead ");
+               color_fprintf(s->fp, header_color, _("ahead "));
                color_fprintf(s->fp, branch_color_local, "%d", num_ours);
-               color_fprintf(s->fp, header_color, ", behind ");
+               color_fprintf(s->fp, header_color, _(", behind "));
                color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
        }