Merge branch 'jk/format-patch-from'
authorJunio C Hamano <gitster@pobox.com>
Mon, 15 Jul 2013 17:28:39 +0000 (10:28 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Jul 2013 17:28:40 +0000 (10:28 -0700)
"git format-patch" learned "--from[=whom]" option, which sets the
"From: " header to the specified person (or the person who runs the
command, if "=whom" part is missing) and move the original author
information to an in-body From: header as necessary.

* jk/format-patch-from:
teach format-patch to place other authors into in-body "From"
pretty.c: drop const-ness from pretty_print_context

64 files changed:
Documentation/RelNotes/1.8.3.3.txt
Documentation/RelNotes/1.8.4.txt
Documentation/config.txt
Documentation/diff-options.txt
Documentation/git-clone.txt
Documentation/git-config.txt
Documentation/git-name-rev.txt
Documentation/git-p4.txt
Documentation/git-pull.txt
Documentation/git-stash.txt
Documentation/git-submodule.txt
Documentation/gitweb.conf.txt
Documentation/glossary-content.txt
Makefile
builtin/checkout.c
builtin/clone.c
builtin/commit.c
builtin/merge.c
builtin/push.c
builtin/reset.c
builtin/rev-list.c
builtin/shortlog.c
commit.c
commit.h
contrib/completion/git-completion.bash
contrib/mw-to-git/git-remote-mediawiki.perl
diff.c
diffcore-pickaxe.c
dir.c
fetch-pack.c
fixup-builtins [deleted file]
git-pull.sh
git-rebase--interactive.sh
git-stash.sh
gitweb/gitweb.perl
lockfile.c
log-tree.c
remote-curl.c
sha1_name.c
submodule.c
t/README
t/check-non-portable-shell.pl
t/perf/perf-lib.sh
t/t0000-basic.sh
t/t0020-crlf.sh
t/t1512-rev-parse-disambiguation.sh
t/t2012-checkout-last.sh
t/t3010-ls-files-killed-modified.sh
t/t3404-rebase-interactive.sh
t/t3903-stash.sh
t/t4041-diff-submodule-option.sh
t/t4205-log-pretty-formats.sh
t/t5505-remote.sh
t/t5528-push-default.sh
t/t6006-rev-list-format.sh
t/t7102-reset.sh
t/t7508-status.sh
t/t7512-status-help.sh
t/t7600-merge.sh
t/t9902-completion.sh
t/test-lib-functions.sh
t/test-lib.sh
t/valgrind/valgrind.sh
wt-status.c
index 58a570ef3dadd5c512bb6b82e805fd531f9ee4c7..04289e793cdee716dfb12cb9115ebb19cb6bbb9c 100644 (file)
@@ -4,8 +4,23 @@ Git v1.8.3.3 Release Notes
 Fixes since v1.8.3.2
 --------------------
 
+ * "gitweb" forgot to clear a global variable $search_regexp upon each
+   request, mistakenly carrying over the previous search to a new one
+   when used as a persistent CGI.
+
+ * The wildmatch engine did not honor WM_CASEFOLD option correctly.
+
+ * "git log -c --follow $path" segfaulted upon hitting the commit that
+   renamed the $path being followed.
+
+ * When a reflog notation is used for implicit "current branch",
+   e.g. "git log @{u}", we did not say which branch and worse said
+   "branch ''" in the error messages.
+
  * Mac OS X does not like to write(2) more than INT_MAX number of
    bytes; work it around by chopping write(2) into smaller pieces.
 
  * Newer MacOS X encourages the programs to compile and link with
    their CommonCrypto, not with OpenSSL.
+
+Also contains various minor documentation updates.
index b85f16b378adfafead7ed62fa505042bc7402100..4250e5a3a90e39cad45d90c9ef836ce2ba04cce8 100644 (file)
@@ -1,11 +1,55 @@
 Git v1.8.4 Release Notes
 ========================
 
+Backward compatibility notes (for Git 2.0)
+------------------------------------------
+
+When "git push [$there]" does not say what to push, we have used the
+traditional "matching" semantics so far (all your branches were sent
+to the remote as long as there already are branches of the same name
+over there).  In Git 2.0, the default will change to the "simple"
+semantics that pushes:
+
+ - only the current branch to the branch with the same name, and only
+   when the current branch is set to integrate with that remote
+   branch, if you are pushing to the same remote as you fetch from; or
+
+ - only the current branch to the branch with the same name, if you
+   are pushing to a remote that is not where you usually fetch from.
+
+Use the user preference configuration variable "push.default" to
+change this.  If you are an old-timer who is used to the "matching"
+semantics, you can set the variable to "matching" to keep the
+traditional behaviour.  If you want to live in the future early, you
+can set it to "simple" today without waiting for Git 2.0.
+
+When "git add -u" (and "git add -A") is run inside a subdirectory and
+does not specify which paths to add on the command line, it
+will operate on the entire tree in Git 2.0 for consistency
+with "git commit -a" and other commands.  There will be no
+mechanism to make plain "git add -u" behave like "git add -u .".
+Current users of "git add -u" (without a pathspec) should start
+training their fingers to explicitly say "git add -u ."
+before Git 2.0 comes.  A warning is issued when these commands are
+run without a pathspec and when you have local changes outside the
+current directory, because the behaviour in Git 2.0 will be different
+from today's version in such a situation.
+
+In Git 2.0, "git add <path>" will behave as "git add -A <path>", so
+that "git add dir/" will notice paths you removed from the directory
+and record the removal.  Versions before Git 2.0, including this
+release, will keep ignoring removals, but the users who rely on this
+behaviour are encouraged to start using "git add --ignore-removal <path>"
+now before 2.0 is released.
+
+
 Updates since v1.8.3
 --------------------
 
 Foreign interfaces, subsystems and ports.
 
+ * "git rebase -i" now honors --strategy and -X options.
+
  * Git-gui has been updated to its 0.18.0 version.
 
  * MediaWiki remote helper (in contrib/) has been updated to use the
@@ -35,6 +79,18 @@ Foreign interfaces, subsystems and ports.
 
 UI, Workflows & Features
 
+ * "gitweb" learned to optionally place extra links that point at the
+   levels higher than the Gitweb pages themselves in the breadcrumbs,
+   so that it can be used as part of a larger installation.
+
+ * "git log --format=" now honors i18n.logoutputencoding configuration
+   variable.
+
+ * The "push.default=simple" mode of "git push" has been updated to
+   behave like "current" without requiring a remote tracking
+   information, when you push to a remote that is different from where
+   you fetch from (i.e. a triangular workflow).
+
  * Having multiple "fixup!" on a line in the rebase instruction sheet
    did not work very well with "git rebase -i --autosquash".
 
@@ -63,9 +119,9 @@ UI, Workflows & Features
  * On Cygwin, "cygstart" is now recognised as a possible way to start
    a web browser (used in "help -w" and "instaweb" among others).
 
-### * "git status" learned status.branch and status.short configuration
-###   variables to use --branch and --short options by default (override
-###   with --no-branch and --no-short options from the command line).
+ * "git status" learned status.branch and status.short configuration
+   variables to use --branch and --short options by default (override
+   with --no-branch and --no-short options from the command line).
 
  * "git cmd <name>", when <name> happens to be a 40-hex string,
    directly uses the 40-hex string as an object name, even if a ref
@@ -188,6 +244,30 @@ Unless otherwise noted, all the fixes since v1.8.3 in the maintenance
 track are contained in this release (see release notes to them for
 details).
 
+ * "git diff" refused to even show difference when core.safecrlf is
+   set to true (i.e. error out) and there are offending lines in the
+   working tree files.
+   (merge 5430bb2 jc/maint-diff-core-safecrlf later to maint).
+
+ * A test that should have failed but didn't revealed a bug that needs
+   to be corrected.
+   (merge 94d75d1 jc/t1512-fix later to maint).
+
+ * An overlong path to a .git directory may have overflown the
+   temporary path buffer used to create a name for lockfiles.
+   (merge 2fbd4f9 mh/maint-lockfile-overflow later to maint).
+
+ * Invocations of "git checkout" used internally by "git rebase" were
+   counted as "checkout", and affected later "git checkout -" to the
+   the user to an unexpected place.
+   (merge 3bed291 rr/rebase-checkout-reflog later to maint).
+
+ * "git stash save", when your local change turns a tracked file into
+   a directory, has to remove files in that directory in order to
+   revert your working tree to a pristine state.  This will lose
+   untracked files in such a directory, and the command now requires
+   you to "--force" it.
+
  * The configuration variable column.ui was poorly documented.
    (merge 5e62cc1 rr/column-doc later to maint).
 
index b4d4887bd79d66635fdc7a7c3b5992aea30308b7..81856dd5a2559149b9dcdf263ed5c3212a07d480 100644 (file)
@@ -1844,39 +1844,59 @@ pull.twohead::
        The default merge strategy to use when pulling a single branch.
 
 push.default::
-       Defines the action `git push` should take if no refspec is given
-       on the command line, no refspec is configured in the remote, and
-       no refspec is implied by any of the options given on the command
-       line. Possible values are:
+       Defines the action `git push` should take if no refspec is
+       explicitly given.  Different values are well-suited for
+       specific workflows; for instance, in a purely central workflow
+       (i.e. the fetch source is equal to the push destination),
+       `upstream` is probably what you want.  Possible values are:
 +
 --
-* `nothing` - do not push anything.
-* `matching` - push all branches having the same name in both ends.
-  This is for those who prepare all the branches into a publishable
-  shape and then push them out with a single command.  It is not
-  appropriate for pushing into a repository shared by multiple users,
-  since locally stalled branches will attempt a non-fast forward push
-  if other users updated the branch.
-  +
-  This is currently the default, but Git 2.0 will change the default
-  to `simple`.
-* `upstream` - push the current branch to its upstream branch
-  (`tracking` is a deprecated synonym for this).
-  With this, `git push` will update the same remote ref as the one which
-  is merged by `git pull`, making `push` and `pull` symmetrical.
-  See "branch.<name>.merge" for how to configure the upstream branch.
-* `simple` - like `upstream`, but refuses to push if the upstream
-  branch's name is different from the local one. This is the safest
-  option and is well-suited for beginners. It will become the default
-  in Git 2.0.
-* `current` - push the current branch to a branch of the same name.
---
+
+* `nothing` - do not push anything (error out) unless a refspec is
+  explicitly given. This is primarily meant for people who want to
+  avoid mistakes by always being explicit.
+
+* `current` - push the current branch to update a branch with the same
+  name on the receiving end.  Works in both central and non-central
+  workflows.
+
+* `upstream` - push the current branch back to the branch whose
+  changes are usually integrated into the current branch (which is
+  called `@{upstream}`).  This mode only makes sense if you are
+  pushing to the same repository you would normally pull from
+  (i.e. central workflow).
+
+* `simple` - in centralized workflow, work like `upstream` with an
+  added safety to refuse to push if the upstream branch's name is
+  different from the local one.
++
+When pushing to a remote that is different from the remote you normally
+pull from, work as `current`.  This is the safest option and is suited
+for beginners.
 +
-The `simple`, `current` and `upstream` modes are for those who want to
-push out a single branch after finishing work, even when the other
-branches are not yet ready to be pushed out. If you are working with
-other people to push into the same shared repository, you would want
-to use one of these.
+This mode will become the default in Git 2.0.
+
+* `matching` - push all branches having the same name on both ends.
+  This makes the repository you are pushing to remember the set of
+  branches that will be pushed out (e.g. if you always push 'maint'
+  and 'master' there and no other branches, the repository you push
+  to will have these two branches, and your local 'maint' and
+  'master' will be pushed there).
++
+To use this mode effectively, you have to make sure _all_ the
+branches you would push out are ready to be pushed out before
+running 'git push', as the whole point of this mode is to allow you
+to push all of the branches in one go.  If you usually finish work
+on only one branch and push out the result, while other branches are
+unfinished, this mode is not for you.  Also this mode is not
+suitable for pushing into a shared central repository, as other
+people may add new branches there, or update the tip of existing
+branches outside your control.
++
+This is currently the default, but Git 2.0 will change the default
+to `simple`.
+
+--
 
 rebase.stat::
        Whether to show a diffstat of what changed upstream since the last
@@ -2092,6 +2112,14 @@ status.relativePaths::
        relative to the repository root (this was the default for Git
        prior to v1.5.4).
 
+status.short::
+       Set to true to enable --short by default in linkgit:git-status[1].
+       The option --no-short takes precedence over this variable.
+
+status.branch::
+       Set to true to enable --branch by default in linkgit:git-status[1].
+       The option --no-branch takes precedence over this variable.
+
 status.showUntrackedFiles::
        By default, linkgit:git-status[1] and linkgit:git-commit[1] show
        files which are not currently tracked by Git. Directories which
index 19f78a7d5cca0c4a08681605d31a57158a869298..87e92d6537a097a172d37b5893dd4c8c092a2368 100644 (file)
@@ -333,7 +333,7 @@ endif::git-log[]
        a fraction, with a decimal point before it.  I.e., `-M5` becomes
        0.5, and is thus the same as `-M50%`.  Similarly, `-M05` is
        the same as `-M5%`.  To limit detection to exact renames, use
-       `-M100%`.
+       `-M100%`.  The default similarity index is 50%.
 
 -C[<n>]::
 --find-copies[=<n>]::
index 450f158779fbfda31c0b3f85d4768a294ef782ef..85769b884e0f018c68fc0393d77b167a09d3ef44 100644 (file)
@@ -182,11 +182,13 @@ objects from the source repository into a pack in the cloned repository.
 --depth <depth>::
        Create a 'shallow' clone with a history truncated to the
        specified number of revisions.  A shallow repository has a
-       number of limitations (you cannot clone or fetch from
-       it, nor push from nor into it), but is adequate if you
-       are only interested in the recent history of a large project
-       with a long history, and would want to send in fixes
-       as patches.
+       number of limitations (you cannot clone or fetch from it, nor
+       push into it), but is adequate if you are only interested in
+       the recent history of a large project with a long history.
++
+Pushing from a shallow clone should be avoided if the git version on
+the receiver end is older than v1.7.10, or any other git
+implementation that does not perform connectivity check.
 
 --[no-]single-branch::
        Clone only the history leading to the tip of a single branch,
index 19a7be085693f7f9386fd3856fa38ebeed364f99..99dc497b6f25243dbe01ce47d6e53ec6952d1737 100644 (file)
@@ -82,7 +82,7 @@ OPTIONS
 --get::
        Get the value for a given key (optionally filtered by a regex
        matching the value). Returns error code 1 if the key was not
-       found and error code 2 if multiple key values were found.
+       found and the last value if multiple key values were found.
 
 --get-all::
        Like get, but does not fail if the number of values for the key
@@ -206,12 +206,8 @@ FILES
 If not set explicitly with '--file', there are four files where
 'git config' will search for configuration options:
 
-$GIT_DIR/config::
-       Repository specific configuration file.
-
-~/.gitconfig::
-       User-specific configuration file. Also called "global"
-       configuration file.
+$(prefix)/etc/gitconfig::
+       System-wide configuration file.
 
 $XDG_CONFIG_HOME/git/config::
        Second user-specific configuration file. If $XDG_CONFIG_HOME is not set
@@ -221,8 +217,12 @@ $XDG_CONFIG_HOME/git/config::
        you sometimes use older versions of Git, as support for this
        file was added fairly recently.
 
-$(prefix)/etc/gitconfig::
-       System-wide configuration file.
+~/.gitconfig::
+       User-specific configuration file. Also called "global"
+       configuration file.
+
+$GIT_DIR/config::
+       Repository specific configuration file.
 
 If no further options are given, all reading options will read all of these
 files that are available. If the global or the system-wide configuration
@@ -230,6 +230,10 @@ file are not available they will be ignored. If the repository configuration
 file is not available or readable, 'git config' will exit with a non-zero
 error code. However, in neither case will an error message be issued.
 
+The files are read in the order given above, with last value found taking
+precedence over values read earlier.  When multiple values are taken then all
+values of a key from all files will be used.
+
 All writing options will per default write to the repository specific
 configuration file. Note that this also affects options like '--replace-all'
 and '--unset'. *'git config' will only ever change one file at a time*.
index 6b0f1ba75fc98dedf7b940355274ad25d3b458c5..15b00e09916fff47a8244432ce396c9b6f7fbec1 100644 (file)
@@ -32,8 +32,10 @@ OPTIONS
        List all commits reachable from all refs
 
 --stdin::
-       Read from stdin, append "(<rev_name>)" to all sha1's of nameable
-       commits, and pass to stdout
+       Transform stdin by substituting all the 40-character SHA-1
+       hexes (say $hex) with "$hex ($rev_name)".  When used with
+       --name-only, substitute with "$rev_name", omitting $hex
+       altogether.  Intended for the scripter's use.
 
 --name-only::
        Instead of printing both the SHA-1 and the name, print only
index c579fbc2b858d0a6fb5cd8dcbcaa25d3b3fca2a5..8cba16d67f29ec48738b00a607add4a20bc7d4b2 100644 (file)
@@ -176,13 +176,16 @@ Sync options
 These options can be used in the initial 'clone' as well as in
 subsequent 'sync' operations.
 
---branch <branch>::
-       Import changes into given branch.  If the branch starts with
-       'refs/', it will be used as is.  Otherwise if it does not start
-       with 'p4/', that prefix is added.  The branch is assumed to
-       name a remote tracking, but this can be modified using
-       '--import-local', or by giving a full ref name.  The default
-       branch is 'master'.
+--branch <ref>::
+       Import changes into <ref> instead of refs/remotes/p4/master.
+       If <ref> starts with refs/, it is used as is.  Otherwise, if
+       it does not start with p4/, that prefix is added.
++
+By default a <ref> not starting with refs/ is treated as the
+name of a remote-tracking branch (under refs/remotes/).  This
+behavior can be modified using the --import-local option.
++
+The default <ref> is "master".
 +
 This example imports a new remote "p4/proj2" into an existing
 Git repository:
index 24ab07a3f8f80c56cbbd7feffc1b5bf65e137968..6ef8d599d31ac20982fa74f213b81494ceae162a 100644 (file)
@@ -3,7 +3,7 @@ git-pull(1)
 
 NAME
 ----
-git-pull - Fetch from and merge with another repository or a local branch
+git-pull - Fetch from and integrate with another repository or a local branch
 
 
 SYNOPSIS
index db7e803038090510609a6534ab7d086245c15270..7c8b648fbe8f76d523f781699447586c838b12fc 100644 (file)
@@ -14,7 +14,8 @@ SYNOPSIS
 'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>]
 'git stash' branch <branchname> [<stash>]
 'git stash' [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
-            [-u|--include-untracked] [-a|--all] [<message>]]
+            [-u|--include-untracked] [-a|--all] [-f|--force]
+            [<message>]]
 'git stash' clear
 'git stash' create [<message>]
 'git stash' store [-m|--message <message>] [-q|--quiet] <commit>
@@ -44,7 +45,7 @@ is also possible).
 OPTIONS
 -------
 
-save [-p|--patch] [--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [<message>]::
+save [-p|--patch] [--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [-f|--force] [<message>]::
 
        Save your local modifications to a new 'stash', and run `git reset
        --hard` to revert them.  The <message> part is optional and gives
@@ -71,6 +72,13 @@ linkgit:git-add[1] to learn how to operate the `--patch` mode.
 +
 The `--patch` option implies `--keep-index`.  You can use
 `--no-keep-index` to override this.
++
+In some cases, saving a stash could mean irretrievably removing some
+data - if a directory with untracked files replaces a tracked file of
+the same name, the new untracked files are not saved (except in case
+of `--include-untracked`) but the original tracked file shall be restored.
+By default, `stash save` will abort in such a case; `--force` will allow
+it to remove the untracked files.
 
 list [<options>]::
 
index e5767134b1a2a84c284e87c900948e4530b25576..bfff09062d028dc038f0926042f651084c1395d6 100644 (file)
@@ -262,7 +262,7 @@ OPTIONS
 --remote::
        This option is only valid for the update command.  Instead of using
        the superproject's recorded SHA-1 to update the submodule, use the
-       status of the submodule's remote tracking branch.  The remote used
+       status of the submodule's remote-tracking branch.  The remote used
        is branch's remote (`branch.<name>.remote`), defaulting to `origin`.
        The remote branch used defaults to `master`, but the branch name may
        be overridden by setting the `submodule.<name>.branch` option in
index ea0526ecc4019802b7088316cba9aed401fa6ee8..305db633ccb1165e819a1061e8ec8b60e33e9eed 100644 (file)
@@ -336,8 +336,26 @@ $home_link_str::
        used as the first component of gitweb's "breadcrumb trail":
        `<home link> / <project> / <action>`.  Can be set at build time using
        the `GITWEB_HOME_LINK_STR` variable.  By default it is set to "projects",
-       as this link leads to the list of projects.  Other popular choice it to
-       set it to the name of site.
+       as this link leads to the list of projects.  Another popular choice is to
+       set it to the name of site.  Note that it is treated as raw HTML so it
+       should not be set from untrusted sources.
+
+@extra_breadcrumbs::
+       Additional links to be added to the start of the breadcrumb trail before
+       the home link, to pages that are logically "above" the gitweb projects
+       list, such as the organization and department which host the gitweb
+       server. Each element of the list is a reference to an array, in which
+       element 0 is the link text (equivalent to `$home_link_str`) and element
+       1 is the target URL (equivalent to `$home_link`).
++
+For example, the following setting produces a breadcrumb trail like
+"home / dev / projects / ..." where "projects" is the home link.
+----------------------------------------------------------------------------
+    our @extra_breadcrumbs = (
+      [ 'home' => 'https://www.example.org/' ],
+      [ 'dev'  => 'https://dev.example.org/' ],
+    );
+----------------------------------------------------------------------------
 
 $logo_url::
 $logo_label::
index db2a74df934f3acd93521e42510b6cd00c9eed6f..dba5062b379cdfcdde31ee0f6809e964f979b5f5 100644 (file)
@@ -113,7 +113,7 @@ Note that commands that operate on the history of the current branch
 while the HEAD is detached. They update the HEAD to point at the tip
 of the updated history without affecting any branch.  Commands that
 update or inquire information _about_ the current branch (e.g. `git
-branch --set-upstream-to` that sets what remote tracking branch the
+branch --set-upstream-to` that sets what remote-tracking branch the
 current branch integrates with) obviously do not work, as there is no
 (real) current branch to ask about in this state.
 
@@ -267,7 +267,7 @@ This commit is referred to as a "merge commit", or sometimes just a
        The default upstream <<def_repository,repository>>. Most projects have
        at least one upstream project which they track. By default
        'origin' is used for that purpose. New upstream updates
-       will be fetched into remote <<def_remote_tracking_branch,remote-tracking branches>> named
+       will be fetched into <<def_remote_tracking_branch,remote-tracking branches>> named
        origin/name-of-upstream-branch, which you can see using
        `git branch -r`.
 
index 5a68fe5431043d2b1b98493434c0c7989d36757c..0600eb46db487c88e24dc3b4089db062ad6350ac 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2305,9 +2305,6 @@ check: common-cmds.h
                exit 1; \
        fi
 
-remove-dashes:
-       ./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
-
 ### Installation rules
 
 ifneq ($(filter /%,$(firstword $(template_dir))),)
index 3be00188216f503ea1f9269acd312aebdb72a0fa..7fe0bffaf8b875b40b5e4e0e5c207f978c932691 100644 (file)
@@ -587,7 +587,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
                                   struct branch_info *new)
 {
        struct strbuf msg = STRBUF_INIT;
-       const char *old_desc;
+       const char *old_desc, *reflog_msg;
        if (opts->new_branch) {
                if (opts->new_orphan_branch) {
                        if (opts->new_branch_log && !log_all_ref_updates) {
@@ -620,8 +620,13 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
        old_desc = old->name;
        if (!old_desc && old->commit)
                old_desc = sha1_to_hex(old->commit->object.sha1);
-       strbuf_addf(&msg, "checkout: moving from %s to %s",
-                   old_desc ? old_desc : "(invalid)", new->name);
+
+       reflog_msg = getenv("GIT_REFLOG_ACTION");
+       if (!reflog_msg)
+               strbuf_addf(&msg, "checkout: moving from %s to %s",
+                       old_desc ? old_desc : "(invalid)", new->name);
+       else
+               strbuf_insert(&msg, 0, reflog_msg, strlen(reflog_msg));
 
        if (!strcmp(new->name, "HEAD") && !new->path && !opts->force_detach) {
                /* Nothing to do. */
index 14b13235682add18daf625295d746ca5dea7ebcc..17f57cdf29a4c74550795ce3f711fbfc57bf38b3 100644 (file)
@@ -701,7 +701,7 @@ static void write_refspec_config(const char* src_ref_prefix,
                        /*
                         * otherwise, the next "git fetch" will
                         * simply fetch from HEAD without updating
-                        * any remote tracking branch, which is what
+                        * any remote-tracking branch, which is what
                         * we want.
                         */
                } else {
index 6b693c16d8842b70b0e1c7bd7df5095947ed0a64..790e5ab5cfee7b0f5760aafed7bf6f3f5927871e 100644 (file)
@@ -112,12 +112,14 @@ static int show_ignored_in_status, have_option_m;
 static const char *only_include_assumed;
 static struct strbuf message = STRBUF_INIT;
 
-static enum {
+static enum status_format {
        STATUS_FORMAT_NONE = 0,
        STATUS_FORMAT_LONG,
        STATUS_FORMAT_SHORT,
-       STATUS_FORMAT_PORCELAIN
-} status_format;
+       STATUS_FORMAT_PORCELAIN,
+
+       STATUS_FORMAT_UNSPECIFIED
+} status_format = STATUS_FORMAT_UNSPECIFIED;
 
 static int opt_parse_m(const struct option *opt, const char *arg, int unset)
 {
@@ -460,6 +462,9 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
        case STATUS_FORMAT_PORCELAIN:
                wt_porcelain_print(s);
                break;
+       case STATUS_FORMAT_UNSPECIFIED:
+               die("BUG: finalize_deferred_config() should have been called");
+               break;
        case STATUS_FORMAT_NONE:
        case STATUS_FORMAT_LONG:
                wt_status_print(s);
@@ -961,6 +966,42 @@ static const char *read_commit_message(const char *name)
        return logmsg_reencode(commit, NULL, out_enc);
 }
 
+/*
+ * Enumerate what needs to be propagated when --porcelain
+ * is not in effect here.
+ */
+static struct status_deferred_config {
+       enum status_format status_format;
+       int show_branch;
+} status_deferred_config = {
+       STATUS_FORMAT_UNSPECIFIED,
+       -1 /* unspecified */
+};
+
+static void finalize_deferred_config(struct wt_status *s)
+{
+       int use_deferred_config = (status_format != STATUS_FORMAT_PORCELAIN &&
+                                  !s->null_termination);
+
+       if (s->null_termination) {
+               if (status_format == STATUS_FORMAT_NONE ||
+                   status_format == STATUS_FORMAT_UNSPECIFIED)
+                       status_format = STATUS_FORMAT_PORCELAIN;
+               else if (status_format == STATUS_FORMAT_LONG)
+                       die(_("--long and -z are incompatible"));
+       }
+
+       if (use_deferred_config && status_format == STATUS_FORMAT_UNSPECIFIED)
+               status_format = status_deferred_config.status_format;
+       if (status_format == STATUS_FORMAT_UNSPECIFIED)
+               status_format = STATUS_FORMAT_NONE;
+
+       if (use_deferred_config && s->show_branch < 0)
+               s->show_branch = status_deferred_config.show_branch;
+       if (s->show_branch < 0)
+               s->show_branch = 0;
+}
+
 static int parse_and_validate_options(int argc, const char *argv[],
                                      const struct option *options,
                                      const char * const usage[],
@@ -971,6 +1012,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
        int f = 0;
 
        argc = parse_options(argc, argv, prefix, options, usage, 0);
+       finalize_deferred_config(s);
 
        if (force_author && !strchr(force_author, '>'))
                force_author = find_author_by_nickname(force_author);
@@ -1055,12 +1097,6 @@ static int parse_and_validate_options(int argc, const char *argv[],
        if (all && argc > 0)
                die(_("Paths with -a does not make sense."));
 
-       if (s->null_termination) {
-               if (status_format == STATUS_FORMAT_NONE)
-                       status_format = STATUS_FORMAT_PORCELAIN;
-               else if (status_format == STATUS_FORMAT_LONG)
-                       die(_("--long and -z are incompatible"));
-       }
        if (status_format != STATUS_FORMAT_NONE)
                dry_run = 1;
 
@@ -1113,6 +1149,17 @@ static int git_status_config(const char *k, const char *v, void *cb)
                        s->submodule_summary = -1;
                return 0;
        }
+       if (!strcmp(k, "status.short")) {
+               if (git_config_bool(k, v))
+                       status_deferred_config.status_format = STATUS_FORMAT_SHORT;
+               else
+                       status_deferred_config.status_format = STATUS_FORMAT_NONE;
+               return 0;
+       }
+       if (!strcmp(k, "status.branch")) {
+               status_deferred_config.show_branch = git_config_bool(k, v);
+               return 0;
+       }
        if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
                s->use_color = git_config_colorbool(k, v);
                return 0;
@@ -1155,8 +1202,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
                OPT__VERBOSE(&verbose, N_("be verbose")),
                OPT_SET_INT('s', "short", &status_format,
                            N_("show status concisely"), STATUS_FORMAT_SHORT),
-               OPT_BOOLEAN('b', "branch", &s.show_branch,
-                           N_("show branch information")),
+               OPT_BOOL('b', "branch", &s.show_branch,
+                        N_("show branch information")),
                OPT_SET_INT(0, "porcelain", &status_format,
                            N_("machine-readable output"),
                            STATUS_FORMAT_PORCELAIN),
@@ -1189,13 +1236,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
                             builtin_status_options,
                             builtin_status_usage, 0);
        finalize_colopts(&s.colopts, -1);
-
-       if (s.null_termination) {
-               if (status_format == STATUS_FORMAT_NONE)
-                       status_format = STATUS_FORMAT_PORCELAIN;
-               else if (status_format == STATUS_FORMAT_LONG)
-                       die(_("--long and -z are incompatible"));
-       }
+       finalize_deferred_config(&s);
 
        handle_untracked_files_arg(&s);
        if (show_ignored_in_status)
@@ -1224,6 +1265,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
        case STATUS_FORMAT_PORCELAIN:
                wt_porcelain_print(&s);
                break;
+       case STATUS_FORMAT_UNSPECIFIED:
+               die("BUG: finalize_deferred_config() should have been called");
+               break;
        case STATUS_FORMAT_NONE:
        case STATUS_FORMAT_LONG:
                s.verbose = verbose;
@@ -1392,7 +1436,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                OPT_BOOLEAN(0, "dry-run", &dry_run, N_("show what would be committed")),
                OPT_SET_INT(0, "short", &status_format, N_("show status concisely"),
                            STATUS_FORMAT_SHORT),
-               OPT_BOOLEAN(0, "branch", &s.show_branch, N_("show branch information")),
+               OPT_BOOL(0, "branch", &s.show_branch, N_("show branch information")),
                OPT_SET_INT(0, "porcelain", &status_format,
                            N_("machine-readable output"), STATUS_FORMAT_PORCELAIN),
                OPT_SET_INT(0, "long", &status_format,
@@ -1433,6 +1477,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        wt_status_prepare(&s);
        gitmodules_config();
        git_config(git_commit_config, &s);
+       status_format = STATUS_FORMAT_NONE; /* Ignore status.short */
        determine_whence(&s);
        s.colopts = 0;
 
index 2ebe732896c1b3bfd920941b5182b793468c0afe..9505e7e426d302522f5e065d741fccd37290ea21 100644 (file)
@@ -47,8 +47,8 @@ static const char * const builtin_merge_usage[] = {
 };
 
 static int show_diffstat = 1, shortlog_len = -1, squash;
-static int option_commit = 1, allow_fast_forward = 1;
-static int fast_forward_only, option_edit = -1;
+static int option_commit = 1;
+static int option_edit = -1;
 static int allow_trivial = 1, have_message, verify_signatures;
 static int overwrite_ignore = 1;
 static struct strbuf merge_msg = STRBUF_INIT;
@@ -76,6 +76,14 @@ static struct strategy all_strategy[] = {
 
 static const char *pull_twohead, *pull_octopus;
 
+enum ff_type {
+       FF_NO,
+       FF_ALLOW,
+       FF_ONLY
+};
+
+static enum ff_type fast_forward = FF_ALLOW;
+
 static int option_parse_message(const struct option *opt,
                                const char *arg, int unset)
 {
@@ -178,6 +186,13 @@ static int option_parse_n(const struct option *opt,
        return 0;
 }
 
+static int option_parse_ff_only(const struct option *opt,
+                         const char *arg, int unset)
+{
+       fast_forward = FF_ONLY;
+       return 0;
+}
+
 static struct option builtin_merge_options[] = {
        { OPTION_CALLBACK, 'n', NULL, NULL, NULL,
                N_("do not show a diffstat at the end of the merge"),
@@ -194,10 +209,10 @@ static struct option builtin_merge_options[] = {
                N_("perform a commit if the merge succeeds (default)")),
        OPT_BOOL('e', "edit", &option_edit,
                N_("edit message before committing")),
-       OPT_BOOLEAN(0, "ff", &allow_fast_forward,
-               N_("allow fast-forward (default)")),
-       OPT_BOOLEAN(0, "ff-only", &fast_forward_only,
-               N_("abort if fast-forward is not possible")),
+       OPT_SET_INT(0, "ff", &fast_forward, N_("allow fast-forward (default)"), FF_ALLOW),
+       { OPTION_CALLBACK, 0, "ff-only", NULL, NULL,
+               N_("abort if fast-forward is not possible"),
+               PARSE_OPT_NOARG | PARSE_OPT_NONEG, option_parse_ff_only },
        OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
        OPT_BOOL(0, "verify-signatures", &verify_signatures,
                N_("Verify that the named commit has a valid GPG signature")),
@@ -581,10 +596,9 @@ static int git_merge_config(const char *k, const char *v, void *cb)
        else if (!strcmp(k, "merge.ff")) {
                int boolval = git_config_maybe_bool(k, v);
                if (0 <= boolval) {
-                       allow_fast_forward = boolval;
+                       fast_forward = boolval ? FF_ALLOW : FF_NO;
                } else if (v && !strcmp(v, "only")) {
-                       allow_fast_forward = 1;
-                       fast_forward_only = 1;
+                       fast_forward = FF_ONLY;
                } /* do not barf on values from future versions of git */
                return 0;
        } else if (!strcmp(k, "merge.defaulttoupstream")) {
@@ -863,7 +877,7 @@ static int finish_automerge(struct commit *head,
 
        free_commit_list(common);
        parents = remoteheads;
-       if (!head_subsumed || !allow_fast_forward)
+       if (!head_subsumed || fast_forward == FF_NO)
                commit_list_insert(head, &parents);
        strbuf_addch(&merge_msg, '\n');
        prepare_to_commit(remoteheads);
@@ -948,7 +962,7 @@ static int evaluate_result(void)
 }
 
 /*
- * Pretend as if the user told us to merge with the tracking
+ * Pretend as if the user told us to merge with the remote-tracking
  * branch we have for the upstream of the current branch
  */
 static int setup_with_upstream(const char ***argv)
@@ -967,7 +981,7 @@ static int setup_with_upstream(const char ***argv)
        args = xcalloc(branch->merge_nr + 1, sizeof(char *));
        for (i = 0; i < branch->merge_nr; i++) {
                if (!branch->merge[i]->dst)
-                       die(_("No remote tracking branch for %s from %s"),
+                       die(_("No remote-tracking branch for %s from %s"),
                            branch->merge[i]->src, branch->remote_name);
                args[i] = branch->merge[i]->dst;
        }
@@ -1008,7 +1022,7 @@ static void write_merge_state(struct commit_list *remoteheads)
        if (fd < 0)
                die_errno(_("Could not open '%s' for writing"), filename);
        strbuf_reset(&buf);
-       if (!allow_fast_forward)
+       if (fast_forward == FF_NO)
                strbuf_addf(&buf, "no-ff");
        if (write_in_full(fd, buf.buf, buf.len) != buf.len)
                die_errno(_("Could not write to '%s'"), filename);
@@ -1157,14 +1171,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                show_diffstat = 0;
 
        if (squash) {
-               if (!allow_fast_forward)
+               if (fast_forward == FF_NO)
                        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."));
-
        if (!abort_current_merge) {
                if (!argc) {
                        if (default_to_upstream)
@@ -1206,7 +1217,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                                "empty head"));
                if (squash)
                        die(_("Squash commit into empty head not supported yet"));
-               if (!allow_fast_forward)
+               if (fast_forward == FF_NO)
                        die(_("Non-fast-forward commit does not make sense into "
                            "an empty head"));
                remoteheads = collect_parents(head_commit, &head_subsumed, argc, argv);
@@ -1294,11 +1305,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                            sha1_to_hex(commit->object.sha1));
                setenv(buf.buf, merge_remote_util(commit)->name, 1);
                strbuf_reset(&buf);
-               if (!fast_forward_only &&
+               if (fast_forward != FF_ONLY &&
                    merge_remote_util(commit) &&
                    merge_remote_util(commit)->obj &&
                    merge_remote_util(commit)->obj->type == OBJ_TAG)
-                       allow_fast_forward = 0;
+                       fast_forward = FF_NO;
        }
 
        if (option_edit < 0)
@@ -1315,7 +1326,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 
        for (i = 0; i < use_strategies_nr; i++) {
                if (use_strategies[i]->attr & NO_FAST_FORWARD)
-                       allow_fast_forward = 0;
+                       fast_forward = FF_NO;
                if (use_strategies[i]->attr & NO_TRIVIAL)
                        allow_trivial = 0;
        }
@@ -1345,7 +1356,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                 */
                finish_up_to_date("Already up-to-date.");
                goto done;
-       } else if (allow_fast_forward && !remoteheads->next &&
+       } else if (fast_forward != FF_NO && !remoteheads->next &&
                        !common->next &&
                        !hashcmp(common->item->object.sha1, head_commit->object.sha1)) {
                /* Again the most common case of merging one remote. */
@@ -1392,7 +1403,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                 * only one common.
                 */
                refresh_cache(REFRESH_QUIET);
-               if (allow_trivial && !fast_forward_only) {
+               if (allow_trivial && fast_forward != FF_ONLY) {
                        /* See if it is really trivial. */
                        git_committer_info(IDENT_STRICT);
                        printf(_("Trying really trivial in-index merge...\n"));
@@ -1433,7 +1444,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                }
        }
 
-       if (fast_forward_only)
+       if (fast_forward == FF_ONLY)
                die(_("Not possible to fast-forward, aborting."));
 
        /* We are going to make a new commit. */
index 2d84d10720fad88becdfe957f3770a2c44ac0a8f..6d36c24268bea3cb658a1aa94f3a037f403d5895 100644 (file)
@@ -120,10 +120,11 @@ static const char message_detached_head_die[] =
           "\n"
           "    git push %s HEAD:<name-of-remote-branch>\n");
 
-static void setup_push_upstream(struct remote *remote, int simple)
+static void setup_push_upstream(struct remote *remote, struct branch *branch,
+                               int triangular)
 {
        struct strbuf refspec = STRBUF_INIT;
-       struct branch *branch = branch_get(NULL);
+
        if (!branch)
                die(_(message_detached_head_die), remote->name);
        if (!branch->merge_nr || !branch->merge || !branch->remote_name)
@@ -137,18 +138,29 @@ static void setup_push_upstream(struct remote *remote, int simple)
        if (branch->merge_nr != 1)
                die(_("The current branch %s has multiple upstream branches, "
                    "refusing to push."), branch->name);
-       if (strcmp(branch->remote_name, remote->name))
+       if (triangular)
                die(_("You are pushing to remote '%s', which is not the upstream of\n"
                      "your current branch '%s', without telling me what to push\n"
                      "to update which remote branch."),
                    remote->name, branch->name);
-       if (simple && strcmp(branch->refname, branch->merge[0]->src))
-               die_push_simple(branch, remote);
+
+       if (push_default == PUSH_DEFAULT_SIMPLE) {
+               /* Additional safety */
+               if (strcmp(branch->refname, branch->merge[0]->src))
+                       die_push_simple(branch, remote);
+       }
 
        strbuf_addf(&refspec, "%s:%s", branch->name, branch->merge[0]->src);
        add_refspec(refspec.buf);
 }
 
+static void setup_push_current(struct remote *remote, struct branch *branch)
+{
+       if (!branch)
+               die(_(message_detached_head_die), remote->name);
+       add_refspec(branch->name);
+}
+
 static char warn_unspecified_push_default_msg[] =
 N_("push.default is unset; its implicit value is changing in\n"
    "Git 2.0 from 'matching' to 'simple'. To squelch this message\n"
@@ -173,9 +185,16 @@ static void warn_unspecified_push_default_configuration(void)
        warning("%s\n", _(warn_unspecified_push_default_msg));
 }
 
+static int is_workflow_triangular(struct remote *remote)
+{
+       struct remote *fetch_remote = remote_get(NULL);
+       return (fetch_remote && fetch_remote != remote);
+}
+
 static void setup_default_push_refspecs(struct remote *remote)
 {
-       struct branch *branch;
+       struct branch *branch = branch_get(NULL);
+       int triangular = is_workflow_triangular(remote);
 
        switch (push_default) {
        default:
@@ -188,18 +207,18 @@ static void setup_default_push_refspecs(struct remote *remote)
                break;
 
        case PUSH_DEFAULT_SIMPLE:
-               setup_push_upstream(remote, 1);
+               if (triangular)
+                       setup_push_current(remote, branch);
+               else
+                       setup_push_upstream(remote, branch, triangular);
                break;
 
        case PUSH_DEFAULT_UPSTREAM:
-               setup_push_upstream(remote, 0);
+               setup_push_upstream(remote, branch, triangular);
                break;
 
        case PUSH_DEFAULT_CURRENT:
-               branch = branch_get(NULL);
-               if (!branch)
-                       die(_(message_detached_head_die), remote->name);
-               add_refspec(branch->name);
+               setup_push_current(remote, branch);
                break;
 
        case PUSH_DEFAULT_NOTHING:
@@ -211,8 +230,8 @@ static void setup_default_push_refspecs(struct remote *remote)
 
 static const char message_advice_pull_before_push[] =
        N_("Updates were rejected because the tip of your current branch is behind\n"
-          "its remote counterpart. Merge the remote changes (e.g. 'git pull')\n"
-          "before pushing again.\n"
+          "its remote counterpart. Integrate the remote changes (e.g.\n"
+          "'git pull ...') before pushing again.\n"
           "See the 'Note about fast-forwards' in 'git push --help' for details.");
 
 static const char message_advice_use_upstream[] =
@@ -223,15 +242,15 @@ static const char message_advice_use_upstream[] =
 
 static const char message_advice_checkout_pull_push[] =
        N_("Updates were rejected because a pushed branch tip is behind its remote\n"
-          "counterpart. Check out this branch and merge the remote changes\n"
-          "(e.g. 'git pull') before pushing again.\n"
+          "counterpart. Check out this branch and integrate the remote changes\n"
+          "(e.g. 'git pull ...') before pushing again.\n"
           "See the 'Note about fast-forwards' in 'git push --help' for details.");
 
 static const char message_advice_ref_fetch_first[] =
        N_("Updates were rejected because the remote contains work that you do\n"
           "not have locally. This is usually caused by another repository pushing\n"
-          "to the same ref. You may want to first merge the remote changes (e.g.,\n"
-          "'git pull') before pushing again.\n"
+          "to the same ref. You may want to first integrate the remote changes\n"
+          "(e.g., 'git pull ...') before pushing again.\n"
           "See the 'Note about fast-forwards' in 'git push --help' for details.");
 
 static const char message_advice_ref_already_exists[] =
index 6032131a9087281e97d0abc05365b7485004121b..afa6e020e83ebac739db474c278e44bc22079848 100644 (file)
@@ -93,10 +93,12 @@ static int reset_index(const unsigned char *sha1, int reset_type, int quiet)
 static void print_new_head_line(struct commit *commit)
 {
        const char *hex, *body;
+       char *msg;
 
        hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
        printf(_("HEAD is now at %s"), hex);
-       body = strstr(commit->buffer, "\n\n");
+       msg = logmsg_reencode(commit, NULL, get_log_output_encoding());
+       body = strstr(msg, "\n\n");
        if (body) {
                const char *eol;
                size_t len;
@@ -107,6 +109,7 @@ static void print_new_head_line(struct commit *commit)
        }
        else
                printf("\n");
+       logmsg_free(msg, commit);
 }
 
 static void update_index_from_diff(struct diff_queue_struct *q,
index 67701be55193db0fd9733ee7c4962db08072045c..a5ec30d74ee1945ddaf99c89307e59aec714714a 100644 (file)
@@ -111,6 +111,7 @@ static void show_commit(struct commit *commit, void *data)
                ctx.date_mode = revs->date_mode;
                ctx.date_mode_explicit = revs->date_mode_explicit;
                ctx.fmt = revs->commit_format;
+               ctx.output_encoding = get_log_output_encoding();
                pretty_print_commit(&ctx, commit, &buf);
                if (revs->graph) {
                        if (buf.len) {
index 1fd6f8ac5977ee670bf8ba230cec8553393baafd..1434f8fee487751abe069250c611bdaed2fa5857 100644 (file)
@@ -137,6 +137,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
                ctx.subject = "";
                ctx.after_subject = "";
                ctx.date_mode = DATE_NORMAL;
+               ctx.output_encoding = get_log_output_encoding();
                pretty_print_commit(&ctx, commit, &ufbuf);
                buffer = ufbuf.buf;
        } else if (*buffer) {
index 521e49c3094acc06340e15f7be27722be9b03ee8..ebc0eeab8f9c1678f3780991a9414f2261215427 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -581,7 +581,7 @@ static int compare_commits_by_author_date(const void *a_, const void *b_,
        return 0;
 }
 
-static int compare_commits_by_commit_date(const void *a_, const void *b_, void *unused)
+int compare_commits_by_commit_date(const void *a_, const void *b_, void *unused)
 {
        const struct commit *a = a_, *b = b_;
        /* newer commits with larger date first */
index c56bc3a0914f9fce3e8b5d0a25d291077429fe03..35cc4e266bd4afe0e00d2efb2781db2e95906936 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -267,4 +267,6 @@ extern void print_commit_list(struct commit_list *list,
  */
 extern void check_commit_signature(const struct commit* commit, struct signature_check *sigc);
 
+int compare_commits_by_commit_date(const void *a_, const void *b_, void *unused);
+
 #endif /* COMMIT_H */
index ebc40d4845586bcdd7df8f02c34db9b157cfe149..fa3ae1e8535c786dc724ab7a73cccb6f3bfca8de 100644 (file)
@@ -2490,9 +2490,10 @@ __git_main ()
                i="${words[c]}"
                case "$i" in
                --git-dir=*) __git_dir="${i#--git-dir=}" ;;
+               --git-dir)   ((c++)) ; __git_dir="${words[c]}" ;;
                --bare)      __git_dir="." ;;
                --help) command="help"; break ;;
-               -c) c=$((++c)) ;;
+               -c|--work-tree|--namespace) ((c++)) ;;
                -*) ;;
                *) command="$i"; break ;;
                esac
@@ -2510,6 +2511,7 @@ __git_main ()
                        --exec-path
                        --exec-path=
                        --html-path
+                       --man-path
                        --info-path
                        --work-tree=
                        --namespace=
index 71baf8ace8882e96eddab19e4b11448044b5190e..d09f5da6681fa62dbb87582031c12fe9dceddb69 100755 (executable)
@@ -635,9 +635,9 @@ sub literal_data_raw {
        my ($content) = @_;
        # Avoid confusion between size in bytes and in characters
        utf8::downgrade($content);
-       binmode {*STDOUT}, ':raw';
+       binmode STDOUT, ':raw';
        print {*STDOUT} 'data ', bytes::length($content), "\n", $content;
-       binmode {*STDOUT}, ':encoding(UTF-8)';
+       binmode STDOUT, ':encoding(UTF-8)';
        return;
 }
 
diff --git a/diff.c b/diff.c
index 208094f6b7d8b6e18459fc1cd57ac8554723d8d4..e53ddad7d485c97ca3f0cf0d5784ac712163a857 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -2677,6 +2677,14 @@ static int diff_populate_gitlink(struct diff_filespec *s, int size_only)
 int diff_populate_filespec(struct diff_filespec *s, int size_only)
 {
        int err = 0;
+       /*
+        * demote FAIL to WARN to allow inspecting the situation
+        * instead of refusing.
+        */
+       enum safe_crlf crlf_warn = (safe_crlf == SAFE_CRLF_FAIL
+                                   ? SAFE_CRLF_WARN
+                                   : safe_crlf);
+
        if (!DIFF_FILE_VALID(s))
                die("internal error: asking to populate invalid file.");
        if (S_ISDIR(s->mode))
@@ -2732,7 +2740,7 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
                /*
                 * Convert from working tree format to canonical git format
                 */
-               if (convert_to_git(s->path, s->data, s->size, &buf, safe_crlf)) {
+               if (convert_to_git(s->path, s->data, s->size, &buf, crlf_warn)) {
                        size_t size = 0;
                        munmap(s->data, s->size);
                        s->should_munmap = 0;
index c97ac9b463fc1248b2dfe70d5fdf1dc1679e2bf8..401eb72c619d432c92fc66b470fae778117bcace 100644 (file)
@@ -131,8 +131,7 @@ static void diffcore_pickaxe_grep(struct diff_options *o)
        return;
 }
 
-static unsigned int contains(mmfile_t *mf, struct diff_options *o,
-                            regex_t *regexp, kwset_t kws)
+static unsigned int contains(mmfile_t *mf, regex_t *regexp, kwset_t kws)
 {
        unsigned int cnt;
        unsigned long sz;
@@ -176,11 +175,9 @@ static int has_changes(mmfile_t *one, mmfile_t *two,
                       struct diff_options *o,
                       regex_t *regexp, kwset_t kws)
 {
-       if (!one)
-               return contains(two, o, regexp, kws) != 0;
-       if (!two)
-               return contains(one, o, regexp, kws) != 0;
-       return contains(one, o, regexp, kws) != contains(two, o, regexp, kws);
+       unsigned int one_contains = one ? contains(one, regexp, kws) : 0;
+       unsigned int two_contains = two ? contains(two, regexp, kws) : 0;
+       return one_contains != two_contains;
 }
 
 static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,
diff --git a/dir.c b/dir.c
index 897c87403e978ab2123ce088cf2d3265e21d7dde..048041954418315d73924b3d73c6f2c794a5edb1 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -1036,9 +1036,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
                return path_recurse;
 
        case index_gitdir:
-               if (dir->flags & DIR_SHOW_OTHER_DIRECTORIES)
-                       return path_none;
-               return path_untracked;
+               return path_none;
 
        case index_nonexistent:
                if (dir->flags & DIR_SHOW_OTHER_DIRECTORIES)
index abe5ffbba55037c34b1bf38a86aa0ec8bd7f3447..6684348c0ec9ea742eb98666b56a0bfcef316560 100644 (file)
@@ -11,6 +11,7 @@
 #include "run-command.h"
 #include "transport.h"
 #include "version.h"
+#include "prio-queue.h"
 
 static int transfer_unpack_limit = -1;
 static int fetch_unpack_limit = -1;
@@ -37,7 +38,7 @@ static int marked;
  */
 #define MAX_IN_VAIN 256
 
-static struct commit_list *rev_list;
+static struct prio_queue rev_list = { compare_commits_by_commit_date };
 static int non_common_revs, multi_ack, use_sideband, allow_tip_sha1_in_want;
 
 static void rev_list_push(struct commit *commit, int mark)
@@ -49,7 +50,7 @@ static void rev_list_push(struct commit *commit, int mark)
                        if (parse_commit(commit))
                                return;
 
-               commit_list_insert_by_date(commit, &rev_list);
+               prio_queue_put(&rev_list, commit);
 
                if (!(commit->object.flags & COMMON))
                        non_common_revs++;
@@ -122,10 +123,10 @@ static const unsigned char *get_rev(void)
                unsigned int mark;
                struct commit_list *parents;
 
-               if (rev_list == NULL || non_common_revs == 0)
+               if (rev_list.nr == 0 || non_common_revs == 0)
                        return NULL;
 
-               commit = rev_list->item;
+               commit = prio_queue_get(&rev_list);
                if (!commit->object.parsed)
                        parse_commit(commit);
                parents = commit->parents;
@@ -152,8 +153,6 @@ static const unsigned char *get_rev(void)
                                mark_common(parents->item, 1, 0);
                        parents = parents->next;
                }
-
-               rev_list = rev_list->next;
        }
 
        return commit->object.sha1;
@@ -442,7 +441,7 @@ static int find_common(struct fetch_pack_args *args,
                                        in_vain = 0;
                                        got_continue = 1;
                                        if (ack == ACK_ready) {
-                                               rev_list = NULL;
+                                               clear_prio_queue(&rev_list);
                                                got_ready = 1;
                                        }
                                        break;
@@ -505,7 +504,7 @@ static int mark_complete(const char *refname, const unsigned char *sha1, int fla
                struct commit *commit = (struct commit *)o;
                if (!(commit->object.flags & COMPLETE)) {
                        commit->object.flags |= COMPLETE;
-                       commit_list_insert_by_date(commit, &complete);
+                       commit_list_insert(commit, &complete);
                }
        }
        return 0;
@@ -622,6 +621,7 @@ static int everything_local(struct fetch_pack_args *args,
        if (!args->depth) {
                for_each_ref(mark_complete, NULL);
                for_each_alternate_ref(mark_alternate_complete, NULL);
+               commit_list_sort_by_date(&complete);
                if (cutoff)
                        mark_recent_complete_commits(args, cutoff);
        }
diff --git a/fixup-builtins b/fixup-builtins
deleted file mode 100755 (executable)
index 63dfa4c..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-while [ "$1" ]
-do
-       if [ "$1" != "git-sh-setup" -a "$1" != "git-parse-remote" -a "$1" != "git-svn" ]; then
-               old="$1"
-               new=$(echo "$1" | sed 's/git-/git /')
-               echo "Converting '$old' to '$new'"
-               sed -i "s/\\<$old\\>/$new/g" $(git ls-files '*.sh')
-       fi
-       shift
-done
-
-sed -i 's/git merge-one-file/git-merge-one-file/g
-s/git rebase-todo/git-rebase-todo/g' $(git ls-files '*.sh')
-git update-index --refresh >& /dev/null
-exit 0
index 6828e2c7157fd80905e864b475c11ccc7a330e03..f0df41c841644208c89230516677db162498be26 100755 (executable)
@@ -5,7 +5,7 @@
 # Fetch one or more remote refs and merge it/them into the current HEAD.
 
 USAGE='[-n | --no-stat] [--[no-]commit] [--[no-]squash] [--[no-]ff] [-s strategy]... [<fetch-options>] <repo> <head>...'
-LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEAD.'
+LONG_USAGE='Fetch one or more remote refs and integrate it/them with the current HEAD.'
 SUBDIRECTORY_OK=Yes
 OPTIONS_SPEC=
 . git-sh-setup
index 169e876eedac48f6367ea3ea3178c01e45cc0560..157690b6858bdd8497be0bcea6f2385d86dc3f33 100644 (file)
@@ -80,6 +80,18 @@ amend="$state_dir"/amend
 rewritten_list="$state_dir"/rewritten-list
 rewritten_pending="$state_dir"/rewritten-pending
 
+strategy_args=
+if test -n "$do_merge"
+then
+       strategy_args=${strategy:+--strategy=$strategy}
+       eval '
+               for strategy_opt in '"$strategy_opts"'
+               do
+                       strategy_args="$strategy_args -X$(git rev-parse --sq-quote "${strategy_opt#--}")"
+               done
+       '
+fi
+
 GIT_CHERRY_PICK_HELP="$resolvemsg"
 export GIT_CHERRY_PICK_HELP
 
@@ -239,7 +251,7 @@ pick_one () {
 
        test -d "$rewritten" &&
                pick_one_preserving_merges "$@" && return
-       output git cherry-pick $empty_args $ff "$@"
+       output eval git cherry-pick "$strategy_args" $empty_args $ff "$@"
 }
 
 pick_one_preserving_merges () {
@@ -340,9 +352,8 @@ pick_one_preserving_merges () {
                        msg_content="$(commit_message $sha1)"
                        # No point in merging the first parent, that's HEAD
                        new_parents=${new_parents# $first_parent}
-                       if ! do_with_author output \
-                               git merge --no-ff ${strategy:+-s $strategy} -m \
-                                       "$msg_content" $new_parents
+                       if ! do_with_author output eval \
+                       'git merge --no-ff $strategy_args -m "$msg_content" $new_parents'
                        then
                                printf "%s\n" "$msg_content" > "$GIT_DIR"/MERGE_MSG
                                die_with_patch $sha1 "Error redoing merge $sha1"
@@ -350,7 +361,7 @@ pick_one_preserving_merges () {
                        echo "$sha1 $(git rev-parse HEAD^0)" >> "$rewritten_list"
                        ;;
                *)
-                       output git cherry-pick "$@" ||
+                       output eval git cherry-pick "$strategy_args" "$@" ||
                                die_with_patch $sha1 "Could not pick $sha1"
                        ;;
                esac
index 1e541a21257c70fa67c0fee552ccb05fc5b6a280..85c9e2c0817c171d67f7458a0764df8d31fb10ad 100755 (executable)
@@ -195,6 +195,7 @@ save_stash () {
        keep_index=
        patch_mode=
        untracked=
+       force=
        while test $# != 0
        do
                case "$1" in
@@ -215,6 +216,9 @@ save_stash () {
                -u|--include-untracked)
                        untracked=untracked
                        ;;
+               -f|--force)
+                       force=t
+                       ;;
                -a|--all)
                        untracked=all
                        ;;
@@ -258,6 +262,14 @@ save_stash () {
                say "$(gettext "No local changes to save")"
                exit 0
        fi
+       if test -z "$untracked$force" &&
+          test -n "$(git ls-files --killed | head -n 1)"
+       then
+               say "$(gettext "The following untracked files would NOT be saved but need to be removed by stash save:")"
+               test -n "$GIT_QUIET" || git ls-files --killed | sed 's/^/\t/'
+               say "$(gettext "Aborting. Consider using either the --force or --include-untracked option.")" >&2
+               exit 1
+       fi
        test -f "$GIT_DIR/logs/$ref_stash" ||
                clear_stash || die "$(gettext "Cannot initialize stash")"
 
index 8d69ada04291e308e39e999d49278b7af602f28f..f429f75897ed10684d017aeaeb93f1c9d9478e0b 100755 (executable)
@@ -85,6 +85,9 @@ sub evaluate_uri {
 # string of the home link on top of all pages
 our $home_link_str = "++GITWEB_HOME_LINK_STR++";
 
+# extra breadcrumbs preceding the home link
+our @extra_breadcrumbs = ();
+
 # name of your site or organization to appear in page titles
 # replace this with something more descriptive for clearer bookmarks
 our $site_name = "++GITWEB_SITENAME++"
@@ -3982,7 +3985,9 @@ sub print_nav_breadcrumbs_path {
 sub print_nav_breadcrumbs {
        my %opts = @_;
 
-       print $cgi->a({-href => esc_url($home_link)}, $home_link_str) . " / ";
+       for my $crumb (@extra_breadcrumbs, [ $home_link_str => $home_link ]) {
+               print $cgi->a({-href => esc_url($crumb->[1])}, $crumb->[0]) . " / ";
+       }
        if (defined $project) {
                my @dirname = split '/', $project;
                my $projectbasename = pop @dirname;
index c6fb77b26fd88f4edf85a8920a6d72e49551deed..8fbcb6a98aae85b48c6f8de29c6f95af58823411 100644 (file)
@@ -124,15 +124,17 @@ static char *resolve_symlink(char *p, size_t s)
 
 static int lock_file(struct lock_file *lk, const char *path, int flags)
 {
-       if (strlen(path) >= sizeof(lk->filename))
-               return -1;
-       strcpy(lk->filename, path);
        /*
         * subtract 5 from size to make sure there's room for adding
         * ".lock" for the lock file name
         */
+       static const size_t max_path_len = sizeof(lk->filename) - 5;
+
+       if (strlen(path) >= max_path_len)
+               return -1;
+       strcpy(lk->filename, path);
        if (!(flags & LOCK_NODEREF))
-               resolve_symlink(lk->filename, sizeof(lk->filename)-5);
+               resolve_symlink(lk->filename, max_path_len);
        strcat(lk->filename, ".lock");
        lk->fd = open(lk->filename, O_RDWR | O_CREAT | O_EXCL, 0666);
        if (0 <= lk->fd) {
index 67da27f909067132c79fdc028679895e280b7ab1..a49d8e895d3ad24f00e8504ec3eccfbddead6b4c 100644 (file)
@@ -617,6 +617,7 @@ void show_log(struct rev_info *opt)
        ctx.fmt = opt->commit_format;
        ctx.mailmap = opt->mailmap;
        ctx.color = opt->diffopt.use_color;
+       ctx.output_encoding = get_log_output_encoding();
        if (opt->from_ident.mail_begin && opt->from_ident.name_begin)
                ctx.from_ident = &opt->from_ident;
        pretty_print_commit(&ctx, commit, &msgbuf);
index 60eda6308197ad3d0b5957b9ae34e2dc15dfe5cc..5b3ce9eed299e312c132b590ea4926cfb019a271 100644 (file)
@@ -7,6 +7,7 @@
 #include "run-command.h"
 #include "pkt-line.h"
 #include "sideband.h"
+#include "argv-array.h"
 
 static struct remote *remote;
 static const char *url; /* always ends with a trailing slash */
@@ -787,36 +788,35 @@ static int push_dav(int nr_spec, char **specs)
 static int push_git(struct discovery *heads, int nr_spec, char **specs)
 {
        struct rpc_state rpc;
-       const char **argv;
-       int argc = 0, i, err;
+       int i, err;
+       struct argv_array args;
+
+       argv_array_init(&args);
+       argv_array_pushl(&args, "send-pack", "--stateless-rpc", "--helper-status",
+                        NULL);
 
-       argv = xmalloc((10 + nr_spec) * sizeof(char*));
-       argv[argc++] = "send-pack";
-       argv[argc++] = "--stateless-rpc";
-       argv[argc++] = "--helper-status";
        if (options.thin)
-               argv[argc++] = "--thin";
+               argv_array_push(&args, "--thin");
        if (options.dry_run)
-               argv[argc++] = "--dry-run";
+               argv_array_push(&args, "--dry-run");
        if (options.verbosity == 0)
-               argv[argc++] = "--quiet";
+               argv_array_push(&args, "--quiet");
        else if (options.verbosity > 1)
-               argv[argc++] = "--verbose";
-       argv[argc++] = options.progress ? "--progress" : "--no-progress";
-       argv[argc++] = url;
+               argv_array_push(&args, "--verbose");
+       argv_array_push(&args, options.progress ? "--progress" : "--no-progress");
+       argv_array_push(&args, url);
        for (i = 0; i < nr_spec; i++)
-               argv[argc++] = specs[i];
-       argv[argc++] = NULL;
+               argv_array_push(&args, specs[i]);
 
        memset(&rpc, 0, sizeof(rpc));
        rpc.service_name = "git-receive-pack",
-       rpc.argv = argv;
+       rpc.argv = args.argv;
 
        err = rpc_service(&rpc, heads);
        if (rpc.result.len)
                write_or_die(1, rpc.result.buf, rpc.result.len);
        strbuf_release(&rpc.result);
-       free(argv);
+       argv_array_clear(&args);
        return err;
 }
 
index 90419efe1052406381af3e35b70dc996fe8533ce..1a75fac05feaefa3cc0c57896aa6ee70813a324a 100644 (file)
@@ -241,7 +241,7 @@ static int disambiguate_committish_only(const unsigned char *sha1, void *cb_data
                return 0;
 
        /* We need to do this the hard way... */
-       obj = deref_tag(lookup_object(sha1), NULL, 0);
+       obj = deref_tag(parse_object(sha1), NULL, 0);
        if (obj && obj->type == OBJ_COMMIT)
                return 1;
        return 0;
index 86854248983be78b3702f5045a659dfe83bf4446..85415d0057402d40c4c9e98e3c94c41eb8dd940f 100644 (file)
@@ -226,6 +226,7 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
        while ((commit = get_revision(rev))) {
                struct pretty_print_context ctx = {0};
                ctx.date_mode = rev->date_mode;
+               ctx.output_encoding = get_log_output_encoding();
                strbuf_setlen(&sb, 0);
                strbuf_addstr(&sb, line_prefix);
                if (commit->object.flags & SYMMETRIC_LEFT) {
index ec5246886132f919ec4b6b05bfedd65eb2011690..2167125008db5e3e1c7d13310c8da3a4243e8718 100644 (file)
--- a/t/README
+++ b/t/README
@@ -76,6 +76,11 @@ appropriately before running "make".
        command being run and their output if any are also
        output.
 
+--verbose-only=<pattern>::
+       Like --verbose, but the effect is limited to tests with
+       numbers matching <pattern>.  The number matched against is
+       simply the running count of the test within the file.
+
 --debug::
        This may help the person who is developing a new test.
        It causes the command defined with test_debug to run.
@@ -121,6 +126,11 @@ appropriately before running "make".
        the 't/valgrind/' directory and use the commands under
        't/valgrind/bin/'.
 
+--valgrind-only=<pattern>::
+       Like --valgrind, but the effect is limited to tests with
+       numbers matching <pattern>.  The number matched against is
+       simply the running count of the test within the file.
+
 --tee::
        In addition to printing the test output to the terminal,
        write it to files named 't/test-results/$TEST_NAME.out'.
index 8b5a71dc05216dc0acfb7761a4b9ca789c716ce0..45971f43b77142fe1bb90262974c83c786cfe43d 100755 (executable)
@@ -21,6 +21,7 @@ sub err {
        /^\s*declare\s+/ and err 'arrays/declare not portable';
        /^\s*[^#]\s*which\s/ and err 'which is not portable (please use type)';
        /test\s+[^=]*==/ and err '"test a == b" is not portable (please use =)';
+       /^\s*export\s+[^=]*=/ and err '"export FOO=bar" is not portable (please use FOO=bar && export FOO)';
        # this resets our $. for each file
        close ARGV if eof;
 }
index a816fbcb7618bb8cdbf1f74a4fd2295923c02ea3..c61d5351e1ff0b1b4431eb28553d0d882ebe7451 100644 (file)
@@ -150,6 +150,7 @@ exit $ret' >&3 2>&4
 
 
 test_perf () {
+       test_start_
        test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
        test "$#" = 2 ||
        error "bug in the test script: not 2 or 3 parameters to test-expect-success"
@@ -187,7 +188,7 @@ test_perf () {
                base="$perf_results_dir"/"$perf_results_prefix$(basename "$0" .sh)"."$test_count"
                "$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".times
        fi
-       echo >&3 ""
+       test_finish_
 }
 
 # We extend test_done to print timings at the end (./run disables this
index 0f1318056cd06d8bcae615be5e573149ac5971d1..10be52beedb4058318555e096d51517f1c30ad9f 100755 (executable)
@@ -47,8 +47,14 @@ test_expect_failure 'pretend we have a known breakage' '
 
 run_sub_test_lib_test () {
        name="$1" descr="$2" # stdin is the body of the test code
+       shift 2
        mkdir "$name" &&
        (
+               # Pretend we're a test harness.  This prevents
+               # test-lib from writing the counts to a file that will
+               # later be summarized, showing spurious "failed" tests
+               HARNESS_ACTIVE=t &&
+               export HARNESS_ACTIVE &&
                cd "$name" &&
                cat >"$name.sh" <<-EOF &&
                #!$SHELL_PATH
@@ -65,7 +71,7 @@ run_sub_test_lib_test () {
                cat >>"$name.sh" &&
                chmod +x "$name.sh" &&
                export TEST_DIRECTORY &&
-               ./"$name.sh" >out 2>err
+               ./"$name.sh" "$@" >out 2>err
        )
 }
 
@@ -215,6 +221,60 @@ test_expect_success 'pretend we have a mix of all possible results' "
        EOF
 "
 
+test_expect_success 'test --verbose' '
+       test_must_fail run_sub_test_lib_test \
+               test-verbose "test verbose" --verbose <<-\EOF &&
+       test_expect_success "passing test" true
+       test_expect_success "test with output" "echo foo"
+       test_expect_success "failing test" false
+       test_done
+       EOF
+       mv test-verbose/out test-verbose/out+
+       grep -v "^Initialized empty" test-verbose/out+ >test-verbose/out &&
+       check_sub_test_lib_test test-verbose <<-\EOF
+       > expecting success: true
+       > Z
+       > ok 1 - passing test
+       > Z
+       > expecting success: echo foo
+       > foo
+       > Z
+       > ok 2 - test with output
+       > Z
+       > expecting success: false
+       > Z
+       > not ok 3 - failing test
+       > #     false
+       > Z
+       > # failed 1 among 3 test(s)
+       > 1..3
+       EOF
+'
+
+test_expect_success 'test --verbose-only' '
+       test_must_fail run_sub_test_lib_test \
+               test-verbose-only-2 "test verbose-only=2" \
+               --verbose-only=2 <<-\EOF &&
+       test_expect_success "passing test" true
+       test_expect_success "test with output" "echo foo"
+       test_expect_success "failing test" false
+       test_done
+       EOF
+       check_sub_test_lib_test test-verbose-only-2 <<-\EOF
+       > ok 1 - passing test
+       > Z
+       > expecting success: echo foo
+       > foo
+       > Z
+       > ok 2 - test with output
+       > Z
+       > not ok 3 - failing test
+       > #     false
+       > # failed 1 among 3 test(s)
+       > 1..3
+       EOF
+'
+
 test_set_prereq HAVEIT
 haveit=no
 test_expect_success HAVEIT 'test runs if prerequisite is satisfied' '
index 1a8f44c44ca3cce70990ec56fec61894be9b3086..e526184a0bfa3c8ad2171d0c41a7bee22cf9a04e 100755 (executable)
@@ -81,6 +81,14 @@ test_expect_success 'safecrlf: print warning only once' '
        test $(git add doublewarn 2>&1 | grep "CRLF will be replaced by LF" | wc -l) = 1
 '
 
+
+test_expect_success 'safecrlf: git diff demotes safecrlf=true to warn' '
+       git config core.autocrlf input &&
+       git config core.safecrlf true &&
+       git diff HEAD
+'
+
+
 test_expect_success 'switch off autocrlf, safecrlf, reset HEAD' '
        git config core.autocrlf false &&
        git config core.safecrlf false &&
index db228086d3977d304a3debd7c3ae6dc54c40ad17..4a155c8d095fb8ca2c2f88802d3501e01d07ce28 100755 (executable)
@@ -77,6 +77,7 @@ test_expect_success 'disambiguate blob' '
 
 test_expect_success 'disambiguate tree' '
        commit=$(echo "d7xm" | git commit-tree 000000000) &&
+       # this commit is fffff2e and not ambiguous with the 00000* objects
        test $(git rev-parse $commit^{tree}) = $(git rev-parse 0000000000cdc)
 '
 
@@ -99,10 +100,14 @@ test_expect_success 'disambiguate commit-ish' '
 
 test_expect_success 'disambiguate commit' '
        commit=$(echo "hoaxj" | git commit-tree 0000000000cdc -p 000000000) &&
+       # this commit is ffffffd8 and not ambiguous with the 00000* objects
        test $(git rev-parse $commit^) = $(git rev-parse 0000000000e4f)
 '
 
 test_expect_success 'log name1..name2 takes only commit-ishes on both ends' '
+       # These are underspecified from the prefix-length point of view
+       # to disambiguate the commit with other objects, but there is only
+       # one commit that has 00000* prefix at this point.
        git log 000000000..000000000 &&
        git log ..000000000 &&
        git log 000000000.. &&
@@ -112,16 +117,19 @@ test_expect_success 'log name1..name2 takes only commit-ishes on both ends' '
 '
 
 test_expect_success 'rev-parse name1..name2 takes only commit-ishes on both ends' '
+       # Likewise.
        git rev-parse 000000000..000000000 &&
        git rev-parse ..000000000 &&
        git rev-parse 000000000..
 '
 
 test_expect_success 'git log takes only commit-ish' '
+       # Likewise.
        git log 000000000
 '
 
 test_expect_success 'git reset takes only commit-ish' '
+       # Likewise.
        git reset 000000000
 '
 
@@ -131,26 +139,30 @@ test_expect_success 'first tag' '
 '
 
 test_expect_failure 'two semi-ambiguous commit-ish' '
+       # At this point, we have a tag 0000000000f8f that points
+       # at a commit 0000000000e4f, and a tree and a blob that
+       # share 0000000000 prefix with these tag and commit.
+       #
        # Once the parser becomes ultra-smart, it could notice that
-       # 110282 before ^{commit} name many different objects, but
+       # 0000000000 before ^{commit} name many different objects, but
        # that only two (HEAD and v1.0.0 tag) can be peeled to commit,
        # and that peeling them down to commit yield the same commit
        # without ambiguity.
-       git rev-parse --verify 110282^{commit} &&
+       git rev-parse --verify 0000000000^{commit} &&
 
        # likewise
-       git log 000000000..000000000 &&
-       git log ..000000000 &&
-       git log 000000000.. &&
-       git log 000000000...000000000 &&
-       git log ...000000000 &&
-       git log 000000000...
+       git log 0000000000..0000000000 &&
+       git log ..0000000000 &&
+       git log 0000000000.. &&
+       git log 0000000000...0000000000 &&
+       git log ...0000000000 &&
+       git log 0000000000...
 '
 
 test_expect_failure 'three semi-ambiguous tree-ish' '
        # Likewise for tree-ish.  HEAD, v1.0.0 and HEAD^{tree} share
        # the prefix but peeling them to tree yields the same thing
-       git rev-parse --verify 000000000^{tree}
+       git rev-parse --verify 0000000000^{tree}
 '
 
 test_expect_success 'parse describe name' '
@@ -241,7 +253,7 @@ test_expect_success 'ambiguous commit-ish' '
        # Now there are many commits that begin with the
        # common prefix, none of these should pick one at
        # random.  They all should result in ambiguity errors.
-       test_must_fail git rev-parse --verify 110282^{commit} &&
+       test_must_fail git rev-parse --verify 00000000^{commit} &&
 
        # likewise
        test_must_fail git log 000000000..000000000 &&
index b44de9dc623fc923941b61719f445170602e21be..e7ba8c505f579ab5cd53ee713eaf6ca894e471a1 100755 (executable)
@@ -116,4 +116,38 @@ test_expect_success 'master...' '
        test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify master^)"
 '
 
+test_expect_success '"checkout -" works after a rebase A' '
+       git checkout master &&
+       git checkout other &&
+       git rebase master &&
+       git checkout - &&
+       test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master"
+'
+
+test_expect_success '"checkout -" works after a rebase A B' '
+       git branch moodle master~1 &&
+       git checkout master &&
+       git checkout other &&
+       git rebase master moodle &&
+       git checkout - &&
+       test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master"
+'
+
+test_expect_success '"checkout -" works after a rebase -i A' '
+       git checkout master &&
+       git checkout other &&
+       git rebase -i master &&
+       git checkout - &&
+       test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master"
+'
+
+test_expect_success '"checkout -" works after a rebase -i A B' '
+       git branch foodle master~1 &&
+       git checkout master &&
+       git checkout other &&
+       git rebase master foodle &&
+       git checkout - &&
+       test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master"
+'
+
 test_done
index 262e61744563b2ce4eb14df0e54f71d56c157007..f611d799b690457e306571adf16813b238a27dc9 100755 (executable)
@@ -11,6 +11,8 @@ This test prepares the following in the cache:
     path1       - a symlink
     path2/file2 - a file in a directory
     path3/file3 - a file in a directory
+    submod1/   - a submodule
+    submod2/   - another submodule
 
 and the following on the filesystem:
 
@@ -21,9 +23,11 @@ and the following on the filesystem:
     path4      - a file
     path5      - a symlink
     path6/file6 - a file in a directory
+    submod1/   - a submodule (modified from the cache)
+    submod2/   - a submodule (matches the cache)
 
-git ls-files -k should report that existing filesystem
-objects except path4, path5 and path6/file6 to be killed.
+git ls-files -k should report that existing filesystem objects
+path0/*, path1/*, path2 and path3 to be killed.
 
 Also for modification test, the cache and working tree have:
 
@@ -33,7 +37,7 @@ Also for modification test, the cache and working tree have:
     path10     - a non-empty file, cache dirtied.
 
 We should report path0, path1, path2/file2, path3/file3, path7 and path8
-modified without reporting path9 and path10.
+modified without reporting path9 and path10.  submod1 is also modified.
 '
 . ./test-lib.sh
 
@@ -48,6 +52,18 @@ test_expect_success 'git update-index --add to add various paths.' '
        : >path9 &&
        date >path10 &&
        git update-index --add -- path0 path?/file? path7 path8 path9 path10 &&
+       for i in 1 2
+       do
+               git init submod$i &&
+               (
+                       cd submod$i && git commit --allow-empty -m "empty $i"
+               ) || break
+       done &&
+       git update-index --add submod[12]
+       (
+               cd submod1 &&
+               git commit --allow-empty -m "empty 1 (updated)"
+       ) &&
        rm -fr path?    # leave path10 alone
 '
 
@@ -94,6 +110,7 @@ test_expect_success 'validate git ls-files -m output.' '
        path3/file3
        path7
        path8
+       submod1
        EOF
        test_cmp .expected .output
 '
index d6b414377306de88e8e294dd5eaadfcb3a234ec2..8a6ec039fe57f6a042fb3fe2e3f4c5807cfe4d68 100755 (executable)
@@ -950,4 +950,15 @@ test_expect_success 'rebase -i, with <onto> and <upstream> specified as :/quuxer
        git checkout branch1
 '
 
+test_expect_success 'rebase -i with --strategy and -X' '
+       git checkout -b conflict-merge-use-theirs conflict-branch &&
+       git reset --hard HEAD^ &&
+       echo five >conflict &&
+       echo Z >file1 &&
+       git commit -a -m "one file conflict" &&
+       EDITOR=true git rebase -i --strategy=recursive -Xours conflict-branch &&
+       test $(git show conflict-branch:conflict) = $(cat conflict) &&
+       test $(cat file1) = Z
+'
+
 test_done
index debda7a678277e1198ba6620210b66984caf03a2..5d22f17ca2d3469c7542805e365246a70a5fba64 100755 (executable)
@@ -673,4 +673,22 @@ test_expect_success 'store updates stash ref and reflog' '
        grep quux bazzy
 '
 
+test_expect_success 'stash a change to turn a non-directory to a directory' '
+       git reset --hard &&
+       >testfile &&
+       git add testfile &&
+       git commit -m "add testfile as a regular file" &&
+       rm testfile &&
+       mkdir testfile &&
+       >testfile/file &&
+       test_must_fail git stash save "recover regular file" &&
+       test -f testfile/file
+'
+
+test_expect_success 'stash a change to turn a non-directory to a directory (forced)' '
+       git stash save --force "recover regular file (forced)" &&
+       ! test -f testfile/file &&
+       test -f testfile
+'
+
 test_done
index 32d4a604250d55e9221a416638c8c8c4fdd6ff87..1751c8330709c56a4b7019513e30434741847b95 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Support for verbose submodule differences in git diff
@@ -10,6 +11,9 @@ This test tries to verify the sanity of the --submodule option of git diff.
 
 . ./test-lib.sh
 
+# String "added" in German (translated with Google Translate), encoded in UTF-8,
+# used in sample commit log messages in add_file() function below.
+added=$(printf "hinzugef\303\274gt")
 add_file () {
        (
                cd "$1" &&
@@ -19,7 +23,8 @@ add_file () {
                        echo "$name" >"$name" &&
                        git add "$name" &&
                        test_tick &&
-                       git commit -m "Add $name" || exit
+                       msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso8859-1) &&
+                       git -c 'i18n.commitEncoding=iso8859-1' commit -m "$msg_added_iso88591"
                done >/dev/null &&
                git rev-parse --short --verify HEAD
        )
@@ -93,7 +98,7 @@ test_expect_success 'modified submodule(forward)' '
        git diff-index -p --submodule=log HEAD >actual &&
        cat >expected <<-EOF &&
        Submodule sm1 $head1..$head2:
-         > Add foo3
+         > Add foo3 ($added foo3)
        EOF
        test_cmp expected actual
 '
@@ -102,7 +107,7 @@ test_expect_success 'modified submodule(forward)' '
        git diff --submodule=log >actual &&
        cat >expected <<-EOF &&
        Submodule sm1 $head1..$head2:
-         > Add foo3
+         > Add foo3 ($added foo3)
        EOF
        test_cmp expected actual
 '
@@ -111,7 +116,7 @@ test_expect_success 'modified submodule(forward) --submodule' '
        git diff --submodule >actual &&
        cat >expected <<-EOF &&
        Submodule sm1 $head1..$head2:
-         > Add foo3
+         > Add foo3 ($added foo3)
        EOF
        test_cmp expected actual
 '
@@ -142,8 +147,8 @@ test_expect_success 'modified submodule(backward)' '
        git diff-index -p --submodule=log HEAD >actual &&
        cat >expected <<-EOF &&
        Submodule sm1 $head2..$head3 (rewind):
-         < Add foo3
-         < Add foo2
+         < Add foo3 ($added foo3)
+         < Add foo2 ($added foo2)
        EOF
        test_cmp expected actual
 '
@@ -153,10 +158,10 @@ test_expect_success 'modified submodule(backward and forward)' '
        git diff-index -p --submodule=log HEAD >actual &&
        cat >expected <<-EOF &&
        Submodule sm1 $head2...$head4:
-         > Add foo5
-         > Add foo4
-         < Add foo3
-         < Add foo2
+         > Add foo5 ($added foo5)
+         > Add foo4 ($added foo4)
+         < Add foo3 ($added foo3)
+         < Add foo2 ($added foo2)
        EOF
        test_cmp expected actual
 '
index 26fbfde4a36689a51c181c13f9d5680fd2780219..fb000411395d50639334c3c0395b2b975aa4bc12 100755 (executable)
@@ -1,20 +1,38 @@
 #!/bin/sh
 #
 # Copyright (c) 2010, Will Palmer
+# Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Test pretty formats'
 . ./test-lib.sh
 
+sample_utf8_part=$(printf "f\303\244ng")
+
+commit_msg () {
+       # String "initial. initial" partly in German
+       # (translated with Google Translate),
+       # encoded in UTF-8, used as a commit log message below.
+       msg="initial. an${sample_utf8_part}lich\n"
+       if test -n "$1"
+       then
+               printf "$msg" | iconv -f utf-8 -t "$1"
+       else
+               printf "$msg"
+       fi
+}
+
 test_expect_success 'set up basic repos' '
        >foo &&
        >bar &&
        git add foo &&
        test_tick &&
-       git commit -m initial &&
+       git config i18n.commitEncoding iso8859-1 &&
+       git commit -m "$(commit_msg iso8859-1)" &&
        git add bar &&
        test_tick &&
-       git commit -m "add bar"
+       git commit -m "add bar" &&
+       git config --unset i18n.commitEncoding
 '
 
 test_expect_success 'alias builtin format' '
@@ -38,6 +56,20 @@ test_expect_success 'alias user-defined format' '
        test_cmp expected actual
 '
 
+test_expect_success 'alias user-defined tformat with %s (iso8859-1 encoding)' '
+       git config i18n.logOutputEncoding iso8859-1 &&
+       git log --oneline >expected-s &&
+       git log --pretty="tformat:%h %s" >actual-s &&
+       git config --unset i18n.logOutputEncoding &&
+       test_cmp expected-s actual-s
+'
+
+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
+       git log --oneline >expected-s &&
+       git log --pretty="tformat:%h %s" >actual-s &&
+       test_cmp expected-s actual-s
+'
+
 test_expect_success 'alias user-defined tformat' '
        git log --pretty="tformat:%h" >expected &&
        git config pretty.test-alias "tformat:%h" &&
@@ -72,13 +104,13 @@ test_expect_success 'alias loop' '
 '
 
 test_expect_success 'NUL separation' '
-       printf "add bar\0initial" >expected &&
+       printf "add bar\0$(commit_msg)" >expected &&
        git log -z --pretty="format:%s" >actual &&
        test_cmp expected actual
 '
 
 test_expect_success 'NUL termination' '
-       printf "add bar\0initial\0" >expected &&
+       printf "add bar\0$(commit_msg)\0" >expected &&
        git log -z --pretty="tformat:%s" >actual &&
        test_cmp expected actual
 '
@@ -86,7 +118,7 @@ test_expect_success 'NUL termination' '
 test_expect_success 'NUL separation with --stat' '
        stat0_part=$(git diff --stat HEAD^ HEAD) &&
        stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
-       printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n" >expected &&
+       printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
        git log -z --stat --pretty="format:%s" >actual &&
        test_i18ncmp expected actual
 '
@@ -94,25 +126,29 @@ test_expect_success 'NUL separation with --stat' '
 test_expect_failure 'NUL termination with --stat' '
        stat0_part=$(git diff --stat HEAD^ HEAD) &&
        stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
-       printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n\0" >expected &&
+       printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected &&
        git log -z --stat --pretty="tformat:%s" >actual &&
        test_i18ncmp expected actual
 '
 
 test_expect_success 'setup more commits' '
        test_commit "message one" one one message-one &&
-       test_commit "message two" two two message-two
+       test_commit "message two" two two message-two &&
+       head1=$(git rev-parse --verify --short HEAD~0) &&
+       head2=$(git rev-parse --verify --short HEAD~1) &&
+       head3=$(git rev-parse --verify --short HEAD~2) &&
+       head4=$(git rev-parse --verify --short HEAD~3)
 '
 
 test_expect_success 'left alignment formatting' '
        git log --pretty="format:%<(40)%s" >actual &&
        # complete the incomplete line at the end
        echo >>actual &&
-       qz_to_tab_space <<\EOF >expected &&
+       qz_to_tab_space <<EOF >expected &&
 message two                            Z
 message one                            Z
 add bar                                Z
-initial                                Z
+$(commit_msg)                    Z
 EOF
        test_cmp expected actual
 '
@@ -121,11 +157,11 @@ test_expect_success 'left alignment formatting at the nth column' '
        git log --pretty="format:%h %<|(40)%s" >actual &&
        # complete the incomplete line at the end
        echo >>actual &&
-       qz_to_tab_space <<\EOF >expected &&
-fa33ab1 message two                    Z
-7cd6c63 message one                    Z
-1711bf9 add bar                        Z
-af20c06 initial                        Z
+       qz_to_tab_space <<EOF >expected &&
+$head1 message two                    Z
+$head2 message one                    Z
+$head3 add bar                        Z
+$head4 $(commit_msg)            Z
 EOF
        test_cmp expected actual
 '
@@ -134,11 +170,11 @@ test_expect_success 'left alignment formatting with no padding' '
        git log --pretty="format:%<(1)%s" >actual &&
        # complete the incomplete line at the end
        echo >>actual &&
-       cat <<\EOF >expected &&
+       cat <<EOF >expected &&
 message two
 message one
 add bar
-initial
+$(commit_msg)
 EOF
        test_cmp expected actual
 '
@@ -147,11 +183,11 @@ test_expect_success 'left alignment formatting with trunc' '
        git log --pretty="format:%<(10,trunc)%s" >actual &&
        # complete the incomplete line at the end
        echo >>actual &&
-       qz_to_tab_space <<\EOF >expected &&
+       qz_to_tab_space <<EOF >expected &&
 message ..
 message ..
 add bar  Z
-initial  Z
+initial...
 EOF
        test_cmp expected actual
 '
@@ -160,11 +196,11 @@ test_expect_success 'left alignment formatting with ltrunc' '
        git log --pretty="format:%<(10,ltrunc)%s" >actual &&
        # complete the incomplete line at the end
        echo >>actual &&
-       qz_to_tab_space <<\EOF >expected &&
+       qz_to_tab_space <<EOF >expected &&
 ..sage two
 ..sage one
 add bar  Z
-initial  Z
+..${sample_utf8_part}lich
 EOF
        test_cmp expected actual
 '
@@ -173,11 +209,11 @@ test_expect_success 'left alignment formatting with mtrunc' '
        git log --pretty="format:%<(10,mtrunc)%s" >actual &&
        # complete the incomplete line at the end
        echo >>actual &&
-       qz_to_tab_space <<\EOF >expected &&
+       qz_to_tab_space <<EOF >expected &&
 mess.. two
 mess.. one
 add bar  Z
-initial  Z
+init..lich
 EOF
        test_cmp expected actual
 '
@@ -186,11 +222,11 @@ test_expect_success 'right alignment formatting' '
        git log --pretty="format:%>(40)%s" >actual &&
        # complete the incomplete line at the end
        echo >>actual &&
-       qz_to_tab_space <<\EOF >expected &&
+       qz_to_tab_space <<EOF >expected &&
 Z                            message two
 Z                            message one
 Z                                add bar
-Z                                initial
+Z                    $(commit_msg)
 EOF
        test_cmp expected actual
 '
@@ -199,11 +235,11 @@ test_expect_success 'right alignment formatting at the nth column' '
        git log --pretty="format:%h %>|(40)%s" >actual &&
        # complete the incomplete line at the end
        echo >>actual &&
-       qz_to_tab_space <<\EOF >expected &&
-fa33ab1                      message two
-7cd6c63                      message one
-1711bf9                          add bar
-af20c06                          initial
+       qz_to_tab_space <<EOF >expected &&
+$head1                      message two
+$head2                      message one
+$head3                          add bar
+$head4              $(commit_msg)
 EOF
        test_cmp expected actual
 '
@@ -212,11 +248,11 @@ test_expect_success 'right alignment formatting with no padding' '
        git log --pretty="format:%>(1)%s" >actual &&
        # complete the incomplete line at the end
        echo >>actual &&
-       cat <<\EOF >expected &&
+       cat <<EOF >expected &&
 message two
 message one
 add bar
-initial
+$(commit_msg)
 EOF
        test_cmp expected actual
 '
@@ -225,11 +261,11 @@ test_expect_success 'center alignment formatting' '
        git log --pretty="format:%><(40)%s" >actual &&
        # complete the incomplete line at the end
        echo >>actual &&
-       qz_to_tab_space <<\EOF >expected &&
+       qz_to_tab_space <<EOF >expected &&
 Z             message two              Z
 Z             message one              Z
 Z               add bar                Z
-Z               initial                Z
+Z         $(commit_msg)          Z
 EOF
        test_cmp expected actual
 '
@@ -238,11 +274,11 @@ test_expect_success 'center alignment formatting at the nth column' '
        git log --pretty="format:%h %><|(40)%s" >actual &&
        # complete the incomplete line at the end
        echo >>actual &&
-       qz_to_tab_space <<\EOF >expected &&
-fa33ab1           message two          Z
-7cd6c63           message one          Z
-1711bf9             add bar            Z
-af20c06             initial            Z
+       qz_to_tab_space <<EOF >expected &&
+$head1           message two          Z
+$head2           message one          Z
+$head3             add bar            Z
+$head4       $(commit_msg)      Z
 EOF
        test_cmp expected actual
 '
@@ -251,11 +287,11 @@ test_expect_success 'center alignment formatting with no padding' '
        git log --pretty="format:%><(1)%s" >actual &&
        # complete the incomplete line at the end
        echo >>actual &&
-       cat <<\EOF >expected &&
+       cat <<EOF >expected &&
 message two
 message one
 add bar
-initial
+$(commit_msg)
 EOF
        test_cmp expected actual
 '
@@ -265,11 +301,11 @@ test_expect_success 'left/right alignment formatting with stealing' '
        git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
        # complete the incomplete line at the end
        echo >>actual &&
-       cat <<\EOF >expected &&
+       cat <<EOF >expected &&
 short long  long long
 message ..   A U Thor
 add bar      A U Thor
-initial      A U Thor
+initial...   A U Thor
 EOF
        test_cmp expected actual
 '
index ee5d65d52f6d1d4dba6b1664f4dae23ebe69429d..8f6e3922dce2b676221610d83a87c5b36d3bc5b6 100755 (executable)
@@ -74,7 +74,7 @@ test_expect_success 'add another remote' '
        )
 '
 
-test_expect_success C_LOCALE_OUTPUT 'check remote tracking' '
+test_expect_success C_LOCALE_OUTPUT 'check remote-tracking' '
        (
                cd test &&
                check_remote_track origin master side &&
index 4736da8f36fd4e69fea0008829f4304020ea338d..6a5ac3add47399918737168e60f75d2d7cec1557 100755 (executable)
@@ -15,17 +15,19 @@ test_expect_success 'setup bare remotes' '
 
 # $1 = local revision
 # $2 = remote revision (tested to be equal to the local one)
+# $3 = [optional] repo to check for actual output (repo1 by default)
 check_pushed_commit () {
        git log -1 --format='%h %s' "$1" >expect &&
-       git --git-dir=repo1 log -1 --format='%h %s' "$2" >actual &&
+       git --git-dir="${3:-repo1}" log -1 --format='%h %s' "$2" >actual &&
        test_cmp expect actual
 }
 
 # $1 = push.default value
 # $2 = expected target branch for the push
+# $3 = [optional] repo to check for actual output (repo1 by default)
 test_push_success () {
        git -c push.default="$1" push &&
-       check_pushed_commit HEAD "$2"
+       check_pushed_commit HEAD "$2" "$3"
 }
 
 # $1 = push.default value
@@ -37,6 +39,26 @@ test_push_failure () {
        test_cmp expect actual
 }
 
+# $1 = success or failure
+# $2 = push.default value
+# $3 = branch to check for actual output (master or foo)
+# $4 = [optional] switch to triangular workflow
+test_pushdefault_workflow () {
+       workflow=central
+       pushdefault=parent1
+       if test -n "${4-}"; then
+               workflow=triangular
+               pushdefault=parent2
+       fi
+       test_expect_success "push.default = $2 $1 in $workflow workflows" "
+               test_config branch.master.remote parent1 &&
+               test_config branch.master.merge refs/heads/foo &&
+               test_config remote.pushdefault $pushdefault &&
+               test_commit commit-for-$2${4+-triangular} &&
+               test_push_$1 $2 $3 ${4+repo2}
+       "
+}
+
 test_expect_success '"upstream" pushes to configured upstream' '
        git checkout master &&
        test_config branch.master.remote parent1 &&
@@ -48,7 +70,6 @@ test_expect_success '"upstream" pushes to configured upstream' '
 test_expect_success '"upstream" does not push on unconfigured remote' '
        git checkout master &&
        test_unconfig branch.master.remote &&
-       test_config push.default upstream &&
        test_commit three &&
        test_push_failure upstream
 '
@@ -57,7 +78,6 @@ test_expect_success '"upstream" does not push on unconfigured branch' '
        git checkout master &&
        test_config branch.master.remote parent1 &&
        test_unconfig branch.master.merge &&
-       test_config push.default upstream
        test_commit four &&
        test_push_failure upstream
 '
@@ -115,4 +135,41 @@ test_expect_success 'push to existing branch, upstream configured with different
        test_cmp expect-other-name actual-other-name
 '
 
+# We are on 'master', which integrates with 'foo' from parent1
+# remote (set in test_pushdefault_workflow helper).  Push to
+# parent1 in centralized, and push to parent2 in triangular workflow.
+# The parent1 repository has 'master' and 'foo' branches, while
+# the parent2 repository has only 'master' branch.
+#
+# test_pushdefault_workflow() arguments:
+# $1 = success or failure
+# $2 = push.default value
+# $3 = branch to check for actual output (master or foo)
+# $4 = [optional] switch to triangular workflow
+
+# update parent1's master (which is not our upstream)
+test_pushdefault_workflow success current master
+
+# update parent1's foo (which is our upstream)
+test_pushdefault_workflow success upstream foo
+
+# upsream is foo which is not the name of the current branch
+test_pushdefault_workflow failure simple master
+
+# master and foo are updated
+test_pushdefault_workflow success matching master
+
+# master is updated
+test_pushdefault_workflow success current master triangular
+
+# upstream mode cannot be used in triangular
+test_pushdefault_workflow failure upstream foo triangular
+
+# in triangular, 'simple' works as 'current' and update the branch
+# with the same name.
+test_pushdefault_workflow success simple master triangular
+
+# master is updated (parent2 does not have foo)
+test_pushdefault_workflow success matching master triangular
+
 test_done
index 0393c9fd0b1c155817855857d7476d1638d2296f..98744038eccb396c752e6a4b6ced702733c0d396 100755 (executable)
@@ -1,20 +1,45 @@
 #!/bin/sh
 
+# Copyright (c) 2009 Jens Lehmann
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
+
 test_description='git rev-list --pretty=format test'
 
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_tick
+# String "added" in German
+# (translated with Google Translate),
+# encoded in UTF-8, used as a commit log message below.
+added=$(printf "added (hinzugef\303\274gt) foo")
+added_iso88591=$(echo "$added" | iconv -f utf-8 -t iso8859-1)
+# same but "changed"
+changed=$(printf "changed (ge\303\244ndert) foo")
+changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso8859-1)
+
 test_expect_success 'setup' '
-touch foo && git add foo && git commit -m "added foo" &&
-  echo changed >foo && git commit -a -m "changed foo"
+       : >foo &&
+       git add foo &&
+       git config i18n.commitEncoding iso8859-1 &&
+       git commit -m "$added_iso88591" &&
+       head1=$(git rev-parse --verify HEAD) &&
+       head1_short=$(git rev-parse --verify --short $head1) &&
+       tree1=$(git rev-parse --verify HEAD:) &&
+       tree1_short=$(git rev-parse --verify --short $tree1) &&
+       echo "$changed" > foo &&
+       git commit -a -m "$changed_iso88591" &&
+       head2=$(git rev-parse --verify HEAD) &&
+       head2_short=$(git rev-parse --verify --short $head2) &&
+       tree2=$(git rev-parse --verify HEAD:) &&
+       tree2_short=$(git rev-parse --verify --short $tree2)
+       git config --unset i18n.commitEncoding
 '
 
-# usage: test_format name format_string <expected_output
+# usage: test_format name format_string [failure] <expected_output
 test_format () {
        cat >expect.$1
-       test_expect_success "format $1" "
+       test_expect_${3:-success} "format $1" "
                git rev-list --pretty=format:'$2' master >output.$1 &&
                test_cmp expect.$1 output.$1
        "
@@ -32,49 +57,49 @@ has_no_color () {
        test_cmp expect "$1"
 }
 
-test_format percent %%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format percent %%h <<EOF
+commit $head2
 %h
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 %h
 EOF
 
-test_format hash %H%n%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-131a310eb913d107dd3c09a65d1651175898735d
-131a310
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
+test_format hash %H%n%h <<EOF
+commit $head2
+$head2
+$head2_short
+commit $head1
+$head1
+$head1_short
 EOF
 
-test_format tree %T%n%t <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-fe722612f26da5064c32ca3843aa154bdb0b08a0
-fe72261
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-4d5fcadc293a348e88f777dc0920f11e7d71441c
-4d5fcad
+test_format tree %T%n%t <<EOF
+commit $head2
+$tree2
+$tree2_short
+commit $head1
+$tree1
+$tree1_short
 EOF
 
-test_format parents %P%n%p <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format parents %P%n%p <<EOF
+commit $head2
+$head1
+$head1_short
+commit $head1
 
 
 EOF
 
 # we don't test relative here
-test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF
+commit $head2
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -82,14 +107,14 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF
+commit $head2
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -97,43 +122,45 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format encoding %e <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format encoding %e <<EOF
+commit $head2
+iso8859-1
+commit $head1
+iso8859-1
 EOF
 
-test_format subject %s <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-added foo
+test_format subject %s <<EOF
+commit $head2
+$changed
+commit $head1
+$added
 EOF
 
-test_format body %b <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format body %b <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format raw-body %B <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-changed foo
+test_format raw-body %B <<EOF
+commit $head2
+$changed
 
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-added foo
+commit $head1
+$added
 
 EOF
 
-test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF
+commit $head2
 \e[31mfoo\e[32mbar\e[34mbaz\e[mxyzzy
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 \e[31mfoo\e[32mbar\e[34mbaz\e[mxyzzy
 EOF
 
-test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<EOF
+commit $head2
 \e[1;31;43mfoo\e[m
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 \e[1;31;43mfoo\e[m
 EOF
 
@@ -179,46 +206,71 @@ test_expect_success '%C(auto) respects --color=auto (stdout not tty)' '
        )
 '
 
-cat >commit-msg <<'EOF'
+iconv -f utf-8 -t iso8859-1 > commit-msg <<EOF
 Test printing of complex bodies
 
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: Â¡bueno!
+include an iso8859 character: Ã‚¡bueno!
 EOF
+
 test_expect_success 'setup complex body' '
-git config i18n.commitencoding iso8859-1 &&
-  echo change2 >foo && git commit -a -F commit-msg
+       git config i18n.commitencoding iso8859-1 &&
+       echo change2 >foo && git commit -a -F commit-msg &&
+       head3=$(git rev-parse --verify HEAD) &&
+       head3_short=$(git rev-parse --short $head3)
 '
 
-test_format complex-encoding %e <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-encoding %e <<EOF
+commit $head3
+iso8859-1
+commit $head2
+iso8859-1
+commit $head1
 iso8859-1
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
 EOF
 
-test_format complex-subject %s <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-subject %s <<EOF
+commit $head3
 Test printing of complex bodies
-commit 131a310eb913d107dd3c09a65d1651175898735d
-changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-added foo
+commit $head2
+$changed_iso88591
+commit $head1
+$added_iso88591
 EOF
 
-test_format complex-body %b <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
-This commit message is much longer than the others,
-and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: Â¡bueno!
+test_expect_success 'prepare expected messages (for test %b)' '
+       cat <<-EOF >expected.utf-8 &&
+       commit $head3
+       This commit message is much longer than the others,
+       and it will be encoded in iso8859-1. We should therefore
+       include an iso8859 character: Â¡bueno!
+
+       commit $head2
+       commit $head1
+       EOF
+       iconv -f utf-8 -t iso8859-1 expected.utf-8 >expected.iso8859-1
+'
+
+test_format complex-body %b <expected.iso8859-1
 
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+# Git uses i18n.commitEncoding if no i18n.logOutputEncoding set
+# so unset i18n.commitEncoding to test encoding conversion
+git config --unset i18n.commitEncoding
+
+test_format complex-subject-commitencoding-unset %s <<EOF
+commit $head3
+Test printing of complex bodies
+commit $head2
+$changed
+commit $head1
+$added
 EOF
 
+test_format complex-body-commitencoding-unset %b <expected.utf-8
+
 test_expect_success '%x00 shows NUL' '
-       echo  >expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 &&
+       echo  >expect commit $head3 &&
        echo >>expect fooQbar &&
        git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
        nul_to_q <actual.nul >actual &&
@@ -265,12 +317,12 @@ test_expect_success 'add LF before non-empty (2)' '
 
 test_expect_success 'add SP before non-empty (1)' '
        git show -s --pretty=format:"%s% bThanks" HEAD^^ >actual &&
-       test $(wc -w <actual) = 2
+       test $(wc -w <actual) = 3
 '
 
 test_expect_success 'add SP before non-empty (2)' '
        git show -s --pretty=format:"%s% sThanks" HEAD^^ >actual &&
-       test $(wc -w <actual) = 4
+       test $(wc -w <actual) = 6
 '
 
 test_expect_success '--abbrev' '
index 300be86c385a93588e987f591357c57421b9cbae..8d4b50d1b5816d69ab165119773a7ffc0c360c0a 100755 (executable)
@@ -9,6 +9,19 @@ Documented tests for git reset'
 
 . ./test-lib.sh
 
+commit_msg () {
+       # String "modify 2nd file (changed)" partly in German
+       # (translated with Google Translate),
+       # encoded in UTF-8, used as a commit log message below.
+       msg="modify 2nd file (ge\303\244ndert)\n"
+       if test -n "$1"
+       then
+               printf "$msg" | iconv -f utf-8 -t "$1"
+       else
+               printf "$msg"
+       fi
+}
+
 test_expect_success 'creating initial files and commits' '
        test_tick &&
        echo "1st file" >first &&
@@ -28,7 +41,7 @@ test_expect_success 'creating initial files and commits' '
 
        echo "1st line 2nd file" >secondfile &&
        echo "2nd line 2nd file" >>secondfile &&
-       git commit -a -m "modify 2nd file" &&
+       git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
        head5=$(git rev-parse --verify HEAD)
 '
 # git log --pretty=oneline # to see those SHA1 involved
@@ -44,6 +57,20 @@ check_changes () {
        done | test_cmp .cat_expect -
 }
 
+test_expect_success 'reset --hard message' '
+       hex=$(git log -1 --format="%h") &&
+       git reset --hard > .actual &&
+       echo HEAD is now at $hex $(commit_msg) > .expected &&
+       test_cmp .expected .actual
+'
+
+test_expect_success 'reset --hard message (iso8859-1 logoutputencoding)' '
+       hex=$(git log -1 --format="%h") &&
+       git -c "i18n.logOutputEncoding=iso8859-1" reset --hard > .actual &&
+       echo HEAD is now at $hex $(commit_msg iso8859-1) > .expected &&
+       test_cmp .expected .actual
+'
+
 >.diff_expect
 >.cached_expect
 cat >.cat_expect <<EOF
@@ -192,7 +219,8 @@ test_expect_success \
        'changing files and redo the last commit should succeed' '
        echo "3rd line 2nd file" >>secondfile &&
        git commit -a -C ORIG_HEAD &&
-       check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&
+       head4=$(git rev-parse --verify HEAD) &&
+       check_changes $head4 &&
        test "$(git rev-parse ORIG_HEAD)" = \
                        $head5
 '
@@ -211,7 +239,7 @@ test_expect_success \
        git reset --hard HEAD~2 &&
        check_changes ddaefe00f1da16864591c61fdc7adb5d7cd6b74e &&
        test "$(git rev-parse ORIG_HEAD)" = \
-                       3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d
+                       $head4
 '
 
 >.diff_expect
@@ -303,7 +331,7 @@ test_expect_success 'redoing the last two commits should succeed' '
 
        echo "1st line 2nd file" >secondfile &&
        echo "2nd line 2nd file" >>secondfile &&
-       git commit -a -m "modify 2nd file" &&
+       git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
        check_changes $head5
 '
 
@@ -326,10 +354,11 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' '
        git checkout branch2 &&
        echo "3rd line in branch2" >>secondfile &&
        git commit -a -m "change in branch2" &&
+       head3=$(git rev-parse --verify HEAD) &&
 
        test_must_fail git pull . branch1 &&
        git reset --hard &&
-       check_changes 77abb337073fb4369a7ad69ff6f5ec0e4d6b54bb
+       check_changes $head3
 '
 
 >.diff_expect
index e2ffdacc267c22e369247791e24338a20badf94d..ac3d0fe44507328f6363edc1d614bc9d8369899b 100755 (executable)
@@ -1335,4 +1335,66 @@ test_expect_failure '.git/config ignore=all suppresses submodule summary' '
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
+test_expect_success 'setup of test environment' '
+       git config status.showUntrackedFiles no &&
+       git status -s >expected_short &&
+       git status --no-short >expected_noshort
+'
+
+test_expect_success '"status.short=true" same as "-s"' '
+       git -c status.short=true status >actual &&
+       test_cmp expected_short actual
+'
+
+test_expect_success '"status.short=true" weaker than "--no-short"' '
+       git -c status.short=true status --no-short >actual &&
+       test_cmp expected_noshort actual
+'
+
+test_expect_success '"status.short=false" same as "--no-short"' '
+       git -c status.short=false status >actual &&
+       test_cmp expected_noshort actual
+'
+
+test_expect_success '"status.short=false" weaker than "-s"' '
+       git -c status.short=false status -s >actual &&
+       test_cmp expected_short actual
+'
+
+test_expect_success '"status.branch=true" same as "-b"' '
+       git status -sb >expected_branch &&
+       git -c status.branch=true status -s >actual &&
+       test_cmp expected_branch actual
+'
+
+test_expect_success '"status.branch=true" different from "--no-branch"' '
+       git status -s --no-branch  >expected_nobranch &&
+       git -c status.branch=true status -s >actual &&
+       test_must_fail test_cmp expected_nobranch actual
+'
+
+test_expect_success '"status.branch=true" weaker than "--no-branch"' '
+       git -c status.branch=true status -s --no-branch >actual &&
+       test_cmp expected_nobranch actual
+'
+
+test_expect_success '"status.branch=true" weaker than "--porcelain"' '
+       git -c status.branch=true status --porcelain >actual &&
+       test_cmp expected_nobranch actual
+'
+
+test_expect_success '"status.branch=false" same as "--no-branch"' '
+       git -c status.branch=false status -s >actual &&
+       test_cmp expected_nobranch actual
+'
+
+test_expect_success '"status.branch=false" weaker than "-b"' '
+       git -c status.branch=false status -sb >actual &&
+       test_cmp expected_branch actual
+'
+
+test_expect_success 'Restore default test environment' '
+       git config --unset status.showUntrackedFiles
+'
+
 test_done
index bd8aab0a5c4f47f76d08712d406eae4efa6adae5..31a798fda21f178cbbedf47ee92dbd997f9c4e42 100755 (executable)
@@ -77,7 +77,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'
        ONTO=$(git rev-parse --short HEAD^^) &&
        test_must_fail git rebase HEAD^ --onto HEAD^^ &&
        cat >expected <<-EOF &&
-       # HEAD detached at $ONTO
+       # rebase in progress; onto $ONTO
        # You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
        #   (fix conflicts and then run "git rebase --continue")
        #   (use "git rebase --skip" to skip this patch)
@@ -104,7 +104,7 @@ test_expect_success 'status when rebase in progress before rebase --continue' '
        echo three >main.txt &&
        git add main.txt &&
        cat >expected <<-EOF &&
-       # HEAD detached at $ONTO
+       # rebase in progress; onto $ONTO
        # You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
        #   (all conflicts fixed: run "git rebase --continue")
        #
@@ -136,7 +136,7 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '
        ONTO=$(git rev-parse --short rebase_i_conflicts) &&
        test_must_fail git rebase -i rebase_i_conflicts &&
        cat >expected <<-EOF &&
-       # HEAD detached at $ONTO
+       # rebase in progress; onto $ONTO
        # You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
        #   (fix conflicts and then run "git rebase --continue")
        #   (use "git rebase --skip" to skip this patch)
@@ -162,7 +162,7 @@ test_expect_success 'status during rebase -i after resolving conflicts' '
        test_must_fail git rebase -i rebase_i_conflicts &&
        git add main.txt &&
        cat >expected <<-EOF &&
-       # HEAD detached at $ONTO
+       # rebase in progress; onto $ONTO
        # You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
        #   (all conflicts fixed: run "git rebase --continue")
        #
@@ -188,10 +188,9 @@ test_expect_success 'status when rebasing -i in edit mode' '
        export FAKE_LINES &&
        test_when_finished "git rebase --abort" &&
        ONTO=$(git rev-parse --short HEAD~2) &&
-       TGT=$(git rev-parse --short two_rebase_i) &&
        git rebase -i HEAD~2 &&
        cat >expected <<-EOF &&
-       # HEAD detached from $TGT
+       # rebase in progress; onto $ONTO
        # You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
        #   (use "git commit --amend" to amend the current commit)
        #   (use "git rebase --continue" once you are satisfied with your changes)
@@ -216,9 +215,8 @@ test_expect_success 'status when splitting a commit' '
        ONTO=$(git rev-parse --short HEAD~3) &&
        git rebase -i HEAD~3 &&
        git reset HEAD^ &&
-       TGT=$(git rev-parse --short HEAD) &&
        cat >expected <<-EOF &&
-       # HEAD detached at $TGT
+       # rebase in progress; onto $ONTO
        # You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
        #   (Once your working directory is clean, run "git rebase --continue")
        #
@@ -246,11 +244,10 @@ test_expect_success 'status after editing the last commit with --amend during a
        export FAKE_LINES &&
        test_when_finished "git rebase --abort" &&
        ONTO=$(git rev-parse --short HEAD~3) &&
-       TGT=$(git rev-parse --short three_amend) &&
        git rebase -i HEAD~3 &&
        git commit --amend -m "foo" &&
        cat >expected <<-EOF &&
-       # HEAD detached from $TGT
+       # rebase in progress; onto $ONTO
        # You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
        #   (use "git commit --amend" to amend the current commit)
        #   (use "git rebase --continue" once you are satisfied with your changes)
@@ -280,7 +277,7 @@ test_expect_success 'status: (continue first edit) second edit' '
        git rebase -i HEAD~3 &&
        git rebase --continue &&
        cat >expected <<-EOF &&
-       # HEAD detached from $ONTO
+       # rebase in progress; onto $ONTO
        # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
        #   (use "git commit --amend" to amend the current commit)
        #   (use "git rebase --continue" once you are satisfied with your changes)
@@ -302,7 +299,7 @@ test_expect_success 'status: (continue first edit) second edit and split' '
        git rebase --continue &&
        git reset HEAD^ &&
        cat >expected <<-EOF &&
-       # HEAD detached from $ONTO
+       # rebase in progress; onto $ONTO
        # You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
        #   (Once your working directory is clean, run "git rebase --continue")
        #
@@ -329,7 +326,7 @@ test_expect_success 'status: (continue first edit) second edit and amend' '
        git rebase --continue &&
        git commit --amend -m "foo" &&
        cat >expected <<-EOF &&
-       # HEAD detached from $ONTO
+       # rebase in progress; onto $ONTO
        # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
        #   (use "git commit --amend" to amend the current commit)
        #   (use "git rebase --continue" once you are satisfied with your changes)
@@ -351,7 +348,7 @@ test_expect_success 'status: (amend first edit) second edit' '
        git commit --amend -m "a" &&
        git rebase --continue &&
        cat >expected <<-EOF &&
-       # HEAD detached from $ONTO
+       # rebase in progress; onto $ONTO
        # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
        #   (use "git commit --amend" to amend the current commit)
        #   (use "git rebase --continue" once you are satisfied with your changes)
@@ -374,7 +371,7 @@ test_expect_success 'status: (amend first edit) second edit and split' '
        git rebase --continue &&
        git reset HEAD^ &&
        cat >expected <<-EOF &&
-       # HEAD detached from $ONTO
+       # rebase in progress; onto $ONTO
        # You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
        #   (Once your working directory is clean, run "git rebase --continue")
        #
@@ -402,7 +399,7 @@ test_expect_success 'status: (amend first edit) second edit and amend' '
        git rebase --continue &&
        git commit --amend -m "d" &&
        cat >expected <<-EOF &&
-       # HEAD detached from $ONTO
+       # rebase in progress; onto $ONTO
        # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
        #   (use "git commit --amend" to amend the current commit)
        #   (use "git rebase --continue" once you are satisfied with your changes)
@@ -426,7 +423,7 @@ test_expect_success 'status: (split first edit) second edit' '
        git commit -m "e" &&
        git rebase --continue &&
        cat >expected <<-EOF &&
-       # HEAD detached from $ONTO
+       # rebase in progress; onto $ONTO
        # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
        #   (use "git commit --amend" to amend the current commit)
        #   (use "git rebase --continue" once you are satisfied with your changes)
@@ -451,7 +448,7 @@ test_expect_success 'status: (split first edit) second edit and split' '
        git rebase --continue &&
        git reset HEAD^ &&
        cat >expected <<-EOF &&
-       # HEAD detached from $ONTO
+       # rebase in progress; onto $ONTO
        # You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
        #   (Once your working directory is clean, run "git rebase --continue")
        #
@@ -481,7 +478,7 @@ test_expect_success 'status: (split first edit) second edit and amend' '
        git rebase --continue &&
        git commit --amend -m "h" &&
        cat >expected <<-EOF &&
-       # HEAD detached from $ONTO
+       # rebase in progress; onto $ONTO
        # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
        #   (use "git commit --amend" to amend the current commit)
        #   (use "git rebase --continue" once you are satisfied with your changes)
@@ -601,7 +598,7 @@ test_expect_success 'status when rebase conflicts with statushints disabled' '
        ONTO=$(git rev-parse --short HEAD^^) &&
        test_must_fail git rebase HEAD^ --onto HEAD^^ &&
        cat >expected <<-EOF &&
-       # HEAD detached at $ONTO
+       # rebase in progress; onto $ONTO
        # You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
        #
        # Unmerged paths:
@@ -669,7 +666,7 @@ test_expect_success 'status when cherry-picking after resolving conflicts' '
        test_i18ncmp expected actual
 '
 
-test_expect_success 'status showing detached from a tag' '
+test_expect_success 'status showing detached at and from a tag' '
        test_commit atag tagging &&
        git checkout atag &&
        cat >expected <<-\EOF
@@ -677,6 +674,14 @@ test_expect_success 'status showing detached from a tag' '
        nothing to commit (use -u to show untracked files)
        EOF
        git status --untracked-files=no >actual &&
+       test_i18ncmp expected actual &&
+
+       git reset --hard HEAD^ &&
+       cat >expected <<-\EOF
+       # HEAD detached from atag
+       nothing to commit (use -u to show untracked files)
+       EOF
+       git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
 
index 460d8ebf48f9ab3826e58e2e9285f6faecd79b78..3ff5fb853c941586e3e5ed69a74a628dfe5bb84a 100755 (executable)
@@ -497,9 +497,15 @@ test_expect_success 'combining --squash and --no-ff is refused' '
        test_must_fail git merge --no-ff --squash c1
 '
 
-test_expect_success 'combining --ff-only and --no-ff is refused' '
-       test_must_fail git merge --ff-only --no-ff c1 &&
-       test_must_fail git merge --no-ff --ff-only c1
+test_expect_success 'option --ff-only overwrites --no-ff' '
+       git merge --no-ff --ff-only c1 &&
+       test_must_fail git merge --no-ff --ff-only c2
+'
+
+test_expect_success 'option --ff-only overwrites merge.ff=only config' '
+       git reset --hard c0 &&
+       test_config merge.ff only &&
+       git merge --no-ff c1
 '
 
 test_expect_success 'merge c0 with c1 (ff overrides no-ff)' '
index 5469dee8d1f39e6cae4205501a774d36913fff73..272a071e85b0b7c6b34da06fd7492a257b09fa52 100755 (executable)
@@ -69,7 +69,7 @@ run_completion ()
        local -a COMPREPLY _words
        local _cword
        _words=( $1 )
-       test "${1: -1}" == ' ' && _words+=('')
+       test "${1: -1}" = ' ' && _words+=('')
        (( _cword = ${#_words[@]} - 1 ))
        __git_wrap__git_main && print_comp
 }
@@ -365,6 +365,7 @@ test_expect_success 'double dash "git" itself' '
        --exec-path Z
        --exec-path=
        --html-path Z
+       --man-path Z
        --info-path Z
        --work-tree=
        --namespace=
index 8828ff78f184a451fb43709771cc39bf17186cfb..a7e9aacbb2d9b05b0d5083a0fd70cb9287fcf454 100644 (file)
@@ -343,6 +343,7 @@ test_declared_prereq () {
 }
 
 test_expect_failure () {
+       test_start_
        test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
        test "$#" = 2 ||
        error "bug in the test script: not 2 or 3 parameters to test-expect-failure"
@@ -357,10 +358,11 @@ test_expect_failure () {
                        test_known_broken_failure_ "$1"
                fi
        fi
-       echo >&3 ""
+       test_finish_
 }
 
 test_expect_success () {
+       test_start_
        test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
        test "$#" = 2 ||
        error "bug in the test script: not 2 or 3 parameters to test-expect-success"
@@ -375,7 +377,7 @@ test_expect_success () {
                        test_failure_ "$@"
                fi
        fi
-       echo >&3 ""
+       test_finish_
 }
 
 # test_external runs external test scripts that provide continuous
index eff3a653d14fc27d4e058fb06fa1a5d98c2978ae..2d633073510c1f6a27fc3f7943fed5dafc717dcb 100644 (file)
@@ -184,6 +184,9 @@ do
                help=t; shift ;;
        -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
                verbose=t; shift ;;
+       --verbose-only=*)
+               verbose_only=$(expr "z$1" : 'z[^=]*=\(.*\)')
+               shift ;;
        -q|--q|--qu|--qui|--quie|--quiet)
                # Ignore --quiet under a TAP::Harness. Saying how many tests
                # passed without the ok/not ok details is always an error.
@@ -198,17 +201,39 @@ do
        --valgrind=*)
                valgrind=$(expr "z$1" : 'z[^=]*=\(.*\)')
                shift ;;
+       --valgrind-only=*)
+               valgrind_only=$(expr "z$1" : 'z[^=]*=\(.*\)')
+               shift ;;
+       --valgrind-parallel=*)
+               valgrind_parallel=$(expr "z$1" : 'z[^=]*=\(.*\)')
+               shift ;;
+       --valgrind-only-stride=*)
+               valgrind_only_stride=$(expr "z$1" : 'z[^=]*=\(.*\)')
+               shift ;;
+       --valgrind-only-offset=*)
+               valgrind_only_offset=$(expr "z$1" : 'z[^=]*=\(.*\)')
+               shift ;;
        --tee)
                shift ;; # was handled already
        --root=*)
                root=$(expr "z$1" : 'z[^=]*=\(.*\)')
                shift ;;
+       --statusprefix=*)
+               statusprefix=$(expr "z$1" : 'z[^=]*=\(.*\)')
+               shift ;;
        *)
                echo "error: unknown test option '$1'" >&2; exit 1 ;;
        esac
 done
 
-test -n "$valgrind" && verbose=t
+if test -n "$valgrind_only" || test -n "$valgrind_only_stride"
+then
+       test -z "$valgrind" && valgrind=memcheck
+       test -z "$verbose" && verbose_only="$valgrind_only"
+elif test -n "$valgrind"
+then
+       verbose=t
+fi
 
 if test -n "$color"
 then
@@ -303,12 +328,12 @@ trap 'die' EXIT
 
 test_ok_ () {
        test_success=$(($test_success + 1))
-       say_color "" "ok $test_count - $@"
+       say_color "" "${statusprefix}ok $test_count - $@"
 }
 
 test_failure_ () {
        test_failure=$(($test_failure + 1))
-       say_color error "not ok $test_count - $1"
+       say_color error "${statusprefix}not ok $test_count - $1"
        shift
        echo "$@" | sed -e 's/^/#       /'
        test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
@@ -316,18 +341,83 @@ test_failure_ () {
 
 test_known_broken_ok_ () {
        test_fixed=$(($test_fixed+1))
-       say_color error "ok $test_count - $@ # TODO known breakage vanished"
+       say_color error "${statusprefix}ok $test_count - $@ # TODO known breakage vanished"
 }
 
 test_known_broken_failure_ () {
        test_broken=$(($test_broken+1))
-       say_color warn "not ok $test_count - $@ # TODO known breakage"
+       say_color warn "${statusprefix}not ok $test_count - $@ # TODO known breakage"
 }
 
 test_debug () {
        test "$debug" = "" || eval "$1"
 }
 
+match_pattern_list () {
+       arg="$1"
+       shift
+       test -z "$*" && return 1
+       for pattern_
+       do
+               case "$arg" in
+               $pattern_)
+                       return 0
+               esac
+       done
+       return 1
+}
+
+maybe_teardown_verbose () {
+       test -z "$verbose_only" && return
+       exec 4>/dev/null 3>/dev/null
+       verbose=
+}
+
+last_verbose=t
+maybe_setup_verbose () {
+       test -z "$verbose_only" && return
+       if match_pattern_list $test_count $verbose_only ||
+               { test -n "$valgrind_only_stride" &&
+               expr $test_count "%" $valgrind_only_stride - $valgrind_only_offset = 0 >/dev/null; }
+       then
+               exec 4>&2 3>&1
+               # Emit a delimiting blank line when going from
+               # non-verbose to verbose.  Within verbose mode the
+               # delimiter is printed by test_expect_*.  The choice
+               # of the initial $last_verbose is such that before
+               # test 1, we do not print it.
+               test -z "$last_verbose" && echo >&3 ""
+               verbose=t
+       else
+               exec 4>/dev/null 3>/dev/null
+               verbose=
+       fi
+       last_verbose=$verbose
+}
+
+maybe_teardown_valgrind () {
+       test -z "$GIT_VALGRIND" && return
+       GIT_VALGRIND_ENABLED=
+}
+
+maybe_setup_valgrind () {
+       test -z "$GIT_VALGRIND" && return
+       if test -z "$valgrind_only" && test -z "$valgrind_only_stride"
+       then
+               GIT_VALGRIND_ENABLED=t
+               return
+       fi
+       GIT_VALGRIND_ENABLED=
+       if match_pattern_list $test_count $valgrind_only
+       then
+               GIT_VALGRIND_ENABLED=t
+       elif test -n "$valgrind_only_stride" &&
+               expr $test_count "%" $valgrind_only_stride - $valgrind_only_offset = 0 >/dev/null
+       then
+               GIT_VALGRIND_ENABLED=t
+       fi
+}
+
 test_eval_ () {
        # This is a separate function because some tests use
        # "return" to end a test_expect_success block early.
@@ -337,8 +427,10 @@ test_eval_ () {
 test_run_ () {
        test_cleanup=:
        expecting_failure=$2
+       setup_malloc_check
        test_eval_ "$1"
        eval_ret=$?
+       teardown_malloc_check
 
        if test -z "$immediate" || test $eval_ret = 0 || test -n "$expecting_failure"
        then
@@ -353,17 +445,24 @@ test_run_ () {
        return "$eval_ret"
 }
 
-test_skip () {
+test_start_ () {
        test_count=$(($test_count+1))
+       maybe_setup_verbose
+       maybe_setup_valgrind
+}
+
+test_finish_ () {
+       echo >&3 ""
+       maybe_teardown_valgrind
+       maybe_teardown_verbose
+}
+
+test_skip () {
        to_skip=
-       for skp in $GIT_SKIP_TESTS
-       do
-               case $this_test.$test_count in
-               $skp)
-                       to_skip=t
-                       break
-               esac
-       done
+       if match_pattern_list $this_test.$test_count $GIT_SKIP_TESTS
+       then
+               to_skip=t
+       fi
        if test -z "$to_skip" && test -n "$test_prereq" &&
           ! test_have_prereq "$test_prereq"
        then
@@ -377,8 +476,8 @@ test_skip () {
                        of_prereq=" of $test_prereq"
                fi
 
-               say_color skip >&3 "skipping test: $@"
-               say_color skip "ok $test_count # skip $1 (missing $missing_prereq${of_prereq})"
+               say_color skip >&3 "${statusprefix}skipping test: $@"
+               say_color skip "${statusprefix}ok $test_count # skip $1 (missing $missing_prereq${of_prereq})"
                : true
                ;;
        *)
@@ -395,6 +494,8 @@ test_at_end_hook_ () {
 test_done () {
        GIT_EXIT_OK=t
 
+       # Note: t0000 relies on $HARNESS_ACTIVE disabling the .counts
+       # output file
        if test -z "$HARNESS_ACTIVE"
        then
                test_results_dir="$TEST_OUTPUT_DIRECTORY/test-results"
@@ -414,11 +515,11 @@ test_done () {
 
        if test "$test_fixed" != 0
        then
-               say_color error "# $test_fixed known breakage(s) vanished; please update test(s)"
+               say_color error "${statusprefix}# $test_fixed known breakage(s) vanished; please update test(s)"
        fi
        if test "$test_broken" != 0
        then
-               say_color warn "# still have $test_broken known breakage(s)"
+               say_color warn "${statusprefix}# still have $test_broken known breakage(s)"
        fi
        if test "$test_broken" != 0 || test "$test_fixed" != 0
        then
@@ -441,9 +542,9 @@ test_done () {
                then
                        if test $test_remaining -gt 0
                        then
-                               say_color pass "# passed all $msg"
+                               say_color pass "${statusprefix}# passed all $msg"
                        fi
-                       say "1..$test_count$skip_all"
+                       say "${statusprefix}1..$test_count$skip_all"
                fi
 
                test -d "$remove_trash" &&
@@ -457,8 +558,8 @@ test_done () {
        *)
                if test $test_external_has_tap -eq 0
                then
-                       say_color error "# failed $test_failure among $msg"
-                       say "1..$test_count"
+                       say_color error "${statusprefix}# failed $test_failure among $msg"
+                       say "${statusprefix}1..$test_count"
                fi
 
                exit 1 ;;
@@ -466,6 +567,9 @@ test_done () {
        esac
 }
 
+
+# Set up a directory that we can put in PATH which redirects all git
+# calls to 'valgrind git ...'.
 if test -n "$valgrind"
 then
        make_symlink () {
@@ -513,31 +617,43 @@ then
                make_symlink "$symlink_target" "$GIT_VALGRIND/bin/$base" || exit
        }
 
-       # override all git executables in TEST_DIRECTORY/..
-       GIT_VALGRIND=$TEST_DIRECTORY/valgrind
-       mkdir -p "$GIT_VALGRIND"/bin
-       for file in $GIT_BUILD_DIR/git* $GIT_BUILD_DIR/test-*
-       do
-               make_valgrind_symlink $file
-       done
-       # special-case the mergetools loadables
-       make_symlink "$GIT_BUILD_DIR"/mergetools "$GIT_VALGRIND/bin/mergetools"
-       OLDIFS=$IFS
-       IFS=:
-       for path in $PATH
-       do
-               ls "$path"/git-* 2> /dev/null |
-               while read file
+       # In the case of --valgrind-parallel, we only need to do the
+       # wrapping once, in the main script.  The worker children all
+       # have $valgrind_only_stride set, so we can skip based on that.
+       if test -z "$valgrind_only_stride"
+       then
+               # override all git executables in TEST_DIRECTORY/..
+               GIT_VALGRIND=$TEST_DIRECTORY/valgrind
+               mkdir -p "$GIT_VALGRIND"/bin
+               for file in $GIT_BUILD_DIR/git* $GIT_BUILD_DIR/test-*
                do
-                       make_valgrind_symlink "$file"
+                       make_valgrind_symlink $file
                done
-       done
-       IFS=$OLDIFS
+               # special-case the mergetools loadables
+               make_symlink "$GIT_BUILD_DIR"/mergetools "$GIT_VALGRIND/bin/mergetools"
+               OLDIFS=$IFS
+               IFS=:
+               for path in $PATH
+               do
+                       ls "$path"/git-* 2> /dev/null |
+                       while read file
+                       do
+                               make_valgrind_symlink "$file"
+                       done
+               done
+               IFS=$OLDIFS
+       fi
        PATH=$GIT_VALGRIND/bin:$PATH
        GIT_EXEC_PATH=$GIT_VALGRIND/bin
        export GIT_VALGRIND
        GIT_VALGRIND_MODE="$valgrind"
        export GIT_VALGRIND_MODE
+       GIT_VALGRIND_ENABLED=t
+       if test -n "$valgrind_only" || test -n "$valgrind_only_stride"
+       then
+               GIT_VALGRIND_ENABLED=
+       fi
+       export GIT_VALGRIND_ENABLED
 elif test -n "$GIT_TEST_INSTALLED"
 then
        GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path)  ||
@@ -622,21 +738,53 @@ then
 else
        mkdir -p "$TRASH_DIRECTORY"
 fi
+
+# Gross hack to spawn N sub-instances of the tests in parallel, and
+# summarize the results.  Note that if this is enabled, the script
+# terminates at the end of this 'if' block.
+if test -n "$valgrind_parallel"
+then
+       for i in $(test_seq 1 $valgrind_parallel)
+       do
+               root="$TRASH_DIRECTORY/vgparallel-$i"
+               mkdir "$root"
+               TEST_OUTPUT_DIRECTORY="$root" \
+                       ${SHELL_PATH} "$0" \
+                       --root="$root" --statusprefix="[$i] " \
+                       --valgrind="$valgrind" \
+                       --valgrind-only-stride="$valgrind_parallel" \
+                       --valgrind-only-offset="$i" &
+               pids="$pids $!"
+       done
+       trap "kill $pids" INT TERM HUP
+       wait $pids
+       trap - INT TERM HUP
+       for i in $(test_seq 1 $valgrind_parallel)
+       do
+               root="$TRASH_DIRECTORY/vgparallel-$i"
+               eval "$(cat "$root/test-results/$(basename "$0" .sh)"-*.counts |
+                       sed 's/^\([a-z][a-z]*\) \([0-9][0-9]*\)/inner_\1=\2/')"
+               test_count=$(expr $test_count + $inner_total)
+               test_success=$(expr $test_success + $inner_success)
+               test_fixed=$(expr $test_fixed + $inner_fixed)
+               test_broken=$(expr $test_broken + $inner_broken)
+               test_failure=$(expr $test_failure + $inner_failed)
+       done
+       test_done
+fi
+
 # Use -P to resolve symlinks in our working directory so that the cwd
 # in subprocesses like git equals our $PWD (for pathname comparisons).
 cd -P "$TRASH_DIRECTORY" || exit 1
 
 this_test=${0##*/}
 this_test=${this_test%%-*}
-for skp in $GIT_SKIP_TESTS
-do
-       case "$this_test" in
-       $skp)
-               say_color info >&3 "skipping test $this_test altogether"
-               skip_all="skip all tests in $this_test"
-               test_done
-       esac
-done
+if match_pattern_list "$this_test" $GIT_SKIP_TESTS
+then
+       say_color info >&3 "skipping test $this_test altogether"
+       skip_all="skip all tests in $this_test"
+       test_done
+fi
 
 # Provide an implementation of the 'yes' utility
 yes () {
@@ -737,7 +885,14 @@ test_i18ngrep () {
 
 test_lazy_prereq PIPE '
        # test whether the filesystem supports FIFOs
-       rm -f testfifo && mkfifo testfifo
+       case $(uname -s) in
+       CYGWIN*)
+               false
+               ;;
+       *)
+               rm -f testfifo && mkfifo testfifo
+               ;;
+       esac
 '
 
 test_lazy_prereq SYMLINKS '
index 6b87c91b60cde4b19d6644227548f1ba6b226545..42153036dcfdee66e54fa4bd777ad3c36233d640 100755 (executable)
@@ -4,6 +4,9 @@ base=$(basename "$0")
 
 TOOL_OPTIONS='--leak-check=no'
 
+test -z "$GIT_VALGRIND_ENABLED" &&
+exec "$GIT_VALGRIND"/../../"$base" "$@"
+
 case "$GIT_VALGRIND_MODE" in
 memcheck-fast)
        ;;
index b191c65382b0714978fe1a6351639ed746db099f..9c4d086b51364ff42a044be95e6ea55dffe7b79e 100644 (file)
@@ -127,6 +127,7 @@ void wt_status_prepare(struct wt_status *s)
        s->change.strdup_strings = 1;
        s->untracked.strdup_strings = 1;
        s->ignored.strdup_strings = 1;
+       s->show_branch = -1;  /* unspecified */
 }
 
 static void wt_status_print_unmerged_header(struct wt_status *s)
@@ -1037,7 +1038,6 @@ static char *read_and_strip_branch(const char *path)
 }
 
 struct grab_1st_switch_cbdata {
-       int found;
        struct strbuf buf;
        unsigned char nsha1[20];
 };
@@ -1061,7 +1061,6 @@ static int grab_1st_switch(unsigned char *osha1, unsigned char *nsha1,
        for (end = target; *end && *end != '\n'; end++)
                ;
        strbuf_add(&cb->buf, target, end - target);
-       cb->found = 1;
        return 1;
 }
 
@@ -1178,7 +1177,10 @@ void wt_status_print(struct wt_status *s)
                        branch_name += 11;
                else if (!strcmp(branch_name, "HEAD")) {
                        branch_status_color = color(WT_STATUS_NOBRANCH, s);
-                       if (state.detached_from) {
+                       if (state.rebase_in_progress || state.rebase_interactive_in_progress) {
+                               on_what = _("rebase in progress; onto ");
+                               branch_name = state.onto;
+                       } else if (state.detached_from) {
                                unsigned char sha1[20];
                                branch_name = state.detached_from;
                                if (!get_sha1("HEAD", sha1) &&