Merge branch 'sg/complete-untracked-filter'
authorJonathan Nieder <jrnieder@gmail.com>
Wed, 25 Sep 2013 06:27:44 +0000 (23:27 -0700)
committerJonathan Nieder <jrnieder@gmail.com>
Wed, 25 Sep 2013 06:27:44 +0000 (23:27 -0700)
* sg/complete-untracked-filter:
completion: improve untracked directory filtering for filename completion

93 files changed:
Documentation/RelNotes/1.8.4.1.txt [new file with mode: 0644]
Documentation/RelNotes/1.8.5.txt
Documentation/config.txt
Documentation/git-branch.txt
Documentation/git-check-ignore.txt
Documentation/git-check-ref-format.txt
Documentation/git-cherry.txt
Documentation/git-update-ref.txt
Documentation/git.txt
Documentation/revisions.txt
bisect.c
branch.c
builtin/branch.c
builtin/check-ignore.c
builtin/clone.c
builtin/commit.c
builtin/fetch.c
builtin/pack-objects.c
builtin/receive-pack.c
builtin/reflog.c
builtin/replace.c
builtin/reset.c
builtin/rev-list.c
builtin/revert.c
builtin/stripspace.c
builtin/tag.c
builtin/update-ref.c
cache.h
commit.h
compat/mingw.h
contrib/contacts/git-contacts
contrib/mw-to-git/git-remote-mediawiki.perl
contrib/mw-to-git/t/t9365-continuing-queries.sh [new file with mode: 0755]
contrib/remote-helpers/git-remote-bzr
contrib/remote-helpers/git-remote-hg
contrib/remote-helpers/test-bzr.sh
contrib/remote-helpers/test-hg-bidi.sh
contrib/remote-helpers/test-hg-hg-git.sh
contrib/remote-helpers/test-hg.sh
environment.c
fast-import.c
fetch-pack.c
git-add--interactive.perl
git-cvsserver.perl
git-p4.py
git-rebase.sh
git-send-email.perl
git-submodule.sh
git.c
http-backend.c
http-push.c
list-objects.c
list-objects.h
object.c
pager.c
perl/Git/SVN/Ra.pm
refs.c
refs.h
remote.c
revision.c
sequencer.c
sha1-lookup.c
sha1_name.c
shallow.c
t/lib-git-p4.sh
t/lib-httpd.sh
t/lib-pack.sh [new file with mode: 0644]
t/t0001-init.sh
t/t0008-ignores.sh
t/t0056-git-C.sh [new file with mode: 0755]
t/t1400-update-ref.sh
t/t1508-at-combinations.sh
t/t1511-rev-parse-caret.sh
t/t2024-checkout-dwim.sh
t/t3001-ls-files-others-exclude.sh
t/t3200-branch.sh
t/t3501-revert-cherry-pick.sh
t/t5308-pack-detect-duplicates.sh [new file with mode: 0755]
t/t5309-pack-delta-cycles.sh [new file with mode: 0755]
t/t5500-fetch-pack.sh
t/t5530-upload-pack-error.sh
t/t6040-tracking-info.sh
t/t6101-rev-parse-parents.sh
t/t7060-wtstatus.sh
t/t7401-submodule-summary.sh
t/t7508-status.sh
t/t7512-status-help.sh
templates/hooks--pre-commit.sample
test-sha1.c
upload-pack.c
urlmatch.c
wt-status.c
wt-status.h
diff --git a/Documentation/RelNotes/1.8.4.1.txt b/Documentation/RelNotes/1.8.4.1.txt
new file mode 100644 (file)
index 0000000..806545a
--- /dev/null
@@ -0,0 +1,50 @@
+Git v1.8.4.1 Release Notes
+========================
+
+Fixes since v1.8.4
+------------------
+
+ * Some people still use rather old versions of bash, which cannot
+   grok some constructs like 'printf -v varname' the prompt and
+   completion code started to use recently.  The completion and
+   prompt scripts have been adjusted to work better with these old
+   versions of bash.
+
+ * "git rebase -i" had a minor bug (the same could be in other
+   programs, as the root cause is pretty generic) where the code
+   feeds a random, data dependeant string to 'echo' and expects it
+   to come out literally.
+
+ * "submodule.<name>.path" variable mistakenly set to the empty
+   "true" caused the configuration parser to segfault.
+
+ * Output from "git log --full-diff -- <pathspec>" looked strange,
+   because comparison was done with the previous ancestor that
+   touched the specified <pathspec>, causing the patches for paths
+   outside the pathspec to show more than the single commit has
+   changed.
+
+ * The auto-tag-following code in "git fetch" tries to reuse the
+   same transport twice when the serving end does not cooperate and
+   does not give tags that point to commits that are asked for as
+   part of the primary transfer.  Unfortunately, Git-aware transport
+   helper interface is not designed to be used more than once, hence
+   this did not work over smart-http transfer.  Fixed.
+
+ * Send a large request to read(2)/write(2) as a smaller but still
+   reasonably large chunks, which would improve the latency when the
+   operation needs to be killed and incidentally works around broken
+   64-bit systems that cannot take a 2GB write or read in one go.
+
+ * A ".mailmap" file that ends with an incomplete line, when read
+   from a blob, was not handled properly.
+
+ * The recent "short-cut clone connectivity check" topic broke a
+   shallow repository when a fetch operation tries to auto-follow
+   tags.
+
+ * On platforms with fgetc() and friends defined as macros,
+   the configuration parser did not compile.
+
+Also contains a handful of trivial code clean-ups, documentation
+updates, updates to the test suite, etc.
index f335bcfcdd8a32ab323630bafed25829177d1ed3..ac5c3fafe59be32e5f276ad4276a5f9d6305fe85 100644 (file)
@@ -48,6 +48,10 @@ Updates since v1.8.4
 
 Foreign interfaces, subsystems and ports.
 
+ * "git-svn" used with SVN 1.8.0 when talking over https:// connection
+   dumped core due to a bug in the serf library that SVN uses.  Work
+   it around on our side, even though the SVN side is being fixed.
+
  * On MacOS X, we detected if the filesystem needs the "pre-composed
    unicode strings" workaround, but did not automatically enable it.
    Now we do.
@@ -67,6 +71,45 @@ Foreign interfaces, subsystems and ports.
 
 UI, Workflows & Features
 
+ * Instead of typing four capital letters "HEAD", you can say "@" now,
+   e.g. "git log @".
+
+ * "git check-ignore" follows the same rule as "git add" and "git
+   status" in that the ignore/exclude mechanism does not take effect
+   on paths that are already tracked.  With "--no-index" option, it
+   can be used to diagnose which paths that should have been ignored
+   have been mistakenly added to the index.
+
+ * Some irrelevant "advice" messages that are shared with "git status"
+   output have been removed from the commit log template.
+
+ * "update-refs" learnt a "--stdin" option to read multiple update
+   requests and perform them in an all-or-none fashion.
+
+ * Just like "make -C <directory>", "git -C <directory> ..." tells Git
+   to go there before doing anything else.
+
+ * Just like "git checkout -" knows to check out and "git merge -"
+   knows to merge the branch you were previously on, "git cherry-pick"
+   now understands "git cherry-pick -" to pick from the previous
+   branch.
+
+ * "git status" now omits the prefix to make its output a comment in a
+   commit log editor, which is not necessary for human consumption.
+
+ * Make "foo^{tag}" to peel a tag to itself, i.e. no-op., and fail if
+   "foo" is not a tag.  "git rev-parse --verify v1.0^{tag}" would be
+   a more convenient way to say "test $(git cat-file -t v1.0) = tag".
+
+ * "git branch -v -v" (and "git status") did not distinguish among a
+   branch that does not build on any other branch, a branch that is in
+   sync with the branch it builds on, and a branch that is configured
+   to build on some other branch that no longer exists.
+
+ * A packfile that stores the same object more than once is broken and
+   will be rejected by "git index-pack" that is run when receiving
+   data over the wire.
+
  * Earlier we started rejecting an attempt to add 0{40} object name to
    the index and to tree objects, but it sometimes is necessary to
    allow so to be able to use tools like filter-branch to correct such
@@ -136,6 +179,10 @@ UI, Workflows & Features
 
 Performance, Internal Implementation, etc.
 
+ * If a build-time fallback is set to "cat" instead of "less", we
+   should apply the same "no subprocess or pipe" optimization as we
+   apply to user-supplied GIT_PAGER=cat.
+
  * Many commands use --dashed-option as a operation mode selector
    (e.g. "git tag --delete") that the user can use at most one
    (e.g. "git tag --delete --verify" is a nonsense) and you cannot
@@ -165,6 +212,50 @@ Unless otherwise noted, all the fixes since v1.8.4 in the maintenance
 track are contained in this release (see release notes to them for
 details).
 
+ * When running "fetch -q", a long silence while the sender side
+   computes the set of objects to send can be mistaken by proxies as
+   dropped connection.  The server side has been taught to send a
+   small empty messages to keep the connection alive.
+   (merge 115dedd jk/upload-pack-keepalive later to maint).
+
+ * "git rebase" had a portability regression in v1.8.4 to trigger a
+   bug in some BSD shell implementations.
+   (merge 99855dd mm/rebase-continue-freebsd-WB later to maint).
+
+ * "git branch --track" had a minor regression in v1.8.3.2 and later
+   that made it impossible to base your local work on anything but a
+   local branch of the upstream repository you are tracking from.
+   (merge b0f49ff jh/checkout-auto-tracking later to maint).
+
+ * When the webserver responds with "405 Method Not Allowed", "git
+   http-backend" should tell the client what methods are allowed with
+   the "Allow" header.
+   (merge 9247be0 bc/http-backend-allow-405 later to maint).
+
+ * When there is no sufficient overlap between old and new history
+   during a "git fetch" into a shallow repository, objects that the
+   sending side knows the receiving end has were unnecessarily sent.
+   (merge f21d2a7 nd/fetch-into-shallow later to maint).
+
+ * "git cvsserver" computed the permission mode bits incorrectly for
+   executable files.
+   (merge 1b48d56 jc/cvsserver-perm-bit-fix later to maint).
+
+ * When send-email comes up with an error message to die with upon
+   failure to start an SSL session, it tried to read the error string
+   from a wrong place.
+   (merge 6cb0c88 bc/send-email-ssl-die-message-fix later to maint).
+
+ * The implementation of "add -i" has a crippling code to work around
+   ActiveState Perl limitation but it by mistake also triggered on Git
+   for Windows where MSYS perl is used.
+   (merge df17e77 js/add-i-mingw later to maint).
+
+ * We made sure that we notice the user-supplied GIT_DIR is actually a
+   gitfile, but did not do the same when the default ".git" is a
+   gitfile.
+   (merge 487a2b7 nd/git-dir-pointing-at-gitfile later to maint).
+
  * When an object is not found after checking the packfiles and then
    loose object directory, read_sha1_file() re-checks the packfiles to
    prevent racing with a concurrent repacker; teach the same logic to
index 44e7873521b05b78e0c5655e39a64c7b06cddb7e..c3f70023ec36ba523d95293fef7b20da64e7be3a 100644 (file)
@@ -2183,6 +2183,13 @@ 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.displayCommentPrefix::
+       If set to true, linkgit:git-status[1] will insert a comment
+       prefix before each output line (starting with
+       `core.commentChar`, i.e. `#` by default). This was the
+       behavior of linkgit:git-status[1] in Git 1.8.4 and previous.
+       Defaults to false.
+
 status.showUntrackedFiles::
        By default, linkgit:git-status[1] and linkgit:git-commit[1] show
        files which are not currently tracked by Git. Directories which
@@ -2281,6 +2288,17 @@ uploadpack.allowtipsha1inwant::
        of a hidden ref (by default, such a request is rejected).
        see also `uploadpack.hiderefs`.
 
+uploadpack.keepalive::
+       When `upload-pack` has started `pack-objects`, there may be a
+       quiet period while `pack-objects` prepares the pack. Normally
+       it would output progress information, but if `--quiet` was used
+       for the fetch, `pack-objects` will output nothing at all until
+       the pack data begins. Some clients and networks may consider
+       the server to be hung and give up. Setting this option instructs
+       `upload-pack` to send an empty keepalive packet every
+       `uploadpack.keepalive` seconds. Setting this option to 0
+       disables keepalive packets entirely. The default is 5 seconds.
+
 url.<base>.insteadOf::
        Any URL that starts with this value will be rewritten to
        start, instead, with <base>. In cases where some site serves a
index b7cb625b894d4ba83cb13914e1fd010e1bfaf0d3..311b33674eb2bda2c8e0bd5d2de4499a156b1719 100644 (file)
@@ -48,7 +48,8 @@ working tree to it; use "git checkout <newbranch>" to switch to the
 new branch.
 
 When a local branch is started off a remote-tracking branch, Git sets up the
-branch so that 'git pull' will appropriately merge from
+branch (specifically the `branch.<name>.remote` and `branch.<name>.merge`
+configuration entries) so that 'git pull' will appropriately merge from
 the remote-tracking branch. This behavior may be changed via the global
 `branch.autosetupmerge` configuration flag. That setting can be
 overridden by using the `--track` and `--no-track` options, and
@@ -156,7 +157,8 @@ This option is only applicable in non-verbose mode.
 
 -t::
 --track::
-       When creating a new branch, set up configuration to mark the
+       When creating a new branch, set up `branch.<name>.remote` and
+       `branch.<name>.merge` configuration entries to mark the
        start-point branch as "upstream" from the new branch. This
        configuration will tell git to show the relationship between the
        two branches in `git status` and `git branch -v`. Furthermore,
index d2df487aa20a89264afee08bcdddf681d7701fda..ee2e0917040909bd62df073e20f1120c23a43a63 100644 (file)
@@ -45,6 +45,13 @@ OPTIONS
        not be possible to distinguish between paths which match a
        pattern and those which don't.
 
+--no-index::
+       Don't look in the index when undertaking the checks. This can
+       be used to debug why a path became tracked by e.g. `git add .`
+       and was not ignored by the rules as expected by the user or when
+       developing patterns including negation to match a path previously
+       added with `git add -f`.
+
 OUTPUT
 ------
 
index a49be1bab49ddcdb65e4b45b578bd183a94657a5..fc02959ba4ab1ae6acc3dc5f707e870e42144f1c 100644 (file)
@@ -54,6 +54,8 @@ Git imposes the following rules on how references are named:
 
 . They cannot contain a sequence `@{`.
 
+. They cannot be the single character `@`.
+
 . They cannot contain a `\`.
 
 These rules make it easy for shell script based tools to parse
index f6c19c734d0fad09e7f7203a69959546f4b6a052..2d0daae626dd8e58c5a5c72ef999e36f56bcdce7 100644 (file)
@@ -14,8 +14,7 @@ DESCRIPTION
 -----------
 The changeset (or "diff") of each commit between the fork-point and <head>
 is compared against each commit between the fork-point and <upstream>.
-The commits are compared with their 'patch id', obtained from
-the 'git patch-id' program.
+The diffs are compared after removing any whitespace and line numbers.
 
 Every commit that doesn't exist in the <upstream> branch
 has its id (sha1) reported, prefixed by a symbol.  The ones that have
index 0df13ff6f4231779a5f0663900f34447ff2c1276..0a0a5512b3c62eb1179a3d5a9687949c39b2a9ef 100644 (file)
@@ -8,7 +8,7 @@ git-update-ref - Update the object name stored in a ref safely
 SYNOPSIS
 --------
 [verse]
-'git update-ref' [-m <reason>] (-d <ref> [<oldvalue>] | [--no-deref] <ref> <newvalue> [<oldvalue>])
+'git update-ref' [-m <reason>] (-d <ref> [<oldvalue>] | [--no-deref] <ref> <newvalue> [<oldvalue>] | --stdin [-z])
 
 DESCRIPTION
 -----------
@@ -58,6 +58,58 @@ archive by creating a symlink tree).
 With `-d` flag, it deletes the named <ref> after verifying it
 still contains <oldvalue>.
 
+With `--stdin`, update-ref reads instructions from standard input and
+performs all modifications together.  Specify commands of the form:
+
+       update SP <ref> SP <newvalue> [SP <oldvalue>] LF
+       create SP <ref> SP <newvalue> LF
+       delete SP <ref> [SP <oldvalue>] LF
+       verify SP <ref> [SP <oldvalue>] LF
+       option SP <opt> LF
+
+Quote fields containing whitespace as if they were strings in C source
+code.  Alternatively, use `-z` to specify commands without quoting:
+
+       update SP <ref> NUL <newvalue> NUL [<oldvalue>] NUL
+       create SP <ref> NUL <newvalue> NUL
+       delete SP <ref> NUL [<oldvalue>] NUL
+       verify SP <ref> NUL [<oldvalue>] NUL
+       option SP <opt> NUL
+
+Lines of any other format or a repeated <ref> produce an error.
+Command meanings are:
+
+update::
+       Set <ref> to <newvalue> after verifying <oldvalue>, if given.
+       Specify a zero <newvalue> to ensure the ref does not exist
+       after the update and/or a zero <oldvalue> to make sure the
+       ref does not exist before the update.
+
+create::
+       Create <ref> with <newvalue> after verifying it does not
+       exist.  The given <newvalue> may not be zero.
+
+delete::
+       Delete <ref> after verifying it exists with <oldvalue>, if
+       given.  If given, <oldvalue> may not be zero.
+
+verify::
+       Verify <ref> against <oldvalue> but do not change it.  If
+       <oldvalue> zero or missing, the ref must not exist.
+
+option::
+       Modify behavior of the next command naming a <ref>.
+       The only valid option is `no-deref` to avoid dereferencing
+       a symbolic ref.
+
+Use 40 "0" or the empty string to specify a zero value, except that
+with `-z` an empty <oldvalue> is considered missing.
+
+If all <ref>s can be locked with matching <oldvalue>s
+simultaneously, all modifications are performed.  Otherwise, no
+modifications are performed.  Note that while each individual
+<ref> is updated or deleted atomically, a concurrent reader may
+still see a subset of the modifications.
 
 Logging Updates
 ---------------
index c4f0ed59576b877a5eab2e36aa874d8c572bb905..5d68d33e46587deb785317a213857f0de5371022 100644 (file)
@@ -9,7 +9,7 @@ git - the stupid content tracker
 SYNOPSIS
 --------
 [verse]
-'git' [--version] [--help] [-c <name>=<value>]
+'git' [--version] [--help] [-C <path>] [-c <name>=<value>]
     [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
     [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
     [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
@@ -395,6 +395,20 @@ displayed. See linkgit:git-help[1] for more information,
 because `git --help ...` is converted internally into `git
 help ...`.
 
+-C <path>::
+       Run as if git was started in '<path>' instead of the current working
+       directory.  When multiple `-C` options are given, each subsequent
+       non-absolute `-C <path>` is interpreted relative to the preceding `-C
+       <path>`.
++
+This option affects options that expect path name like `--git-dir` and
+`--work-tree` in that their interpretations of the path names would be
+made relative to the working directory caused by the `-C` option. For
+example the following invocations are equivalent:
+
+    git --git-dir=a.git --work-tree=b -C c status
+    git --git-dir=c/a.git --work-tree=c/b status
+
 -c <name>=<value>::
        Pass a configuration parameter to the command. The value
        given will override values from configuration files.
index b0f4284cfbec9745d25fb242d32f808c83d0953f..2c06ed34ad2ed72f9cf856fb617e54a1956da599 100644 (file)
@@ -58,6 +58,9 @@ the '$GIT_DIR/refs' directory or from the '$GIT_DIR/packed-refs' file.
 While the ref name encoding is unspecified, UTF-8 is preferred as
 some output processing may assume ref names in UTF-8.
 
+'@'::
+  '@' alone is a shortcut for 'HEAD'.
+
 '<refname>@\{<date>\}', e.g. 'master@\{yesterday\}', 'HEAD@\{5 minutes ago\}'::
   A ref followed by the suffix '@' with a date specification
   enclosed in a brace
@@ -125,6 +128,9 @@ some output processing may assume ref names in UTF-8.
 object that exists, without requiring 'rev' to be a tag, and
 without dereferencing 'rev'; because a tag is already an object,
 it does not have to be dereferenced even once to get to an object.
++
+'rev{caret}\{tag\}' can be used to ensure that 'rev' identifies an
+existing tag object.
 
 '<rev>{caret}\{\}', e.g. 'v0.99.8{caret}\{\}'::
   A suffix '{caret}' followed by an empty brace pair
index 71c19581daccffc87e5128c61d9adfae0be3e7de..1e46a4f50e16f059fa768cecc4c8331a88997021 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -624,7 +624,7 @@ static void bisect_common(struct rev_info *revs)
        if (prepare_revision_walk(revs))
                die("revision walk setup failed");
        if (revs->tree_objects)
-               mark_edges_uninteresting(revs->commits, revs, NULL);
+               mark_edges_uninteresting(revs, NULL);
 }
 
 static void exit_if_skipped_commits(struct commit_list *tried,
index 546c4b44060a3eddec3124379030bdb068d637d6..9e6c68edaf90f27cf447ad1522da6d7de7827141 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -203,8 +203,7 @@ static int check_tracking_branch(struct remote *remote, void *cb_data)
        struct refspec query;
        memset(&query, 0, sizeof(struct refspec));
        query.dst = tracking_branch;
-       return !(remote_find_tracking(remote, &query) ||
-                prefixcmp(query.src, "refs/heads/"));
+       return !remote_find_tracking(remote, &query);
 }
 
 static int validate_remote_tracking_branch(char *ref)
@@ -291,7 +290,7 @@ void create_branch(const char *head,
        hashcpy(sha1, commit->object.sha1);
 
        if (!dont_change_ref) {
-               lock = lock_any_ref_for_update(ref.buf, NULL, 0);
+               lock = lock_any_ref_for_update(ref.buf, NULL, 0, NULL);
                if (!lock)
                        die_errno(_("Failed to lock ref for update"));
        }
index 0903763702a436dc8b3ffc89aa64b2598e257446..ad0f86de540dc394199f71c03665d0cd76371c35 100644 (file)
@@ -423,19 +423,19 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
        char *ref = NULL;
        struct branch *branch = branch_get(branch_name);
        struct strbuf fancy = STRBUF_INIT;
+       int upstream_is_gone = 0;
 
-       if (!stat_tracking_info(branch, &ours, &theirs)) {
-               if (branch && branch->merge && branch->merge[0]->dst &&
-                   show_upstream_ref) {
-                       ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
-                       if (want_color(branch_use_color))
-                               strbuf_addf(stat, "[%s%s%s] ",
-                                               branch_get_color(BRANCH_COLOR_UPSTREAM),
-                                               ref, branch_get_color(BRANCH_COLOR_RESET));
-                       else
-                               strbuf_addf(stat, "[%s] ", ref);
-               }
+       switch (stat_tracking_info(branch, &ours, &theirs)) {
+       case 0:
+               /* no base */
                return;
+       case -1:
+               /* with "gone" base */
+               upstream_is_gone = 1;
+               break;
+       default:
+               /* with base */
+               break;
        }
 
        if (show_upstream_ref) {
@@ -448,19 +448,25 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
                        strbuf_addstr(&fancy, ref);
        }
 
-       if (!ours) {
-               if (ref)
+       if (upstream_is_gone) {
+               if (show_upstream_ref)
+                       strbuf_addf(stat, _("[%s: gone]"), fancy.buf);
+       } else if (!ours && !theirs) {
+               if (show_upstream_ref)
+                       strbuf_addf(stat, _("[%s]"), fancy.buf);
+       } else if (!ours) {
+               if (show_upstream_ref)
                        strbuf_addf(stat, _("[%s: behind %d]"), fancy.buf, theirs);
                else
                        strbuf_addf(stat, _("[behind %d]"), theirs);
 
        } else if (!theirs) {
-               if (ref)
+               if (show_upstream_ref)
                        strbuf_addf(stat, _("[%s: ahead %d]"), fancy.buf, ours);
                else
                        strbuf_addf(stat, _("[ahead %d]"), ours);
        } else {
-               if (ref)
+               if (show_upstream_ref)
                        strbuf_addf(stat, _("[%s: ahead %d, behind %d]"),
                                    fancy.buf, ours, theirs);
                else
index e2a1cef6843b7db2f7ffb4b9c89003397948c748..594463a11bcba3cf99748ccdaeb055bd79283ddd 100644 (file)
@@ -5,7 +5,7 @@
 #include "pathspec.h"
 #include "parse-options.h"
 
-static int quiet, verbose, stdin_paths, show_non_matching;
+static int quiet, verbose, stdin_paths, show_non_matching, no_index;
 static const char * const check_ignore_usage[] = {
 "git check-ignore [options] pathname...",
 "git check-ignore [options] --stdin < <list-of-paths>",
@@ -24,6 +24,8 @@ static const struct option check_ignore_options[] = {
                 N_("terminate input and output records by a NUL character")),
        OPT_BOOL('n', "non-matching", &show_non_matching,
                 N_("show non-matching input paths")),
+       OPT_BOOL(0, "no-index", &no_index,
+                N_("ignore index when checking")),
        OPT_END()
 };
 
@@ -166,7 +168,7 @@ int cmd_check_ignore(int argc, const char **argv, const char *prefix)
                die(_("--non-matching is only valid with --verbose"));
 
        /* read_cache() is only necessary so we can watch out for submodules. */
-       if (read_cache() < 0)
+       if (!no_index && read_cache() < 0)
                die(_("index file corrupt"));
 
        memset(&dir, 0, sizeof(dir));
index ca3eb68d72b0ab9ee683eff3206d28012f27c4fc..0aff974a64c9cbb035f77c82b22d35c8249fcf1f 100644 (file)
@@ -556,7 +556,7 @@ static void update_remote_refs(const struct ref *refs,
                                                              0, &rm, transport))
                        die(_("remote did not send all necessary objects"));
                if (0 <= option_verbosity)
-                       printf(_("done\n"));
+                       printf(_("done.\n"));
        }
 
        if (refs) {
index 084d70fd4da5d38196cbde1f692bd2d70c0c3800..6ab4605cf5c2e6ef5efb37518c9c215bf8895f97 100644 (file)
@@ -164,6 +164,15 @@ static void determine_whence(struct wt_status *s)
                s->whence = whence;
 }
 
+static void status_init_config(struct wt_status *s, config_fn_t fn)
+{
+       wt_status_prepare(s);
+       gitmodules_config();
+       git_config(fn, s);
+       determine_whence(s);
+       s->hints = advice_status_hints; /* must come after git_config() */
+}
+
 static void rollback_index_files(void)
 {
        switch (commit_style) {
@@ -598,6 +607,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
        const char *hook_arg2 = NULL;
        int ident_shown = 0;
        int clean_message_contents = (cleanup_mode != CLEANUP_NONE);
+       int old_display_comment_prefix;
 
        /* This checks and barfs if author is badly specified */
        determine_author_info(author_ident);
@@ -695,6 +705,16 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
        if (s->fp == NULL)
                die_errno(_("could not open '%s'"), git_path(commit_editmsg));
 
+       /* Ignore status.displayCommentPrefix: we do need comments in COMMIT_EDITMSG. */
+       old_display_comment_prefix = s->display_comment_prefix;
+       s->display_comment_prefix = 1;
+
+       /*
+        * Most hints are counter-productive when the commit has
+        * already started.
+        */
+       s->hints = 0;
+
        if (clean_message_contents)
                stripspace(&sb, 0);
 
@@ -820,6 +840,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
         */
        if (!commitable && whence != FROM_MERGE && !allow_empty &&
            !(amend && is_a_merge(current_head))) {
+               s->display_comment_prefix = old_display_comment_prefix;
                run_status(stdout, index_file, prefix, 0, s);
                if (amend)
                        fputs(_(empty_amend_advice), stderr);
@@ -1186,6 +1207,10 @@ static int git_status_config(const char *k, const char *v, void *cb)
                s->use_color = git_config_colorbool(k, v);
                return 0;
        }
+       if (!strcmp(k, "status.displaycommentprefix")) {
+               s->display_comment_prefix = git_config_bool(k, v);
+               return 0;
+       }
        if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
                int slot = parse_status_slot(k, 13);
                if (slot < 0)
@@ -1250,10 +1275,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
        if (argc == 2 && !strcmp(argv[1], "-h"))
                usage_with_options(builtin_status_usage, builtin_status_options);
 
-       wt_status_prepare(&s);
-       gitmodules_config();
-       git_config(git_status_config, &s);
-       determine_whence(&s);
+       status_init_config(&s, git_status_config);
        argc = parse_options(argc, argv, prefix,
                             builtin_status_options,
                             builtin_status_usage, 0);
@@ -1495,11 +1517,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        if (argc == 2 && !strcmp(argv[1], "-h"))
                usage_with_options(builtin_commit_usage, builtin_commit_options);
 
-       wt_status_prepare(&s);
-       gitmodules_config();
-       git_config(git_commit_config, &s);
+       status_init_config(&s, git_commit_config);
        status_format = STATUS_FORMAT_NONE; /* Ignore status.short */
-       determine_whence(&s);
        s.colopts = 0;
 
        if (get_sha1("HEAD", sha1))
@@ -1621,7 +1640,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                                           !current_head
                                           ? NULL
                                           : current_head->object.sha1,
-                                          0);
+                                          0, NULL);
 
        nl = strchr(sb.buf, '\n');
        if (nl)
index 9e654efa3bb725edd91f6eb7059b263668e622bc..bd7a10164f4fed8aeb6e8148e2ae8c0a793e7ee0 100644 (file)
@@ -262,7 +262,8 @@ static int s_update_ref(const char *action,
                rla = default_rla.buf;
        snprintf(msg, sizeof(msg), "%s: %s", rla, action);
        lock = lock_any_ref_for_update(ref->name,
-                                      check_old ? ref->old_sha1 : NULL, 0);
+                                      check_old ? ref->old_sha1 : NULL,
+                                      0, NULL);
        if (!lock)
                return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT :
                                          STORE_REF_ERROR_OTHER;
index 4eb0521c815870abb670e8ddb035caa9c6507e67..e86cd5729f38316bf6e304e4e97ce671e4ea135b 100644 (file)
@@ -2378,7 +2378,7 @@ static void get_object_list(int ac, const char **av)
 
        if (prepare_revision_walk(&revs))
                die("revision walk setup failed");
-       mark_edges_uninteresting(revs.commits, &revs, show_edge);
+       mark_edges_uninteresting(&revs, show_edge);
        traverse_commit_list(&revs, show_commit, show_object, NULL);
 
        if (keep_unreachable)
index b7e71a04f61798ed72282f683a6fcd3c156007ab..67ce1ef105d1494e7905e66750b14676e082e11c 100644 (file)
@@ -526,7 +526,8 @@ static const char *update(struct command *cmd)
                return NULL; /* good */
        }
        else {
-               lock = lock_any_ref_for_update(namespaced_name, old_sha1, 0);
+               lock = lock_any_ref_for_update(namespaced_name, old_sha1,
+                                              0, NULL);
                if (!lock) {
                        rp_error("failed to lock %s", name);
                        return "failed to lock";
index ba27f7cc614214eb32f60b684b3617c39a0066ef..6eb24c8da27d265cad38628aeaa3e040dd298aab 100644 (file)
@@ -365,7 +365,7 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
         * we take the lock for the ref itself to prevent it from
         * getting updated.
         */
-       lock = lock_any_ref_for_update(ref, sha1, 0);
+       lock = lock_any_ref_for_update(ref, sha1, 0, NULL);
        if (!lock)
                return error("cannot lock ref '%s'", ref);
        log_file = git_pathdup("logs/%s", ref);
index 11b0a55ae7f6e3d1a04eeb4026b151144d0315ba..301b45ce6a453c472566278521bb51fcbd91ee10 100644 (file)
@@ -105,7 +105,7 @@ static int replace_object(const char *object_ref, const char *replace_ref,
        else if (!force)
                die("replace ref '%s' already exists", ref);
 
-       lock = lock_any_ref_for_update(ref, prev, 0);
+       lock = lock_any_ref_for_update(ref, prev, 0, NULL);
        if (!lock)
                die("%s: cannot lock the ref", ref);
        if (write_ref_sha1(lock, repl, NULL) < 0)
index 088ccffba07a4227150290492f22dc3bbac56fdc..1a5344877212e675d685055a631aba2ac0a4c661 100644 (file)
@@ -226,7 +226,7 @@ static void parse_args(struct pathspec *pathspec,
                       prefix, argv);
 }
 
-static int update_refs(const char *rev, const unsigned char *sha1)
+static int reset_refs(const char *rev, const unsigned char *sha1)
 {
        int update_ref_status;
        struct strbuf msg = STRBUF_INIT;
@@ -354,7 +354,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
        if (!pathspec.nr && !unborn) {
                /* Any resets without paths update HEAD to the head being
                 * switched to, saving the previous head in ORIG_HEAD before. */
-               update_ref_status = update_refs(rev, sha1);
+               update_ref_status = reset_refs(rev, sha1);
 
                if (reset_type == HARD && !update_ref_status && !quiet)
                        print_new_head_line(lookup_commit_reference(sha1));
index a5ec30d74ee1945ddaf99c89307e59aec714714a..4fc16166374b86927e605ccbfe341aebe0e3240f 100644 (file)
@@ -336,7 +336,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
        if (prepare_revision_walk(&revs))
                die("revision walk setup failed");
        if (revs.tree_objects)
-               mark_edges_uninteresting(revs.commits, &revs, show_edge);
+               mark_edges_uninteresting(&revs, show_edge);
 
        if (bisect_list) {
                int reaches = reaches, all = all;
index 8e87acd12e622957df6bc0a93903898361149f91..52c35e75d90dc07f6a80362f200212e314a14ec8 100644 (file)
@@ -202,6 +202,8 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
        memset(&opts, 0, sizeof(opts));
        opts.action = REPLAY_PICK;
        git_config(git_default_config, NULL);
+       if (!strcmp(argv[1], "-"))
+               argv[1] = "@{-1}";
        parse_args(argc, argv, &opts);
        res = sequencer_pick_revisions(&opts);
        if (res < 0)
index e981dfb9f088cbbfdfb199700a6de17758bf1eca..1259ed708b6b5dd1322b6db5683cf5555f41570f 100644 (file)
@@ -89,11 +89,11 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)
 
        if (argc == 2) {
                if (!strcmp(argv[1], "-s") ||
-                       !strcmp(argv[1], "--strip-comments")) {
-                        strip_comments = 1;
+                   !strcmp(argv[1], "--strip-comments")) {
+                       strip_comments = 1;
                } else if (!strcmp(argv[1], "-c") ||
-                                        !strcmp(argv[1], "--comment-lines")) {
-                        mode = COMMENT_LINES;
+                          !strcmp(argv[1], "--comment-lines")) {
+                       mode = COMMENT_LINES;
                } else {
                        mode = INVAL;
                }
index b577af562a4a554f43c64256e112fcbc423edd3d..ea55f1d1bdd524abd46e6baa7a02ef85d56d5eb2 100644 (file)
@@ -574,7 +574,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
        if (annotate)
                create_tag(object, tag, &buf, &opt, prev, object);
 
-       lock = lock_any_ref_for_update(ref.buf, prev, 0);
+       lock = lock_any_ref_for_update(ref.buf, prev, 0, NULL);
        if (!lock)
                die(_("%s: cannot lock the ref"), ref.buf);
        if (write_ref_sha1(lock, object, NULL) < 0)
index 7484d36a65ba1f722f2dda33473bf509f30727c9..702e90db2a82a0eba2ff233b9ec46690da5afc3e 100644 (file)
 #include "refs.h"
 #include "builtin.h"
 #include "parse-options.h"
+#include "quote.h"
+#include "argv-array.h"
 
 static const char * const git_update_ref_usage[] = {
        N_("git update-ref [options] -d <refname> [<oldval>]"),
        N_("git update-ref [options]    <refname> <newval> [<oldval>]"),
+       N_("git update-ref [options] --stdin [-z]"),
        NULL
 };
 
+static int updates_alloc;
+static int updates_count;
+static const struct ref_update **updates;
+
+static char line_termination = '\n';
+static int update_flags;
+
+static struct ref_update *update_alloc(void)
+{
+       struct ref_update *update;
+
+       /* Allocate and zero-init a struct ref_update */
+       update = xcalloc(1, sizeof(*update));
+       ALLOC_GROW(updates, updates_count + 1, updates_alloc);
+       updates[updates_count++] = update;
+
+       /* Store and reset accumulated options */
+       update->flags = update_flags;
+       update_flags = 0;
+
+       return update;
+}
+
+static void update_store_ref_name(struct ref_update *update,
+                                 const char *ref_name)
+{
+       if (check_refname_format(ref_name, REFNAME_ALLOW_ONELEVEL))
+               die("invalid ref format: %s", ref_name);
+       update->ref_name = xstrdup(ref_name);
+}
+
+static void update_store_new_sha1(struct ref_update *update,
+                                 const char *newvalue)
+{
+       if (*newvalue && get_sha1(newvalue, update->new_sha1))
+               die("invalid new value for ref %s: %s",
+                   update->ref_name, newvalue);
+}
+
+static void update_store_old_sha1(struct ref_update *update,
+                                 const char *oldvalue)
+{
+       if (*oldvalue && get_sha1(oldvalue, update->old_sha1))
+               die("invalid old value for ref %s: %s",
+                   update->ref_name, oldvalue);
+
+       /* We have an old value if non-empty, or if empty without -z */
+       update->have_old = *oldvalue || line_termination;
+}
+
+static const char *parse_arg(const char *next, struct strbuf *arg)
+{
+       /* Parse SP-terminated, possibly C-quoted argument */
+       if (*next != '"')
+               while (*next && !isspace(*next))
+                       strbuf_addch(arg, *next++);
+       else if (unquote_c_style(arg, next, &next))
+               die("badly quoted argument: %s", next);
+
+       /* Return position after the argument */
+       return next;
+}
+
+static const char *parse_first_arg(const char *next, struct strbuf *arg)
+{
+       /* Parse argument immediately after "command SP" */
+       strbuf_reset(arg);
+       if (line_termination) {
+               /* Without -z, use the next argument */
+               next = parse_arg(next, arg);
+       } else {
+               /* With -z, use rest of first NUL-terminated line */
+               strbuf_addstr(arg, next);
+               next = next + arg->len;
+       }
+       return next;
+}
+
+static const char *parse_next_arg(const char *next, struct strbuf *arg)
+{
+       /* Parse next SP-terminated or NUL-terminated argument, if any */
+       strbuf_reset(arg);
+       if (line_termination) {
+               /* Without -z, consume SP and use next argument */
+               if (!*next)
+                       return NULL;
+               if (*next != ' ')
+                       die("expected SP but got: %s", next);
+               next = parse_arg(next + 1, arg);
+       } else {
+               /* With -z, read the next NUL-terminated line */
+               if (*next)
+                       die("expected NUL but got: %s", next);
+               if (strbuf_getline(arg, stdin, '\0') == EOF)
+                       return NULL;
+               next = arg->buf + arg->len;
+       }
+       return next;
+}
+
+static void parse_cmd_update(const char *next)
+{
+       struct strbuf ref = STRBUF_INIT;
+       struct strbuf newvalue = STRBUF_INIT;
+       struct strbuf oldvalue = STRBUF_INIT;
+       struct ref_update *update;
+
+       update = update_alloc();
+
+       if ((next = parse_first_arg(next, &ref)) != NULL && ref.buf[0])
+               update_store_ref_name(update, ref.buf);
+       else
+               die("update line missing <ref>");
+
+       if ((next = parse_next_arg(next, &newvalue)) != NULL)
+               update_store_new_sha1(update, newvalue.buf);
+       else
+               die("update %s missing <newvalue>", ref.buf);
+
+       if ((next = parse_next_arg(next, &oldvalue)) != NULL)
+               update_store_old_sha1(update, oldvalue.buf);
+       else if(!line_termination)
+               die("update %s missing [<oldvalue>] NUL", ref.buf);
+
+       if (next && *next)
+               die("update %s has extra input: %s", ref.buf, next);
+}
+
+static void parse_cmd_create(const char *next)
+{
+       struct strbuf ref = STRBUF_INIT;
+       struct strbuf newvalue = STRBUF_INIT;
+       struct ref_update *update;
+
+       update = update_alloc();
+
+       if ((next = parse_first_arg(next, &ref)) != NULL && ref.buf[0])
+               update_store_ref_name(update, ref.buf);
+       else
+               die("create line missing <ref>");
+
+       if ((next = parse_next_arg(next, &newvalue)) != NULL)
+               update_store_new_sha1(update, newvalue.buf);
+       else
+               die("create %s missing <newvalue>", ref.buf);
+       if (is_null_sha1(update->new_sha1))
+               die("create %s given zero new value", ref.buf);
+
+       if (next && *next)
+               die("create %s has extra input: %s", ref.buf, next);
+}
+
+static void parse_cmd_delete(const char *next)
+{
+       struct strbuf ref = STRBUF_INIT;
+       struct strbuf oldvalue = STRBUF_INIT;
+       struct ref_update *update;
+
+       update = update_alloc();
+
+       if ((next = parse_first_arg(next, &ref)) != NULL && ref.buf[0])
+               update_store_ref_name(update, ref.buf);
+       else
+               die("delete line missing <ref>");
+
+       if ((next = parse_next_arg(next, &oldvalue)) != NULL)
+               update_store_old_sha1(update, oldvalue.buf);
+       else if(!line_termination)
+               die("delete %s missing [<oldvalue>] NUL", ref.buf);
+       if (update->have_old && is_null_sha1(update->old_sha1))
+               die("delete %s given zero old value", ref.buf);
+
+       if (next && *next)
+               die("delete %s has extra input: %s", ref.buf, next);
+}
+
+static void parse_cmd_verify(const char *next)
+{
+       struct strbuf ref = STRBUF_INIT;
+       struct strbuf value = STRBUF_INIT;
+       struct ref_update *update;
+
+       update = update_alloc();
+
+       if ((next = parse_first_arg(next, &ref)) != NULL && ref.buf[0])
+               update_store_ref_name(update, ref.buf);
+       else
+               die("verify line missing <ref>");
+
+       if ((next = parse_next_arg(next, &value)) != NULL) {
+               update_store_old_sha1(update, value.buf);
+               update_store_new_sha1(update, value.buf);
+       } else if(!line_termination)
+               die("verify %s missing [<oldvalue>] NUL", ref.buf);
+
+       if (next && *next)
+               die("verify %s has extra input: %s", ref.buf, next);
+}
+
+static void parse_cmd_option(const char *next)
+{
+       if (!strcmp(next, "no-deref"))
+               update_flags |= REF_NODEREF;
+       else
+               die("option unknown: %s", next);
+}
+
+static void update_refs_stdin(void)
+{
+       struct strbuf cmd = STRBUF_INIT;
+
+       /* Read each line dispatch its command */
+       while (strbuf_getline(&cmd, stdin, line_termination) != EOF)
+               if (!cmd.buf[0])
+                       die("empty command in input");
+               else if (isspace(*cmd.buf))
+                       die("whitespace before command: %s", cmd.buf);
+               else if (!prefixcmp(cmd.buf, "update "))
+                       parse_cmd_update(cmd.buf + 7);
+               else if (!prefixcmp(cmd.buf, "create "))
+                       parse_cmd_create(cmd.buf + 7);
+               else if (!prefixcmp(cmd.buf, "delete "))
+                       parse_cmd_delete(cmd.buf + 7);
+               else if (!prefixcmp(cmd.buf, "verify "))
+                       parse_cmd_verify(cmd.buf + 7);
+               else if (!prefixcmp(cmd.buf, "option "))
+                       parse_cmd_option(cmd.buf + 7);
+               else
+                       die("unknown command: %s", cmd.buf);
+
+       strbuf_release(&cmd);
+}
+
 int cmd_update_ref(int argc, const char **argv, const char *prefix)
 {
        const char *refname, *oldval, *msg = NULL;
        unsigned char sha1[20], oldsha1[20];
-       int delete = 0, no_deref = 0, flags = 0;
+       int delete = 0, no_deref = 0, read_stdin = 0, end_null = 0, flags = 0;
        struct option options[] = {
                OPT_STRING( 'm', NULL, &msg, N_("reason"), N_("reason of the update")),
                OPT_BOOL('d', NULL, &delete, N_("delete the reference")),
                OPT_BOOL( 0 , "no-deref", &no_deref,
                                        N_("update <refname> not the one it points to")),
+               OPT_BOOL('z', NULL, &end_null, N_("stdin has NUL-terminated arguments")),
+               OPT_BOOL( 0 , "stdin", &read_stdin, N_("read updates from stdin")),
                OPT_END(),
        };
 
@@ -28,6 +266,18 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
        if (msg && !*msg)
                die("Refusing to perform update with empty message.");
 
+       if (read_stdin) {
+               if (delete || no_deref || argc > 0)
+                       usage_with_options(git_update_ref_usage, options);
+               if (end_null)
+                       line_termination = '\0';
+               update_refs_stdin();
+               return update_refs(msg, updates, updates_count, DIE_ON_ERR);
+       }
+
+       if (end_null)
+               usage_with_options(git_update_ref_usage, options);
+
        if (delete) {
                if (argc < 1 || argc > 2)
                        usage_with_options(git_update_ref_usage, options);
diff --git a/cache.h b/cache.h
index a47b9c03036d41e8067a843dda305bc9b6161255..51d6602cd9da8f8da6b5176ea352574bcc7036f5 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -880,7 +880,7 @@ extern char *resolve_refdup(const char *ref, unsigned char *sha1, int reading, i
 
 extern int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref);
 extern int dwim_log(const char *str, int len, unsigned char *sha1, char **ref);
-extern int interpret_branch_name(const char *str, struct strbuf *);
+extern int interpret_branch_name(const char *str, int len, struct strbuf *);
 extern int get_sha1_mb(const char *str, unsigned char *sha1);
 
 extern int refname_match(const char *abbrev_name, const char *full_name, const char **rules);
index 90a5a3c361e02cd7a9562eff2ca1b15f77be0941..bd841f4d0c5e2b7fb8e83d55ba0d0b7e2839bf8a 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -201,6 +201,10 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads,
                int depth, int shallow_flag, int not_shallow_flag);
 extern void check_shallow_file_for_update(void);
 extern void set_alternate_shallow_file(const char *path);
+extern int write_shallow_commits(struct strbuf *out, int use_pack_protocol);
+extern void setup_alternate_shallow(struct lock_file *shallow_lock,
+                                   const char **alternate_shallow_file);
+extern char *setup_temporary_shallow(void);
 
 int is_descendant_of(struct commit *, struct commit_list *);
 int in_merge_bases(struct commit *, struct commit *);
index bd0a88bc1d19583b7dfed36fd8f7a7af7f386296..9eb3b17ff071a724c269978bb6f4e3272238216c 100644 (file)
@@ -322,6 +322,7 @@ static inline char *mingw_find_last_dir_sep(const char *path)
 #define find_last_dir_sep mingw_find_last_dir_sep
 #define PATH_SEP ';'
 #define PRIuMAX "I64u"
+#define PRId64 "I64d"
 
 void mingw_open_html(const char *path);
 #define open_html mingw_open_html
index fb6429b64be3cf7011ce69950987a8b328e0e758..428cc1a9a1367e36c2739cb226a0ffdd2704ce82 100755 (executable)
@@ -181,6 +181,10 @@ if (@rev_args) {
        scan_rev_args(\%sources, \@rev_args)
 }
 
+my $toplevel = `git rev-parse --show-toplevel`;
+chomp $toplevel;
+chdir($toplevel) or die "chdir failure: $toplevel: $!\n";
+
 my %commits;
 blame_sources(\%sources, \%commits);
 import_commits(\%commits);
index c9a4805ec1f0d5767af7a5f27428db5a02fa94a1..476e0a2bc02d0708e01c63f6e0fc524a840d4c77 100755 (executable)
@@ -625,6 +625,9 @@ sub fetch_mw_revisions_for_page {
                rvstartid => $fetch_from,
                rvlimit => 500,
                pageids => $id,
+
+               # Let MediaWiki know that we support the latest API.
+               continue => '',
        };
 
        my $revnum = 0;
@@ -640,8 +643,15 @@ sub fetch_mw_revisions_for_page {
                        push(@page_revs, $page_rev_ids);
                        $revnum++;
                }
-               last if (!$result->{'query-continue'});
-               $query->{rvstartid} = $result->{'query-continue'}->{revisions}->{rvstartid};
+
+               if ($result->{'query-continue'}) { # For legacy APIs
+                       $query->{rvstartid} = $result->{'query-continue'}->{revisions}->{rvstartid};
+               } elsif ($result->{continue}) { # For newer APIs
+                       $query->{rvstartid} = $result->{continue}->{rvcontinue};
+                       $query->{continue} = $result->{continue}->{continue};
+               } else {
+                       last;
+               }
        }
        if ($shallow_import && @page_revs) {
                print {*STDERR} "  Found 1 revision (shallow import).\n";
diff --git a/contrib/mw-to-git/t/t9365-continuing-queries.sh b/contrib/mw-to-git/t/t9365-continuing-queries.sh
new file mode 100755 (executable)
index 0000000..27e267f
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+test_description='Test the Git Mediawiki remote helper: queries w/ more than 500 results'
+
+. ./test-gitmw-lib.sh
+. $TEST_DIRECTORY/test-lib.sh
+
+test_check_precond
+
+test_expect_success 'creating page w/ >500 revisions' '
+       wiki_reset &&
+       for i in `test_seq 501`
+       do
+               echo "creating revision $i" &&
+               wiki_editpage foo "revision $i<br/>" true
+       done
+'
+
+test_expect_success 'cloning page w/ >500 revisions' '
+       git clone mediawiki::'"$WIKI_URL"' mw_dir
+'
+
+test_done
index 1e0044b69fc5c87ec03833b6fb1bf434a9e0acc0..054161ae21b0c884d314c984992a6c7aa8276a96 100755 (executable)
 # or
 # % git clone bzr::lp:myrepo
 #
-# If you want to specify which branches you want track (per repo):
-# git config remote-bzr.branches 'trunk, devel, test'
+# If you want to specify which branches you want to track (per repo):
+# % git config remote.origin.bzr-branches 'trunk, devel, test'
+#
+# Where 'origin' is the name of the repository you want to specify the
+# branches.
 #
 
 import sys
@@ -168,17 +171,16 @@ class Parser:
         if not m:
             return None
         _, name, email, date, tz = m.groups()
+        name = name.decode('utf-8')
         committer = '%s <%s>' % (name, email)
         tz = int(tz)
         tz = ((tz / 100) * 3600) + ((tz % 100) * 60)
         return (committer, int(date), tz)
 
 def rev_to_mark(rev):
-    global marks
     return marks.from_rev(rev)
 
 def mark_to_rev(mark):
-    global marks
     return marks.to_rev(mark)
 
 def fixup_user(user):
@@ -233,8 +235,6 @@ def get_filechanges(cur, prev):
     return modified, removed
 
 def export_files(tree, files):
-    global marks, filenodes
-
     final = []
     for path, fid in files.iteritems():
         kind = tree.kind(fid)
@@ -276,8 +276,6 @@ def export_files(tree, files):
     return final
 
 def export_branch(repo, name):
-    global prefix
-
     ref = '%s/heads/%s' % (prefix, name)
     tip = marks.get_tip(name)
 
@@ -378,16 +376,12 @@ def export_branch(repo, name):
     marks.set_tip(name, revid)
 
 def export_tag(repo, name):
-    global tags, prefix
-
     ref = '%s/tags/%s' % (prefix, name)
     print "reset %s" % ref
     print "from :%u" % rev_to_mark(tags[name])
     print
 
 def do_import(parser):
-    global dirname
-
     repo = parser.repo
     path = os.path.join(dirname, 'marks-git')
 
@@ -413,8 +407,6 @@ def do_import(parser):
     sys.stdout.flush()
 
 def parse_blob(parser):
-    global blob_marks
-
     parser.next()
     mark = parser.get_mark()
     parser.next()
@@ -425,8 +417,6 @@ def parse_blob(parser):
 class CustomTree():
 
     def __init__(self, branch, revid, parents, files):
-        global files_cache
-
         self.updates = {}
         self.branch = branch
 
@@ -484,7 +474,7 @@ class CustomTree():
             add_entry(fid, dirname, 'directory')
             return fid
 
-        def add_entry(fid, path, kind, mode = None):
+        def add_entry(fid, path, kind, mode=None):
             dirname, basename = os.path.split(path)
             parent_fid = get_parent(dirname, basename)
 
@@ -505,7 +495,7 @@ class CustomTree():
             self.files[path] = [change[0], None]
             changes.append(change)
 
-        def update_entry(fid, path, kind, mode = None):
+        def update_entry(fid, path, kind, mode=None):
             dirname, basename = os.path.split(path)
             parent_fid = get_parent(dirname, basename)
 
@@ -583,9 +573,6 @@ def c_style_unescape(string):
     return string
 
 def parse_commit(parser):
-    global marks, blob_marks, parsed_refs
-    global mode
-
     parents = []
 
     ref = parser[1]
@@ -657,8 +644,6 @@ def parse_commit(parser):
     marks.new_mark(revid, commit_mark)
 
 def parse_reset(parser):
-    global parsed_refs
-
     ref = parser[1]
     parser.next()
 
@@ -674,8 +659,6 @@ def parse_reset(parser):
     parsed_refs[ref] = mark_to_rev(from_mark)
 
 def do_export(parser):
-    global parsed_refs, dirname, transports
-
     parser.next()
 
     for line in parser.each_block('done'):
@@ -725,8 +708,6 @@ def do_export(parser):
     print
 
 def do_capabilities(parser):
-    global dirname
-
     print "import"
     print "export"
     print "refspec refs/heads/*:%s/heads/*" % prefix
@@ -744,8 +725,6 @@ def ref_is_valid(name):
     return not True in [c in name for c in '~^: \\']
 
 def do_list(parser):
-    global tags
-
     master_branch = None
 
     for name in branches:
@@ -770,7 +749,6 @@ def do_list(parser):
     print
 
 def clone(path, remote_branch):
-    global transports
     try:
         bdir = bzrlib.bzrdir.BzrDir.create(path, possible_transports=transports)
     except bzrlib.errors.AlreadyControlDirError:
@@ -780,8 +758,6 @@ def clone(path, remote_branch):
     return remote_branch.sprout(bdir, repository=repo)
 
 def get_remote_branch(name):
-    global dirname, branches, transports
-
     remote_branch = bzrlib.branch.Branch.open(branches[name],
                                               possible_transports=transports)
     if isinstance(remote_branch.user_transport, bzrlib.transport.local.LocalTransport):
@@ -825,8 +801,6 @@ def find_branches(repo):
             yield name, branch.base
 
 def get_repo(url, alias):
-    global dirname, peer, branches, transports
-
     normal_url = bzrlib.urlutils.normalize_url(url)
     origin = bzrlib.bzrdir.BzrDir.open(url, possible_transports=transports)
     is_local = isinstance(origin.transport, bzrlib.transport.local.LocalTransport)
@@ -858,9 +832,13 @@ def get_repo(url, alias):
             except bzrlib.errors.NoRepositoryPresent:
                 pass
 
-    wanted = get_config('remote-bzr.branches').rstrip().split(', ')
+    wanted = get_config('remote.%s.bzr-branches' % alias).rstrip().split(', ')
     # stupid python
     wanted = [e for e in wanted if e]
+    if not wanted:
+        wanted = get_config('remote-bzr.branches').rstrip().split(', ')
+        # stupid python
+        wanted = [e for e in wanted if e]
 
     if not wanted:
         try:
index c27603965ab6970dd71003603d6a77e637a22ab5..92d994e470f05db8536ba443a6afb192be8c2452 100755 (executable)
@@ -23,7 +23,11 @@ import subprocess
 import urllib
 import atexit
 import urlparse, hashlib
+import time as ptime
 
+#
+# If you want to see Mercurial revisions as Git commit notes:
+# git config core.notesRef refs/notes/hg
 #
 # If you are not in hg-git-compat mode and want to disable the tracking of
 # named branches:
@@ -126,6 +130,7 @@ class Marks:
         self.rev_marks = {}
         self.last_mark = 0
         self.version = 0
+        self.last_note = 0
 
     def load(self):
         if not os.path.exists(self.path):
@@ -137,6 +142,7 @@ class Marks:
         self.marks = tmp['marks']
         self.last_mark = tmp['last-mark']
         self.version = tmp.get('version', 1)
+        self.last_note = tmp.get('last-note', 0)
 
         for rev, mark in self.marks.iteritems():
             self.rev_marks[mark] = rev
@@ -150,7 +156,7 @@ class Marks:
         self.version = 2
 
     def dict(self):
-        return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version }
+        return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version, 'last-note' : self.last_note }
 
     def store(self):
         json.dump(self.dict(), open(self.path, 'w'))
@@ -227,8 +233,6 @@ class Parser:
         return sys.stdin.read(size)
 
     def get_author(self):
-        global bad_mail
-
         ex = None
         m = RAW_AUTHOR_RE.match(self.line)
         if not m:
@@ -261,8 +265,6 @@ def fix_file_path(path):
     return os.path.relpath(path, '/')
 
 def export_files(files):
-    global marks, filenodes
-
     final = []
     for f in files:
         fid = node.hex(f.filenode())
@@ -344,8 +346,6 @@ def fixup_user_hg(user):
     return (name, mail)
 
 def fixup_user(user):
-    global mode, bad_mail
-
     if mode == 'git':
         name, mail = fixup_user_git(user)
     else:
@@ -374,7 +374,7 @@ def updatebookmarks(repo, peer):
         bookmarks.write(repo)
 
 def get_repo(url, alias):
-    global dirname, peer
+    global peer
 
     myui = ui.ui()
     myui.setconfig('ui', 'interactive', 'off')
@@ -429,16 +429,12 @@ def get_repo(url, alias):
     return repo
 
 def rev_to_mark(rev):
-    global marks
     return marks.from_rev(rev.hex())
 
 def mark_to_rev(mark):
-    global marks
     return marks.to_rev(mark)
 
 def export_ref(repo, name, kind, head):
-    global prefix, marks, mode
-
     ename = '%s/%s' % (kind, name)
     try:
         tip = marks.get_tip(ename)
@@ -535,6 +531,31 @@ def export_ref(repo, name, kind, head):
     print "from :%u" % rev_to_mark(head)
     print
 
+    pending_revs = set(revs) - notes
+    if pending_revs:
+        note_mark = marks.next_mark()
+        ref = "refs/notes/hg"
+
+        print "commit %s" % ref
+        print "mark :%d" % (note_mark)
+        print "committer remote-hg <> %s" % (ptime.strftime('%s %z'))
+        desc = "Notes for %s\n" % (name)
+        print "data %d" % (len(desc))
+        print desc
+        if marks.last_note:
+            print "from :%u" % marks.last_note
+
+        for rev in pending_revs:
+            notes.add(rev)
+            c = repo[rev]
+            print "N inline :%u" % rev_to_mark(c)
+            msg = c.hex()
+            print "data %d" % (len(msg))
+            print msg
+        print
+
+        marks.last_note = note_mark
+
     marks.set_tip(ename, head.hex())
 
 def export_tag(repo, tag):
@@ -550,12 +571,9 @@ def export_branch(repo, branch):
     export_ref(repo, branch, 'branches', head)
 
 def export_head(repo):
-    global g_head
     export_ref(repo, g_head[0], 'bookmarks', g_head[1])
 
 def do_capabilities(parser):
-    global prefix, dirname
-
     print "import"
     print "export"
     print "refspec refs/heads/branches/*:%s/branches/*" % prefix
@@ -575,8 +593,6 @@ def branch_tip(branch):
     return branches[branch][-1]
 
 def get_branch_tip(repo, branch):
-    global branches
-
     heads = branches.get(hgref(branch), None)
     if not heads:
         return None
@@ -589,7 +605,7 @@ def get_branch_tip(repo, branch):
     return heads[0]
 
 def list_head(repo, cur):
-    global g_head, bmarks, fake_bmark
+    global g_head, fake_bmark
 
     if 'default' not in branches:
         # empty repo
@@ -605,8 +621,6 @@ def list_head(repo, cur):
     g_head = (head, node)
 
 def do_list(parser):
-    global branches, bmarks, track_branches
-
     repo = parser.repo
     for bmark, node in bookmarks.listbookmarks(repo).iteritems():
         bmarks[bmark] = repo[node]
@@ -674,8 +688,6 @@ def do_import(parser):
     print 'done'
 
 def parse_blob(parser):
-    global blob_marks
-
     parser.next()
     mark = parser.get_mark()
     parser.next()
@@ -692,9 +704,6 @@ def get_merge_files(repo, p1, p2, files):
             files[e] = f
 
 def parse_commit(parser):
-    global marks, blob_marks, parsed_refs
-    global mode
-
     from_mark = merge_mark = None
 
     ref = parser[1]
@@ -812,8 +821,6 @@ def parse_commit(parser):
     marks.new_mark(node, commit_mark)
 
 def parse_reset(parser):
-    global parsed_refs
-
     ref = parser[1]
     parser.next()
     # ugh
@@ -1006,8 +1013,6 @@ def check_tip(ref, kind, name, heads):
         return tip in heads
 
 def do_export(parser):
-    global parsed_refs, bmarks, peer
-
     p_bmarks = []
     p_revs = {}
 
@@ -1079,7 +1084,7 @@ def do_export(parser):
             author, msg = parsed_tags.get(tag, (None, None))
             if mode == 'git':
                 if not msg:
-                    msg = 'Added tag %s for changeset %s' % (tag, node[:12]);
+                    msg = 'Added tag %s for changeset %s' % (tag, node[:12])
                 tagnode, branch = write_tag(parser.repo, tag, node, msg, author)
                 p_revs[tagnode] = 'refs/heads/branches/' + gitref(branch)
             else:
@@ -1152,6 +1157,7 @@ def main(args):
     global filenodes
     global fake_bmark, hg_version
     global dry_run
+    global notes, alias
 
     alias = args[1]
     url = args[2]
@@ -1191,6 +1197,7 @@ def main(args):
     except:
         hg_version = None
     dry_run = False
+    notes = set()
 
     repo = get_repo(url, alias)
     prefix = 'refs/hg/%s' % alias
index dce281f91195cde4937b935910ec73f597bb826a..5c5025178370813aabec64c8bfbd7ac59c6186a5 100755 (executable)
@@ -7,19 +7,21 @@ test_description='Test remote-bzr'
 
 . ./test-lib.sh
 
-if ! test_have_prereq PYTHON; then
+if ! test_have_prereq PYTHON
+then
        skip_all='skipping remote-bzr tests; python not available'
        test_done
 fi
 
-if ! python -c 'import bzrlib'; then
+if ! python -c 'import bzrlib'
+then
        skip_all='skipping remote-bzr tests; bzr not available'
        test_done
 fi
 
 check () {
-       echo $3 > expected &&
-       git --git-dir=$1/.git log --format='%s' -1 $2 > actual
+       echo $3 >expected &&
+       git --git-dir=$1/.git log --format='%s' -1 $2 >actual
        test_cmp expected actual
 }
 
@@ -29,7 +31,7 @@ test_expect_success 'cloning' '
        (
        bzr init bzrrepo &&
        cd bzrrepo &&
-       echo one > content &&
+       echo one >content &&
        bzr add content &&
        bzr commit -m one
        ) &&
@@ -41,7 +43,7 @@ test_expect_success 'cloning' '
 test_expect_success 'pulling' '
        (
        cd bzrrepo &&
-       echo two > content &&
+       echo two >content &&
        bzr commit -m two
        ) &&
 
@@ -53,13 +55,13 @@ test_expect_success 'pulling' '
 test_expect_success 'pushing' '
        (
        cd gitrepo &&
-       echo three > content &&
+       echo three >content &&
        git commit -a -m three &&
        git push
        ) &&
 
-       echo three > expected &&
-       cat bzrrepo/content > actual &&
+       echo three >expected &&
+       cat bzrrepo/content >actual &&
        test_cmp expected actual
 '
 
@@ -67,16 +69,16 @@ test_expect_success 'roundtrip' '
        (
        cd gitrepo &&
        git pull &&
-       git log --format="%s" -1 origin/master > actual
+       git log --format="%s" -1 origin/master >actual
        ) &&
-       echo three > expected &&
+       echo three >expected &&
        test_cmp expected actual &&
 
        (cd gitrepo && git push && git pull) &&
 
        (
        cd bzrrepo &&
-       echo four > content &&
+       echo four >content &&
        bzr commit -m four
        ) &&
 
@@ -86,19 +88,19 @@ test_expect_success 'roundtrip' '
 
        (
        cd gitrepo &&
-       echo five > content &&
+       echo five >content &&
        git commit -a -m five &&
        git push && git pull
        ) &&
 
        (cd bzrrepo && bzr revert) &&
 
-       echo five > expected &&
-       cat bzrrepo/content > actual &&
+       echo five >expected &&
+       cat bzrrepo/content >actual &&
        test_cmp expected actual
 '
 
-cat > expected <<EOF
+cat >expected <<\EOF
 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af   content
 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb   executable
 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea   link
@@ -107,7 +109,7 @@ EOF
 test_expect_success 'special modes' '
        (
        cd bzrrepo &&
-       echo exec > executable
+       echo exec >executable
        chmod +x executable &&
        bzr add executable
        bzr commit -m exec &&
@@ -122,21 +124,21 @@ test_expect_success 'special modes' '
        (
        cd gitrepo &&
        git pull
-       git ls-tree HEAD > ../actual
+       git ls-tree HEAD >../actual
        ) &&
 
        test_cmp expected actual &&
 
        (
        cd gitrepo &&
-       git cat-file -p HEAD:link > ../actual
+       git cat-file -p HEAD:link >../actual
        ) &&
 
-       printf content > expected &&
+       printf content >expected &&
        test_cmp expected actual
 '
 
-cat > expected <<EOF
+cat >expected <<\EOF
 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af   content
 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb   executable
 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea   link
@@ -147,8 +149,8 @@ test_expect_success 'moving directory' '
        (
        cd bzrrepo &&
        mkdir movedir &&
-       echo one > movedir/one &&
-       echo two > movedir/two &&
+       echo one >movedir/one &&
+       echo two >movedir/two &&
        bzr add movedir &&
        bzr commit -m movedir &&
        bzr mv movedir movedir-new &&
@@ -158,7 +160,7 @@ test_expect_success 'moving directory' '
        (
        cd gitrepo &&
        git pull &&
-       git ls-tree HEAD > ../actual
+       git ls-tree HEAD >../actual
        ) &&
 
        test_cmp expected actual
@@ -167,7 +169,7 @@ test_expect_success 'moving directory' '
 test_expect_success 'different authors' '
        (
        cd bzrrepo &&
-       echo john >> content &&
+       echo john >>content &&
        bzr commit -m john \
          --author "Jane Rey <jrey@example.com>" \
          --author "John Doe <jdoe@example.com>"
@@ -176,10 +178,10 @@ test_expect_success 'different authors' '
        (
        cd gitrepo &&
        git pull &&
-       git show --format="%an <%ae>, %cn <%ce>" --quiet > ../actual
+       git show --format="%an <%ae>, %cn <%ce>" --quiet >../actual
        ) &&
 
-       echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" > expected &&
+       echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" >expected &&
        test_cmp expected actual
 '
 
@@ -196,12 +198,12 @@ test_expect_success 'fetch utf-8 filenames' '
        bzr init bzrrepo &&
        cd bzrrepo &&
 
-       echo test >> "ærø" &&
+       echo test >>"ærø" &&
        bzr add "ærø" &&
-       echo test >> "ø~?" &&
+       echo test >>"ø~?" &&
        bzr add "ø~?" &&
        bzr commit -m add-utf-8 &&
-       echo test >> "ærø" &&
+       echo test >>"ærø" &&
        bzr commit -m test-utf-8 &&
        bzr rm "ø~?" &&
        bzr mv "ærø" "ø~?" &&
@@ -211,9 +213,9 @@ test_expect_success 'fetch utf-8 filenames' '
        (
        git clone "bzr::bzrrepo" gitrepo &&
        cd gitrepo &&
-       git -c core.quotepath=false ls-files > ../actual
+       git -c core.quotepath=false ls-files >../actual
        ) &&
-       echo "ø~?" > expected &&
+       echo "ø~?" >expected &&
        test_cmp expected actual
 '
 
@@ -229,7 +231,7 @@ test_expect_success 'push utf-8 filenames' '
        bzr init bzrrepo &&
        cd bzrrepo &&
 
-       echo one >> content &&
+       echo one >>content &&
        bzr add content &&
        bzr commit -m one
        ) &&
@@ -238,15 +240,15 @@ test_expect_success 'push utf-8 filenames' '
        git clone "bzr::bzrrepo" gitrepo &&
        cd gitrepo &&
 
-       echo test >> "ærø" &&
+       echo test >>"ærø" &&
        git add "ærø" &&
        git commit -m utf-8 &&
 
        git push
        ) &&
 
-       (cd bzrrepo && bzr ls > ../actual) &&
-       printf "content\nærø\n" > expected &&
+       (cd bzrrepo && bzr ls >../actual) &&
+       printf "content\nærø\n" >expected &&
        test_cmp expected actual
 '
 
@@ -256,7 +258,7 @@ test_expect_success 'pushing a merge' '
        (
        bzr init bzrrepo &&
        cd bzrrepo &&
-       echo one > content &&
+       echo one >content &&
        bzr add content &&
        bzr commit -m one
        ) &&
@@ -265,27 +267,27 @@ test_expect_success 'pushing a merge' '
 
        (
        cd bzrrepo &&
-       echo two > content &&
+       echo two >content &&
        bzr commit -m two
        ) &&
 
        (
        cd gitrepo &&
-       echo three > content &&
+       echo three >content &&
        git commit -a -m three &&
        git fetch &&
        git merge origin/master || true &&
-       echo three > content &&
+       echo three >content &&
        git commit -a --no-edit &&
        git push
        ) &&
 
-       echo three > expected &&
-       cat bzrrepo/content > actual &&
+       echo three >expected &&
+       cat bzrrepo/content >actual &&
        test_cmp expected actual
 '
 
-cat > expected <<EOF
+cat >expected <<\EOF
 origin/HEAD
 origin/branch
 origin/trunk
@@ -299,7 +301,7 @@ test_expect_success 'proper bzr repo' '
        (
        bzr init bzrrepo/trunk &&
        cd bzrrepo/trunk &&
-       echo one >> content &&
+       echo one >>content &&
        bzr add content &&
        bzr commit -m one
        ) &&
@@ -307,14 +309,14 @@ test_expect_success 'proper bzr repo' '
        (
        bzr branch bzrrepo/trunk bzrrepo/branch &&
        cd bzrrepo/branch &&
-       echo two >> content &&
+       echo two >>content &&
        bzr commit -m one
        ) &&
 
        (
        git clone "bzr::bzrrepo" gitrepo &&
        cd gitrepo &&
-       git for-each-ref --format "%(refname:short)" refs/remotes/origin > ../actual
+       git for-each-ref --format "%(refname:short)" refs/remotes/origin >../actual
        ) &&
 
        test_cmp expected actual
@@ -327,11 +329,11 @@ test_expect_success 'strip' '
        bzr init bzrrepo &&
        cd bzrrepo &&
 
-       echo one >> content &&
+       echo one >>content &&
        bzr add content &&
        bzr commit -m one &&
 
-       echo two >> content &&
+       echo two >>content &&
        bzr commit -m two
        ) &&
 
@@ -341,21 +343,51 @@ test_expect_success 'strip' '
        cd bzrrepo &&
        bzr uncommit --force &&
 
-       echo three >> content &&
+       echo three >>content &&
        bzr commit -m three &&
 
-       echo four >> content &&
+       echo four >>content &&
        bzr commit -m four &&
-       bzr log --line | sed -e "s/^[0-9][0-9]*: //" > ../expected
+       bzr log --line | sed -e "s/^[0-9][0-9]*: //" >../expected
        ) &&
 
        (
        cd gitrepo &&
        git fetch &&
-       git log --format="%an %ad %s" --date=short origin/master > ../actual
+       git log --format="%an %ad %s" --date=short origin/master >../actual
        ) &&
 
        test_cmp expected actual
 '
 
+test_expect_success 'export utf-8 authors' '
+       test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C && unset GIT_COMMITTER_NAME" &&
+
+       LC_ALL=en_US.UTF-8
+       export LC_ALL
+
+       GIT_COMMITTER_NAME="Grégoire"
+       export GIT_COMMITTER_NAME
+
+       bzr init bzrrepo &&
+
+       (
+       git init gitrepo &&
+       cd gitrepo &&
+       echo greg >>content &&
+       git add content &&
+       git commit -m one &&
+       git remote add bzr "bzr::../bzrrepo" &&
+       git push bzr
+       ) &&
+
+       (
+       cd bzrrepo &&
+       bzr log | grep "^committer: " >../actual
+       ) &&
+
+       echo "committer: Grégoire <committer@example.com>" >expected &&
+       test_cmp expected actual
+'
+
 test_done
index f83d67d74fc97cb597388ab556d7a31e9d01835b..e24c51daad1038184bd6113ceee77c042dc26f17 100755 (executable)
@@ -10,12 +10,14 @@ test_description='Test bidirectionality of remote-hg'
 
 . ./test-lib.sh
 
-if ! test_have_prereq PYTHON; then
+if ! test_have_prereq PYTHON
+then
        skip_all='skipping remote-hg tests; python not available'
        test_done
 fi
 
-if ! python -c 'import mercurial'; then
+if ! python -c 'import mercurial'
+then
        skip_all='skipping remote-hg tests; mercurial not available'
        test_done
 fi
@@ -43,7 +45,7 @@ hg_push () {
        git checkout -q -b tmp &&
        git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
        git checkout -q @{-1} &&
-       git branch -q -D tmp 2> /dev/null || true
+       git branch -q -D tmp 2>/dev/null || true
        )
 }
 
@@ -62,7 +64,7 @@ setup () {
        echo "tag = -d \"0 0\""
        echo "[extensions]"
        echo "graphlog ="
-       ) >> "$HOME"/.hgrc &&
+       ) >>"$HOME"/.hgrc &&
        git config --global remote-hg.hg-git-compat true
        git config --global remote-hg.track-branches true
 
@@ -81,22 +83,22 @@ test_expect_success 'encoding' '
        git init -q gitrepo &&
        cd gitrepo &&
 
-       echo alpha > alpha &&
+       echo alpha >alpha &&
        git add alpha &&
        git commit -m "add Ã¤lphà" &&
 
        GIT_AUTHOR_NAME="tést Ã¨ncödîng" &&
        export GIT_AUTHOR_NAME &&
-       echo beta > beta &&
+       echo beta >beta &&
        git add beta &&
        git commit -m "add beta" &&
 
-       echo gamma > gamma &&
+       echo gamma >gamma &&
        git add gamma &&
        git commit -m "add gämmâ" &&
 
        : TODO git config i18n.commitencoding latin-1 &&
-       echo delta > delta &&
+       echo delta >delta &&
        git add delta &&
        git commit -m "add déltà"
        ) &&
@@ -105,8 +107,8 @@ test_expect_success 'encoding' '
        git_clone hgrepo gitrepo2 &&
        hg_clone gitrepo2 hgrepo2 &&
 
-       HGENCODING=utf-8 hg_log hgrepo > expected &&
-       HGENCODING=utf-8 hg_log hgrepo2 > actual &&
+       HGENCODING=utf-8 hg_log hgrepo >expected &&
+       HGENCODING=utf-8 hg_log hgrepo2 >actual &&
 
        test_cmp expected actual
 '
@@ -117,14 +119,14 @@ test_expect_success 'file removal' '
        (
        git init -q gitrepo &&
        cd gitrepo &&
-       echo alpha > alpha &&
+       echo alpha >alpha &&
        git add alpha &&
        git commit -m "add alpha" &&
-       echo beta > beta &&
+       echo beta >beta &&
        git add beta &&
        git commit -m "add beta"
        mkdir foo &&
-       echo blah > foo/bar &&
+       echo blah >foo/bar &&
        git add foo &&
        git commit -m "add foo" &&
        git rm alpha &&
@@ -137,8 +139,8 @@ test_expect_success 'file removal' '
        git_clone hgrepo gitrepo2 &&
        hg_clone gitrepo2 hgrepo2 &&
 
-       hg_log hgrepo > expected &&
-       hg_log hgrepo2 > actual &&
+       hg_log hgrepo >expected &&
+       hg_log hgrepo2 >actual &&
 
        test_cmp expected actual
 '
@@ -150,12 +152,12 @@ test_expect_success 'git tags' '
        git init -q gitrepo &&
        cd gitrepo &&
        git config receive.denyCurrentBranch ignore &&
-       echo alpha > alpha &&
+       echo alpha >alpha &&
        git add alpha &&
        git commit -m "add alpha" &&
        git tag alpha &&
 
-       echo beta > beta &&
+       echo beta >beta &&
        git add beta &&
        git commit -m "add beta" &&
        git tag -a -m "added tag beta" beta
@@ -165,8 +167,8 @@ test_expect_success 'git tags' '
        git_clone hgrepo gitrepo2 &&
        hg_clone gitrepo2 hgrepo2 &&
 
-       hg_log hgrepo > expected &&
-       hg_log hgrepo2 > actual &&
+       hg_log hgrepo >expected &&
+       hg_log hgrepo2 >actual &&
 
        test_cmp expected actual
 '
@@ -178,7 +180,7 @@ test_expect_success 'hg branch' '
        git init -q gitrepo &&
        cd gitrepo &&
 
-       echo alpha > alpha &&
+       echo alpha >alpha &&
        git add alpha &&
        git commit -q -m "add alpha" &&
        git checkout -q -b not-master
@@ -201,8 +203,8 @@ test_expect_success 'hg branch' '
        : Back to the common revision &&
        (cd hgrepo && hg checkout default) &&
 
-       hg_log hgrepo > expected &&
-       hg_log hgrepo2 > actual &&
+       hg_log hgrepo >expected &&
+       hg_log hgrepo2 >actual &&
 
        test_cmp expected actual
 '
@@ -214,7 +216,7 @@ test_expect_success 'hg tags' '
        git init -q gitrepo &&
        cd gitrepo &&
 
-       echo alpha > alpha &&
+       echo alpha >alpha &&
        git add alpha &&
        git commit -m "add alpha" &&
        git checkout -q -b not-master
@@ -231,8 +233,8 @@ test_expect_success 'hg tags' '
        hg_push hgrepo gitrepo &&
        hg_clone gitrepo hgrepo2 &&
 
-       hg_log hgrepo > expected &&
-       hg_log hgrepo2 > actual &&
+       hg_log hgrepo >expected &&
+       hg_log hgrepo2 >actual &&
 
        test_cmp expected actual
 '
index 2219284382f0e987423ae00e5bd89e9b7a4b0046..6dcd95d10f618ee3ac4920f5f2ae684c0b8d4d36 100755 (executable)
@@ -10,17 +10,20 @@ test_description='Test remote-hg output compared to hg-git'
 
 . ./test-lib.sh
 
-if ! test_have_prereq PYTHON; then
+if ! test_have_prereq PYTHON
+then
        skip_all='skipping remote-hg tests; python not available'
        test_done
 fi
 
-if ! python -c 'import mercurial'; then
+if ! python -c 'import mercurial'
+then
        skip_all='skipping remote-hg tests; mercurial not available'
        test_done
 fi
 
-if ! python -c 'import hggit'; then
+if ! python -c 'import hggit'
+then
        skip_all='skipping remote-hg tests; hg-git not available'
        test_done
 fi
@@ -66,7 +69,7 @@ hg_push_git () {
        git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
        git branch -D default &&
        git checkout -q @{-1} &&
-       git branch -q -D tmp 2> /dev/null || true
+       git branch -q -D tmp 2>/dev/null || true
        )
 }
 
@@ -100,7 +103,7 @@ setup () {
        echo "hgext.bookmarks ="
        echo "hggit ="
        echo "graphlog ="
-       ) >> "$HOME"/.hgrc &&
+       ) >>"$HOME"/.hgrc &&
        git config --global receive.denycurrentbranch warn
        git config --global remote-hg.hg-git-compat true
        git config --global remote-hg.track-branches false
@@ -121,7 +124,7 @@ test_expect_success 'executable bit' '
        (
        git init -q gitrepo &&
        cd gitrepo &&
-       echo alpha > alpha &&
+       echo alpha >alpha &&
        chmod 0644 alpha &&
        git add alpha &&
        git commit -m "add alpha" &&
@@ -133,17 +136,18 @@ test_expect_success 'executable bit' '
        git commit -m "clear executable bit"
        ) &&
 
-       for x in hg git; do
+       for x in hg git
+       do
                (
                hg_clone_$x gitrepo hgrepo-$x &&
                cd hgrepo-$x &&
                hg_log . &&
                hg manifest -r 1 -v &&
                hg manifest -v
-               ) > output-$x &&
+               ) >"output-$x" &&
 
                git_clone_$x hgrepo-$x gitrepo2-$x &&
-               git_log gitrepo2-$x > log-$x
+               git_log gitrepo2-$x >"log-$x"
        done &&
 
        test_cmp output-hg output-git &&
@@ -156,7 +160,7 @@ test_expect_success 'symlink' '
        (
        git init -q gitrepo &&
        cd gitrepo &&
-       echo alpha > alpha &&
+       echo alpha >alpha &&
        git add alpha &&
        git commit -m "add alpha" &&
        ln -s alpha beta &&
@@ -164,16 +168,17 @@ test_expect_success 'symlink' '
        git commit -m "add beta"
        ) &&
 
-       for x in hg git; do
+       for x in hg git
+       do
                (
                hg_clone_$x gitrepo hgrepo-$x &&
                cd hgrepo-$x &&
                hg_log . &&
                hg manifest -v
-               ) > output-$x &&
+               ) >"output-$x" &&
 
                git_clone_$x hgrepo-$x gitrepo2-$x &&
-               git_log gitrepo2-$x > log-$x
+               git_log gitrepo2-$x >"log-$x"
        done &&
 
        test_cmp output-hg output-git &&
@@ -186,28 +191,29 @@ test_expect_success 'merge conflict 1' '
        (
        hg init hgrepo1 &&
        cd hgrepo1 &&
-       echo A > afile &&
+       echo A >afile &&
        hg add afile &&
        hg ci -m "origin" &&
 
-       echo B > afile &&
+       echo B >afile &&
        hg ci -m "A->B" &&
 
        hg up -r0 &&
-       echo C > afile &&
+       echo C >afile &&
        hg ci -m "A->C" &&
 
        hg merge -r1 &&
-       echo C > afile &&
+       echo C >afile &&
        hg resolve -m afile &&
        hg ci -m "merge to C"
        ) &&
 
-       for x in hg git; do
+       for x in hg git
+       do
                git_clone_$x hgrepo1 gitrepo-$x &&
                hg_clone_$x gitrepo-$x hgrepo2-$x &&
-               hg_log hgrepo2-$x > hg-log-$x &&
-               git_log gitrepo-$x > git-log-$x
+               hg_log hgrepo2-$x >"hg-log-$x" &&
+               git_log gitrepo-$x >"git-log-$x"
        done &&
 
        test_cmp hg-log-hg hg-log-git &&
@@ -220,28 +226,29 @@ test_expect_success 'merge conflict 2' '
        (
        hg init hgrepo1 &&
        cd hgrepo1 &&
-       echo A > afile &&
+       echo A >afile &&
        hg add afile &&
        hg ci -m "origin" &&
 
-       echo B > afile &&
+       echo B >afile &&
        hg ci -m "A->B" &&
 
        hg up -r0 &&
-       echo C > afile &&
+       echo C >afile &&
        hg ci -m "A->C" &&
 
        hg merge -r1 || true &&
-       echo B > afile &&
+       echo B >afile &&
        hg resolve -m afile &&
        hg ci -m "merge to B"
        ) &&
 
-       for x in hg git; do
+       for x in hg git
+       do
                git_clone_$x hgrepo1 gitrepo-$x &&
                hg_clone_$x gitrepo-$x hgrepo2-$x &&
-               hg_log hgrepo2-$x > hg-log-$x &&
-               git_log gitrepo-$x > git-log-$x
+               hg_log hgrepo2-$x >"hg-log-$x" &&
+               git_log gitrepo-$x >"git-log-$x"
        done &&
 
        test_cmp hg-log-hg hg-log-git &&
@@ -254,29 +261,30 @@ test_expect_success 'converged merge' '
        (
        hg init hgrepo1 &&
        cd hgrepo1 &&
-       echo A > afile &&
+       echo A >afile &&
        hg add afile &&
        hg ci -m "origin" &&
 
-       echo B > afile &&
+       echo B >afile &&
        hg ci -m "A->B" &&
 
-       echo C > afile &&
+       echo C >afile &&
        hg ci -m "B->C" &&
 
        hg up -r0 &&
-       echo C > afile &&
+       echo C >afile &&
        hg ci -m "A->C" &&
 
        hg merge -r2 || true &&
        hg ci -m "merge"
        ) &&
 
-       for x in hg git; do
+       for x in hg git
+       do
                git_clone_$x hgrepo1 gitrepo-$x &&
                hg_clone_$x gitrepo-$x hgrepo2-$x &&
-               hg_log hgrepo2-$x > hg-log-$x &&
-               git_log gitrepo-$x > git-log-$x
+               hg_log hgrepo2-$x >"hg-log-$x" &&
+               git_log gitrepo-$x >"git-log-$x"
        done &&
 
        test_cmp hg-log-hg hg-log-git &&
@@ -290,32 +298,33 @@ test_expect_success 'encoding' '
        git init -q gitrepo &&
        cd gitrepo &&
 
-       echo alpha > alpha &&
+       echo alpha >alpha &&
        git add alpha &&
        git commit -m "add Ã¤lphà" &&
 
        GIT_AUTHOR_NAME="tést Ã¨ncödîng" &&
        export GIT_AUTHOR_NAME &&
-       echo beta > beta &&
+       echo beta >beta &&
        git add beta &&
        git commit -m "add beta" &&
 
-       echo gamma > gamma &&
+       echo gamma >gamma &&
        git add gamma &&
        git commit -m "add gämmâ" &&
 
        : TODO git config i18n.commitencoding latin-1 &&
-       echo delta > delta &&
+       echo delta >delta &&
        git add delta &&
        git commit -m "add déltà"
        ) &&
 
-       for x in hg git; do
+       for x in hg git
+       do
                hg_clone_$x gitrepo hgrepo-$x &&
                git_clone_$x hgrepo-$x gitrepo2-$x &&
 
-               HGENCODING=utf-8 hg_log hgrepo-$x > hg-log-$x &&
-               git_log gitrepo2-$x > git-log-$x
+               HGENCODING=utf-8 hg_log hgrepo-$x >"hg-log-$x" &&
+               git_log gitrepo2-$x >"git-log-$x"
        done &&
 
        test_cmp hg-log-hg hg-log-git &&
@@ -328,14 +337,14 @@ test_expect_success 'file removal' '
        (
        git init -q gitrepo &&
        cd gitrepo &&
-       echo alpha > alpha &&
+       echo alpha >alpha &&
        git add alpha &&
        git commit -m "add alpha" &&
-       echo beta > beta &&
+       echo beta >beta &&
        git add beta &&
        git commit -m "add beta"
        mkdir foo &&
-       echo blah > foo/bar &&
+       echo blah >foo/bar &&
        git add foo &&
        git commit -m "add foo" &&
        git rm alpha &&
@@ -344,17 +353,18 @@ test_expect_success 'file removal' '
        git commit -m "remove foo/bar"
        ) &&
 
-       for x in hg git; do
+       for x in hg git
+       do
                (
                hg_clone_$x gitrepo hgrepo-$x &&
                cd hgrepo-$x &&
                hg_log . &&
                hg manifest -r 3 &&
                hg manifest
-               ) > output-$x &&
+               ) >"output-$x" &&
 
                git_clone_$x hgrepo-$x gitrepo2-$x &&
-               git_log gitrepo2-$x > log-$x
+               git_log gitrepo2-$x >"log-$x"
        done &&
 
        test_cmp output-hg output-git &&
@@ -368,20 +378,21 @@ test_expect_success 'git tags' '
        git init -q gitrepo &&
        cd gitrepo &&
        git config receive.denyCurrentBranch ignore &&
-       echo alpha > alpha &&
+       echo alpha >alpha &&
        git add alpha &&
        git commit -m "add alpha" &&
        git tag alpha &&
 
-       echo beta > beta &&
+       echo beta >beta &&
        git add beta &&
        git commit -m "add beta" &&
        git tag -a -m "added tag beta" beta
        ) &&
 
-       for x in hg git; do
+       for x in hg git
+       do
                hg_clone_$x gitrepo hgrepo-$x &&
-               hg_log hgrepo-$x > log-$x
+               hg_log hgrepo-$x >"log-$x"
        done &&
 
        test_cmp log-hg log-git
@@ -390,12 +401,13 @@ test_expect_success 'git tags' '
 test_expect_success 'hg author' '
        test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
-       for x in hg git; do
+       for x in hg git
+       do
                (
                git init -q gitrepo-$x &&
                cd gitrepo-$x &&
 
-               echo alpha > alpha &&
+               echo alpha >alpha &&
                git add alpha &&
                git commit -m "add alpha" &&
                git checkout -q -b not-master
@@ -406,38 +418,38 @@ test_expect_success 'hg author' '
                cd hgrepo-$x &&
 
                hg co master &&
-               echo beta > beta &&
+               echo beta >beta &&
                hg add beta &&
                hg commit -u "test" -m "add beta" &&
 
-               echo gamma >> beta &&
+               echo gamma >>beta &&
                hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
 
-               echo gamma > gamma &&
+               echo gamma >gamma &&
                hg add gamma &&
                hg commit -u "<test@example.com>" -m "add gamma" &&
 
-               echo delta > delta &&
+               echo delta >delta &&
                hg add delta &&
                hg commit -u "name<test@example.com>" -m "add delta" &&
 
-               echo epsilon > epsilon &&
+               echo epsilon >epsilon &&
                hg add epsilon &&
                hg commit -u "name <test@example.com" -m "add epsilon" &&
 
-               echo zeta > zeta &&
+               echo zeta >zeta &&
                hg add zeta &&
                hg commit -u " test " -m "add zeta" &&
 
-               echo eta > eta &&
+               echo eta >eta &&
                hg add eta &&
                hg commit -u "test < test@example.com >" -m "add eta" &&
 
-               echo theta > theta &&
+               echo theta >theta &&
                hg add theta &&
                hg commit -u "test >test@example.com>" -m "add theta" &&
 
-               echo iota > iota &&
+               echo iota >iota &&
                hg add iota &&
                hg commit -u "test <test <at> example <dot> com>" -m "add iota"
                ) &&
@@ -445,8 +457,8 @@ test_expect_success 'hg author' '
                hg_push_$x hgrepo-$x gitrepo-$x &&
                hg_clone_$x gitrepo-$x hgrepo2-$x &&
 
-               hg_log hgrepo2-$x > hg-log-$x &&
-               git_log gitrepo-$x > git-log-$x
+               hg_log hgrepo2-$x >"hg-log-$x" &&
+               git_log gitrepo-$x >"git-log-$x"
        done &&
 
        test_cmp hg-log-hg hg-log-git &&
@@ -456,12 +468,13 @@ test_expect_success 'hg author' '
 test_expect_success 'hg branch' '
        test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
-       for x in hg git; do
+       for x in hg git
+       do
                (
                git init -q gitrepo-$x &&
                cd gitrepo-$x &&
 
-               echo alpha > alpha &&
+               echo alpha >alpha &&
                git add alpha &&
                git commit -q -m "add alpha" &&
                git checkout -q -b not-master
@@ -481,8 +494,8 @@ test_expect_success 'hg branch' '
                hg_push_$x hgrepo-$x gitrepo-$x &&
                hg_clone_$x gitrepo-$x hgrepo2-$x &&
 
-               hg_log hgrepo2-$x > hg-log-$x &&
-               git_log gitrepo-$x > git-log-$x
+               hg_log hgrepo2-$x >"hg-log-$x" &&
+               git_log gitrepo-$x >"git-log-$x"
        done &&
 
        test_cmp hg-log-hg hg-log-git &&
@@ -492,12 +505,13 @@ test_expect_success 'hg branch' '
 test_expect_success 'hg tags' '
        test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
-       for x in hg git; do
+       for x in hg git
+       do
                (
                git init -q gitrepo-$x &&
                cd gitrepo-$x &&
 
-               echo alpha > alpha &&
+               echo alpha >alpha &&
                git add alpha &&
                git commit -m "add alpha" &&
                git checkout -q -b not-master
@@ -518,7 +532,7 @@ test_expect_success 'hg tags' '
                git --git-dir=gitrepo-$x/.git tag -l &&
                hg_log hgrepo2-$x &&
                cat hgrepo2-$x/.hgtags
-               ) > output-$x
+               ) >"output-$x"
        done &&
 
        test_cmp output-hg output-git
index f7ce8aa853d5ad9689f49a9cadf0d43ce16ed34f..72f745d63f2f225b4976b27875d726b4652198ed 100755 (executable)
@@ -10,40 +10,44 @@ test_description='Test remote-hg'
 
 . ./test-lib.sh
 
-if ! test_have_prereq PYTHON; then
+if ! test_have_prereq PYTHON
+then
        skip_all='skipping remote-hg tests; python not available'
        test_done
 fi
 
-if ! python -c 'import mercurial'; then
+if ! python -c 'import mercurial'
+then
        skip_all='skipping remote-hg tests; mercurial not available'
        test_done
 fi
 
 check () {
-       echo $3 > expected &&
-       git --git-dir=$1/.git log --format='%s' -1 $2 > actual
+       echo $3 >expected &&
+       git --git-dir=$1/.git log --format='%s' -1 $2 >actual
        test_cmp expected actual
 }
 
 check_branch () {
-       if [ -n "$3" ]; then
-               echo $3 > expected &&
-               hg -R $1 log -r $2 --template '{desc}\n' > actual &&
+       if test -n "$3"
+       then
+               echo $3 >expected &&
+               hg -R $1 log -r $2 --template '{desc}\n' >actual &&
                test_cmp expected actual
        else
-               hg -R $1 branches > out &&
+               hg -R $1 branches >out &&
                ! grep $2 out
        fi
 }
 
 check_bookmark () {
-       if [ -n "$3" ]; then
-               echo $3 > expected &&
-               hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' > actual &&
+       if test -n "$3"
+       then
+               echo $3 >expected &&
+               hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' >actual &&
                test_cmp expected actual
        else
-               hg -R $1 bookmarks > out &&
+               hg -R $1 bookmarks >out &&
                ! grep $2 out
        fi
 }
@@ -52,7 +56,7 @@ check_push () {
        local expected_ret=$1 ret=0 ref_ret=0 IFS=':'
 
        shift
-       git push origin "$@" 2> error
+       git push origin "$@" 2>error
        ret=$?
        cat error
 
@@ -75,10 +79,10 @@ check_push () {
                        grep "^   [a-f0-9]*\.\.[a-f0-9]* *${branch} -> ${branch}$" error || ref_ret=1
                        ;;
                esac
-               let 'ref_ret' && echo "match for '$branch' failed" && break
+               test $ref_ret -ne 0 && echo "match for '$branch' failed" && break
        done
 
-       if let 'expected_ret != ret || ref_ret'
+       if test $expected_ret -ne $ret -o $ref_ret -ne 0
        then
                return 1
        fi
@@ -92,7 +96,7 @@ setup () {
        echo "username = H G Wells <wells@example.com>"
        echo "[extensions]"
        echo "mq ="
-       ) >> "$HOME"/.hgrc &&
+       ) >>"$HOME"/.hgrc &&
 
        GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230" &&
        GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" &&
@@ -107,7 +111,7 @@ test_expect_success 'cloning' '
        (
        hg init hgrepo &&
        cd hgrepo &&
-       echo zero > content &&
+       echo zero >content &&
        hg add content &&
        hg commit -m zero
        ) &&
@@ -122,7 +126,7 @@ test_expect_success 'cloning with branches' '
        (
        cd hgrepo &&
        hg branch next &&
-       echo next > content &&
+       echo next >content &&
        hg commit -m next
        ) &&
 
@@ -137,7 +141,7 @@ test_expect_success 'cloning with bookmarks' '
        cd hgrepo &&
        hg checkout default &&
        hg bookmark feature-a &&
-       echo feature-a > content &&
+       echo feature-a >content &&
        hg commit -m feature-a
        ) &&
 
@@ -157,7 +161,7 @@ test_expect_success 'update bookmark' '
        git clone "hg::hgrepo" gitrepo &&
        cd gitrepo &&
        git checkout --quiet devel &&
-       echo devel > content &&
+       echo devel >content &&
        git commit -a -m devel &&
        git push --quiet
        ) &&
@@ -172,7 +176,7 @@ test_expect_success 'new bookmark' '
        git clone "hg::hgrepo" gitrepo &&
        cd gitrepo &&
        git checkout --quiet -b feature-b &&
-       echo feature-b > content &&
+       echo feature-b >content &&
        git commit -a -m feature-b &&
        git push --quiet origin feature-b
        ) &&
@@ -184,9 +188,9 @@ test_expect_success 'new bookmark' '
 rm -rf hgrepo
 
 author_test () {
-       echo $1 >> content &&
+       echo $1 >>content &&
        hg commit -u "$2" -m "add $1" &&
-       echo "$3" >> ../expected
+       echo "$3" >>../expected
 }
 
 test_expect_success 'authors' '
@@ -199,7 +203,7 @@ test_expect_success 'authors' '
        touch content &&
        hg add content &&
 
-       > ../expected &&
+       >../expected &&
        author_test alpha "" "H G Wells <wells@example.com>" &&
        author_test beta "test" "test <unknown>" &&
        author_test beta "test <test@example.com> (comment)" "test <test@example.com>" &&
@@ -214,7 +218,7 @@ test_expect_success 'authors' '
        ) &&
 
        git clone "hg::hgrepo" gitrepo &&
-       git --git-dir=gitrepo/.git log --reverse --format="%an <%ae>" > actual &&
+       git --git-dir=gitrepo/.git log --reverse --format="%an <%ae>" >actual &&
 
        test_cmp expected actual
 '
@@ -226,11 +230,11 @@ test_expect_success 'strip' '
        hg init hgrepo &&
        cd hgrepo &&
 
-       echo one >> content &&
+       echo one >>content &&
        hg add content &&
        hg commit -m one &&
 
-       echo two >> content &&
+       echo two >>content &&
        hg commit -m two
        ) &&
 
@@ -240,20 +244,20 @@ test_expect_success 'strip' '
        cd hgrepo &&
        hg strip 1 &&
 
-       echo three >> content &&
+       echo three >>content &&
        hg commit -m three &&
 
-       echo four >> content &&
+       echo four >>content &&
        hg commit -m four
        ) &&
 
        (
        cd gitrepo &&
        git fetch &&
-       git log --format="%s" origin/master > ../actual
+       git log --format="%s" origin/master >../actual
        ) &&
 
-       hg -R hgrepo log --template "{desc}\n" > expected &&
+       hg -R hgrepo log --template "{desc}\n" >expected &&
        test_cmp actual expected
 '
 
@@ -263,18 +267,18 @@ test_expect_success 'remote push with master bookmark' '
        (
        hg init hgrepo &&
        cd hgrepo &&
-       echo zero > content &&
+       echo zero >content &&
        hg add content &&
        hg commit -m zero &&
        hg bookmark master &&
-       echo one > content &&
+       echo one >content &&
        hg commit -m one
        ) &&
 
        (
        git clone "hg::hgrepo" gitrepo &&
        cd gitrepo &&
-       echo two > content &&
+       echo two >content &&
        git commit -a -m two &&
        git push
        ) &&
@@ -282,7 +286,7 @@ test_expect_success 'remote push with master bookmark' '
        check_branch hgrepo default two
 '
 
-cat > expected <<EOF
+cat >expected <<\EOF
 changeset:   0:6e2126489d3d
 tag:         tip
 user:        A U Thor <author@example.com>
@@ -300,13 +304,13 @@ test_expect_success 'remote push from master branch' '
        git init gitrepo &&
        cd gitrepo &&
        git remote add origin "hg::../hgrepo" &&
-       echo one > content &&
+       echo one >content &&
        git add content &&
        git commit -a -m one &&
        git push origin master
        ) &&
 
-       hg -R hgrepo log > actual &&
+       hg -R hgrepo log >actual &&
        cat actual &&
        test_cmp expected actual &&
 
@@ -322,7 +326,7 @@ test_expect_success 'remote cloning' '
        (
        hg init hgrepo &&
        cd hgrepo &&
-       echo zero > content &&
+       echo zero >content &&
        hg add content &&
        hg commit -m zero
        ) &&
@@ -343,7 +347,7 @@ test_expect_success 'remote update bookmark' '
        git clone "hg::hgrepo" gitrepo &&
        cd gitrepo &&
        git checkout --quiet devel &&
-       echo devel > content &&
+       echo devel >content &&
        git commit -a -m devel &&
        git push --quiet
        ) &&
@@ -358,7 +362,7 @@ test_expect_success 'remote new bookmark' '
        git clone "hg::hgrepo" gitrepo &&
        cd gitrepo &&
        git checkout --quiet -b feature-b &&
-       echo feature-b > content &&
+       echo feature-b >content &&
        git commit -a -m feature-b &&
        git push --quiet origin feature-b
        ) &&
@@ -374,15 +378,15 @@ test_expect_success 'remote push diverged' '
        (
        cd hgrepo &&
        hg checkout default &&
-       echo bump > content &&
+       echo bump >content &&
        hg commit -m bump
        ) &&
 
        (
        cd gitrepo &&
-       echo diverge > content &&
+       echo diverge >content &&
        git commit -a -m diverged &&
-       check_push 1 <<-EOF
+       check_push 1 <<-\EOF
        master:non-fast-forward
        EOF
        ) &&
@@ -403,16 +407,16 @@ test_expect_success 'remote update bookmark diverge' '
 
        (
        cd hgrepo &&
-       echo "bump bookmark" > content &&
+       echo "bump bookmark" >content &&
        hg commit -m "bump bookmark"
        ) &&
 
        (
        cd gitrepo &&
        git checkout --quiet diverge &&
-       echo diverge > content &&
+       echo diverge >content &&
        git commit -a -m diverge &&
-       check_push 1 <<-EOF
+       check_push 1 <<-\EOF
        diverge:fetch-first
        EOF
        ) &&
@@ -427,7 +431,7 @@ test_expect_success 'remote new bookmark multiple branch head' '
        git clone "hg::hgrepo" gitrepo &&
        cd gitrepo &&
        git checkout --quiet -b feature-c HEAD^ &&
-       echo feature-c > content &&
+       echo feature-c >content &&
        git commit -a -m feature-c &&
        git push --quiet origin feature-c
        ) &&
@@ -442,20 +446,20 @@ setup_big_push () {
        (
        hg init hgrepo &&
        cd hgrepo &&
-       echo zero > content &&
+       echo zero >content &&
        hg add content &&
        hg commit -m zero &&
        hg bookmark bad_bmark1 &&
-       echo one > content &&
+       echo one >content &&
        hg commit -m one &&
        hg bookmark bad_bmark2 &&
        hg bookmark good_bmark &&
        hg bookmark -i good_bmark &&
        hg -q branch good_branch &&
-       echo "good branch" > content &&
+       echo "good branch" >content &&
        hg commit -m "good branch" &&
        hg -q branch bad_branch &&
-       echo "bad branch" > content &&
+       echo "bad branch" >content &&
        hg commit -m "bad branch"
        ) &&
 
@@ -463,40 +467,40 @@ setup_big_push () {
 
        (
        cd gitrepo &&
-       echo two > content &&
+       echo two >content &&
        git commit -q -a -m two &&
 
        git checkout -q good_bmark &&
-       echo three > content &&
+       echo three >content &&
        git commit -q -a -m three &&
 
        git checkout -q bad_bmark1 &&
        git reset --hard HEAD^ &&
-       echo four > content &&
+       echo four >content &&
        git commit -q -a -m four &&
 
        git checkout -q bad_bmark2 &&
        git reset --hard HEAD^ &&
-       echo five > content &&
+       echo five >content &&
        git commit -q -a -m five &&
 
        git checkout -q -b new_bmark master &&
-       echo six > content &&
+       echo six >content &&
        git commit -q -a -m six &&
 
        git checkout -q branches/good_branch &&
-       echo seven > content &&
+       echo seven >content &&
        git commit -q -a -m seven &&
-       echo eight > content &&
+       echo eight >content &&
        git commit -q -a -m eight &&
 
        git checkout -q branches/bad_branch &&
        git reset --hard HEAD^ &&
-       echo nine > content &&
+       echo nine >content &&
        git commit -q -a -m nine &&
 
        git checkout -q -b branches/new_branch master &&
-       echo ten > content &&
+       echo ten >content &&
        git commit -q -a -m ten
        )
 }
@@ -509,7 +513,7 @@ test_expect_success 'remote big push' '
        (
        cd gitrepo &&
 
-       check_push 1 --all <<-EOF
+       check_push 1 --all <<-\EOF
        master
        good_bmark
        branches/good_branch
@@ -537,17 +541,17 @@ test_expect_success 'remote big push fetch first' '
        (
        hg init hgrepo &&
        cd hgrepo &&
-       echo zero > content &&
+       echo zero >content &&
        hg add content &&
        hg commit -m zero &&
        hg bookmark bad_bmark &&
        hg bookmark good_bmark &&
        hg bookmark -i good_bmark &&
        hg -q branch good_branch &&
-       echo "good branch" > content &&
+       echo "good branch" >content &&
        hg commit -m "good branch" &&
        hg -q branch bad_branch &&
-       echo "bad branch" > content &&
+       echo "bad branch" >content &&
        hg commit -m "bad branch"
        ) &&
 
@@ -556,39 +560,37 @@ test_expect_success 'remote big push fetch first' '
        (
        cd hgrepo &&
        hg bookmark -f bad_bmark &&
-       echo update_bmark > content &&
+       echo update_bmark >content &&
        hg commit -m "update bmark"
        ) &&
 
        (
        cd gitrepo &&
-       echo two > content &&
+       echo two >content &&
        git commit -q -a -m two &&
 
        git checkout -q good_bmark &&
-       echo three > content &&
+       echo three >content &&
        git commit -q -a -m three &&
 
        git checkout -q bad_bmark &&
-       echo four > content &&
+       echo four >content &&
        git commit -q -a -m four &&
 
        git checkout -q branches/bad_branch &&
-       echo five > content &&
+       echo five >content &&
        git commit -q -a -m five &&
 
-       check_push 1 --all <<-EOF
+       check_push 1 --all <<-\EOF &&
        master
        good_bmark
-       new_bmark:new
-       new_branch:new
        bad_bmark:fetch-first
        branches/bad_branch:festch-first
        EOF
 
        git fetch &&
 
-       check_push 1 --all <<-EOF
+       check_push 1 --all <<-\EOF
        master
        good_bmark
        bad_bmark:non-fast-forward
@@ -605,7 +607,7 @@ test_expect_failure 'remote big push force' '
        (
        cd gitrepo &&
 
-       check_push 0 --force --all <<-EOF
+       check_push 0 --force --all <<-\EOF
        master
        good_bmark
        branches/good_branch
@@ -635,7 +637,7 @@ test_expect_failure 'remote big push dry-run' '
        (
        cd gitrepo &&
 
-       check_push 0 --dry-run --all <<-EOF
+       check_push 1 --dry-run --all <<-\EOF &&
        master
        good_bmark
        branches/good_branch
@@ -646,7 +648,7 @@ test_expect_failure 'remote big push dry-run' '
        branches/bad_branch:non-fast-forward
        EOF
 
-       check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-EOF
+       check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-\EOF
        master
        good_bmark
        branches/good_branch
@@ -671,10 +673,10 @@ test_expect_success 'remote double failed push' '
        (
        hg init hgrepo &&
        cd hgrepo &&
-       echo zero > content &&
+       echo zero >content &&
        hg add content &&
        hg commit -m zero &&
-       echo one > content &&
+       echo one >content &&
        hg commit -m one
        ) &&
 
@@ -682,7 +684,7 @@ test_expect_success 'remote double failed push' '
        git clone "hg::hgrepo" gitrepo &&
        cd gitrepo &&
        git reset --hard HEAD^ &&
-       echo two > content &&
+       echo two >content &&
        git commit -a -m two &&
        test_expect_code 1 git push &&
        test_expect_code 1 git push
index 5398c36dd4dc2c1d7ded3f92c217a99a240a0a23..378254c77a00f93ef667c0510fa11b75988ef05a 100644 (file)
@@ -123,14 +123,13 @@ static char *expand_namespace(const char *raw_namespace)
 
 static void setup_git_env(void)
 {
+       const char *gitfile;
+
        git_dir = getenv(GIT_DIR_ENVIRONMENT);
-       git_dir = git_dir ? xstrdup(git_dir) : NULL;
-       if (!git_dir) {
-               git_dir = read_gitfile(DEFAULT_GIT_DIR_ENVIRONMENT);
-               git_dir = git_dir ? xstrdup(git_dir) : NULL;
-       }
        if (!git_dir)
                git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
+       gitfile = read_gitfile(git_dir);
+       git_dir = xstrdup(gitfile ? gitfile : git_dir);
        git_object_dir = getenv(DB_ENVIRONMENT);
        if (!git_object_dir) {
                git_object_dir = xmalloc(strlen(git_dir) + 9);
index 45c87648677a90b293c633b02232f9a490be6833..f4d9969e5c81f9c1415f0908f090bf62b156e179 100644 (file)
@@ -1694,7 +1694,7 @@ static int update_branch(struct branch *b)
                return 0;
        if (read_ref(b->name, old_sha1))
                hashclr(old_sha1);
-       lock = lock_any_ref_for_update(b->name, old_sha1, 0);
+       lock = lock_any_ref_for_update(b->name, old_sha1, 0, NULL);
        if (!lock)
                return error("Unable to lock %s", b->name);
        if (!force_update && !is_null_sha1(old_sha1)) {
index 094267fd80cdb09feec75c89aa2f4931f11e583d..a0e0350ae6bdf338b3c11c21fc050edb60c88569 100644 (file)
@@ -185,36 +185,6 @@ static void consume_shallow_list(struct fetch_pack_args *args, int fd)
        }
 }
 
-struct write_shallow_data {
-       struct strbuf *out;
-       int use_pack_protocol;
-       int count;
-};
-
-static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
-{
-       struct write_shallow_data *data = cb_data;
-       const char *hex = sha1_to_hex(graft->sha1);
-       data->count++;
-       if (data->use_pack_protocol)
-               packet_buf_write(data->out, "shallow %s", hex);
-       else {
-               strbuf_addstr(data->out, hex);
-               strbuf_addch(data->out, '\n');
-       }
-       return 0;
-}
-
-static int write_shallow_commits(struct strbuf *out, int use_pack_protocol)
-{
-       struct write_shallow_data data;
-       data.out = out;
-       data.use_pack_protocol = use_pack_protocol;
-       data.count = 0;
-       for_each_commit_graft(write_one_shallow, &data);
-       return data.count;
-}
-
 static enum ack_type get_ack(int fd, unsigned char *result_sha1)
 {
        int len;
@@ -689,7 +659,7 @@ static int get_pack(struct fetch_pack_args *args,
        const char *argv[22];
        char keep_arg[256];
        char hdr_arg[256];
-       const char **av;
+       const char **av, *cmd_name;
        int do_keep = args->keep_pack;
        struct child_process cmd;
        int ret;
@@ -736,7 +706,7 @@ static int get_pack(struct fetch_pack_args *args,
        if (do_keep) {
                if (pack_lockfile)
                        cmd.out = -1;
-               *av++ = "index-pack";
+               *av++ = cmd_name = "index-pack";
                *av++ = "--stdin";
                if (!args->quiet && !args->no_progress)
                        *av++ = "-v";
@@ -753,7 +723,7 @@ static int get_pack(struct fetch_pack_args *args,
                        *av++ = "--check-self-contained-and-connected";
        }
        else {
-               *av++ = "unpack-objects";
+               *av++ = cmd_name = "unpack-objects";
                if (args->quiet || args->no_progress)
                        *av++ = "-q";
                args->check_self_contained_and_connected = 0;
@@ -771,7 +741,7 @@ static int get_pack(struct fetch_pack_args *args,
        cmd.in = demux.out;
        cmd.git_cmd = 1;
        if (start_command(&cmd))
-               die("fetch-pack: unable to fork off %s", argv[0]);
+               die("fetch-pack: unable to fork off %s", cmd_name);
        if (do_keep && pack_lockfile) {
                *pack_lockfile = index_pack_lockfile(cmd.out);
                close(cmd.out);
@@ -783,7 +753,7 @@ static int get_pack(struct fetch_pack_args *args,
                        args->check_self_contained_and_connected &&
                        ret == 0;
        else
-               die("%s failed", argv[0]);
+               die("%s failed", cmd_name);
        if (use_sideband && finish_async(&demux))
                die("error in sideband demultiplexer");
        return 0;
@@ -796,27 +766,6 @@ static int cmp_ref_by_name(const void *a_, const void *b_)
        return strcmp(a->name, b->name);
 }
 
-static void setup_alternate_shallow(void)
-{
-       struct strbuf sb = STRBUF_INIT;
-       int fd;
-
-       check_shallow_file_for_update();
-       fd = hold_lock_file_for_update(&shallow_lock, git_path("shallow"),
-                                      LOCK_DIE_ON_ERROR);
-       if (write_shallow_commits(&sb, 0)) {
-               if (write_in_full(fd, sb.buf, sb.len) != sb.len)
-                       die_errno("failed to write to %s", shallow_lock.filename);
-               alternate_shallow_file = shallow_lock.filename;
-       } else
-               /*
-                * is_repository_shallow() sees empty string as "no
-                * shallow file".
-                */
-               alternate_shallow_file = "";
-       strbuf_release(&sb);
-}
-
 static struct ref *do_fetch_pack(struct fetch_pack_args *args,
                                 int fd[2],
                                 const struct ref *orig_ref,
@@ -897,7 +846,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
        if (args->stateless_rpc)
                packet_flush(fd[1]);
        if (args->depth > 0)
-               setup_alternate_shallow();
+               setup_alternate_shallow(&shallow_lock, &alternate_shallow_file);
        else
                alternate_shallow_file = NULL;
        if (get_pack(args, fd, pack_lockfile))
index 75a991f7ec8a2e4926cb925ad9ff23be2f6aedeb..51563840f49089cf250992fd47fe70a45cef0c52 100755 (executable)
@@ -169,7 +169,7 @@ sub colored {
 my %patch_mode_flavour = %{$patch_modes{stage}};
 
 sub run_cmd_pipe {
-       if ($^O eq 'MSWin32' || $^O eq 'msys') {
+       if ($^O eq 'MSWin32') {
                my @invalid = grep {m/[":*]/} @_;
                die "$^O does not support: @invalid\n" if @invalid;
                my @args = map { m/ /o ? "\"$_\"": $_ } @_;
index a9f6f8ebd443a338509f9c100e2d5c056c9f889f..74d1cc7db040c4d4fa736567be9340e4b4070863 100755 (executable)
@@ -4167,7 +4167,7 @@ sub convertToDbMode
     #  this half-converted form, but it isn't currently worth the
     #  backwards compatibility headaches.
 
-    $mode=~/^\d\d(\d)\d{3}$/;
+    $mode=~/^\d{3}(\d)\d\d$/;
     my $userBits=$1;
 
     my $dbMode = "";
index a53a6dc406c26daaf263944d38b53b27db271072..06a3cc6122410efcccf0fd77f359ffc2e809aff9 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -780,11 +780,14 @@ def getClientSpec():
     # dictionary of all client parameters
     entry = specList[0]
 
+    # the //client/ name
+    client_name = entry["Client"]
+
     # just the keys that start with "View"
     view_keys = [ k for k in entry.keys() if k.startswith("View") ]
 
     # hold this new View
-    view = View()
+    view = View(client_name)
 
     # append the lines, in order, to the view
     for view_num in range(len(view_keys)):
@@ -1555,8 +1558,8 @@ def exportGitTags(self, gitTags):
             for b in body:
                 labelTemplate += "\t" + b + "\n"
             labelTemplate += "View:\n"
-            for mapping in clientSpec.mappings:
-                labelTemplate += "\t%s\n" % mapping.depot_side.path
+            for depot_side in clientSpec.mappings:
+                labelTemplate += "\t%s\n" % depot_side
 
             if self.dry_run:
                 print "Would create p4 label %s for tag" % name
@@ -1568,7 +1571,7 @@ def exportGitTags(self, gitTags):
 
                 # Use the label
                 p4_system(["tag", "-l", name] +
-                          ["%s@%s" % (mapping.depot_side.path, changelist) for mapping in clientSpec.mappings])
+                          ["%s@%s" % (depot_side, changelist) for depot_side in clientSpec.mappings])
 
                 if verbose:
                     print "created p4 label for tag %s" % name
@@ -1796,117 +1799,16 @@ class View(object):
     """Represent a p4 view ("p4 help views"), and map files in a
        repo according to the view."""
 
-    class Path(object):
-        """A depot or client path, possibly containing wildcards.
-           The only one supported is ... at the end, currently.
-           Initialize with the full path, with //depot or //client."""
-
-        def __init__(self, path, is_depot):
-            self.path = path
-            self.is_depot = is_depot
-            self.find_wildcards()
-            # remember the prefix bit, useful for relative mappings
-            m = re.match("(//[^/]+/)", self.path)
-            if not m:
-                die("Path %s does not start with //prefix/" % self.path)
-            prefix = m.group(1)
-            if not self.is_depot:
-                # strip //client/ on client paths
-                self.path = self.path[len(prefix):]
-
-        def find_wildcards(self):
-            """Make sure wildcards are valid, and set up internal
-               variables."""
-
-            self.ends_triple_dot = False
-            # There are three wildcards allowed in p4 views
-            # (see "p4 help views").  This code knows how to
-            # handle "..." (only at the end), but cannot deal with
-            # "%%n" or "*".  Only check the depot_side, as p4 should
-            # validate that the client_side matches too.
-            if re.search(r'%%[1-9]', self.path):
-                die("Can't handle %%n wildcards in view: %s" % self.path)
-            if self.path.find("*") >= 0:
-                die("Can't handle * wildcards in view: %s" % self.path)
-            triple_dot_index = self.path.find("...")
-            if triple_dot_index >= 0:
-                if triple_dot_index != len(self.path) - 3:
-                    die("Can handle only single ... wildcard, at end: %s" %
-                        self.path)
-                self.ends_triple_dot = True
-
-        def ensure_compatible(self, other_path):
-            """Make sure the wildcards agree."""
-            if self.ends_triple_dot != other_path.ends_triple_dot:
-                 die("Both paths must end with ... if either does;\n" +
-                     "paths: %s %s" % (self.path, other_path.path))
-
-        def match_wildcards(self, test_path):
-            """See if this test_path matches us, and fill in the value
-               of the wildcards if so.  Returns a tuple of
-               (True|False, wildcards[]).  For now, only the ... at end
-               is supported, so at most one wildcard."""
-            if self.ends_triple_dot:
-                dotless = self.path[:-3]
-                if test_path.startswith(dotless):
-                    wildcard = test_path[len(dotless):]
-                    return (True, [ wildcard ])
-            else:
-                if test_path == self.path:
-                    return (True, [])
-            return (False, [])
-
-        def match(self, test_path):
-            """Just return if it matches; don't bother with the wildcards."""
-            b, _ = self.match_wildcards(test_path)
-            return b
-
-        def fill_in_wildcards(self, wildcards):
-            """Return the relative path, with the wildcards filled in
-               if there are any."""
-            if self.ends_triple_dot:
-                return self.path[:-3] + wildcards[0]
-            else:
-                return self.path
-
-    class Mapping(object):
-        def __init__(self, depot_side, client_side, overlay, exclude):
-            # depot_side is without the trailing /... if it had one
-            self.depot_side = View.Path(depot_side, is_depot=True)
-            self.client_side = View.Path(client_side, is_depot=False)
-            self.overlay = overlay  # started with "+"
-            self.exclude = exclude  # started with "-"
-            assert not (self.overlay and self.exclude)
-            self.depot_side.ensure_compatible(self.client_side)
-
-        def __str__(self):
-            c = " "
-            if self.overlay:
-                c = "+"
-            if self.exclude:
-                c = "-"
-            return "View.Mapping: %s%s -> %s" % \
-                   (c, self.depot_side.path, self.client_side.path)
-
-        def map_depot_to_client(self, depot_path):
-            """Calculate the client path if using this mapping on the
-               given depot path; does not consider the effect of other
-               mappings in a view.  Even excluded mappings are returned."""
-            matches, wildcards = self.depot_side.match_wildcards(depot_path)
-            if not matches:
-                return ""
-            client_path = self.client_side.fill_in_wildcards(wildcards)
-            return client_path
-
-    #
-    # View methods
-    #
-    def __init__(self):
+    def __init__(self, client_name):
         self.mappings = []
+        self.client_prefix = "//%s/" % client_name
+        # cache results of "p4 where" to lookup client file locations
+        self.client_spec_path_cache = {}
 
     def append(self, view_line):
         """Parse a view line, splitting it into depot and client
-           sides.  Append to self.mappings, preserving order."""
+           sides.  Append to self.mappings, preserving order.  This
+           is only needed for tag creation."""
 
         # Split the view line into exactly two words.  P4 enforces
         # structure on these lines that simplifies this quite a bit.
@@ -1934,76 +1836,62 @@ def append(self, view_line):
             depot_side = view_line[0:space_index]
             rhs_index = space_index + 1
 
-        if view_line[rhs_index] == '"':
-            # Second word is double quoted.  Make sure there is a
-            # double quote at the end too.
-            if not view_line.endswith('"'):
-                die("View line with rhs quote should end with one: %s" %
-                    view_line)
-            # skip the quotes
-            client_side = view_line[rhs_index+1:-1]
-        else:
-            client_side = view_line[rhs_index:]
-
         # prefix + means overlay on previous mapping
-        overlay = False
         if depot_side.startswith("+"):
-            overlay = True
             depot_side = depot_side[1:]
 
-        # prefix - means exclude this path
+        # prefix - means exclude this path, leave out of mappings
         exclude = False
         if depot_side.startswith("-"):
             exclude = True
             depot_side = depot_side[1:]
 
-        m = View.Mapping(depot_side, client_side, overlay, exclude)
-        self.mappings.append(m)
+        if not exclude:
+            self.mappings.append(depot_side)
 
-    def map_in_client(self, depot_path):
-        """Return the relative location in the client where this
-           depot file should live.  Returns "" if the file should
-           not be mapped in the client."""
+    def convert_client_path(self, clientFile):
+        # chop off //client/ part to make it relative
+        if not clientFile.startswith(self.client_prefix):
+            die("No prefix '%s' on clientFile '%s'" %
+                (self.client_prefix, clientFile))
+        return clientFile[len(self.client_prefix):]
 
-        paths_filled = []
-        client_path = ""
+    def update_client_spec_path_cache(self, files):
+        """ Caching file paths by "p4 where" batch query """
 
-        # look at later entries first
-        for m in self.mappings[::-1]:
+        # List depot file paths exclude that already cached
+        fileArgs = [f['path'] for f in files if f['path'] not in self.client_spec_path_cache]
 
-            # see where will this path end up in the client
-            p = m.map_depot_to_client(depot_path)
+        if len(fileArgs) == 0:
+            return  # All files in cache
 
-            if p == "":
-                # Depot path does not belong in client.  Must remember
-                # this, as previous items should not cause files to
-                # exist in this path either.  Remember that the list is
-                # being walked from the end, which has higher precedence.
-                # Overlap mappings do not exclude previous mappings.
-                if not m.overlay:
-                    paths_filled.append(m.client_side)
+        where_result = p4CmdList(["-x", "-", "where"], stdin=fileArgs)
+        for res in where_result:
+            if "code" in res and res["code"] == "error":
+                # assume error is "... file(s) not in client view"
+                continue
+            if "clientFile" not in res:
+                die("No clientFile from 'p4 where %s'" % depot_path)
+            if "unmap" in res:
+                # it will list all of them, but only one not unmap-ped
+                continue
+            self.client_spec_path_cache[res['depotFile']] = self.convert_client_path(res["clientFile"])
 
-            else:
-                # This mapping matched; no need to search any further.
-                # But, the mapping could be rejected if the client path
-                # has already been claimed by an earlier mapping (i.e.
-                # one later in the list, which we are walking backwards).
-                already_mapped_in_client = False
-                for f in paths_filled:
-                    # this is View.Path.match
-                    if f.match(p):
-                        already_mapped_in_client = True
-                        break
-                if not already_mapped_in_client:
-                    # Include this file, unless it is from a line that
-                    # explicitly said to exclude it.
-                    if not m.exclude:
-                        client_path = p
+        # not found files or unmap files set to ""
+        for depotFile in fileArgs:
+            if depotFile not in self.client_spec_path_cache:
+                self.client_spec_path_cache[depotFile] = ""
 
-                # a match, even if rejected, always stops the search
-                break
+    def map_in_client(self, depot_path):
+        """Return the relative location in the client where this
+           depot file should live.  Returns "" if the file should
+           not be mapped in the client."""
 
-        return client_path
+        if depot_path in self.client_spec_path_cache:
+            return self.client_spec_path_cache[depot_path]
+
+        die( "Error: %s is not found in client spec path" % depot_path )
+        return ""
 
 class P4Sync(Command, P4UserMap):
     delete_actions = ( "delete", "move/delete", "purge" )
@@ -2130,6 +2018,10 @@ def splitFilesIntoBranches(self, commit):
         """Look at each depotFile in the commit to figure out to what
            branch it belongs."""
 
+        if self.clientSpecDirs:
+            files = self.extractFilesFromCommit(commit)
+            self.clientSpecDirs.update_client_spec_path_cache(files)
+
         branches = {}
         fnum = 0
         while commit.has_key("depotFile%s" % fnum):
@@ -2383,6 +2275,9 @@ def commit(self, details, files, branch, parent = ""):
             else:
                 sys.stderr.write("Ignoring file outside of prefix: %s\n" % f['path'])
 
+        if self.clientSpecDirs:
+            self.clientSpecDirs.update_client_spec_path_cache(files)
+
         self.gitStream.write("commit %s\n" % branch)
 #        gitStream.write("mark :%s\n" % details["change"])
         self.committedChanges.add(int(details["change"]))
index 8d7659a22c253b9f9535aee38e3bf0ce380cef75..226752fbff62f4f27da95f7d711c898503fd7148 100755 (executable)
@@ -167,13 +167,22 @@ You can run "git stash pop" or "git stash drop" at any time.
        rm -rf "$state_dir"
 }
 
-run_specific_rebase () {
+run_specific_rebase_internal () {
        if [ "$interactive_rebase" = implied ]; then
                GIT_EDITOR=:
                export GIT_EDITOR
                autosquash=
        fi
+       # On FreeBSD, the shell's "return" returns from the current
+       # function, not from the current file inclusion.
+       # run_specific_rebase_internal has the file inclusion as a
+       # last statement, so POSIX and FreeBSD's return will do the
+       # same thing.
        . git-rebase--$type
+}
+
+run_specific_rebase () {
+       run_specific_rebase_internal
        ret=$?
        if test $ret -eq 0
        then
index 2162478392728f156ba6c541cdc69447aa9b0119..3782c3b0cb4f9356790ae581c0d408dc4f4cae75 100755 (executable)
@@ -1234,7 +1234,7 @@ sub send_message {
                                if ($smtp->code == 220) {
                                        $smtp = Net::SMTP::SSL->start_SSL($smtp,
                                                                          ssl_verify_params())
-                                               or die "STARTTLS failed! ".$smtp->message;
+                                               or die "STARTTLS failed! ".IO::Socket::SSL::errstr();
                                        $smtp_encryption = '';
                                        # Send EHLO again to receive fresh
                                        # supported commands
index 2979197087f2c6d97e2945008394d50c16a195a5..c17bef10629d3fe53e03647ee16de7f9de24dfb5 100755 (executable)
@@ -1149,18 +1149,7 @@ cmd_summary() {
                        echo
                fi
                echo
-       done |
-       if test -n "$for_status"; then
-               if [ -n "$files" ]; then
-                       gettextln "Submodules changed but not updated:" | git stripspace -c
-               else
-                       gettextln "Submodule changes to be committed:" | git stripspace -c
-               fi
-               printf "\n" | git stripspace -c
-               git stripspace -c
-       else
-               cat
-       fi
+       done
 }
 #
 # List all submodules, prefixed with:
diff --git a/git.c b/git.c
index b3893e73c93c59431516bccb86e12e8f64d39319..1188979465654248c5936e8246886341846cc6f1 100644 (file)
--- a/git.c
+++ b/git.c
@@ -7,7 +7,7 @@
 #include "commit.h"
 
 const char git_usage_string[] =
-       "git [--version] [--help] [-c name=value]\n"
+       "git [--version] [--help] [-C <path>] [-c name=value]\n"
        "           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n"
        "           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]\n"
        "           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n"
@@ -165,6 +165,17 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
                        set_alternate_shallow_file((*argv)[0]);
                        if (envchanged)
                                *envchanged = 1;
+               } else if (!strcmp(cmd, "-C")) {
+                       if (*argc < 2) {
+                               fprintf(stderr, "No directory given for -C.\n" );
+                               usage(git_usage_string);
+                       }
+                       if (chdir((*argv)[1]))
+                               die_errno("Cannot change to '%s'", (*argv)[1]);
+                       if (envchanged)
+                               *envchanged = 1;
+                       (*argv)++;
+                       (*argc)--;
                } else {
                        fprintf(stderr, "Unknown option: %s\n", cmd);
                        usage(git_usage_string);
index 03244172977ba44399383c5b22f90877c94da964..8c464bd8051ed813175b01f832e5e78a91bba8ea 100644 (file)
@@ -594,9 +594,11 @@ int main(int argc, char **argv)
 
                        if (strcmp(method, c->method)) {
                                const char *proto = getenv("SERVER_PROTOCOL");
-                               if (proto && !strcmp(proto, "HTTP/1.1"))
+                               if (proto && !strcmp(proto, "HTTP/1.1")) {
                                        http_status(405, "Method Not Allowed");
-                               else
+                                       hdr_str("Allow", !strcmp(c->method, "GET") ?
+                                               "GET, HEAD" : c->method);
+                               } else
                                        http_status(400, "Bad Request");
                                hdr_nocache();
                                end_headers();
index eea158a8785c4d7c87724146c141edadac0f8dfe..69200baf7651c2bcb99d6bc2068429e22865f900 100644 (file)
@@ -1975,7 +1975,7 @@ int main(int argc, char **argv)
                pushing = 0;
                if (prepare_revision_walk(&revs))
                        die("revision walk setup failed");
-               mark_edges_uninteresting(revs.commits, &revs, NULL);
+               mark_edges_uninteresting(&revs, NULL);
                objects_to_send = get_delta(&revs, ref_lock);
                finish_all_active_slots();
 
index c8c3463cad6db4145434ee08f6c3a494e26a8675..6cbedf0280076d8fe6e49241d89938955ecddead 100644 (file)
@@ -144,19 +144,35 @@ static void mark_edge_parents_uninteresting(struct commit *commit,
        }
 }
 
-void mark_edges_uninteresting(struct commit_list *list,
-                             struct rev_info *revs,
-                             show_edge_fn show_edge)
+void mark_edges_uninteresting(struct rev_info *revs, show_edge_fn show_edge)
 {
-       for ( ; list; list = list->next) {
+       struct commit_list *list;
+       int i;
+
+       for (list = revs->commits; list; list = list->next) {
                struct commit *commit = list->item;
 
                if (commit->object.flags & UNINTERESTING) {
                        mark_tree_uninteresting(commit->tree);
+                       if (revs->edge_hint && !(commit->object.flags & SHOWN)) {
+                               commit->object.flags |= SHOWN;
+                               show_edge(commit);
+                       }
                        continue;
                }
                mark_edge_parents_uninteresting(commit, revs, show_edge);
        }
+       for (i = 0; i < revs->cmdline.nr; i++) {
+               struct object *obj = revs->cmdline.rev[i].item;
+               struct commit *commit = (struct commit *)obj;
+               if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING))
+                       continue;
+               mark_tree_uninteresting(commit->tree);
+               if (revs->edge_hint && !(obj->flags & SHOWN)) {
+                       obj->flags |= SHOWN;
+                       show_edge(commit);
+               }
+       }
 }
 
 static void add_pending_tree(struct rev_info *revs, struct tree *tree)
index 3db7bb6fa386df2ccb73b78ee72881f32074a1b8..136a1da5a6f048c0f4645112cdbf29c7b0982526 100644 (file)
@@ -6,6 +6,6 @@ typedef void (*show_object_fn)(struct object *, const struct name_path *, const
 void traverse_commit_list(struct rev_info *, show_commit_fn, show_object_fn, void *);
 
 typedef void (*show_edge_fn)(struct commit *);
-void mark_edges_uninteresting(struct commit_list *, struct rev_info *, show_edge_fn);
+void mark_edges_uninteresting(struct rev_info *, show_edge_fn);
 
 #endif
index d8a4b1ffbe68d6e9f720e979168f9d010c9c5a06..5f792cbfd38c0b30d763902ba5f9399992ddab89 100644 (file)
--- a/object.c
+++ b/object.c
@@ -43,16 +43,17 @@ int type_from_string(const char *str)
        die("invalid object type \"%s\"", str);
 }
 
-static unsigned int hash_obj(struct object *obj, unsigned int n)
+static unsigned int hash_obj(const unsigned char *sha1, unsigned int n)
 {
        unsigned int hash;
-       memcpy(&hash, obj->sha1, sizeof(unsigned int));
-       return hash % n;
+       memcpy(&hash, sha1, sizeof(unsigned int));
+       /* Assumes power-of-2 hash sizes in grow_object_hash */
+       return hash & (n - 1);
 }
 
 static void insert_obj_hash(struct object *obj, struct object **hash, unsigned int size)
 {
-       unsigned int j = hash_obj(obj, size);
+       unsigned int j = hash_obj(obj->sha1, size);
 
        while (hash[j]) {
                j++;
@@ -62,13 +63,6 @@ static void insert_obj_hash(struct object *obj, struct object **hash, unsigned i
        hash[j] = obj;
 }
 
-static unsigned int hashtable_index(const unsigned char *sha1)
-{
-       unsigned int i;
-       memcpy(&i, sha1, sizeof(unsigned int));
-       return i % obj_hash_size;
-}
-
 struct object *lookup_object(const unsigned char *sha1)
 {
        unsigned int i, first;
@@ -77,7 +71,7 @@ struct object *lookup_object(const unsigned char *sha1)
        if (!obj_hash)
                return NULL;
 
-       first = i = hashtable_index(sha1);
+       first = i = hash_obj(sha1, obj_hash_size);
        while ((obj = obj_hash[i]) != NULL) {
                if (!hashcmp(sha1, obj->sha1))
                        break;
@@ -101,6 +95,10 @@ struct object *lookup_object(const unsigned char *sha1)
 static void grow_object_hash(void)
 {
        int i;
+       /*
+        * Note that this size must always be power-of-2 to match hash_obj
+        * above.
+        */
        int new_hash_size = obj_hash_size < 32 ? 32 : 2 * obj_hash_size;
        struct object **new_hash;
 
diff --git a/pager.c b/pager.c
index c1ecf657fdb32c1fa669f08ba33e358f15c5a07b..fa19765eb9e60d2dbc17887773fff4ad66a32c37 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -54,7 +54,7 @@ const char *git_pager(int stdout_is_tty)
                pager = getenv("PAGER");
        if (!pager)
                pager = DEFAULT_PAGER;
-       else if (!*pager || !strcmp(pager, "cat"))
+       if (!*pager || !strcmp(pager, "cat"))
                pager = NULL;
 
        return pager;
index 75ecc425b6ebbf2cb1941b6b6bca78f8d0b70d62..a7b0119ee5945e062aee27a8bb21bf7c818fb8c6 100644 (file)
@@ -32,6 +32,14 @@ BEGIN
        }
 }
 
+# serf has a bug that leads to a coredump upon termination if the
+# remote access object is left around (not fixed yet in serf 1.3.1).
+# Explicitly free it to work around the issue.
+END {
+       $RA = undef;
+       $ra_invalid = 1;
+}
+
 sub _auth_providers () {
        my @rv = (
          SVN::Client::get_simple_provider(),
diff --git a/refs.c b/refs.c
index d78860c46d95ea9785c83c08824355275393ed99..ad5d66c8c95ca7e10b020da05b1d11157cee7af2 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -72,6 +72,10 @@ int check_refname_format(const char *refname, int flags)
 {
        int component_len, component_count = 0;
 
+       if (!strcmp(refname, "@"))
+               /* Refname is a single character '@'. */
+               return -1;
+
        while (1) {
                /* We are at the start of a path component. */
                component_len = check_refname_component(refname, flags);
@@ -1951,7 +1955,7 @@ static int remove_empty_directories(const char *file)
 static char *substitute_branch_name(const char **string, int *len)
 {
        struct strbuf buf = STRBUF_INIT;
-       int ret = interpret_branch_name(*string, &buf);
+       int ret = interpret_branch_name(*string, *len, &buf);
 
        if (ret == *len) {
                size_t size;
@@ -2121,11 +2125,12 @@ struct ref_lock *lock_ref_sha1(const char *refname, const unsigned char *old_sha
 }
 
 struct ref_lock *lock_any_ref_for_update(const char *refname,
-                                        const unsigned char *old_sha1, int flags)
+                                        const unsigned char *old_sha1,
+                                        int flags, int *type_p)
 {
        if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))
                return NULL;
-       return lock_ref_sha1_basic(refname, old_sha1, flags, NULL);
+       return lock_ref_sha1_basic(refname, old_sha1, flags, type_p);
 }
 
 /*
@@ -2413,60 +2418,82 @@ static int curate_packed_ref_fn(struct ref_entry *entry, void *cb_data)
        return 0;
 }
 
-static int repack_without_ref(const char *refname)
+static int repack_without_refs(const char **refnames, int n)
 {
        struct ref_dir *packed;
        struct string_list refs_to_delete = STRING_LIST_INIT_DUP;
        struct string_list_item *ref_to_delete;
+       int i, removed = 0;
+
+       /* Look for a packed ref */
+       for (i = 0; i < n; i++)
+               if (get_packed_ref(refnames[i]))
+                       break;
 
-       if (!get_packed_ref(refname))
-               return 0; /* refname does not exist in packed refs */
+       /* Avoid locking if we have nothing to do */
+       if (i == n)
+               return 0; /* no refname exists in packed refs */
 
        if (lock_packed_refs(0)) {
                unable_to_lock_error(git_path("packed-refs"), errno);
-               return error("cannot delete '%s' from packed refs", refname);
+               return error("cannot delete '%s' from packed refs", refnames[i]);
        }
        packed = get_packed_refs(&ref_cache);
 
-       /* Remove refname from the cache: */
-       if (remove_entry(packed, refname) == -1) {
+       /* Remove refnames from the cache */
+       for (i = 0; i < n; i++)
+               if (remove_entry(packed, refnames[i]) != -1)
+                       removed = 1;
+       if (!removed) {
                /*
-                * The packed entry disappeared while we were
+                * All packed entries disappeared while we were
                 * acquiring the lock.
                 */
                rollback_packed_refs();
                return 0;
        }
 
-       /* Remove any other accumulated cruft: */
+       /* Remove any other accumulated cruft */
        do_for_each_entry_in_dir(packed, 0, curate_packed_ref_fn, &refs_to_delete);
        for_each_string_list_item(ref_to_delete, &refs_to_delete) {
                if (remove_entry(packed, ref_to_delete->string) == -1)
                        die("internal error");
        }
 
-       /* Write what remains: */
+       /* Write what remains */
        return commit_packed_refs();
 }
 
-int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
+static int repack_without_ref(const char *refname)
 {
-       struct ref_lock *lock;
-       int err, i = 0, ret = 0, flag = 0;
+       return repack_without_refs(&refname, 1);
+}
 
-       lock = lock_ref_sha1_basic(refname, sha1, delopt, &flag);
-       if (!lock)
-               return 1;
+static int delete_ref_loose(struct ref_lock *lock, int flag)
+{
        if (!(flag & REF_ISPACKED) || flag & REF_ISSYMREF) {
                /* loose */
-               i = strlen(lock->lk->filename) - 5; /* .lock */
+               int err, i = strlen(lock->lk->filename) - 5; /* .lock */
+
                lock->lk->filename[i] = 0;
                err = unlink_or_warn(lock->lk->filename);
-               if (err && errno != ENOENT)
-                       ret = 1;
-
                lock->lk->filename[i] = '.';
+               if (err && errno != ENOENT)
+                       return 1;
        }
+       return 0;
+}
+
+int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
+{
+       struct ref_lock *lock;
+       int ret = 0, flag = 0;
+
+       lock = lock_ref_sha1_basic(refname, sha1, delopt, &flag);
+       if (!lock)
+               return 1;
+       ret |= delete_ref_loose(lock, flag);
+
        /* removing the loose one could have resurrected an earlier
         * packed one.  Also, if it was not loose we need to repack
         * without it.
@@ -3169,12 +3196,13 @@ int for_each_reflog(each_ref_fn fn, void *cb_data)
        return retval;
 }
 
-int update_ref(const char *action, const char *refname,
-               const unsigned char *sha1, const unsigned char *oldval,
-               int flags, enum action_on_err onerr)
+static struct ref_lock *update_ref_lock(const char *refname,
+                                       const unsigned char *oldval,
+                                       int flags, int *type_p,
+                                       enum action_on_err onerr)
 {
-       static struct ref_lock *lock;
-       lock = lock_any_ref_for_update(refname, oldval, flags);
+       struct ref_lock *lock;
+       lock = lock_any_ref_for_update(refname, oldval, flags, type_p);
        if (!lock) {
                const char *str = "Cannot lock the ref '%s'.";
                switch (onerr) {
@@ -3182,8 +3210,14 @@ int update_ref(const char *action, const char *refname,
                case DIE_ON_ERR: die(str, refname); break;
                case QUIET_ON_ERR: break;
                }
-               return 1;
        }
+       return lock;
+}
+
+static int update_ref_write(const char *action, const char *refname,
+                           const unsigned char *sha1, struct ref_lock *lock,
+                           enum action_on_err onerr)
+{
        if (write_ref_sha1(lock, sha1, action) < 0) {
                const char *str = "Cannot update the ref '%s'.";
                switch (onerr) {
@@ -3196,6 +3230,117 @@ int update_ref(const char *action, const char *refname,
        return 0;
 }
 
+int update_ref(const char *action, const char *refname,
+              const unsigned char *sha1, const unsigned char *oldval,
+              int flags, enum action_on_err onerr)
+{
+       struct ref_lock *lock;
+       lock = update_ref_lock(refname, oldval, flags, 0, onerr);
+       if (!lock)
+               return 1;
+       return update_ref_write(action, refname, sha1, lock, onerr);
+}
+
+static int ref_update_compare(const void *r1, const void *r2)
+{
+       const struct ref_update * const *u1 = r1;
+       const struct ref_update * const *u2 = r2;
+       return strcmp((*u1)->ref_name, (*u2)->ref_name);
+}
+
+static int ref_update_reject_duplicates(struct ref_update **updates, int n,
+                                       enum action_on_err onerr)
+{
+       int i;
+       for (i = 1; i < n; i++)
+               if (!strcmp(updates[i - 1]->ref_name, updates[i]->ref_name)) {
+                       const char *str =
+                               "Multiple updates for ref '%s' not allowed.";
+                       switch (onerr) {
+                       case MSG_ON_ERR:
+                               error(str, updates[i]->ref_name); break;
+                       case DIE_ON_ERR:
+                               die(str, updates[i]->ref_name); break;
+                       case QUIET_ON_ERR:
+                               break;
+                       }
+                       return 1;
+               }
+       return 0;
+}
+
+int update_refs(const char *action, const struct ref_update **updates_orig,
+               int n, enum action_on_err onerr)
+{
+       int ret = 0, delnum = 0, i;
+       struct ref_update **updates;
+       int *types;
+       struct ref_lock **locks;
+       const char **delnames;
+
+       if (!updates_orig || !n)
+               return 0;
+
+       /* Allocate work space */
+       updates = xmalloc(sizeof(*updates) * n);
+       types = xmalloc(sizeof(*types) * n);
+       locks = xcalloc(n, sizeof(*locks));
+       delnames = xmalloc(sizeof(*delnames) * n);
+
+       /* Copy, sort, and reject duplicate refs */
+       memcpy(updates, updates_orig, sizeof(*updates) * n);
+       qsort(updates, n, sizeof(*updates), ref_update_compare);
+       ret = ref_update_reject_duplicates(updates, n, onerr);
+       if (ret)
+               goto cleanup;
+
+       /* Acquire all locks while verifying old values */
+       for (i = 0; i < n; i++) {
+               locks[i] = update_ref_lock(updates[i]->ref_name,
+                                          (updates[i]->have_old ?
+                                           updates[i]->old_sha1 : NULL),
+                                          updates[i]->flags,
+                                          &types[i], onerr);
+               if (!locks[i]) {
+                       ret = 1;
+                       goto cleanup;
+               }
+       }
+
+       /* Perform updates first so live commits remain referenced */
+       for (i = 0; i < n; i++)
+               if (!is_null_sha1(updates[i]->new_sha1)) {
+                       ret = update_ref_write(action,
+                                              updates[i]->ref_name,
+                                              updates[i]->new_sha1,
+                                              locks[i], onerr);
+                       locks[i] = NULL; /* freed by update_ref_write */
+                       if (ret)
+                               goto cleanup;
+               }
+
+       /* Perform deletes now that updates are safely completed */
+       for (i = 0; i < n; i++)
+               if (locks[i]) {
+                       delnames[delnum++] = locks[i]->ref_name;
+                       ret |= delete_ref_loose(locks[i], types[i]);
+               }
+       ret |= repack_without_refs(delnames, delnum);
+       for (i = 0; i < delnum; i++)
+               unlink_or_warn(git_path("logs/%s", delnames[i]));
+       clear_loose_ref_cache(&ref_cache);
+
+cleanup:
+       for (i = 0; i < n; i++)
+               if (locks[i])
+                       unlock_ref(locks[i]);
+       free(updates);
+       free(types);
+       free(locks);
+       free(delnames);
+       return ret;
+}
+
 /*
  * generate a format suitable for scanf from a ref_rev_parse_rules
  * rule, that is replace the "%.*s" spec with a "%s" spec
diff --git a/refs.h b/refs.h
index 9e5db3ae26ec7898d8ee9083c37562d3af05c0ab..b113377c4806423af2cad13f1b38284b5f5e5f2f 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -10,6 +10,20 @@ struct ref_lock {
        int force_write;
 };
 
+/**
+ * Information needed for a single ref update.  Set new_sha1 to the
+ * new value or to zero to delete the ref.  To check the old value
+ * while locking the ref, set have_old to 1 and set old_sha1 to the
+ * value or to zero to ensure the ref does not exist before update.
+ */
+struct ref_update {
+       const char *ref_name;
+       unsigned char new_sha1[20];
+       unsigned char old_sha1[20];
+       int flags; /* REF_NODEREF? */
+       int have_old; /* 1 if old_sha1 is valid, 0 otherwise */
+};
+
 /*
  * Bit values set in the flags argument passed to each_ref_fn():
  */
@@ -137,7 +151,7 @@ extern struct ref_lock *lock_ref_sha1(const char *refname, const unsigned char *
 #define REF_NODEREF    0x01
 extern struct ref_lock *lock_any_ref_for_update(const char *refname,
                                                const unsigned char *old_sha1,
-                                               int flags);
+                                               int flags, int *type_p);
 
 /** Close the file descriptor owned by a lock and return the status */
 extern int close_ref(struct ref_lock *lock);
@@ -214,6 +228,12 @@ int update_ref(const char *action, const char *refname,
                const unsigned char *sha1, const unsigned char *oldval,
                int flags, enum action_on_err onerr);
 
+/**
+ * Lock all refs and then perform all modifications.
+ */
+int update_refs(const char *action, const struct ref_update **updates,
+               int n, enum action_on_err onerr);
+
 extern int parse_hide_refs_config(const char *var, const char *value, const char *);
 extern int ref_is_hidden(const char *);
 
index 24334679e0971e3af5e168d1cf7259da55d21d50..e9fedfa918d6806532184b8735d2761951fd4a2e 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -1729,7 +1729,11 @@ int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1)
 }
 
 /*
- * Return true if there is anything to report, otherwise false.
+ * Compare a branch with its upstream, and save their differences (number
+ * of commits) in *num_ours and *num_theirs.
+ *
+ * Return 0 if branch has no upstream (no base), -1 if upstream is missing
+ * (with "gone" base), otherwise 1 (with base).
  */
 int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
 {
@@ -1740,34 +1744,30 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
        const char *rev_argv[10], *base;
        int rev_argc;
 
-       /*
-        * Nothing to report unless we are marked to build on top of
-        * somebody else.
-        */
+       /* Cannot stat unless we are marked to build on top of somebody else. */
        if (!branch ||
            !branch->merge || !branch->merge[0] || !branch->merge[0]->dst)
                return 0;
 
-       /*
-        * If what we used to build on no longer exists, there is
-        * nothing to report.
-        */
+       /* Cannot stat if what we used to build on no longer exists */
        base = branch->merge[0]->dst;
        if (read_ref(base, sha1))
-               return 0;
+               return -1;
        theirs = lookup_commit_reference(sha1);
        if (!theirs)
-               return 0;
+               return -1;
 
        if (read_ref(branch->refname, sha1))
-               return 0;
+               return -1;
        ours = lookup_commit_reference(sha1);
        if (!ours)
-               return 0;
+               return -1;
 
        /* are we the same? */
-       if (theirs == ours)
-               return 0;
+       if (theirs == ours) {
+               *num_theirs = *num_ours = 0;
+               return 1;
+       }
 
        /* Run "rev-list --left-right ours...theirs" internally... */
        rev_argc = 0;
@@ -1809,31 +1809,53 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
  */
 int format_tracking_info(struct branch *branch, struct strbuf *sb)
 {
-       int num_ours, num_theirs;
+       int ours, theirs;
        const char *base;
+       int upstream_is_gone = 0;
 
-       if (!stat_tracking_info(branch, &num_ours, &num_theirs))
+       switch (stat_tracking_info(branch, &ours, &theirs)) {
+       case 0:
+               /* no base */
                return 0;
+       case -1:
+               /* with "gone" base */
+               upstream_is_gone = 1;
+               break;
+       default:
+               /* with base */
+               break;
+       }
 
        base = branch->merge[0]->dst;
        base = shorten_unambiguous_ref(base, 0);
-       if (!num_theirs) {
+       if (upstream_is_gone) {
+               strbuf_addf(sb,
+                       _("Your branch is based on '%s', but the upstream is gone.\n"),
+                       base);
+               if (advice_status_hints)
+                       strbuf_addf(sb,
+                               _("  (use \"git branch --unset-upstream\" to fixup)\n"));
+       } else if (!ours && !theirs) {
+               strbuf_addf(sb,
+                       _("Your branch is up-to-date with '%s'.\n"),
+                       base);
+       } else if (!theirs) {
                strbuf_addf(sb,
                        Q_("Your branch is ahead of '%s' by %d commit.\n",
                           "Your branch is ahead of '%s' by %d commits.\n",
-                          num_ours),
-                       base, num_ours);
+                          ours),
+                       base, ours);
                if (advice_status_hints)
                        strbuf_addf(sb,
                                _("  (use \"git push\" to publish your local commits)\n"));
-       } else if (!num_ours) {
+       } else if (!ours) {
                strbuf_addf(sb,
                        Q_("Your branch is behind '%s' by %d commit, "
                               "and can be fast-forwarded.\n",
                           "Your branch is behind '%s' by %d commits, "
                               "and can be fast-forwarded.\n",
-                          num_theirs),
-                       base, num_theirs);
+                          theirs),
+                       base, theirs);
                if (advice_status_hints)
                        strbuf_addf(sb,
                                _("  (use \"git pull\" to update your local branch)\n"));
@@ -1845,8 +1867,8 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
                           "Your branch and '%s' have diverged,\n"
                               "and have %d and %d different commits each, "
                               "respectively.\n",
-                          num_theirs),
-                       base, num_ours, num_theirs);
+                          theirs),
+                       base, ours, theirs);
                if (advice_status_hints)
                        strbuf_addf(sb,
                                _("  (use \"git pull\" to merge the remote branch into yours)\n"));
index 172b0d3b2c090c4b0bcce40b5cb19d5e544a0aed..0173e0148b850bd1a3e2e7e5c652050ade6d5ba4 100644 (file)
@@ -200,7 +200,7 @@ static void add_pending_object_with_mode(struct rev_info *revs,
                revs->no_walk = 0;
        if (revs->reflog_info && obj->type == OBJ_COMMIT) {
                struct strbuf buf = STRBUF_INIT;
-               int len = interpret_branch_name(name, &buf);
+               int len = interpret_branch_name(name, 0, &buf);
                int st;
 
                if (0 < len && name[len] && buf.len)
index 351548f57db61e62b47584020464aee877b48d8d..06e52b4c83ffc0ce2b9414afe3fb1b4ee91d4335 100644 (file)
@@ -279,7 +279,8 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
        read_cache();
        if (checkout_fast_forward(from, to, 1))
                exit(1); /* the callee should have complained already */
-       ref_lock = lock_any_ref_for_update("HEAD", unborn ? null_sha1 : from, 0);
+       ref_lock = lock_any_ref_for_update("HEAD", unborn ? null_sha1 : from,
+                                          0, NULL);
        strbuf_addf(&sb, "%s: fast-forward", action_name(opts));
        ret = write_ref_sha1(ref_lock, to, sb.buf);
        strbuf_release(&sb);
index c4dc55d1f5cd07adcf46865354f841cc587c51f6..2dd851598a9d1444fe479d149ee3c2cb93e8cba9 100644 (file)
@@ -204,7 +204,54 @@ int sha1_entry_pos(const void *table,
                         * byte 0 thru (ofs-1) are the same between
                         * lo and hi; ofs is the first byte that is
                         * different.
+                        *
+                        * If ofs==20, then no bytes are different,
+                        * meaning we have entries with duplicate
+                        * keys. We know that we are in a solid run
+                        * of this entry (because the entries are
+                        * sorted, and our lo and hi are the same,
+                        * there can be nothing but this single key
+                        * in between). So we can stop the search.
+                        * Either one of these entries is it (and
+                        * we do not care which), or we do not have
+                        * it.
+                        *
+                        * Furthermore, we know that one of our
+                        * endpoints must be the edge of the run of
+                        * duplicates. For example, given this
+                        * sequence:
+                        *
+                        *     idx 0 1 2 3 4 5
+                        *     key A C C C C D
+                        *
+                        * If we are searching for "B", we might
+                        * hit the duplicate run at lo=1, hi=3
+                        * (e.g., by first mi=3, then mi=0). But we
+                        * can never have lo > 1, because B < C.
+                        * That is, if our key is less than the
+                        * run, we know that "lo" is the edge, but
+                        * we can say nothing of "hi". Similarly,
+                        * if our key is greater than the run, we
+                        * know that "hi" is the edge, but we can
+                        * say nothing of "lo".
+                        *
+                        * Therefore if we do not find it, we also
+                        * know where it would go if it did exist:
+                        * just on the far side of the edge that we
+                        * know about.
                         */
+                       if (ofs == 20) {
+                               mi = lo;
+                               mi_key = base + elem_size * mi + key_offset;
+                               cmp = memcmp(mi_key, key, 20);
+                               if (!cmp)
+                                       return mi;
+                               if (cmp < 0)
+                                       return -1 - hi;
+                               else
+                                       return -1 - lo;
+                       }
+
                        hiv = hi_key[ofs_0];
                        if (ofs_0 < 19)
                                hiv = (hiv << 8) | hi_key[ofs_0+1];
index ad79d7b81249b6908bb9728b88addbb2fe6955cd..0e5fe7f9371d2e6ae5aa9ce99c4b6c2dfb7a456f 100644 (file)
@@ -677,11 +677,13 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)
                return -1;
 
        sp++; /* beginning of type name, or closing brace for empty */
-       if (!strncmp(commit_type, sp, 6) && sp[6] == '}')
+       if (!prefixcmp(sp, "commit}"))
                expected_type = OBJ_COMMIT;
-       else if (!strncmp(tree_type, sp, 4) && sp[4] == '}')
+       else if (!prefixcmp(sp, "tag}"))
+               expected_type = OBJ_TAG;
+       else if (!prefixcmp(sp, "tree}"))
                expected_type = OBJ_TREE;
-       else if (!strncmp(blob_type, sp, 4) && sp[4] == '}')
+       else if (!prefixcmp(sp, "blob}"))
                expected_type = OBJ_BLOB;
        else if (!prefixcmp(sp, "object}"))
                expected_type = OBJ_ANY;
@@ -1004,6 +1006,28 @@ int get_sha1_mb(const char *name, unsigned char *sha1)
        return st;
 }
 
+/* parse @something syntax, when 'something' is not {.*} */
+static int interpret_empty_at(const char *name, int namelen, int len, struct strbuf *buf)
+{
+       const char *next;
+
+       if (len || name[1] == '{')
+               return -1;
+
+       /* make sure it's a single @, or @@{.*}, not @foo */
+       next = strchr(name + len + 1, '@');
+       if (next && next[1] != '{')
+               return -1;
+       if (!next)
+               next = name + namelen;
+       if (next != name + 1)
+               return -1;
+
+       strbuf_reset(buf);
+       strbuf_add(buf, "HEAD", 4);
+       return 1;
+}
+
 static int reinterpret(const char *name, int namelen, int len, struct strbuf *buf)
 {
        /* we have extra data, which might need further processing */
@@ -1012,7 +1036,7 @@ static int reinterpret(const char *name, int namelen, int len, struct strbuf *bu
        int ret;
 
        strbuf_add(buf, name + len, namelen - len);
-       ret = interpret_branch_name(buf->buf, &tmp);
+       ret = interpret_branch_name(buf->buf, buf->len, &tmp);
        /* that data was not interpreted, remove our cruft */
        if (ret < 0) {
                strbuf_setlen(buf, used);
@@ -1046,14 +1070,16 @@ static int reinterpret(const char *name, int namelen, int len, struct strbuf *bu
  * If the input was ok but there are not N branch switches in the
  * reflog, it returns 0.
  */
-int interpret_branch_name(const char *name, struct strbuf *buf)
+int interpret_branch_name(const char *name, int namelen, struct strbuf *buf)
 {
        char *cp;
        struct branch *upstream;
-       int namelen = strlen(name);
        int len = interpret_nth_prior_checkout(name, buf);
        int tmp_len;
 
+       if (!namelen)
+               namelen = strlen(name);
+
        if (!len) {
                return len; /* syntax Ok, not enough switches */
        } else if (len > 0) {
@@ -1066,9 +1092,15 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
        cp = strchr(name, '@');
        if (!cp)
                return -1;
+
+       len = interpret_empty_at(name, namelen, cp - name, buf);
+       if (len > 0)
+               return reinterpret(name, namelen, len, buf);
+
        tmp_len = upstream_mark(cp, namelen - (cp - name));
        if (!tmp_len)
                return -1;
+
        len = cp + tmp_len - name;
        cp = xstrndup(name, cp - name);
        upstream = branch_get(*cp ? cp : NULL);
@@ -1100,7 +1132,7 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
 int strbuf_branchname(struct strbuf *sb, const char *name)
 {
        int len = strlen(name);
-       int used = interpret_branch_name(name, sb);
+       int used = interpret_branch_name(name, len, sb);
 
        if (used == len)
                return 0;
index 8a9c96d019a1b3df4942f370fe0d312467a36799..cdf37d694de175adcce10fa2e2a79c6579603b0b 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "commit.h"
 #include "tag.h"
+#include "pkt-line.h"
 
 static int is_shallow = -1;
 static struct stat shallow_stat;
@@ -141,3 +142,81 @@ void check_shallow_file_for_update(void)
                   )
                die("shallow file was changed during fetch");
 }
+
+struct write_shallow_data {
+       struct strbuf *out;
+       int use_pack_protocol;
+       int count;
+};
+
+static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
+{
+       struct write_shallow_data *data = cb_data;
+       const char *hex = sha1_to_hex(graft->sha1);
+       if (graft->nr_parent != -1)
+               return 0;
+       data->count++;
+       if (data->use_pack_protocol)
+               packet_buf_write(data->out, "shallow %s", hex);
+       else {
+               strbuf_addstr(data->out, hex);
+               strbuf_addch(data->out, '\n');
+       }
+       return 0;
+}
+
+int write_shallow_commits(struct strbuf *out, int use_pack_protocol)
+{
+       struct write_shallow_data data;
+       data.out = out;
+       data.use_pack_protocol = use_pack_protocol;
+       data.count = 0;
+       for_each_commit_graft(write_one_shallow, &data);
+       return data.count;
+}
+
+char *setup_temporary_shallow(void)
+{
+       struct strbuf sb = STRBUF_INIT;
+       int fd;
+
+       if (write_shallow_commits(&sb, 0)) {
+               struct strbuf path = STRBUF_INIT;
+               strbuf_addstr(&path, git_path("shallow_XXXXXX"));
+               fd = xmkstemp(path.buf);
+               if (write_in_full(fd, sb.buf, sb.len) != sb.len)
+                       die_errno("failed to write to %s",
+                                 path.buf);
+               close(fd);
+               strbuf_release(&sb);
+               return strbuf_detach(&path, NULL);
+       }
+       /*
+        * is_repository_shallow() sees empty string as "no shallow
+        * file".
+        */
+       return xstrdup("");
+}
+
+void setup_alternate_shallow(struct lock_file *shallow_lock,
+                            const char **alternate_shallow_file)
+{
+       struct strbuf sb = STRBUF_INIT;
+       int fd;
+
+       check_shallow_file_for_update();
+       fd = hold_lock_file_for_update(shallow_lock, git_path("shallow"),
+                                      LOCK_DIE_ON_ERROR);
+       if (write_shallow_commits(&sb, 0)) {
+               if (write_in_full(fd, sb.buf, sb.len) != sb.len)
+                       die_errno("failed to write to %s",
+                                 shallow_lock->filename);
+               *alternate_shallow_file = shallow_lock->filename;
+       } else
+               /*
+                * is_repository_shallow() sees empty string as "no
+                * shallow file".
+                */
+               *alternate_shallow_file = "";
+       strbuf_release(&sb);
+}
index 2098b9ba053b09b00ed4382aa55ea0802d749d89..ccd918e79ef4fa7962984c5ed4890ec07e92f03a 100644 (file)
@@ -48,7 +48,8 @@ P4DPORT=$((10669 + ($testid - $git_p4_test_start)))
 P4PORT=localhost:$P4DPORT
 P4CLIENT=client
 P4EDITOR=:
-export P4PORT P4CLIENT P4EDITOR
+unset P4CHARSET
+export P4PORT P4CLIENT P4EDITOR P4CHARSET
 
 db="$TRASH_DIRECTORY/db"
 cli="$TRASH_DIRECTORY/cli"
index dab405d57479fe95dcb71b16a7a059410d2ae005..54dbbfe5ceeb9bf91cdad3393c2fdfe95c06fd18 100644 (file)
@@ -169,7 +169,7 @@ test_http_push_nonff () {
                test_i18ngrep "Updates were rejected because" output
        '
 
-       test_expect_failure 'force with lease aka cas' '
+       test_expect_${EXPECT_CAS_RESULT} 'force with lease aka cas' '
                HEAD=$( cd "$REMOTE_REPO" && git rev-parse --verify HEAD ) &&
                test_when_finished '\''
                        (cd "$REMOTE_REPO" && git update-ref HEAD "$HEAD")
diff --git a/t/lib-pack.sh b/t/lib-pack.sh
new file mode 100644 (file)
index 0000000..7e8685b
--- /dev/null
@@ -0,0 +1,100 @@
+#!/bin/sh
+#
+# Support routines for hand-crafting weird or malicious packs.
+#
+# You can make a complete pack like:
+#
+#   pack_header 2 >foo.pack &&
+#   pack_obj e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 >>foo.pack &&
+#   pack_obj e68fe8129b546b101aee9510c5328e7f21ca1d18 >>foo.pack &&
+#   pack_trailer foo.pack
+
+# Print the big-endian 4-byte octal representation of $1
+uint32_octal () {
+       n=$1
+       printf '\%o' $(($n / 16777216)); n=$((n % 16777216))
+       printf '\%o' $(($n /    65536)); n=$((n %    65536))
+       printf '\%o' $(($n /      256)); n=$((n %      256))
+       printf '\%o' $(($n           ));
+}
+
+# Print the big-endian 4-byte binary representation of $1
+uint32_binary () {
+       printf "$(uint32_octal "$1")"
+}
+
+# Print a pack header, version 2, for a pack with $1 objects
+pack_header () {
+       printf 'PACK' &&
+       printf '\0\0\0\2' &&
+       uint32_binary "$1"
+}
+
+# Print the pack data for object $1, as a delta against object $2 (or as a full
+# object if $2 is missing or empty). The output is suitable for including
+# directly in the packfile, and represents the entirety of the object entry.
+# Doing this on the fly (especially picking your deltas) is quite tricky, so we
+# have hardcoded some well-known objects. See the case statements below for the
+# complete list.
+pack_obj () {
+       case "$1" in
+       # empty blob
+       e69de29bb2d1d6434b8b29ae775ad8c2e48c5391)
+               case "$2" in
+               '')
+                       printf '\060\170\234\003\0\0\0\0\1'
+                       return
+                       ;;
+               esac
+               ;;
+
+       # blob containing "\7\76"
+       e68fe8129b546b101aee9510c5328e7f21ca1d18)
+               case "$2" in
+               '')
+                       printf '\062\170\234\143\267\3\0\0\116\0\106'
+                       return
+                       ;;
+               01d7713666f4de822776c7622c10f1b07de280dc)
+                       printf '\165\1\327\161\66\146\364\336\202\47\166' &&
+                       printf '\307\142\54\20\361\260\175\342\200\334\170' &&
+                       printf '\234\143\142\142\142\267\003\0\0\151\0\114'
+                       return
+                       ;;
+               esac
+               ;;
+
+       # blob containing "\7\0"
+       01d7713666f4de822776c7622c10f1b07de280dc)
+               case "$2" in
+               '')
+                       printf '\062\170\234\143\147\0\0\0\20\0\10'
+                       return
+                       ;;
+               e68fe8129b546b101aee9510c5328e7f21ca1d18)
+                       printf '\165\346\217\350\22\233\124\153\20\32\356' &&
+                       printf '\225\20\305\62\216\177\41\312\35\30\170\234' &&
+                       printf '\143\142\142\142\147\0\0\0\53\0\16'
+                       return
+                       ;;
+               esac
+               ;;
+       esac
+
+       echo >&2 "BUG: don't know how to print $1${2:+ (from $2)}"
+       return 1
+}
+
+# Compute and append pack trailer to "$1"
+pack_trailer () {
+       test-sha1 -b <"$1" >trailer.tmp &&
+       cat trailer.tmp >>"$1" &&
+       rm -f trailer.tmp
+}
+
+# Remove any existing packs to make sure that
+# whatever we index next will be the pack that we
+# actually use.
+clear_packs () {
+       rm -f .git/objects/pack/*
+}
index ad664105646d4579a4e31ea5d230268acc33c0f5..9fb582b192e7d44856d3687234de922217e511f4 100755 (executable)
@@ -379,6 +379,10 @@ test_expect_success 'init with separate gitdir' '
        test -d realgitdir/refs
 '
 
+test_expect_success 're-init on .git file' '
+       ( cd newdir && git init )
+'
+
 test_expect_success 're-init to update git link' '
        (
        cd newdir &&
index 96f40fedfb7285b50243a1c1bbe64649ef7f8edb..181513ab4fba47750b3e6b25eb105f2c8a4a011f 100755 (executable)
@@ -66,11 +66,11 @@ test_check_ignore () {
 
        init_vars &&
        rm -f "$HOME/stdout" "$HOME/stderr" "$HOME/cmd" &&
-       echo git $global_args check-ignore $quiet_opt $verbose_opt $non_matching_opt $args \
+       echo git $global_args check-ignore $quiet_opt $verbose_opt $non_matching_opt $no_index_opt $args \
                >"$HOME/cmd" &&
        echo "$expect_code" >"$HOME/expected-exit-code" &&
        test_expect_code "$expect_code" \
-               git $global_args check-ignore $quiet_opt $verbose_opt $non_matching_opt $args \
+               git $global_args check-ignore $quiet_opt $verbose_opt $non_matching_opt $no_index_opt $args \
                >"$HOME/stdout" 2>"$HOME/stderr" &&
        test_cmp "$HOME/expected-stdout" "$HOME/stdout" &&
        stderr_empty_on_success "$expect_code"
@@ -87,6 +87,9 @@ test_check_ignore () {
 # check-ignore --verbose output is the same as normal output except
 # for the extra first column.
 #
+# A parameter is used to determine if the tests are run with the
+# normal case (using the index), or with the --no-index option.
+#
 # Arguments:
 #   - (optional) prereqs for this test, e.g. 'SYMLINKS'
 #   - test name
@@ -94,19 +97,26 @@ test_check_ignore () {
 #     from the other verbosity modes is automatically inferred
 #     from this value)
 #   - code to run (should invoke test_check_ignore)
-test_expect_success_multi () {
+#   - index option: --index or --no-index
+test_expect_success_multiple () {
        prereq=
-       if test $# -eq 4
+       if test $# -eq 5
        then
                prereq=$1
                shift
        fi
+       if test "$4" = "--index"
+       then
+               no_index_opt=
+       else
+               no_index_opt=$4
+       fi
        testname="$1" expect_all="$2" code="$3"
 
        expect_verbose=$( echo "$expect_all" | grep -v '^::     ' )
        expect=$( echo "$expect_verbose" | sed -e 's/.* //' )
 
-       test_expect_success $prereq "$testname" '
+       test_expect_success $prereq "$testname${no_index_opt:+ with $no_index_opt}" '
                expect "$expect" &&
                eval "$code"
        '
@@ -116,7 +126,8 @@ test_expect_success_multi () {
        then
                for quiet_opt in '-q' '--quiet'
                do
-                       test_expect_success $prereq "$testname${quiet_opt:+ with $quiet_opt}" "
+                       opts="${no_index_opt:+$no_index_opt }$quiet_opt"
+                       test_expect_success $prereq "$testname${opts:+ with $opts}" "
                        expect '' &&
                        $code
                "
@@ -126,7 +137,7 @@ test_expect_success_multi () {
 
        for verbose_opt in '-v' '--verbose'
        do
-               for non_matching_opt in '' ' -n' ' --non-matching'
+               for non_matching_opt in '' '-n' '--non-matching'
                do
                        if test -n "$non_matching_opt"
                        then
@@ -139,12 +150,21 @@ test_expect_success_multi () {
                                expect '$my_expect' &&
                                $code
                        "
-                       opts="$verbose_opt$non_matching_opt"
+                       opts="${no_index_opt:+$no_index_opt }$verbose_opt${non_matching_opt:+ $non_matching_opt}"
                        test_expect_success $prereq "$testname${opts:+ with $opts}" "$test_code"
                done
        done
        verbose_opt=
        non_matching_opt=
+       no_index_opt=
+}
+
+test_expect_success_multi () {
+       test_expect_success_multiple "$@" "--index"
+}
+
+test_expect_success_no_index_multi () {
+       test_expect_success_multiple "$@" "--no-index"
 }
 
 test_expect_success 'setup' '
@@ -288,7 +308,7 @@ test_expect_success_multi 'needs work tree' '' '
 
 # First make sure that the presence of a file in the working tree
 # does not impact results, but that the presence of a file in the
-# index does.
+# index does unless the --no-index option is used.
 
 for subdir in '' 'a/'
 do
@@ -303,27 +323,61 @@ do
                "::     ${subdir}non-existent" \
                "test_check_ignore '${subdir}non-existent' 1"
 
+       test_expect_success_no_index_multi "non-existent file $where not ignored" \
+               "::     ${subdir}non-existent" \
+               "test_check_ignore '${subdir}non-existent' 1"
+
        test_expect_success_multi "non-existent file $where ignored" \
                ".gitignore:1:one       ${subdir}one" \
                "test_check_ignore '${subdir}one'"
 
+       test_expect_success_no_index_multi "non-existent file $where ignored" \
+               ".gitignore:1:one       ${subdir}one" \
+               "test_check_ignore '${subdir}one'"
+
        test_expect_success_multi "existing untracked file $where not ignored" \
                "::     ${subdir}not-ignored" \
                "test_check_ignore '${subdir}not-ignored' 1"
 
+       test_expect_success_no_index_multi "existing untracked file $where not ignored" \
+               "::     ${subdir}not-ignored" \
+               "test_check_ignore '${subdir}not-ignored' 1"
+
        test_expect_success_multi "existing tracked file $where not ignored" \
                "::     ${subdir}ignored-but-in-index" \
                "test_check_ignore '${subdir}ignored-but-in-index' 1"
 
+       test_expect_success_no_index_multi "existing tracked file $where shown as ignored" \
+               ".gitignore:2:ignored-* ${subdir}ignored-but-in-index" \
+               "test_check_ignore '${subdir}ignored-but-in-index'"
+
        test_expect_success_multi "existing untracked file $where ignored" \
                ".gitignore:2:ignored-* ${subdir}ignored-and-untracked" \
                "test_check_ignore '${subdir}ignored-and-untracked'"
 
+       test_expect_success_no_index_multi "existing untracked file $where ignored" \
+               ".gitignore:2:ignored-* ${subdir}ignored-and-untracked" \
+               "test_check_ignore '${subdir}ignored-and-untracked'"
+
        test_expect_success_multi "mix of file types $where" \
 "::    ${subdir}non-existent
 .gitignore:1:one       ${subdir}one
 ::     ${subdir}not-ignored
 ::     ${subdir}ignored-but-in-index
+.gitignore:2:ignored-* ${subdir}ignored-and-untracked" \
+               "test_check_ignore '
+                       ${subdir}non-existent
+                       ${subdir}one
+                       ${subdir}not-ignored
+                       ${subdir}ignored-but-in-index
+                       ${subdir}ignored-and-untracked'
+               "
+
+       test_expect_success_no_index_multi "mix of file types $where" \
+"::    ${subdir}non-existent
+.gitignore:1:one       ${subdir}one
+::     ${subdir}not-ignored
+.gitignore:2:ignored-* ${subdir}ignored-but-in-index
 .gitignore:2:ignored-* ${subdir}ignored-and-untracked" \
                "test_check_ignore '
                        ${subdir}non-existent
diff --git a/t/t0056-git-C.sh b/t/t0056-git-C.sh
new file mode 100755 (executable)
index 0000000..99c0377
--- /dev/null
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+test_description='"-C <path>" option and its effects on other path-related options'
+
+. ./test-lib.sh
+
+test_expect_success '"git -C <path>" runs git from the directory <path>' '
+       test_create_repo dir1 &&
+       echo 1 >dir1/a.txt &&
+       msg="initial in dir1" &&
+       (cd dir1 && git add a.txt && git commit -m "$msg") &&
+       echo "$msg" >expected &&
+       git -C dir1 log --format=%s >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'Multiple -C options: "-C dir1 -C dir2" is equivalent to "-C dir1/dir2"' '
+       test_create_repo dir1/dir2 &&
+       echo 1 >dir1/dir2/b.txt &&
+       git -C dir1/dir2 add b.txt &&
+       msg="initial in dir1/dir2" &&
+       echo "$msg" >expected &&
+       git -C dir1/dir2 commit -m "$msg" &&
+       git -C dir1 -C dir2 log --format=%s >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'Effect on --git-dir option: "-C c --git-dir=a.git" is equivalent to "--git-dir c/a.git"' '
+       mkdir c &&
+       mkdir c/a &&
+       mkdir c/a.git &&
+       (cd c/a.git && git init --bare) &&
+       echo 1 >c/a/a.txt &&
+       git --git-dir c/a.git --work-tree=c/a add a.txt &&
+       git --git-dir c/a.git --work-tree=c/a commit -m "initial" &&
+       git --git-dir=c/a.git log -1 --format=%s >expected &&
+       git -C c --git-dir=a.git log -1 --format=%s >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'Order should not matter: "--git-dir=a.git -C c" is equivalent to "-C c --git-dir=a.git"' '
+       git -C c --git-dir=a.git log -1 --format=%s >expected &&
+       git --git-dir=a.git -C c log -1 --format=%s >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'Effect on --work-tree option: "-C c/a.git --work-tree=../a"  is equivalent to "--work-tree=c/a --git-dir=c/a.git"' '
+       rm c/a/a.txt &&
+       git --git-dir=c/a.git --work-tree=c/a status >expected &&
+       git -C c/a.git --work-tree=../a status >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'Order should not matter: "--work-tree=../a -C c/a.git" is equivalent to "-C c/a.git --work-tree=../a"' '
+       git -C c/a.git --work-tree=../a status >expected &&
+       git --work-tree=../a -C c/a.git status >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'Effect on --git-dir and --work-tree options - "-C c --git-dir=a.git --work-tree=a" is equivalent to "--git-dir=c/a.git --work-tree=c/a"' '
+       git --git-dir=c/a.git --work-tree=c/a status >expected &&
+       git -C c --git-dir=a.git --work-tree=a status >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'Order should not matter: "-C c --git-dir=a.git --work-tree=a" is equivalent to "--git-dir=a.git -C c --work-tree=a"' '
+       git -C c --git-dir=a.git --work-tree=a status >expected &&
+       git --git-dir=a.git -C c --work-tree=a status >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'Order should not matter: "-C c --git-dir=a.git --work-tree=a" is equivalent to "--git-dir=a.git --work-tree=a -C c"' '
+       git -C c --git-dir=a.git --work-tree=a status >expected &&
+       git --git-dir=a.git --work-tree=a -C c status >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'Relative followed by fullpath: "-C ./here -C /there" is equivalent to "-C /there"' '
+       echo "initial in dir1/dir2" >expected &&
+       git -C dir1 -C "$(pwd)/dir1/dir2" log --format=%s >actual &&
+       test_cmp expected actual
+'
+
+test_done
index e415ee0bbf1dcf45f3ee771d0fefedb1c8fa4246..6ffd82fe321cd3154d6f193c21198218e762f1b2 100755 (executable)
@@ -302,4 +302,636 @@ test_expect_success \
        'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \
        'test OTHER = $(git cat-file blob "master@{2005-05-26 23:42}:F")'
 
+a=refs/heads/a
+b=refs/heads/b
+c=refs/heads/c
+E='""'
+F='%s\0'
+pws='path with space'
+
+test_expect_success 'stdin test setup' '
+       echo "$pws" >"$pws" &&
+       git add -- "$pws" &&
+       git commit -m "$pws"
+'
+
+test_expect_success '-z fails without --stdin' '
+       test_must_fail git update-ref -z $m $m $m 2>err &&
+       grep "usage: git update-ref" err
+'
+
+test_expect_success 'stdin works with no input' '
+       >stdin &&
+       git update-ref --stdin <stdin &&
+       git rev-parse --verify -q $m
+'
+
+test_expect_success 'stdin fails on empty line' '
+       echo "" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: empty command in input" err
+'
+
+test_expect_success 'stdin fails on only whitespace' '
+       echo " " >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: whitespace before command:  " err
+'
+
+test_expect_success 'stdin fails on leading whitespace' '
+       echo " create $a $m" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: whitespace before command:  create $a $m" err
+'
+
+test_expect_success 'stdin fails on unknown command' '
+       echo "unknown $a" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: unknown command: unknown $a" err
+'
+
+test_expect_success 'stdin fails on badly quoted input' '
+       echo "create $a \"master" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: badly quoted argument: \\\"master" err
+'
+
+test_expect_success 'stdin fails on arguments not separated by space' '
+       echo "create \"$a\"master" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: expected SP but got: master" err
+'
+
+test_expect_success 'stdin fails create with no ref' '
+       echo "create " >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: create line missing <ref>" err
+'
+
+test_expect_success 'stdin fails create with bad ref name' '
+       echo "create ~a $m" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: invalid ref format: ~a" err
+'
+
+test_expect_success 'stdin fails create with no new value' '
+       echo "create $a" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: create $a missing <newvalue>" err
+'
+
+test_expect_success 'stdin fails create with too many arguments' '
+       echo "create $a $m $m" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: create $a has extra input:  $m" err
+'
+
+test_expect_success 'stdin fails update with no ref' '
+       echo "update " >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: update line missing <ref>" err
+'
+
+test_expect_success 'stdin fails update with bad ref name' '
+       echo "update ~a $m" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: invalid ref format: ~a" err
+'
+
+test_expect_success 'stdin fails update with no new value' '
+       echo "update $a" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: update $a missing <newvalue>" err
+'
+
+test_expect_success 'stdin fails update with too many arguments' '
+       echo "update $a $m $m $m" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: update $a has extra input:  $m" err
+'
+
+test_expect_success 'stdin fails delete with no ref' '
+       echo "delete " >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: delete line missing <ref>" err
+'
+
+test_expect_success 'stdin fails delete with bad ref name' '
+       echo "delete ~a $m" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: invalid ref format: ~a" err
+'
+
+test_expect_success 'stdin fails delete with too many arguments' '
+       echo "delete $a $m $m" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: delete $a has extra input:  $m" err
+'
+
+test_expect_success 'stdin fails verify with too many arguments' '
+       echo "verify $a $m $m" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: verify $a has extra input:  $m" err
+'
+
+test_expect_success 'stdin fails option with unknown name' '
+       echo "option unknown" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: option unknown: unknown" err
+'
+
+test_expect_success 'stdin fails with duplicate refs' '
+       cat >stdin <<-EOF &&
+       create $a $m
+       create $b $m
+       create $a $m
+       EOF
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: Multiple updates for ref '"'"'$a'"'"' not allowed." err
+'
+
+test_expect_success 'stdin create ref works' '
+       echo "create $a $m" >stdin &&
+       git update-ref --stdin <stdin &&
+       git rev-parse $m >expect &&
+       git rev-parse $a >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin update ref creates with zero old value' '
+       echo "update $b $m $Z" >stdin &&
+       git update-ref --stdin <stdin &&
+       git rev-parse $m >expect &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual &&
+       git update-ref -d $b
+'
+
+test_expect_success 'stdin update ref creates with empty old value' '
+       echo "update $b $m $E" >stdin &&
+       git update-ref --stdin <stdin &&
+       git rev-parse $m >expect &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin create ref works with path with space to blob' '
+       echo "create refs/blobs/pws \"$m:$pws\"" >stdin &&
+       git update-ref --stdin <stdin &&
+       git rev-parse "$m:$pws" >expect &&
+       git rev-parse refs/blobs/pws >actual &&
+       test_cmp expect actual &&
+       git update-ref -d refs/blobs/pws
+'
+
+test_expect_success 'stdin update ref fails with wrong old value' '
+       echo "update $c $m $m~1" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: Cannot lock the ref '"'"'$c'"'"'" err &&
+       test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin update ref fails with bad old value' '
+       echo "update $c $m does-not-exist" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: invalid old value for ref $c: does-not-exist" err &&
+       test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin create ref fails with bad new value' '
+       echo "create $c does-not-exist" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: invalid new value for ref $c: does-not-exist" err &&
+       test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin create ref fails with zero new value' '
+       echo "create $c " >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: create $c given zero new value" err &&
+       test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin update ref works with right old value' '
+       echo "update $b $m~1 $m" >stdin &&
+       git update-ref --stdin <stdin &&
+       git rev-parse $m~1 >expect &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin delete ref fails with wrong old value' '
+       echo "delete $a $m~1" >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: Cannot lock the ref '"'"'$a'"'"'" err &&
+       git rev-parse $m >expect &&
+       git rev-parse $a >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin delete ref fails with zero old value' '
+       echo "delete $a " >stdin &&
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: delete $a given zero old value" err &&
+       git rev-parse $m >expect &&
+       git rev-parse $a >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin update symref works option no-deref' '
+       git symbolic-ref TESTSYMREF $b &&
+       cat >stdin <<-EOF &&
+       option no-deref
+       update TESTSYMREF $a $b
+       EOF
+       git update-ref --stdin <stdin &&
+       git rev-parse TESTSYMREF >expect &&
+       git rev-parse $a >actual &&
+       test_cmp expect actual &&
+       git rev-parse $m~1 >expect &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin delete symref works option no-deref' '
+       git symbolic-ref TESTSYMREF $b &&
+       cat >stdin <<-EOF &&
+       option no-deref
+       delete TESTSYMREF $b
+       EOF
+       git update-ref --stdin <stdin &&
+       test_must_fail git rev-parse --verify -q TESTSYMREF &&
+       git rev-parse $m~1 >expect &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin delete ref works with right old value' '
+       echo "delete $b $m~1" >stdin &&
+       git update-ref --stdin <stdin &&
+       test_must_fail git rev-parse --verify -q $b
+'
+
+test_expect_success 'stdin update/create/verify combination works' '
+       cat >stdin <<-EOF &&
+       update $a $m
+       create $b $m
+       verify $c
+       EOF
+       git update-ref --stdin <stdin &&
+       git rev-parse $m >expect &&
+       git rev-parse $a >actual &&
+       test_cmp expect actual &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual &&
+       test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin update refs works with identity updates' '
+       cat >stdin <<-EOF &&
+       update $a $m $m
+       update $b $m $m
+       update $c $Z $E
+       EOF
+       git update-ref --stdin <stdin &&
+       git rev-parse $m >expect &&
+       git rev-parse $a >actual &&
+       test_cmp expect actual &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual &&
+       test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin update refs fails with wrong old value' '
+       git update-ref $c $m &&
+       cat >stdin <<-EOF &&
+       update $a $m $m
+       update $b $m $m
+       update $c  ''
+       EOF
+       test_must_fail git update-ref --stdin <stdin 2>err &&
+       grep "fatal: Cannot lock the ref '"'"'$c'"'"'" err &&
+       git rev-parse $m >expect &&
+       git rev-parse $a >actual &&
+       test_cmp expect actual &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual &&
+       git rev-parse $c >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin delete refs works with packed and loose refs' '
+       git pack-refs --all &&
+       git update-ref $c $m~1 &&
+       cat >stdin <<-EOF &&
+       delete $a $m
+       update $b $Z $m
+       update $c $E $m~1
+       EOF
+       git update-ref --stdin <stdin &&
+       test_must_fail git rev-parse --verify -q $a &&
+       test_must_fail git rev-parse --verify -q $b &&
+       test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin -z works on empty input' '
+       >stdin &&
+       git update-ref -z --stdin <stdin &&
+       git rev-parse --verify -q $m
+'
+
+test_expect_success 'stdin -z fails on empty line' '
+       echo "" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: whitespace before command: " err
+'
+
+test_expect_success 'stdin -z fails on empty command' '
+       printf $F "" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: empty command in input" err
+'
+
+test_expect_success 'stdin -z fails on only whitespace' '
+       printf $F " " >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: whitespace before command:  " err
+'
+
+test_expect_success 'stdin -z fails on leading whitespace' '
+       printf $F " create $a" "$m" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: whitespace before command:  create $a" err
+'
+
+test_expect_success 'stdin -z fails on unknown command' '
+       printf $F "unknown $a" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: unknown command: unknown $a" err
+'
+
+test_expect_success 'stdin -z fails create with no ref' '
+       printf $F "create " >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: create line missing <ref>" err
+'
+
+test_expect_success 'stdin -z fails create with bad ref name' '
+       printf $F "create ~a " "$m" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: invalid ref format: ~a " err
+'
+
+test_expect_success 'stdin -z fails create with no new value' '
+       printf $F "create $a" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: create $a missing <newvalue>" err
+'
+
+test_expect_success 'stdin -z fails create with too many arguments' '
+       printf $F "create $a" "$m" "$m" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: unknown command: $m" err
+'
+
+test_expect_success 'stdin -z fails update with no ref' '
+       printf $F "update " >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: update line missing <ref>" err
+'
+
+test_expect_success 'stdin -z fails update with bad ref name' '
+       printf $F "update ~a" "$m" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: invalid ref format: ~a" err
+'
+
+test_expect_success 'stdin -z fails update with no new value' '
+       printf $F "update $a" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: update $a missing <newvalue>" err
+'
+
+test_expect_success 'stdin -z fails update with no old value' '
+       printf $F "update $a" "$m" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: update $a missing \\[<oldvalue>\\] NUL" err
+'
+
+test_expect_success 'stdin -z fails update with too many arguments' '
+       printf $F "update $a" "$m" "$m" "$m" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: unknown command: $m" err
+'
+
+test_expect_success 'stdin -z fails delete with no ref' '
+       printf $F "delete " >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: delete line missing <ref>" err
+'
+
+test_expect_success 'stdin -z fails delete with bad ref name' '
+       printf $F "delete ~a" "$m" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: invalid ref format: ~a" err
+'
+
+test_expect_success 'stdin -z fails delete with no old value' '
+       printf $F "delete $a" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: delete $a missing \\[<oldvalue>\\] NUL" err
+'
+
+test_expect_success 'stdin -z fails delete with too many arguments' '
+       printf $F "delete $a" "$m" "$m" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: unknown command: $m" err
+'
+
+test_expect_success 'stdin -z fails verify with too many arguments' '
+       printf $F "verify $a" "$m" "$m" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: unknown command: $m" err
+'
+
+test_expect_success 'stdin -z fails verify with no old value' '
+       printf $F "verify $a" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: verify $a missing \\[<oldvalue>\\] NUL" err
+'
+
+test_expect_success 'stdin -z fails option with unknown name' '
+       printf $F "option unknown" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: option unknown: unknown" err
+'
+
+test_expect_success 'stdin -z fails with duplicate refs' '
+       printf $F "create $a" "$m" "create $b" "$m" "create $a" "$m" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: Multiple updates for ref '"'"'$a'"'"' not allowed." err
+'
+
+test_expect_success 'stdin -z create ref works' '
+       printf $F "create $a" "$m" >stdin &&
+       git update-ref -z --stdin <stdin &&
+       git rev-parse $m >expect &&
+       git rev-parse $a >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin -z update ref creates with zero old value' '
+       printf $F "update $b" "$m" "$Z" >stdin &&
+       git update-ref -z --stdin <stdin &&
+       git rev-parse $m >expect &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual &&
+       git update-ref -d $b
+'
+
+test_expect_success 'stdin -z update ref creates with empty old value' '
+       printf $F "update $b" "$m" "" >stdin &&
+       git update-ref -z --stdin <stdin &&
+       git rev-parse $m >expect &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin -z create ref works with path with space to blob' '
+       printf $F "create refs/blobs/pws" "$m:$pws" >stdin &&
+       git update-ref -z --stdin <stdin &&
+       git rev-parse "$m:$pws" >expect &&
+       git rev-parse refs/blobs/pws >actual &&
+       test_cmp expect actual &&
+       git update-ref -d refs/blobs/pws
+'
+
+test_expect_success 'stdin -z update ref fails with wrong old value' '
+       printf $F "update $c" "$m" "$m~1" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: Cannot lock the ref '"'"'$c'"'"'" err &&
+       test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin -z update ref fails with bad old value' '
+       printf $F "update $c" "$m" "does-not-exist" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: invalid old value for ref $c: does-not-exist" err &&
+       test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin -z create ref fails with bad new value' '
+       printf $F "create $c" "does-not-exist" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: invalid new value for ref $c: does-not-exist" err &&
+       test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin -z create ref fails with zero new value' '
+       printf $F "create $c" "" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: create $c given zero new value" err &&
+       test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin -z update ref works with right old value' '
+       printf $F "update $b" "$m~1" "$m" >stdin &&
+       git update-ref -z --stdin <stdin &&
+       git rev-parse $m~1 >expect &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin -z delete ref fails with wrong old value' '
+       printf $F "delete $a" "$m~1" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: Cannot lock the ref '"'"'$a'"'"'" err &&
+       git rev-parse $m >expect &&
+       git rev-parse $a >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin -z delete ref fails with zero old value' '
+       printf $F "delete $a" "$Z" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: delete $a given zero old value" err &&
+       git rev-parse $m >expect &&
+       git rev-parse $a >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin -z update symref works option no-deref' '
+       git symbolic-ref TESTSYMREF $b &&
+       printf $F "option no-deref" "update TESTSYMREF" "$a" "$b" >stdin &&
+       git update-ref -z --stdin <stdin &&
+       git rev-parse TESTSYMREF >expect &&
+       git rev-parse $a >actual &&
+       test_cmp expect actual &&
+       git rev-parse $m~1 >expect &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin -z delete symref works option no-deref' '
+       git symbolic-ref TESTSYMREF $b &&
+       printf $F "option no-deref" "delete TESTSYMREF" "$b" >stdin &&
+       git update-ref -z --stdin <stdin &&
+       test_must_fail git rev-parse --verify -q TESTSYMREF &&
+       git rev-parse $m~1 >expect &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin -z delete ref works with right old value' '
+       printf $F "delete $b" "$m~1" >stdin &&
+       git update-ref -z --stdin <stdin &&
+       test_must_fail git rev-parse --verify -q $b
+'
+
+test_expect_success 'stdin -z update/create/verify combination works' '
+       printf $F "update $a" "$m" "" "create $b" "$m" "verify $c" "" >stdin &&
+       git update-ref -z --stdin <stdin &&
+       git rev-parse $m >expect &&
+       git rev-parse $a >actual &&
+       test_cmp expect actual &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual &&
+       test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin -z update refs works with identity updates' '
+       printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$Z" "" >stdin &&
+       git update-ref -z --stdin <stdin &&
+       git rev-parse $m >expect &&
+       git rev-parse $a >actual &&
+       test_cmp expect actual &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual &&
+       test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin -z update refs fails with wrong old value' '
+       git update-ref $c $m &&
+       printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "" "$Z" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: Cannot lock the ref '"'"'$c'"'"'" err &&
+       git rev-parse $m >expect &&
+       git rev-parse $a >actual &&
+       test_cmp expect actual &&
+       git rev-parse $b >actual &&
+       test_cmp expect actual &&
+       git rev-parse $c >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'stdin -z delete refs works with packed and loose refs' '
+       git pack-refs --all &&
+       git update-ref $c $m~1 &&
+       printf $F "delete $a" "$m" "update $b" "$Z" "$m" "update $c" "" "$m~1" >stdin &&
+       git update-ref -z --stdin <stdin &&
+       test_must_fail git rev-parse --verify -q $a &&
+       test_must_fail git rev-parse --verify -q $b &&
+       test_must_fail git rev-parse --verify -q $c
+'
+
 test_done
index e5aea3b89602fdaf5ed3a9a230a604dd3f48cda0..ceb844985f97e9472ffcc3fe2f375912d126a4e8 100755 (executable)
@@ -32,6 +32,9 @@ test_expect_success 'setup' '
        git checkout -b upstream-branch &&
        test_commit upstream-one &&
        test_commit upstream-two &&
+       git checkout -b @/at-test &&
+       git checkout -b @@/at-test &&
+       git checkout -b @at-test &&
        git checkout -b old-branch &&
        test_commit old-one &&
        test_commit old-two &&
@@ -55,6 +58,11 @@ check "HEAD@{u}" ref refs/heads/upstream-branch
 check "@{u}@{1}" commit upstream-one
 check "@{-1}@{u}" ref refs/heads/master
 check "@{-1}@{u}@{1}" commit master-one
+check "@" commit new-two
+check "@@{u}" ref refs/heads/upstream-branch
+check "@@/at-test" ref refs/heads/@@/at-test
+check "@/at-test" ref refs/heads/@/at-test
+check "@at-test" ref refs/heads/@at-test
 nonsense "@{u}@{-1}"
 nonsense "@{0}@{0}"
 nonsense "@{1}@{u}"
index eaefc777bd98aeb4cae2ba34eec0e5fe2c2fbd72..15973f20945769fd7661cd4b203e96032495a60e 100755 (executable)
@@ -54,6 +54,13 @@ test_expect_success 'ref^{tree}' '
        test_must_fail git rev-parse blob-tag^{tree}
 '
 
+test_expect_success 'ref^{tag}' '
+       test_must_fail git rev-parse HEAD^{tag} &&
+       git rev-parse commit-tag >expected &&
+       git rev-parse commit-tag^{tag} >actual &&
+       test_cmp expected actual
+'
+
 test_expect_success 'ref^{/.}' '
        git rev-parse master >expected &&
        git rev-parse master^{/.} >actual &&
index dee55e428f07eeac9c2d2c329ff2c1aca3f4ea98..094b92ef489156980dc1429136d5dad25d01ac7d 100755 (executable)
@@ -104,7 +104,7 @@ test_expect_success 'setup more remotes with unconventional refspecs' '
                cd repo_c &&
                test_commit c_master &&
                git checkout -b bar &&
-               test_commit c_bar
+               test_commit c_bar &&
                git checkout -b spam &&
                test_commit c_spam
        ) &&
@@ -113,9 +113,9 @@ test_expect_success 'setup more remotes with unconventional refspecs' '
                cd repo_d &&
                test_commit d_master &&
                git checkout -b baz &&
-               test_commit f_baz
+               test_commit d_baz &&
                git checkout -b eggs &&
-               test_commit c_eggs
+               test_commit d_eggs
        ) &&
        git remote add repo_c repo_c &&
        git config remote.repo_c.fetch \
index f0421c09c700bc1203d2ef563c54157e94c83b33..b2798feef7316e74584058f594e97af01cb5065e 100755 (executable)
@@ -115,7 +115,7 @@ EOF
 
 git config core.excludesFile excludes-file
 
-git status | grep "^#  " > output
+git -c status.displayCommentPrefix=true status | grep "^#      " > output
 
 cat > expect << EOF
 #      .gitignore
index 44ec6a45f473ffe47aca6945c0e0aab445728f67..0fe7647928b9d20963e60e56009f72c54ee488e2 100755 (executable)
@@ -14,7 +14,8 @@ test_expect_success 'prepare a trivial repository' '
        echo World >>A &&
        git update-index --add A &&
        git commit -m "Second commit." &&
-       HEAD=$(git rev-parse --verify HEAD)'
+       HEAD=$(git rev-parse --verify HEAD)
+'
 
 test_expect_success 'git branch --help should not have created a bogus branch' '
        test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&
@@ -319,8 +320,9 @@ test_expect_success 'test tracking setup (non-wildcard, matching)' '
 
 test_expect_success 'tracking setup fails on non-matching refspec' '
        git config remote.local.url . &&
-       git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
+       git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
        (git show-ref -q refs/remotes/local/master || git fetch local) &&
+       git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
        test_must_fail git branch --track my5 local/master &&
        test_must_fail git config branch.my5.remote &&
        test_must_fail git config branch.my5.merge
@@ -350,7 +352,7 @@ test_expect_success 'test overriding tracking setup via --no-track' '
 test_expect_success 'no tracking without .fetch entries' '
        git config branch.autosetupmerge true &&
        git branch my6 s &&
-       git config branch.automsetupmerge false &&
+       git config branch.autosetupmerge false &&
        test -z "$(git config branch.my6.remote)" &&
        test -z "$(git config branch.my6.merge)"
 '
@@ -424,14 +426,14 @@ test_expect_success '--set-upstream-to fails on a non-ref' '
 test_expect_success 'use --set-upstream-to modify HEAD' '
        test_config branch.master.remote foo &&
        test_config branch.master.merge foo &&
-       git branch my12
+       git branch my12 &&
        git branch --set-upstream-to my12 &&
        test "$(git config branch.master.remote)" = "." &&
        test "$(git config branch.master.merge)" = "refs/heads/my12"
 '
 
 test_expect_success 'use --set-upstream-to modify a particular branch' '
-       git branch my13
+       git branch my13 &&
        git branch --set-upstream-to master my13 &&
        test "$(git config branch.my13.remote)" = "." &&
        test "$(git config branch.my13.merge)" = "refs/heads/master"
@@ -442,7 +444,7 @@ test_expect_success '--unset-upstream should fail if given a non-existent branch
 '
 
 test_expect_success 'test --unset-upstream on HEAD' '
-       git branch my14
+       git branch my14 &&
        test_config branch.master.remote foo &&
        test_config branch.master.merge foo &&
        git branch --set-upstream-to my14 &&
@@ -464,7 +466,7 @@ test_expect_success '--unset-upstream should fail on detached HEAD' '
 '
 
 test_expect_success 'test --unset-upstream on a particular branch' '
-       git branch my15
+       git branch my15 &&
        git branch --set-upstream-to master my14 &&
        git branch --unset-upstream my14 &&
        test_must_fail git config branch.my14.remote &&
@@ -870,4 +872,39 @@ test_expect_success '--merged catches invalid object names' '
        test_must_fail git branch --merged 0000000000000000000000000000000000000000
 '
 
+test_expect_success 'tracking with unexpected .fetch refspec' '
+       rm -rf a b c d &&
+       git init a &&
+       (
+               cd a &&
+               test_commit a
+       ) &&
+       git init b &&
+       (
+               cd b &&
+               test_commit b
+       ) &&
+       git init c &&
+       (
+               cd c &&
+               test_commit c &&
+               git remote add a ../a &&
+               git remote add b ../b &&
+               git fetch --all
+       ) &&
+       git init d &&
+       (
+               cd d &&
+               git remote add c ../c &&
+               git config remote.c.fetch "+refs/remotes/*:refs/remotes/*" &&
+               git fetch c &&
+               git branch --track local/a/master remotes/a/master &&
+               test "$(git config branch.local/a/master.remote)" = "c" &&
+               test "$(git config branch.local/a/master.merge)" = "refs/remotes/a/master" &&
+               git rev-parse --verify a >expect &&
+               git rev-parse --verify local/a/master >actual &&
+               test_cmp expect actual
+       )
+'
+
 test_done
index 46aaf2f511f6d37e8552d0b12fa64f7e30accd1d..bff6ffe08817ed0c057909aa1d3f93140cf6a3e0 100755 (executable)
@@ -109,4 +109,24 @@ test_expect_success 'cherry-pick on unborn branch' '
        ! test_cmp_rev initial HEAD
 '
 
+test_expect_success 'cherry-pick "-" to pick from previous branch' '
+       git checkout unborn &&
+       test_commit to-pick actual content &&
+       git checkout master &&
+       git cherry-pick - &&
+       echo content >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success 'cherry-pick "-" is meaningless without checkout' '
+       test_create_repo afresh &&
+       (
+               cd afresh &&
+               test_commit one &&
+               test_commit two &&
+               test_commit three &&
+               test_must_fail git cherry-pick -
+       )
+'
+
 test_done
diff --git a/t/t5308-pack-detect-duplicates.sh b/t/t5308-pack-detect-duplicates.sh
new file mode 100755 (executable)
index 0000000..9c5a876
--- /dev/null
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+test_description='handling of duplicate objects in incoming packfiles'
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-pack.sh
+
+# The sha1s we have in our pack. It's important that these have the same
+# starting byte, so that they end up in the same fanout section of the index.
+# That lets us make sure we are exercising the binary search with both sets.
+LO_SHA1=e68fe8129b546b101aee9510c5328e7f21ca1d18
+HI_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
+
+# And here's a "missing sha1" which will produce failed lookups. It must also
+# be in the same fanout section, and should be between the two (so that during
+# our binary search, we are sure to end up looking at one or the other of the
+# duplicate runs).
+MISSING_SHA1='e69d000000000000000000000000000000000000'
+
+# git will never intentionally create packfiles with
+# duplicate objects, so we have to construct them by hand.
+#
+# $1 is the name of the packfile to create
+#
+# $2 is the number of times to duplicate each object
+create_pack () {
+       pack_header "$((2 * $2))" >"$1" &&
+       for i in $(test_seq 1 "$2"); do
+               pack_obj $LO_SHA1 &&
+               pack_obj $HI_SHA1
+       done >>"$1" &&
+       pack_trailer "$1"
+}
+
+# double-check that create_pack actually works
+test_expect_success 'pack with no duplicates' '
+       create_pack no-dups.pack 1 &&
+       git index-pack --stdin <no-dups.pack
+'
+
+test_expect_success 'index-pack will allow duplicate objects by default' '
+       clear_packs &&
+       create_pack dups.pack 100 &&
+       git index-pack --stdin <dups.pack
+'
+
+test_expect_success 'create batch-check test vectors' '
+       cat >input <<-EOF &&
+       $LO_SHA1
+       $HI_SHA1
+       $MISSING_SHA1
+       EOF
+       cat >expect <<-EOF
+       $LO_SHA1 blob 2
+       $HI_SHA1 blob 0
+       $MISSING_SHA1 missing
+       EOF
+'
+
+test_expect_success 'lookup in duplicated pack (binary search)' '
+       git cat-file --batch-check <input >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'lookup in duplicated pack (GIT_USE_LOOKUP)' '
+       (
+               GIT_USE_LOOKUP=1 &&
+               export GIT_USE_LOOKUP &&
+               git cat-file --batch-check <input >actual
+       ) &&
+       test_cmp expect actual
+'
+
+test_expect_success 'index-pack can reject packs with duplicates' '
+       clear_packs &&
+       create_pack dups.pack 2 &&
+       test_must_fail git index-pack --strict --stdin <dups.pack &&
+       test_expect_code 1 git cat-file -e $LO_SHA1
+'
+
+test_done
diff --git a/t/t5309-pack-delta-cycles.sh b/t/t5309-pack-delta-cycles.sh
new file mode 100755 (executable)
index 0000000..3e7861b
--- /dev/null
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+test_description='test index-pack handling of delta cycles in packfiles'
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-pack.sh
+
+# Two similar-ish objects that we have computed deltas between.
+A=01d7713666f4de822776c7622c10f1b07de280dc
+B=e68fe8129b546b101aee9510c5328e7f21ca1d18
+
+# double-check our hand-constucted packs
+test_expect_success 'index-pack works with a single delta (A->B)' '
+       clear_packs &&
+       {
+               pack_header 2 &&
+               pack_obj $A $B &&
+               pack_obj $B
+       } >ab.pack &&
+       pack_trailer ab.pack &&
+       git index-pack --stdin <ab.pack &&
+       git cat-file -t $A &&
+       git cat-file -t $B
+'
+
+test_expect_success 'index-pack works with a single delta (B->A)' '
+       clear_packs &&
+       {
+               pack_header 2 &&
+               pack_obj $A &&
+               pack_obj $B $A
+       } >ba.pack &&
+       pack_trailer ba.pack &&
+       git index-pack --stdin <ba.pack &&
+       git cat-file -t $A &&
+       git cat-file -t $B
+'
+
+test_expect_success 'index-pack detects missing base objects' '
+       clear_packs &&
+       {
+               pack_header 1 &&
+               pack_obj $A $B
+       } >missing.pack &&
+       pack_trailer missing.pack &&
+       test_must_fail git index-pack --fix-thin --stdin <missing.pack
+'
+
+test_expect_success 'index-pack detects REF_DELTA cycles' '
+       clear_packs &&
+       {
+               pack_header 2 &&
+               pack_obj $A $B &&
+               pack_obj $B $A
+       } >cycle.pack &&
+       pack_trailer cycle.pack &&
+       test_must_fail git index-pack --fix-thin --stdin <cycle.pack
+'
+
+test_expect_failure 'failover to an object in another pack' '
+       clear_packs &&
+       git index-pack --stdin <ab.pack &&
+       git index-pack --stdin --fix-thin <cycle.pack
+'
+
+test_expect_failure 'failover to a duplicate object in the same pack' '
+       clear_packs &&
+       {
+               pack_header 3 &&
+               pack_obj $A $B &&
+               pack_obj $B $A &&
+               pack_obj $A
+       } >recoverable.pack &&
+       pack_trailer recoverable.pack &&
+       git index-pack --fix-thin --stdin <recoverable.pack
+'
+
+test_done
index a80584ea0eaba854ff21318e3c9646f72325bee7..d87ddf73b7127bc624ca739653db9389831b817e 100755 (executable)
@@ -393,6 +393,17 @@ test_expect_success 'fetch in shallow repo unreachable shallow objects' '
                git fsck --no-dangling
        )
 '
+test_expect_success 'fetch creating new shallow root' '
+       (
+               git clone "file://$(pwd)/." shallow10 &&
+               git commit --allow-empty -m empty &&
+               cd shallow10 &&
+               git fetch --depth=1 --progress 2>actual &&
+               # This should fetch only the empty commit, no tree or
+               # blob objects
+               grep "remote: Total 1" actual
+       )
+'
 
 test_expect_success 'setup tests for the --stdin parameter' '
        for head in C D E F
index c983d3694c74cf6de6b7bd9a74c28d41462171f0..3932e797f7f60545e6e8c140824a5ca5ee16832a 100755 (executable)
@@ -54,9 +54,6 @@ test_expect_success 'upload-pack fails due to error in rev-list' '
        printf "0032want %s\n0034shallow %s00000009done\n0000" \
                $(git rev-parse HEAD) $(git rev-parse HEAD^) >input &&
        test_must_fail git upload-pack . <input >/dev/null 2>output.err &&
-       # pack-objects survived
-       grep "Total.*, reused" output.err &&
-       # but there was an error, which must have been in rev-list
        grep "bad tree object" output.err
 '
 
index ec2b516c3f79901ca5593f1edb97455e3fa8389e..ba26cfe9239306035c2496f922055eaea6b46a31 100755 (executable)
@@ -28,10 +28,15 @@ test_expect_success setup '
                git reset --hard HEAD^ &&
                git checkout -b b4 origin &&
                advance e &&
-               advance f
+               advance f &&
+               git checkout -b brokenbase origin &&
+               git checkout -b b5 --track brokenbase &&
+               advance g &&
+               git branch -d brokenbase &&
+               git checkout -b b6 origin
        ) &&
        git checkout -b follower --track master &&
-       advance g
+       advance h
 '
 
 script='s/^..\(b.\)[    0-9a-f]*\[\([^]]*\)\].*/\1 \2/p'
@@ -56,6 +61,8 @@ b1 origin/master: ahead 1, behind 1
 b2 origin/master: ahead 1, behind 1
 b3 origin/master: behind 1
 b4 origin/master: ahead 2
+b5 brokenbase: gone
+b6 origin/master
 EOF
 
 test_expect_success 'branch -vv' '
@@ -67,7 +74,7 @@ test_expect_success 'branch -vv' '
        test_i18ncmp expect actual
 '
 
-test_expect_success 'checkout' '
+test_expect_success 'checkout (diverged from upstream)' '
        (
                cd test && git checkout b1
        ) >actual &&
@@ -80,7 +87,22 @@ test_expect_success 'checkout with local tracked branch' '
        test_i18ngrep "is ahead of" actual
 '
 
-test_expect_success 'status' '
+test_expect_success 'checkout (upstream is gone)' '
+       (
+               cd test &&
+               git checkout b5
+       ) >actual &&
+       test_i18ngrep "is based on .*, but the upstream is gone." actual
+'
+
+test_expect_success 'checkout (up-to-date with upstream)' '
+       (
+               cd test && git checkout b6
+       ) >actual &&
+       test_i18ngrep "Your branch is up-to-date with .origin/master" actual
+'
+
+test_expect_success 'status (diverged from upstream)' '
        (
                cd test &&
                git checkout b1 >/dev/null &&
@@ -90,6 +112,65 @@ test_expect_success 'status' '
        test_i18ngrep "have 1 and 1 different" actual
 '
 
+test_expect_success 'status (upstream is gone)' '
+       (
+               cd test &&
+               git checkout b5 >/dev/null &&
+               # reports nothing to commit
+               test_must_fail git commit --dry-run
+       ) >actual &&
+       test_i18ngrep "is based on .*, but the upstream is gone." actual
+'
+
+test_expect_success 'status (up-to-date with upstream)' '
+       (
+               cd test &&
+               git checkout b6 >/dev/null &&
+               # reports nothing to commit
+               test_must_fail git commit --dry-run
+       ) >actual &&
+       test_i18ngrep "Your branch is up-to-date with .origin/master" actual
+'
+
+cat >expect <<\EOF
+## b1...origin/master [ahead 1, behind 1]
+EOF
+
+test_expect_success 'status -s -b (diverged from upstream)' '
+       (
+               cd test &&
+               git checkout b1 >/dev/null &&
+               git status -s -b | head -1
+       ) >actual &&
+       test_i18ncmp expect actual
+'
+
+cat >expect <<\EOF
+## b5...brokenbase [gone]
+EOF
+
+test_expect_success 'status -s -b (upstream is gone)' '
+       (
+               cd test &&
+               git checkout b5 >/dev/null &&
+               git status -s -b | head -1
+       ) >actual &&
+       test_i18ncmp expect actual
+'
+
+cat >expect <<\EOF
+## b6...origin/master
+EOF
+
+test_expect_success 'status -s -b (up-to-date with upstream)' '
+       (
+               cd test &&
+               git checkout b6 >/dev/null &&
+               git status -s -b | head -1
+       ) >actual &&
+       test_i18ncmp expect actual
+'
+
 test_expect_success 'fail to track lightweight tags' '
        git checkout master &&
        git tag light &&
index e673c25e943f77430d7f61b0ab9e0b21e38e6915..7ea14ced313d3f0dd20d4afd2fc2a0d3309b938f 100755 (executable)
@@ -6,39 +6,86 @@
 test_description='Test git rev-parse with different parent options'
 
 . ./test-lib.sh
-. "$TEST_DIRECTORY"/lib-t6000.sh # t6xxx specific functions
-
-date >path0
-git update-index --add path0
-save_tag tree git write-tree
-hide_error save_tag start unique_commit "start" tree
-save_tag second unique_commit "second" tree -p start
-hide_error save_tag start2 unique_commit "start2" tree
-save_tag two_parents unique_commit "next" tree -p second -p start2
-save_tag final unique_commit "final" tree -p two_parents
-
-test_expect_success 'start is valid' 'git rev-parse start | grep "^[0-9a-f]\{40\}$"'
-test_expect_success 'start^0' "test $(cat .git/refs/tags/start) = $(git rev-parse start^0)"
-test_expect_success 'start^1 not valid' "if git rev-parse --verify start^1; then false; else :; fi"
-test_expect_success 'second^1 = second^' "test $(git rev-parse second^1) = $(git rev-parse second^)"
-test_expect_success 'final^1^1^1' "test $(git rev-parse start) = $(git rev-parse final^1^1^1)"
-test_expect_success 'final^1^1^1 = final^^^' "test $(git rev-parse final^1^1^1) = $(git rev-parse final^^^)"
-test_expect_success 'final^1^2' "test $(git rev-parse start2) = $(git rev-parse final^1^2)"
-test_expect_success 'final^1^2 != final^1^1' "test $(git rev-parse final^1^2) != $(git rev-parse final^1^1)"
-test_expect_success 'final^1^3 not valid' "if git rev-parse --verify final^1^3; then false; else :; fi"
-test_expect_success '--verify start2^1' 'test_must_fail git rev-parse --verify start2^1'
-test_expect_success '--verify start2^0' 'git rev-parse --verify start2^0'
-test_expect_success 'final^1^@ = final^1^1 final^1^2' "test \"$(git rev-parse final^1^@)\" = \"$(git rev-parse final^1^1 final^1^2)\""
-test_expect_success 'final^1^! = final^1 ^final^1^1 ^final^1^2' "test \"$(git rev-parse final^1^\!)\" = \"$(git rev-parse final^1 ^final^1^1 ^final^1^2)\""
-
-test_expect_success 'repack for next test' 'git repack -a -d'
+
+test_cmp_rev_output () {
+       git rev-parse --verify "$1" >expect &&
+       eval "$2" >actual &&
+       test_cmp expect actual
+}
+
+test_expect_success 'setup' '
+       test_commit start &&
+       test_commit second &&
+       git checkout --orphan tmp &&
+       test_commit start2 &&
+       git checkout master &&
+       git merge -m next start2 &&
+       test_commit final
+'
+
+test_expect_success 'start is valid' '
+       git rev-parse start | grep "^[0-9a-f]\{40\}$"
+'
+
+test_expect_success 'start^0' '
+       test_cmp_rev_output tags/start "git rev-parse start^0"
+'
+
+test_expect_success 'start^1 not valid' '
+       test_must_fail git rev-parse --verify start^1
+'
+
+test_expect_success 'second^1 = second^' '
+       test_cmp_rev_output second^ "git rev-parse second^1"
+'
+
+test_expect_success 'final^1^1^1' '
+       test_cmp_rev_output start "git rev-parse final^1^1^1"
+'
+
+test_expect_success 'final^1^1^1 = final^^^' '
+       test_cmp_rev_output final^^^ "git rev-parse final^1^1^1"
+'
+
+test_expect_success 'final^1^2' '
+       test_cmp_rev_output start2 "git rev-parse final^1^2"
+'
+
+test_expect_success 'final^1^2 != final^1^1' '
+       test $(git rev-parse final^1^2) != $(git rev-parse final^1^1)
+'
+
+test_expect_success 'final^1^3 not valid' '
+       test_must_fail git rev-parse --verify final^1^3
+'
+
+test_expect_success '--verify start2^1' '
+       test_must_fail git rev-parse --verify start2^1
+'
+
+test_expect_success '--verify start2^0' '
+       git rev-parse --verify start2^0
+'
+
+test_expect_success 'final^1^@ = final^1^1 final^1^2' '
+       git rev-parse final^1^1 final^1^2 >expect &&
+       git rev-parse final^1^@ >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'final^1^! = final^1 ^final^1^1 ^final^1^2' '
+       git rev-parse final^1 ^final^1^1 ^final^1^2 >expect &&
+       git rev-parse final^1^! >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'repack for next test' '
+       git repack -a -d
+'
+
 test_expect_success 'short SHA-1 works' '
-       start=`git rev-parse --verify start` &&
-       echo $start &&
-       abbrv=`echo $start | sed s/.\$//` &&
-       echo $abbrv &&
-       abbrv=`git rev-parse --verify $abbrv` &&
-       echo $abbrv &&
-       test $start = $abbrv'
+       start=$(git rev-parse --verify start) &&
+       test_cmp_rev_output start "git rev-parse ${start%?}"
+'
 
 test_done
index 52ef06b0005aabf2a201d20dbb5f232e3a26766a..7d467c034a27f50e8b60b4b0f390f08fdf126e55 100755 (executable)
@@ -29,20 +29,19 @@ test_expect_success 'Report new path with conflict' '
        test_cmp expect actual
 '
 
-cat >expect <<EOF
-# On branch side
-# You have unmerged paths.
-#   (fix conflicts and run "git commit")
-#
-# Unmerged paths:
-#   (use "git add/rm <file>..." as appropriate to mark resolution)
-#
-#      deleted by us:      foo
-#
+test_expect_success 'M/D conflict does not segfault' '
+       cat >expect <<EOF &&
+On branch side
+You have unmerged paths.
+  (fix conflicts and run "git commit")
+
+Unmerged paths:
+  (use "git add/rm <file>..." as appropriate to mark resolution)
+
+       deleted by us:      foo
+
 no changes added to commit (use "git add" and/or "git commit -a")
 EOF
-
-test_expect_success 'M/D conflict does not segfault' '
        mkdir mdconflict &&
        (
                cd mdconflict &&
@@ -135,19 +134,19 @@ test_expect_success 'status when conflicts with add and rm advice (deleted by th
        test_commit on_second main.txt on_second &&
        test_commit master conflict.txt master &&
        test_must_fail git merge second_branch &&
-       cat >expected <<-\EOF &&
-       # On branch master
-       # You have unmerged paths.
-       #   (fix conflicts and run "git commit")
-       #
-       # Unmerged paths:
-       #   (use "git add/rm <file>..." as appropriate to mark resolution)
-       #
-       #       both added:         conflict.txt
-       #       deleted by them:    main.txt
-       #
-       no changes added to commit (use "git add" and/or "git commit -a")
-       EOF
+       cat >expected <<\EOF &&
+On branch master
+You have unmerged paths.
+  (fix conflicts and run "git commit")
+
+Unmerged paths:
+  (use "git add/rm <file>..." as appropriate to mark resolution)
+
+       both added:         conflict.txt
+       deleted by them:    main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -168,20 +167,20 @@ test_expect_success 'prepare for conflicts' '
 
 test_expect_success 'status when conflicts with add and rm advice (both deleted)' '
        test_must_fail git merge conflict &&
-       cat >expected <<-\EOF &&
-       # On branch conflict_second
-       # You have unmerged paths.
-       #   (fix conflicts and run "git commit")
-       #
-       # Unmerged paths:
-       #   (use "git add/rm <file>..." as appropriate to mark resolution)
-       #
-       #       both deleted:       main.txt
-       #       added by them:      sub_master.txt
-       #       added by us:        sub_second.txt
-       #
-       no changes added to commit (use "git add" and/or "git commit -a")
-       EOF
+       cat >expected <<\EOF &&
+On branch conflict_second
+You have unmerged paths.
+  (fix conflicts and run "git commit")
+
+Unmerged paths:
+  (use "git add/rm <file>..." as appropriate to mark resolution)
+
+       both deleted:       main.txt
+       added by them:      sub_master.txt
+       added by us:        sub_second.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -192,22 +191,22 @@ test_expect_success 'status when conflicts with only rm advice (both deleted)' '
        test_must_fail git merge conflict &&
        git add sub_master.txt &&
        git add sub_second.txt &&
-       cat >expected <<-\EOF &&
-       # On branch conflict_second
-       # You have unmerged paths.
-       #   (fix conflicts and run "git commit")
-       #
-       # Changes to be committed:
-       #
-       #       new file:   sub_master.txt
-       #
-       # Unmerged paths:
-       #   (use "git rm <file>..." to mark resolution)
-       #
-       #       both deleted:       main.txt
-       #
-       # Untracked files not listed (use -u option to show untracked files)
-       EOF
+       cat >expected <<\EOF &&
+On branch conflict_second
+You have unmerged paths.
+  (fix conflicts and run "git commit")
+
+Changes to be committed:
+
+       new file:   sub_master.txt
+
+Unmerged paths:
+  (use "git rm <file>..." to mark resolution)
+
+       both deleted:       main.txt
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual &&
        git reset --hard &&
index ac2434c0dbdaf837d8dd7f896e680fbb7b6ab954..5a6d6d62ebcb0e506fcb0bd16dbd4a451ef3fbd1 100755 (executable)
@@ -265,13 +265,11 @@ EOF
 test_expect_success '--for-status' "
        git submodule summary --for-status HEAD^ >actual &&
        test_i18ncmp actual - <<EOF
-# Submodule changes to be committed:
-#
-# * sm1 $head6...0000000:
-#
-# * sm2 0000000...$head7 (2):
-#   > Add foo9
-#
+* sm1 $head6...0000000:
+
+* sm2 0000000...$head7 (2):
+  > Add foo9
+
 EOF
 "
 
index ac3d0fe44507328f6363edc1d614bc9d8369899b..d8c531da765009b3b2261f1263a399b1d4c2a8b5 100755 (executable)
@@ -60,8 +60,13 @@ test_expect_success 'status (1)' '
        test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output
 '
 
+strip_comments () {
+       tab='   '
+       sed "s/^\# //; s/^\#$//; s/^#$tab/$tab/" <"$1" >"$1".tmp &&
+       rm "$1" && mv "$1".tmp "$1"
+}
+
 test_expect_success 'status --column' '
-       COLUMNS=50 git status --column="column dense" >output &&
        cat >expect <<\EOF &&
 # On branch master
 # Changes to be committed:
@@ -78,9 +83,17 @@ test_expect_success 'status --column' '
 # Untracked files:
 #   (use "git add <file>..." to include in what will be committed)
 #
-#      dir1/untracked dir2/untracked untracked
-#      dir2/modified  output
+#      dir1/untracked dir2/untracked output
+#      dir2/modified  expect         untracked
+#
 EOF
+       COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
+       test_i18ncmp expect output
+'
+
+test_expect_success 'status --column status.displayCommentPrefix=false' '
+       strip_comments expect &&
+       COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output &&
        test_i18ncmp expect output
 '
 
@@ -106,28 +119,58 @@ cat >expect <<\EOF
 #      expect
 #      output
 #      untracked
+#
 EOF
 
-test_expect_success 'status (2)' '
-       git status >output &&
+test_expect_success 'status with status.displayCommentPrefix=true' '
+       git -c status.displayCommentPrefix=true status >output &&
+       test_i18ncmp expect output
+'
+
+test_expect_success 'status with status.displayCommentPrefix=false' '
+       strip_comments expect &&
+       git -c status.displayCommentPrefix=false status >output &&
        test_i18ncmp expect output
 '
 
+test_expect_success 'setup fake editor' '
+       cat >.git/editor <<-\EOF &&
+       #! /bin/sh
+       cp "$1" output
+EOF
+       chmod 755 .git/editor
+'
+
+commit_template_commented () {
+       (
+               EDITOR=.git/editor &&
+               export EDITOR &&
+               # Fails due to empty message
+               test_must_fail git commit
+       ) &&
+       ! grep '^[^#]' output
+}
+
+test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' '
+       commit_template_commented
+'
+
 cat >expect <<\EOF
-# On branch master
-# Changes to be committed:
-#      new file:   dir2/added
-#
-# Changes not staged for commit:
-#      modified:   dir1/modified
-#
-# Untracked files:
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
+On branch master
+Changes to be committed:
+       new file:   dir2/added
+
+Changes not staged for commit:
+       modified:   dir1/modified
+
+Untracked files:
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       expect
+       output
+       untracked
+
 EOF
 
 test_expect_success 'status (advice.statusHints false)' '
@@ -185,33 +228,35 @@ test_expect_success 'status with gitignore' '
        git status -s --ignored >output &&
        test_cmp expect output &&
 
-       cat >expect <<-\EOF &&
-       # On branch master
-       # Changes to be committed:
-       #   (use "git reset HEAD <file>..." to unstage)
-       #
-       #       new file:   dir2/added
-       #
-       # Changes not staged for commit:
-       #   (use "git add <file>..." to update what will be committed)
-       #   (use "git checkout -- <file>..." to discard changes in working directory)
-       #
-       #       modified:   dir1/modified
-       #
-       # Untracked files:
-       #   (use "git add <file>..." to include in what will be committed)
-       #
-       #       dir2/modified
-       # Ignored files:
-       #   (use "git add -f <file>..." to include in what will be committed)
-       #
-       #       .gitignore
-       #       dir1/untracked
-       #       dir2/untracked
-       #       expect
-       #       output
-       #       untracked
-       EOF
+       cat >expect <<\EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir2/modified
+
+Ignored files:
+  (use "git add -f <file>..." to include in what will be committed)
+
+       .gitignore
+       dir1/untracked
+       dir2/untracked
+       expect
+       output
+       untracked
+
+EOF
        git status --ignored >output &&
        test_i18ncmp expect output
 '
@@ -246,30 +291,31 @@ test_expect_success 'status with gitignore (nothing untracked)' '
        git status -s --ignored >output &&
        test_cmp expect output &&
 
-       cat >expect <<-\EOF &&
-       # On branch master
-       # Changes to be committed:
-       #   (use "git reset HEAD <file>..." to unstage)
-       #
-       #       new file:   dir2/added
-       #
-       # Changes not staged for commit:
-       #   (use "git add <file>..." to update what will be committed)
-       #   (use "git checkout -- <file>..." to discard changes in working directory)
-       #
-       #       modified:   dir1/modified
-       #
-       # Ignored files:
-       #   (use "git add -f <file>..." to include in what will be committed)
-       #
-       #       .gitignore
-       #       dir1/untracked
-       #       dir2/modified
-       #       dir2/untracked
-       #       expect
-       #       output
-       #       untracked
-       EOF
+       cat >expect <<\EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Ignored files:
+  (use "git add -f <file>..." to include in what will be committed)
+
+       .gitignore
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       expect
+       output
+       untracked
+
+EOF
        git status --ignored >output &&
        test_i18ncmp expect output
 '
@@ -310,22 +356,22 @@ test_expect_success 'setup dir3' '
        : >dir3/untracked2
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      new file:   dir2/added
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Untracked files not listed (use -u option to show untracked files)
-EOF
 test_expect_success 'status -uno' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
        git status -uno >output &&
        test_i18ncmp expect output
 '
@@ -336,17 +382,17 @@ test_expect_success 'status (status.showUntrackedFiles no)' '
        test_i18ncmp expect output
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#      new file:   dir2/added
-#
-# Changes not staged for commit:
-#      modified:   dir1/modified
-#
-# Untracked files not listed
-EOF
 test_expect_success 'status -uno (advice.statusHints false)' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+       new file:   dir2/added
+
+Changes not staged for commit:
+       modified:   dir1/modified
+
+Untracked files not listed
+EOF
        test_config advice.statusHints false &&
        git status -uno >output &&
        test_i18ncmp expect output
@@ -367,31 +413,32 @@ test_expect_success 'status -s (status.showUntrackedFiles no)' '
        test_cmp expect output
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      new file:   dir2/added
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      dir3/
-#      expect
-#      output
-#      untracked
-EOF
 test_expect_success 'status -unormal' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       dir3/
+       expect
+       output
+       untracked
+
+EOF
        git status -unormal >output &&
        test_i18ncmp expect output
 '
@@ -424,32 +471,33 @@ test_expect_success 'status -s (status.showUntrackedFiles normal)' '
        test_cmp expect output
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      new file:   dir2/added
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      dir3/untracked1
-#      dir3/untracked2
-#      expect
-#      output
-#      untracked
-EOF
 test_expect_success 'status -uall' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       dir3/untracked1
+       dir3/untracked2
+       expect
+       output
+       untracked
+
+EOF
        git status -uall >output &&
        test_i18ncmp expect output
 '
@@ -486,31 +534,31 @@ test_expect_success 'status -s (status.showUntrackedFiles all)' '
        test_cmp expect output
 '
 
-cat >expect <<\EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      new file:   ../dir2/added
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      untracked
-#      ../dir2/modified
-#      ../dir2/untracked
-#      ../expect
-#      ../output
-#      ../untracked
-EOF
-
 test_expect_success 'status with relative paths' '
+       cat >expect <<\EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   ../dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       untracked
+       ../dir2/modified
+       ../dir2/untracked
+       ../expect
+       ../output
+       ../untracked
+
+EOF
        (cd dir1 && git status) >output &&
        test_i18ncmp expect output
 '
@@ -557,31 +605,31 @@ test_expect_success 'setup unique colors' '
 
 '
 
-cat >expect <<\EOF
-# On branch <GREEN>master<RESET>
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      <GREEN>new file:   dir2/added<RESET>
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      <RED>modified:   dir1/modified<RESET>
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      <BLUE>dir1/untracked<RESET>
-#      <BLUE>dir2/modified<RESET>
-#      <BLUE>dir2/untracked<RESET>
-#      <BLUE>expect<RESET>
-#      <BLUE>output<RESET>
-#      <BLUE>untracked<RESET>
-EOF
-
 test_expect_success 'status with color.ui' '
+       cat >expect <<\EOF &&
+On branch <GREEN>master<RESET>
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       <GREEN>new file:   dir2/added<RESET>
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       <RED>modified:   dir1/modified<RESET>
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       <BLUE>dir1/untracked<RESET>
+       <BLUE>dir2/modified<RESET>
+       <BLUE>dir2/untracked<RESET>
+       <BLUE>expect<RESET>
+       <BLUE>output<RESET>
+       <BLUE>untracked<RESET>
+
+EOF
        test_config color.ui always &&
        git status | test_decode_color >output &&
        test_i18ncmp expect output
@@ -685,33 +733,33 @@ test_expect_success 'status --porcelain respects -b' '
 
 '
 
-cat >expect <<\EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      new file:   dir2/added
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
-EOF
 
 
 test_expect_success 'status without relative paths' '
+       cat >expect <<\EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
 
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       expect
+       output
+       untracked
+
+EOF
        test_config status.relativePaths false &&
        (cd dir1 && git status) >output &&
        test_i18ncmp expect output
@@ -737,23 +785,24 @@ test_expect_success 'status -s without relative paths' '
 
 '
 
-cat <<EOF >expect
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/
-#      expect
-#      output
-#      untracked
-EOF
 test_expect_success 'dry-run of partial commit excluding new file in index' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir1/untracked
+       dir2/
+       expect
+       output
+       untracked
+
+EOF
        git commit --dry-run dir1/modified >output &&
        test_i18ncmp expect output
 '
@@ -778,31 +827,32 @@ test_expect_success 'setup status submodule summary' '
        git add sm
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      new file:   dir2/added
-#      new file:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
-EOF
 test_expect_success 'status submodule summary is disabled by default' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
+       new file:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       expect
+       output
+       untracked
+
+EOF
        git status >output &&
        test_i18ncmp expect output
 '
@@ -837,41 +887,52 @@ test_expect_success 'status -s --untracked-files=all does not show submodule' '
 
 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      new file:   dir2/added
-#      new file:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Submodule changes to be committed:
-#
-# * sm 0000000...$head (1):
-#   > Add foo
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
-EOF
 test_expect_success 'status submodule summary' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
+       new file:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Submodule changes to be committed:
+
+* sm 0000000...$head (1):
+  > Add foo
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       expect
+       output
+       untracked
+
+EOF
        git config status.submodulesummary 10 &&
        git status >output &&
        test_i18ncmp expect output
 '
 
+test_expect_success 'status submodule summary with status.displayCommentPrefix=false' '
+       strip_comments expect &&
+       git -c status.displayCommentPrefix=false status >output &&
+       test_i18ncmp expect output
+'
+
+test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' '
+       commit_template_commented
+'
+
 cat >expect <<EOF
  M dir1/modified
 A  dir2/added
@@ -888,26 +949,27 @@ test_expect_success 'status -s submodule summary' '
        test_cmp expect output
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
+test_expect_success 'status submodule summary (clean submodule): commit' '
+       cat >expect <<EOF &&
+On branch master
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       expect
+       output
+       untracked
+
 no changes added to commit (use "git add" and/or "git commit -a")
 EOF
-test_expect_success 'status submodule summary (clean submodule): commit' '
        git commit -m "commit submodule" &&
        git config status.submodulesummary 10 &&
        test_must_fail git commit --dry-run >output &&
@@ -937,36 +999,37 @@ test_expect_success 'status -z implies porcelain' '
        test_cmp expect output
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD^1 <file>..." to unstage)
-#
-#      new file:   dir2/added
-#      new file:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Submodule changes to be committed:
-#
-# * sm 0000000...$head (1):
-#   > Add foo
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
-EOF
 test_expect_success 'commit --dry-run submodule summary (--amend)' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD^1 <file>..." to unstage)
+
+       new file:   dir2/added
+       new file:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Submodule changes to be committed:
+
+* sm 0000000...$head (1):
+  > Add foo
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       expect
+       output
+       untracked
+
+EOF
        git config status.submodulesummary 10 &&
        git commit --dry-run --amend >output &&
        test_i18ncmp expect output
@@ -991,37 +1054,37 @@ test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository'
 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
 touch .gitmodules
 
-cat > expect << EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      modified:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Submodule changes to be committed:
-#
-# * sm $head...$new_head (1):
-#   > Add bar
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      .gitmodules
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
-EOF
-
 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
+       cat > expect << EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       modified:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Submodule changes to be committed:
+
+* sm $head...$new_head (1):
+  > Add bar
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       .gitmodules
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       expect
+       output
+       untracked
+
+EOF
        echo modified  sm/untracked &&
        git status --ignore-submodules=untracked >output &&
        test_i18ncmp expect output
@@ -1101,39 +1164,39 @@ test_expect_success '.git/config ignore=dirty suppresses submodules with modifie
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
-cat > expect << EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      modified:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#   (commit or discard the untracked or modified content in submodules)
-#
-#      modified:   dir1/modified
-#      modified:   sm (modified content)
-#
-# Submodule changes to be committed:
-#
-# * sm $head...$new_head (1):
-#   > Add bar
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      .gitmodules
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
-EOF
-
 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
+       cat > expect << EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       modified:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+  (commit or discard the untracked or modified content in submodules)
+
+       modified:   dir1/modified
+       modified:   sm (modified content)
+
+Submodule changes to be committed:
+
+* sm $head...$new_head (1):
+  > Add bar
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       .gitmodules
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       expect
+       output
+       untracked
+
+EOF
        git status --ignore-submodules=untracked > output &&
        test_i18ncmp expect output
 '
@@ -1159,43 +1222,43 @@ test_expect_success ".git/config ignore=untracked doesn't suppress submodules wi
 
 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
 
-cat > expect << EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      modified:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#      modified:   sm (new commits)
-#
-# Submodule changes to be committed:
-#
-# * sm $head...$new_head (1):
-#   > Add bar
-#
-# Submodules changed but not updated:
-#
-# * sm $new_head...$head2 (1):
-#   > 2nd commit
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      .gitmodules
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
-EOF
-
 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
+       cat > expect << EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       modified:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+       modified:   sm (new commits)
+
+Submodule changes to be committed:
+
+* sm $head...$new_head (1):
+  > Add bar
+
+Submodules changed but not updated:
+
+* sm $new_head...$head2 (1):
+  > 2nd commit
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       .gitmodules
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       expect
+       output
+       untracked
+
+EOF
        git status --ignore-submodules=untracked > output &&
        test_i18ncmp expect output
 '
@@ -1276,42 +1339,43 @@ cat > expect << EOF
 ;      expect
 ;      output
 ;      untracked
+;
 EOF
 
 test_expect_success "status (core.commentchar with submodule summary)" '
        test_config core.commentchar ";" &&
-       git status >output &&
+       git -c status.displayCommentPrefix=true status >output &&
        test_i18ncmp expect output
 '
 
 test_expect_success "status (core.commentchar with two chars with submodule summary)" '
        test_config core.commentchar ";;" &&
-       git status >output &&
+       git -c status.displayCommentPrefix=true status >output &&
        test_i18ncmp expect output
 '
 
-cat > expect << EOF
-# On branch master
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      .gitmodules
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
+test_expect_success "--ignore-submodules=all suppresses submodule summary" '
+       cat > expect << EOF &&
+On branch master
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       .gitmodules
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       expect
+       output
+       untracked
+
 no changes added to commit (use "git add" and/or "git commit -a")
 EOF
-
-test_expect_success "--ignore-submodules=all suppresses submodule summary" '
        git status --ignore-submodules=all > output &&
        test_i18ncmp expect output
 '
index 31a798fda21f178cbbedf47ee92dbd997f9c4e42..0688d58884962c4e0bcfb89191602a36131ebf92 100755 (executable)
@@ -25,18 +25,18 @@ test_expect_success 'prepare for conflicts' '
 
 test_expect_success 'status when conflicts unresolved' '
        test_must_fail git merge master &&
-       cat >expected <<-\EOF &&
-       # On branch conflicts
-       # You have unmerged paths.
-       #   (fix conflicts and run "git commit")
-       #
-       # Unmerged paths:
-       #   (use "git add <file>..." to mark resolution)
-       #
-       #       both modified:      main.txt
-       #
-       no changes added to commit (use "git add" and/or "git commit -a")
-       EOF
+       cat >expected <<\EOF &&
+On branch conflicts
+You have unmerged paths.
+  (fix conflicts and run "git commit")
+
+Unmerged paths:
+  (use "git add <file>..." to mark resolution)
+
+       both modified:      main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -47,17 +47,17 @@ test_expect_success 'status when conflicts resolved before commit' '
        test_must_fail git merge master &&
        echo one >main.txt &&
        git add main.txt &&
-       cat >expected <<-\EOF &&
-       # On branch conflicts
-       # All conflicts fixed but you are still merging.
-       #   (use "git commit" to conclude merge)
-       #
-       # Changes to be committed:
-       #
-       #       modified:   main.txt
-       #
-       # Untracked files not listed (use -u option to show untracked files)
-       EOF
+       cat >expected <<\EOF &&
+On branch conflicts
+All conflicts fixed but you are still merging.
+  (use "git commit" to conclude merge)
+
+Changes to be committed:
+
+       modified:   main.txt
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -76,21 +76,21 @@ test_expect_success 'status when rebase in progress before resolving conflicts'
        test_when_finished "git rebase --abort" &&
        ONTO=$(git rev-parse --short HEAD^^) &&
        test_must_fail git rebase HEAD^ --onto HEAD^^ &&
-       cat >expected <<-EOF &&
-       # 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)
-       #   (use "git rebase --abort" to check out the original branch)
-       #
-       # Unmerged paths:
-       #   (use "git reset HEAD <file>..." to unstage)
-       #   (use "git add <file>..." to mark resolution)
-       #
-       #       both modified:      main.txt
-       #
-       no changes added to commit (use "git add" and/or "git commit -a")
-       EOF
+       cat >expected <<EOF &&
+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)
+  (use "git rebase --abort" to check out the original branch)
+
+Unmerged paths:
+  (use "git reset HEAD <file>..." to unstage)
+  (use "git add <file>..." to mark resolution)
+
+       both modified:      main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -103,18 +103,18 @@ test_expect_success 'status when rebase in progress before rebase --continue' '
        test_must_fail git rebase HEAD^ --onto HEAD^^ &&
        echo three >main.txt &&
        git add main.txt &&
-       cat >expected <<-EOF &&
-       # rebase in progress; onto $ONTO
-       # You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
-       #   (all conflicts fixed: run "git rebase --continue")
-       #
-       # Changes to be committed:
-       #   (use "git reset HEAD <file>..." to unstage)
-       #
-       #       modified:   main.txt
-       #
-       # Untracked files not listed (use -u option to show untracked files)
-       EOF
+       cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
+  (all conflicts fixed: run "git rebase --continue")
+
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       modified:   main.txt
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -135,21 +135,21 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '
        test_when_finished "git rebase --abort" &&
        ONTO=$(git rev-parse --short rebase_i_conflicts) &&
        test_must_fail git rebase -i rebase_i_conflicts &&
-       cat >expected <<-EOF &&
-       # 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)
-       #   (use "git rebase --abort" to check out the original branch)
-       #
-       # Unmerged paths:
-       #   (use "git reset HEAD <file>..." to unstage)
-       #   (use "git add <file>..." to mark resolution)
-       #
-       #       both modified:      main.txt
-       #
-       no changes added to commit (use "git add" and/or "git commit -a")
-       EOF
+       cat >expected <<EOF &&
+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)
+  (use "git rebase --abort" to check out the original branch)
+
+Unmerged paths:
+  (use "git reset HEAD <file>..." to unstage)
+  (use "git add <file>..." to mark resolution)
+
+       both modified:      main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -161,18 +161,18 @@ test_expect_success 'status during rebase -i after resolving conflicts' '
        ONTO=$(git rev-parse --short rebase_i_conflicts) &&
        test_must_fail git rebase -i rebase_i_conflicts &&
        git add main.txt &&
-       cat >expected <<-EOF &&
-       # rebase in progress; onto $ONTO
-       # You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
-       #   (all conflicts fixed: run "git rebase --continue")
-       #
-       # Changes to be committed:
-       #   (use "git reset HEAD <file>..." to unstage)
-       #
-       #       modified:   main.txt
-       #
-       # Untracked files not listed (use -u option to show untracked files)
-       EOF
+       cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
+  (all conflicts fixed: run "git rebase --continue")
+
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       modified:   main.txt
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -189,14 +189,14 @@ test_expect_success 'status when rebasing -i in edit mode' '
        test_when_finished "git rebase --abort" &&
        ONTO=$(git rev-parse --short HEAD~2) &&
        git rebase -i HEAD~2 &&
-       cat >expected <<-EOF &&
-       # 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)
-       #
-       nothing to commit (use -u to show untracked files)
-       EOF
+       cat >expected <<EOF &&
+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)
+
+nothing to commit (use -u to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -215,19 +215,19 @@ test_expect_success 'status when splitting a commit' '
        ONTO=$(git rev-parse --short HEAD~3) &&
        git rebase -i HEAD~3 &&
        git reset HEAD^ &&
-       cat >expected <<-EOF &&
-       # 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")
-       #
-       # Changes not staged for commit:
-       #   (use "git add <file>..." to update what will be committed)
-       #   (use "git checkout -- <file>..." to discard changes in working directory)
-       #
-       #       modified:   main.txt
-       #
-       no changes added to commit (use "git add" and/or "git commit -a")
-       EOF
+       cat >expected <<EOF &&
+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")
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -246,14 +246,14 @@ test_expect_success 'status after editing the last commit with --amend during a
        ONTO=$(git rev-parse --short HEAD~3) &&
        git rebase -i HEAD~3 &&
        git commit --amend -m "foo" &&
-       cat >expected <<-EOF &&
-       # 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)
-       #
-       nothing to commit (use -u to show untracked files)
-       EOF
+       cat >expected <<EOF &&
+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)
+
+nothing to commit (use -u to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -276,14 +276,14 @@ test_expect_success 'status: (continue first edit) second edit' '
        ONTO=$(git rev-parse --short HEAD~3) &&
        git rebase -i HEAD~3 &&
        git rebase --continue &&
-       cat >expected <<-EOF &&
-       # 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)
-       #
-       nothing to commit (use -u to show untracked files)
-       EOF
+       cat >expected <<EOF &&
+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)
+
+nothing to commit (use -u to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -298,19 +298,19 @@ test_expect_success 'status: (continue first edit) second edit and split' '
        git rebase -i HEAD~3 &&
        git rebase --continue &&
        git reset HEAD^ &&
-       cat >expected <<-EOF &&
-       # 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")
-       #
-       # Changes not staged for commit:
-       #   (use "git add <file>..." to update what will be committed)
-       #   (use "git checkout -- <file>..." to discard changes in working directory)
-       #
-       #       modified:   main.txt
-       #
-       no changes added to commit (use "git add" and/or "git commit -a")
-       EOF
+       cat >expected <<EOF &&
+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")
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -325,14 +325,14 @@ test_expect_success 'status: (continue first edit) second edit and amend' '
        git rebase -i HEAD~3 &&
        git rebase --continue &&
        git commit --amend -m "foo" &&
-       cat >expected <<-EOF &&
-       # 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)
-       #
-       nothing to commit (use -u to show untracked files)
-       EOF
+       cat >expected <<EOF &&
+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)
+
+nothing to commit (use -u to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -347,14 +347,14 @@ test_expect_success 'status: (amend first edit) second edit' '
        git rebase -i HEAD~3 &&
        git commit --amend -m "a" &&
        git rebase --continue &&
-       cat >expected <<-EOF &&
-       # 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)
-       #
-       nothing to commit (use -u to show untracked files)
-       EOF
+       cat >expected <<EOF &&
+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)
+
+nothing to commit (use -u to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -370,19 +370,19 @@ test_expect_success 'status: (amend first edit) second edit and split' '
        git commit --amend -m "b" &&
        git rebase --continue &&
        git reset HEAD^ &&
-       cat >expected <<-EOF &&
-       # 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")
-       #
-       # Changes not staged for commit:
-       #   (use "git add <file>..." to update what will be committed)
-       #   (use "git checkout -- <file>..." to discard changes in working directory)
-       #
-       #       modified:   main.txt
-       #
-       no changes added to commit (use "git add" and/or "git commit -a")
-       EOF
+       cat >expected <<EOF &&
+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")
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -398,14 +398,14 @@ test_expect_success 'status: (amend first edit) second edit and amend' '
        git commit --amend -m "c" &&
        git rebase --continue &&
        git commit --amend -m "d" &&
-       cat >expected <<-EOF &&
-       # 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)
-       #
-       nothing to commit (use -u to show untracked files)
-       EOF
+       cat >expected <<EOF &&
+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)
+
+nothing to commit (use -u to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -422,14 +422,14 @@ test_expect_success 'status: (split first edit) second edit' '
        git add main.txt &&
        git commit -m "e" &&
        git rebase --continue &&
-       cat >expected <<-EOF &&
-       # 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)
-       #
-       nothing to commit (use -u to show untracked files)
-       EOF
+       cat >expected <<EOF &&
+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)
+
+nothing to commit (use -u to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -447,19 +447,19 @@ test_expect_success 'status: (split first edit) second edit and split' '
        git commit --amend -m "f" &&
        git rebase --continue &&
        git reset HEAD^ &&
-       cat >expected <<-EOF &&
-       # 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")
-       #
-       # Changes not staged for commit:
-       #   (use "git add <file>..." to update what will be committed)
-       #   (use "git checkout -- <file>..." to discard changes in working directory)
-       #
-       #       modified:   main.txt
-       #
-       no changes added to commit (use "git add" and/or "git commit -a")
-       EOF
+       cat >expected <<EOF &&
+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")
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -477,14 +477,14 @@ test_expect_success 'status: (split first edit) second edit and amend' '
        git commit --amend -m "g" &&
        git rebase --continue &&
        git commit --amend -m "h" &&
-       cat >expected <<-EOF &&
-       # 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)
-       #
-       nothing to commit (use -u to show untracked files)
-       EOF
+       cat >expected <<EOF &&
+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)
+
+nothing to commit (use -u to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -504,15 +504,15 @@ test_expect_success 'status in an am session: file already exists' '
        test_when_finished "rm Maildir/* && git am --abort" &&
        git format-patch -1 -oMaildir &&
        test_must_fail git am Maildir/*.patch &&
-       cat >expected <<-\EOF &&
-       # On branch am_already_exists
-       # You are in the middle of an am session.
-       #   (fix conflicts and then run "git am --continue")
-       #   (use "git am --skip" to skip this patch)
-       #   (use "git am --abort" to restore the original branch)
-       #
-       nothing to commit (use -u to show untracked files)
-       EOF
+       cat >expected <<\EOF &&
+On branch am_already_exists
+You are in the middle of an am session.
+  (fix conflicts and then run "git am --continue")
+  (use "git am --skip" to skip this patch)
+  (use "git am --abort" to restore the original branch)
+
+nothing to commit (use -u to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -526,15 +526,15 @@ test_expect_success 'status in an am session: file does not exist' '
        test_when_finished "rm Maildir/* && git am --abort" &&
        git format-patch -1 -oMaildir &&
        test_must_fail git am Maildir/*.patch &&
-       cat >expected <<-\EOF &&
-       # On branch am_not_exists
-       # You are in the middle of an am session.
-       #   (fix conflicts and then run "git am --continue")
-       #   (use "git am --skip" to skip this patch)
-       #   (use "git am --abort" to restore the original branch)
-       #
-       nothing to commit (use -u to show untracked files)
-       EOF
+       cat >expected <<\EOF &&
+On branch am_not_exists
+You are in the middle of an am session.
+  (fix conflicts and then run "git am --continue")
+  (use "git am --skip" to skip this patch)
+  (use "git am --abort" to restore the original branch)
+
+nothing to commit (use -u to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -549,15 +549,15 @@ test_expect_success 'status in an am session: empty patch' '
        git commit -m "delete all am_empty" &&
        echo error >Maildir/0002-two_am.patch &&
        test_must_fail git am Maildir/*.patch &&
-       cat >expected <<-\EOF &&
-       # On branch am_empty
-       # You are in the middle of an am session.
-       # The current patch is empty.
-       #   (use "git am --skip" to skip this patch)
-       #   (use "git am --abort" to restore the original branch)
-       #
-       nothing to commit (use -u to show untracked files)
-       EOF
+       cat >expected <<\EOF &&
+On branch am_empty
+You are in the middle of an am session.
+The current patch is empty.
+  (use "git am --skip" to skip this patch)
+  (use "git am --abort" to restore the original branch)
+
+nothing to commit (use -u to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -574,13 +574,13 @@ test_expect_success 'status when bisecting' '
        git bisect bad &&
        git bisect good one_bisect &&
        TGT=$(git rev-parse --short two_bisect) &&
-       cat >expected <<-EOF &&
-       # HEAD detached at $TGT
-       # You are currently bisecting, started from branch '\''bisect'\''.
-       #   (use "git bisect reset" to get back to the original branch)
-       #
-       nothing to commit (use -u to show untracked files)
-       EOF
+       cat >expected <<EOF &&
+HEAD detached at $TGT
+You are currently bisecting, started from branch '\''bisect'\''.
+  (use "git bisect reset" to get back to the original branch)
+
+nothing to commit (use -u to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -597,15 +597,15 @@ test_expect_success 'status when rebase conflicts with statushints disabled' '
        test_when_finished "git rebase --abort" &&
        ONTO=$(git rev-parse --short HEAD^^) &&
        test_must_fail git rebase HEAD^ --onto HEAD^^ &&
-       cat >expected <<-EOF &&
-       # rebase in progress; onto $ONTO
-       # You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
-       #
-       # Unmerged paths:
-       #       both modified:      main.txt
-       #
-       no changes added to commit
-       EOF
+       cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
+
+Unmerged paths:
+       both modified:      main.txt
+
+no changes added to commit
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -626,19 +626,19 @@ test_expect_success 'prepare for cherry-pick conflicts' '
 test_expect_success 'status when cherry-picking before resolving conflicts' '
        test_when_finished "git cherry-pick --abort" &&
        test_must_fail git cherry-pick cherry_branch_second &&
-       cat >expected <<-\EOF &&
-       # On branch cherry_branch
-       # You are currently cherry-picking.
-       #   (fix conflicts and run "git cherry-pick --continue")
-       #   (use "git cherry-pick --abort" to cancel the cherry-pick operation)
-       #
-       # Unmerged paths:
-       #   (use "git add <file>..." to mark resolution)
-       #
-       #       both modified:      main.txt
-       #
-       no changes added to commit (use "git add" and/or "git commit -a")
-       EOF
+       cat >expected <<\EOF &&
+On branch cherry_branch
+You are currently cherry-picking.
+  (fix conflicts and run "git cherry-pick --continue")
+  (use "git cherry-pick --abort" to cancel the cherry-pick operation)
+
+Unmerged paths:
+  (use "git add <file>..." to mark resolution)
+
+       both modified:      main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -650,18 +650,18 @@ test_expect_success 'status when cherry-picking after resolving conflicts' '
        test_must_fail git cherry-pick cherry_branch_second &&
        echo end >main.txt &&
        git add main.txt &&
-       cat >expected <<-\EOF &&
-       # On branch cherry_branch
-       # You are currently cherry-picking.
-       #   (all conflicts fixed: run "git cherry-pick --continue")
-       #   (use "git cherry-pick --abort" to cancel the cherry-pick operation)
-       #
-       # Changes to be committed:
-       #
-       #       modified:   main.txt
-       #
-       # Untracked files not listed (use -u option to show untracked files)
-       EOF
+       cat >expected <<\EOF &&
+On branch cherry_branch
+You are currently cherry-picking.
+  (all conflicts fixed: run "git cherry-pick --continue")
+  (use "git cherry-pick --abort" to cancel the cherry-pick operation)
+
+Changes to be committed:
+
+       modified:   main.txt
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -669,18 +669,18 @@ test_expect_success 'status when cherry-picking after resolving conflicts' '
 test_expect_success 'status showing detached at and from a tag' '
        test_commit atag tagging &&
        git checkout atag &&
-       cat >expected <<-\EOF
-       # HEAD detached at atag
-       nothing to commit (use -u to show untracked files)
-       EOF
+       cat >expected <<\EOF
+HEAD detached at atag
+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
+       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
 '
@@ -695,20 +695,20 @@ test_expect_success 'status while reverting commit (conflicts)' '
        test_commit new to-revert.txt &&
        TO_REVERT=$(git rev-parse --short HEAD^) &&
        test_must_fail git revert $TO_REVERT &&
-       cat >expected <<-EOF
-       # On branch master
-       # You are currently reverting commit $TO_REVERT.
-       #   (fix conflicts and run "git revert --continue")
-       #   (use "git revert --abort" to cancel the revert operation)
-       #
-       # Unmerged paths:
-       #   (use "git reset HEAD <file>..." to unstage)
-       #   (use "git add <file>..." to mark resolution)
-       #
-       #       both modified:      to-revert.txt
-       #
-       no changes added to commit (use "git add" and/or "git commit -a")
-       EOF
+       cat >expected <<EOF
+On branch master
+You are currently reverting commit $TO_REVERT.
+  (fix conflicts and run "git revert --continue")
+  (use "git revert --abort" to cancel the revert operation)
+
+Unmerged paths:
+  (use "git reset HEAD <file>..." to unstage)
+  (use "git add <file>..." to mark resolution)
+
+       both modified:      to-revert.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
@@ -716,29 +716,29 @@ test_expect_success 'status while reverting commit (conflicts)' '
 test_expect_success 'status while reverting commit (conflicts resolved)' '
        echo reverted >to-revert.txt &&
        git add to-revert.txt &&
-       cat >expected <<-EOF
-       # On branch master
-       # You are currently reverting commit $TO_REVERT.
-       #   (all conflicts fixed: run "git revert --continue")
-       #   (use "git revert --abort" to cancel the revert operation)
-       #
-       # Changes to be committed:
-       #   (use "git reset HEAD <file>..." to unstage)
-       #
-       #       modified:   to-revert.txt
-       #
-       # Untracked files not listed (use -u option to show untracked files)
-       EOF
+       cat >expected <<EOF
+On branch master
+You are currently reverting commit $TO_REVERT.
+  (all conflicts fixed: run "git revert --continue")
+  (use "git revert --abort" to cancel the revert operation)
+
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       modified:   to-revert.txt
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
 
 test_expect_success 'status after reverting commit' '
        git revert --continue &&
-       cat >expected <<-\EOF
-       # On branch master
-       nothing to commit (use -u to show untracked files)
-       EOF
+       cat >expected <<\EOF
+On branch master
+nothing to commit (use -u to show untracked files)
+EOF
        git status --untracked-files=no >actual &&
        test_i18ncmp expected actual
 '
index 586e3bf94da1a2d69a061fe98aa1604f9223280b..68d62d5446d963dc69006ad9a83907c6690f92c1 100755 (executable)
@@ -16,7 +16,7 @@ else
 fi
 
 # If you want to allow non-ASCII filenames set this variable to true.
-allownonascii=$(git config hooks.allownonascii)
+allownonascii=$(git config --bool hooks.allownonascii)
 
 # Redirect output to stderr.
 exec 1>&2
index 80daba980ecd85852ee3a23c155602e4cd1ba07a..e57eae10bf73baac79fd8b95ddb0ff1b4c8c0cd6 100644 (file)
@@ -5,10 +5,15 @@ int main(int ac, char **av)
        git_SHA_CTX ctx;
        unsigned char sha1[20];
        unsigned bufsz = 8192;
+       int binary = 0;
        char *buffer;
 
-       if (ac == 2)
-               bufsz = strtoul(av[1], NULL, 10) * 1024 * 1024;
+       if (ac == 2) {
+               if (!strcmp(av[1], "-b"))
+                       binary = 1;
+               else
+                       bufsz = strtoul(av[1], NULL, 10) * 1024 * 1024;
+       }
 
        if (!bufsz)
                bufsz = 8192;
@@ -42,6 +47,10 @@ int main(int ac, char **av)
                git_SHA1_Update(&ctx, buffer, this_sz);
        }
        git_SHA1_Final(sha1, &ctx);
-       puts(sha1_to_hex(sha1));
+
+       if (binary)
+               fwrite(sha1, 1, 20, stdout);
+       else
+               puts(sha1_to_hex(sha1));
        exit(0);
 }
index b03492e664daa53f09d13787494c925af702d949..a6c54e06bb4c4725ace576740912cbb6133e291e 100644 (file)
@@ -41,6 +41,7 @@ static struct object_array have_obj;
 static struct object_array want_obj;
 static struct object_array extra_edge_obj;
 static unsigned int timeout;
+static int keepalive = 5;
 /* 0 for no sideband,
  * otherwise maximum packet size (up to 65520 bytes).
  */
@@ -69,87 +70,28 @@ static ssize_t send_client_data(int fd, const char *data, ssize_t sz)
        return sz;
 }
 
-static FILE *pack_pipe = NULL;
-static void show_commit(struct commit *commit, void *data)
-{
-       if (commit->object.flags & BOUNDARY)
-               fputc('-', pack_pipe);
-       if (fputs(sha1_to_hex(commit->object.sha1), pack_pipe) < 0)
-               die("broken output pipe");
-       fputc('\n', pack_pipe);
-       fflush(pack_pipe);
-       free(commit->buffer);
-       commit->buffer = NULL;
-}
-
-static void show_object(struct object *obj,
-                       const struct name_path *path, const char *component,
-                       void *cb_data)
-{
-       show_object_with_name(pack_pipe, obj, path, component);
-}
-
-static void show_edge(struct commit *commit)
-{
-       fprintf(pack_pipe, "-%s\n", sha1_to_hex(commit->object.sha1));
-}
-
-static int do_rev_list(int in, int out, void *user_data)
-{
-       int i;
-       struct rev_info revs;
-
-       pack_pipe = xfdopen(out, "w");
-       init_revisions(&revs, NULL);
-       revs.tag_objects = 1;
-       revs.tree_objects = 1;
-       revs.blob_objects = 1;
-       if (use_thin_pack)
-               revs.edge_hint = 1;
-
-       for (i = 0; i < want_obj.nr; i++) {
-               struct object *o = want_obj.objects[i].item;
-               /* why??? */
-               o->flags &= ~UNINTERESTING;
-               add_pending_object(&revs, o, NULL);
-       }
-       for (i = 0; i < have_obj.nr; i++) {
-               struct object *o = have_obj.objects[i].item;
-               o->flags |= UNINTERESTING;
-               add_pending_object(&revs, o, NULL);
-       }
-       setup_revisions(0, NULL, &revs, NULL);
-       if (prepare_revision_walk(&revs))
-               die("revision walk setup failed");
-       mark_edges_uninteresting(revs.commits, &revs, show_edge);
-       if (use_thin_pack)
-               for (i = 0; i < extra_edge_obj.nr; i++)
-                       fprintf(pack_pipe, "-%s\n", sha1_to_hex(
-                                       extra_edge_obj.objects[i].item->sha1));
-       traverse_commit_list(&revs, show_commit, show_object, NULL);
-       fflush(pack_pipe);
-       fclose(pack_pipe);
-       return 0;
-}
-
 static void create_pack_file(void)
 {
-       struct async rev_list;
        struct child_process pack_objects;
        char data[8193], progress[128];
        char abort_msg[] = "aborting due to possible repository "
                "corruption on the remote side.";
        int buffered = -1;
        ssize_t sz;
-       const char *argv[10];
-       int arg = 0;
+       const char *argv[12];
+       int i, arg = 0;
+       FILE *pipe_fd;
+       char *shallow_file = NULL;
 
-       argv[arg++] = "pack-objects";
-       if (!shallow_nr) {
-               argv[arg++] = "--revs";
-               if (use_thin_pack)
-                       argv[arg++] = "--thin";
+       if (shallow_nr) {
+               shallow_file = setup_temporary_shallow();
+               argv[arg++] = "--shallow-file";
+               argv[arg++] = shallow_file;
        }
+       argv[arg++] = "pack-objects";
+       argv[arg++] = "--revs";
+       if (use_thin_pack)
+               argv[arg++] = "--thin";
 
        argv[arg++] = "--stdout";
        if (!no_progress)
@@ -170,29 +112,21 @@ static void create_pack_file(void)
        if (start_command(&pack_objects))
                die("git upload-pack: unable to fork git-pack-objects");
 
-       if (shallow_nr) {
-               memset(&rev_list, 0, sizeof(rev_list));
-               rev_list.proc = do_rev_list;
-               rev_list.out = pack_objects.in;
-               if (start_async(&rev_list))
-                       die("git upload-pack: unable to fork git-rev-list");
-       }
-       else {
-               FILE *pipe_fd = xfdopen(pack_objects.in, "w");
-               int i;
-
-               for (i = 0; i < want_obj.nr; i++)
-                       fprintf(pipe_fd, "%s\n",
-                               sha1_to_hex(want_obj.objects[i].item->sha1));
-               fprintf(pipe_fd, "--not\n");
-               for (i = 0; i < have_obj.nr; i++)
-                       fprintf(pipe_fd, "%s\n",
-                               sha1_to_hex(have_obj.objects[i].item->sha1));
-               fprintf(pipe_fd, "\n");
-               fflush(pipe_fd);
-               fclose(pipe_fd);
-       }
-
+       pipe_fd = xfdopen(pack_objects.in, "w");
+
+       for (i = 0; i < want_obj.nr; i++)
+               fprintf(pipe_fd, "%s\n",
+                       sha1_to_hex(want_obj.objects[i].item->sha1));
+       fprintf(pipe_fd, "--not\n");
+       for (i = 0; i < have_obj.nr; i++)
+               fprintf(pipe_fd, "%s\n",
+                       sha1_to_hex(have_obj.objects[i].item->sha1));
+       for (i = 0; i < extra_edge_obj.nr; i++)
+               fprintf(pipe_fd, "%s\n",
+                       sha1_to_hex(extra_edge_obj.objects[i].item->sha1));
+       fprintf(pipe_fd, "\n");
+       fflush(pipe_fd);
+       fclose(pipe_fd);
 
        /* We read from pack_objects.err to capture stderr output for
         * progress bar, and pack_objects.out to capture the pack data.
@@ -201,6 +135,7 @@ static void create_pack_file(void)
        while (1) {
                struct pollfd pfd[2];
                int pe, pu, pollsize;
+               int ret;
 
                reset_timeout();
 
@@ -223,7 +158,8 @@ static void create_pack_file(void)
                if (!pollsize)
                        break;
 
-               if (poll(pfd, pollsize, -1) < 0) {
+               ret = poll(pfd, pollsize, 1000 * keepalive);
+               if (ret < 0) {
                        if (errno != EINTR) {
                                error("poll failed, resuming: %s",
                                      strerror(errno));
@@ -285,14 +221,32 @@ static void create_pack_file(void)
                        if (sz < 0)
                                goto fail;
                }
+
+               /*
+                * We hit the keepalive timeout without saying anything; send
+                * an empty message on the data sideband just to let the other
+                * side know we're still working on it, but don't have any data
+                * yet.
+                *
+                * If we don't have a sideband channel, there's no room in the
+                * protocol to say anything, so those clients are just out of
+                * luck.
+                */
+               if (!ret && use_sideband) {
+                       static const char buf[] = "0005\1";
+                       write_or_die(1, buf, 5);
+               }
        }
 
        if (finish_command(&pack_objects)) {
                error("git upload-pack: git-pack-objects died with error.");
                goto fail;
        }
-       if (shallow_nr && finish_async(&rev_list))
-               goto fail;      /* error was already reported */
+       if (shallow_file) {
+               if (*shallow_file)
+                       unlink(shallow_file);
+               free(shallow_file);
+       }
 
        /* flush the data */
        if (0 <= buffered) {
@@ -786,6 +740,11 @@ static int upload_pack_config(const char *var, const char *value, void *unused)
 {
        if (!strcmp("uploadpack.allowtipsha1inwant", var))
                allow_tip_sha1_in_want = git_config_bool(var, value);
+       else if (!strcmp("uploadpack.keepalive", var)) {
+               keepalive = git_config_int(var, value);
+               if (!keepalive)
+                       keepalive = -1;
+       }
        return parse_hide_refs_config(var, value, "uploadpack");
 }
 
index 1db76c89bc2183855da5d6e3bc54f4fdef471462..ec87cba75099ebe05e936430ca3b688275e01a4a 100644 (file)
@@ -281,9 +281,11 @@ char *url_normalize(const char *url, struct url_info *out_info)
                url_len--;
        }
        for (;;) {
-               const char *seg_start = norm.buf + norm.len;
+               const char *seg_start;
+               size_t seg_start_off = norm.len;
                const char *next_slash = url + strcspn(url, "/?#");
                int skip_add_slash = 0;
+
                /*
                 * RFC 3689 indicates that any . or .. segments should be
                 * unescaped before being checked for.
@@ -297,6 +299,8 @@ char *url_normalize(const char *url, struct url_info *out_info)
                        strbuf_release(&norm);
                        return NULL;
                }
+
+               seg_start = norm.buf + seg_start_off;
                if (!strcmp(seg_start, ".")) {
                        /* ignore a . segment; be careful not to remove initial '/' */
                        if (seg_start == path_start + 1) {
index ff4b32426a36db38fba9e4cc51e09a988efe34a6..cbdce726512f3daa5ad574c3aae07ed25b80c502 100644 (file)
@@ -9,6 +9,7 @@
 #include "diffcore.h"
 #include "quote.h"
 #include "run-command.h"
+#include "argv-array.h"
 #include "remote.h"
 #include "refs.h"
 #include "submodule.h"
@@ -46,9 +47,11 @@ static void status_vprintf(struct wt_status *s, int at_bol, const char *color,
 
        strbuf_vaddf(&sb, fmt, ap);
        if (!sb.len) {
-               strbuf_addch(&sb, comment_line_char);
-               if (!trail)
-                       strbuf_addch(&sb, ' ');
+               if (s->display_comment_prefix) {
+                       strbuf_addch(&sb, comment_line_char);
+                       if (!trail)
+                               strbuf_addch(&sb, ' ');
+               }
                color_print_strbuf(s->fp, color, &sb);
                if (trail)
                        fprintf(s->fp, "%s", trail);
@@ -59,7 +62,7 @@ static void status_vprintf(struct wt_status *s, int at_bol, const char *color,
                eol = strchr(line, '\n');
 
                strbuf_reset(&linebuf);
-               if (at_bol) {
+               if (at_bol && s->display_comment_prefix) {
                        strbuf_addch(&linebuf, comment_line_char);
                        if (*line != '\n' && *line != '\t')
                                strbuf_addch(&linebuf, ' ');
@@ -129,6 +132,7 @@ void wt_status_prepare(struct wt_status *s)
        s->untracked.strdup_strings = 1;
        s->ignored.strdup_strings = 1;
        s->show_branch = -1;  /* unspecified */
+       s->display_comment_prefix = 0;
 }
 
 static void wt_status_print_unmerged_header(struct wt_status *s)
@@ -161,7 +165,7 @@ static void wt_status_print_unmerged_header(struct wt_status *s)
                }
        }
 
-       if (!advice_status_hints)
+       if (!s->hints)
                return;
        if (s->whence != FROM_COMMIT)
                ;
@@ -188,7 +192,7 @@ static void wt_status_print_cached_header(struct wt_status *s)
        const char *c = color(WT_STATUS_HEADER, s);
 
        status_printf_ln(s, c, _("Changes to be committed:"));
-       if (!advice_status_hints)
+       if (!s->hints)
                return;
        if (s->whence != FROM_COMMIT)
                ; /* NEEDSWORK: use "git reset --unresolve"??? */
@@ -206,7 +210,7 @@ static void wt_status_print_dirty_header(struct wt_status *s,
        const char *c = color(WT_STATUS_HEADER, s);
 
        status_printf_ln(s, c, _("Changes not staged for commit:"));
-       if (!advice_status_hints)
+       if (!s->hints)
                return;
        if (!has_deleted)
                status_printf_ln(s, c, _("  (use \"git add <file>...\" to update what will be committed)"));
@@ -224,7 +228,7 @@ static void wt_status_print_other_header(struct wt_status *s,
 {
        const char *c = color(WT_STATUS_HEADER, s);
        status_printf_ln(s, c, "%s:", what);
-       if (!advice_status_hints)
+       if (!s->hints)
                return;
        status_printf_ln(s, c, _("  (use \"git %s <file>...\" to include in what will be committed)"), how);
        status_printf_ln(s, c, "");
@@ -661,29 +665,57 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
        char summary_limit[64];
        char index[PATH_MAX];
        const char *env[] = { NULL, NULL };
-       const char *argv[8];
-
-       env[0] =        index;
-       argv[0] =       "submodule";
-       argv[1] =       "summary";
-       argv[2] =       uncommitted ? "--files" : "--cached";
-       argv[3] =       "--for-status";
-       argv[4] =       "--summary-limit";
-       argv[5] =       summary_limit;
-       argv[6] =       uncommitted ? NULL : (s->amend ? "HEAD^" : "HEAD");
-       argv[7] =       NULL;
+       struct argv_array argv = ARGV_ARRAY_INIT;
+       struct strbuf cmd_stdout = STRBUF_INIT;
+       struct strbuf summary = STRBUF_INIT;
+       char *summary_content;
+       size_t len;
 
        sprintf(summary_limit, "%d", s->submodule_summary);
        snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file);
 
+       env[0] = index;
+       argv_array_push(&argv, "submodule");
+       argv_array_push(&argv, "summary");
+       argv_array_push(&argv, uncommitted ? "--files" : "--cached");
+       argv_array_push(&argv, "--for-status");
+       argv_array_push(&argv, "--summary-limit");
+       argv_array_push(&argv, summary_limit);
+       if (!uncommitted)
+               argv_array_push(&argv, s->amend ? "HEAD^" : "HEAD");
+
        memset(&sm_summary, 0, sizeof(sm_summary));
-       sm_summary.argv = argv;
+       sm_summary.argv = argv.argv;
        sm_summary.env = env;
        sm_summary.git_cmd = 1;
        sm_summary.no_stdin = 1;
        fflush(s->fp);
-       sm_summary.out = dup(fileno(s->fp));    /* run_command closes it */
+       sm_summary.out = -1;
+
        run_command(&sm_summary);
+       argv_array_clear(&argv);
+
+       len = strbuf_read(&cmd_stdout, sm_summary.out, 1024);
+
+       /* prepend header, only if there's an actual output */
+       if (len) {
+               if (uncommitted)
+                       strbuf_addstr(&summary, _("Submodules changed but not updated:"));
+               else
+                       strbuf_addstr(&summary, _("Submodule changes to be committed:"));
+               strbuf_addstr(&summary, "\n\n");
+       }
+       strbuf_addbuf(&summary, &cmd_stdout);
+       strbuf_release(&cmd_stdout);
+
+       if (s->display_comment_prefix) {
+               summary_content = strbuf_detach(&summary, &len);
+               strbuf_add_commented_lines(&summary, summary_content, len);
+               free(summary_content);
+       }
+
+       fputs(summary.buf, s->fp);
+       strbuf_release(&summary);
 }
 
 static void wt_status_print_other(struct wt_status *s,
@@ -717,10 +749,11 @@ static void wt_status_print_other(struct wt_status *s,
 
        strbuf_release(&buf);
        if (!column_active(s->colopts))
-               return;
+               goto conclude;
 
-       strbuf_addf(&buf, "%s#\t%s",
+       strbuf_addf(&buf, "%s%s\t%s",
                    color(WT_STATUS_HEADER, s),
+                   s->display_comment_prefix ? "#" : "",
                    color(WT_STATUS_UNTRACKED, s));
        memset(&copts, 0, sizeof(copts));
        copts.padding = 1;
@@ -730,6 +763,8 @@ static void wt_status_print_other(struct wt_status *s,
        print_columns(&output, s->colopts, &copts);
        string_list_clear(&output, 0);
        strbuf_release(&buf);
+conclude:
+       status_printf_ln(s, GIT_COLOR_NORMAL, "");
 }
 
 static void wt_status_print_verbose(struct wt_status *s)
@@ -764,6 +799,8 @@ static void wt_status_print_tracking(struct wt_status *s)
        struct strbuf sb = STRBUF_INIT;
        const char *cp, *ep;
        struct branch *branch;
+       char comment_line_string[3];
+       int i;
 
        assert(s->branch && !s->is_initial);
        if (prefixcmp(s->branch, "refs/heads/"))
@@ -772,12 +809,22 @@ static void wt_status_print_tracking(struct wt_status *s)
        if (!format_tracking_info(branch, &sb))
                return;
 
+       i = 0;
+       if (s->display_comment_prefix) {
+               comment_line_string[i++] = comment_line_char;
+               comment_line_string[i++] = ' ';
+       }
+       comment_line_string[i] = '\0';
+
        for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1)
                color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s),
-                                "%c %.*s", comment_line_char,
+                                "%s%.*s", comment_line_string,
                                 (int)(ep - cp), cp);
-       color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c",
-                        comment_line_char);
+       if (s->display_comment_prefix)
+               color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c",
+                                comment_line_char);
+       else
+               fprintf_ln(s->fp, "");
 }
 
 static int has_unmerged(struct wt_status *s)
@@ -799,13 +846,13 @@ static void show_merge_in_progress(struct wt_status *s,
 {
        if (has_unmerged(s)) {
                status_printf_ln(s, color, _("You have unmerged paths."));
-               if (advice_status_hints)
+               if (s->hints)
                        status_printf_ln(s, color,
                                _("  (fix conflicts and run \"git commit\")"));
        } else {
                status_printf_ln(s, color,
                        _("All conflicts fixed but you are still merging."));
-               if (advice_status_hints)
+               if (s->hints)
                        status_printf_ln(s, color,
                                _("  (use \"git commit\" to conclude merge)"));
        }
@@ -821,7 +868,7 @@ static void show_am_in_progress(struct wt_status *s,
        if (state->am_empty_patch)
                status_printf_ln(s, color,
                        _("The current patch is empty."));
-       if (advice_status_hints) {
+       if (s->hints) {
                if (!state->am_empty_patch)
                        status_printf_ln(s, color,
                                _("  (fix conflicts and then run \"git am --continue\")"));
@@ -894,7 +941,7 @@ static void show_rebase_in_progress(struct wt_status *s,
                else
                        status_printf_ln(s, color,
                                         _("You are currently rebasing."));
-               if (advice_status_hints) {
+               if (s->hints) {
                        status_printf_ln(s, color,
                                _("  (fix conflicts and then run \"git rebase --continue\")"));
                        status_printf_ln(s, color,
@@ -911,7 +958,7 @@ static void show_rebase_in_progress(struct wt_status *s,
                else
                        status_printf_ln(s, color,
                                         _("You are currently rebasing."));
-               if (advice_status_hints)
+               if (s->hints)
                        status_printf_ln(s, color,
                                _("  (all conflicts fixed: run \"git rebase --continue\")"));
        } else if (split_commit_in_progress(s)) {
@@ -923,7 +970,7 @@ static void show_rebase_in_progress(struct wt_status *s,
                else
                        status_printf_ln(s, color,
                                         _("You are currently splitting a commit during a rebase."));
-               if (advice_status_hints)
+               if (s->hints)
                        status_printf_ln(s, color,
                                _("  (Once your working directory is clean, run \"git rebase --continue\")"));
        } else {
@@ -935,7 +982,7 @@ static void show_rebase_in_progress(struct wt_status *s,
                else
                        status_printf_ln(s, color,
                                         _("You are currently editing a commit during a rebase."));
-               if (advice_status_hints && !s->amend) {
+               if (s->hints && !s->amend) {
                        status_printf_ln(s, color,
                                _("  (use \"git commit --amend\" to amend the current commit)"));
                        status_printf_ln(s, color,
@@ -950,7 +997,7 @@ static void show_cherry_pick_in_progress(struct wt_status *s,
                                        const char *color)
 {
        status_printf_ln(s, color, _("You are currently cherry-picking."));
-       if (advice_status_hints) {
+       if (s->hints) {
                if (has_unmerged(s))
                        status_printf_ln(s, color,
                                _("  (fix conflicts and run \"git cherry-pick --continue\")"));
@@ -969,7 +1016,7 @@ static void show_revert_in_progress(struct wt_status *s,
 {
        status_printf_ln(s, color, _("You are currently reverting commit %s."),
                         find_unique_abbrev(state->revert_head_sha1, DEFAULT_ABBREV));
-       if (advice_status_hints) {
+       if (s->hints) {
                if (has_unmerged(s))
                        status_printf_ln(s, color,
                                _("  (fix conflicts and run \"git revert --continue\")"));
@@ -993,7 +1040,7 @@ static void show_bisect_in_progress(struct wt_status *s,
        else
                status_printf_ln(s, color,
                                 _("You are currently bisecting."));
-       if (advice_status_hints)
+       if (s->hints)
                status_printf_ln(s, color,
                        _("  (use \"git bisect reset\" to get back to the original branch)"));
        wt_status_print_trailer(s);
@@ -1231,7 +1278,7 @@ void wt_status_print(struct wt_status *s)
                }
        } else if (s->commitable)
                status_printf_ln(s, GIT_COLOR_NORMAL, _("Untracked files not listed%s"),
-                       advice_status_hints
+                       s->hints
                        ? _(" (use -u option to show untracked files)") : "");
 
        if (s->verbose)
@@ -1242,25 +1289,25 @@ void wt_status_print(struct wt_status *s)
                else if (s->nowarn)
                        ; /* nothing */
                else if (s->workdir_dirty) {
-                       if (advice_status_hints)
+                       if (s->hints)
                                printf(_("no changes added to commit "
                                         "(use \"git add\" and/or \"git commit -a\")\n"));
                        else
                                printf(_("no changes added to commit\n"));
                } else if (s->untracked.nr) {
-                       if (advice_status_hints)
+                       if (s->hints)
                                printf(_("nothing added to commit but untracked files "
                                         "present (use \"git add\" to track)\n"));
                        else
                                printf(_("nothing added to commit but untracked files present\n"));
                } else if (s->is_initial) {
-                       if (advice_status_hints)
+                       if (s->hints)
                                printf(_("nothing to commit (create/copy files "
                                         "and use \"git add\" to track)\n"));
                        else
                                printf(_("nothing to commit\n"));
                } else if (!s->show_untracked_files) {
-                       if (advice_status_hints)
+                       if (s->hints)
                                printf(_("nothing to commit (use -u to show untracked files)\n"));
                        else
                                printf(_("nothing to commit\n"));
@@ -1363,6 +1410,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
        const char *base;
        const char *branch_name;
        int num_ours, num_theirs;
+       int upstream_is_gone = 0;
 
        color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "## ");
 
@@ -1380,20 +1428,37 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
        branch = branch_get(s->branch + 11);
        if (s->is_initial)
                color_fprintf(s->fp, header_color, _("Initial commit on "));
-       if (!stat_tracking_info(branch, &num_ours, &num_theirs)) {
-               color_fprintf(s->fp, branch_color_local, "%s", branch_name);
+
+       color_fprintf(s->fp, branch_color_local, "%s", branch_name);
+
+       switch (stat_tracking_info(branch, &num_ours, &num_theirs)) {
+       case 0:
+               /* no base */
                fputc(s->null_termination ? '\0' : '\n', s->fp);
                return;
+       case -1:
+               /* with "gone" base */
+               upstream_is_gone = 1;
+               break;
+       default:
+               /* with base */
+               break;
        }
 
        base = branch->merge[0]->dst;
        base = shorten_unambiguous_ref(base, 0);
-       color_fprintf(s->fp, branch_color_local, "%s", branch_name);
        color_fprintf(s->fp, header_color, "...");
        color_fprintf(s->fp, branch_color_remote, "%s", base);
 
+       if (!upstream_is_gone && !num_ours && !num_theirs) {
+               fputc(s->null_termination ? '\0' : '\n', s->fp);
+               return;
+       }
+
        color_fprintf(s->fp, header_color, " [");
-       if (!num_ours) {
+       if (upstream_is_gone) {
+               color_fprintf(s->fp, header_color, _("gone"));
+       } else if (!num_ours) {
                color_fprintf(s->fp, header_color, _("behind "));
                color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
        } else if (!num_theirs) {
index 9966c13deb678857d5fdb0c3648865fa7189686b..9341c569a52e53cc939fa3bd94e013bbc2c8444d 100644 (file)
@@ -50,6 +50,7 @@ struct wt_status {
        enum commit_whence whence;
        int nowarn;
        int use_color;
+       int display_comment_prefix;
        int relative_paths;
        int submodule_summary;
        int show_ignored_files;
@@ -59,6 +60,7 @@ struct wt_status {
        unsigned colopts;
        int null_termination;
        int show_branch;
+       int hints;
 
        /* These are computed during processing of the individual sections */
        int commitable;