Merge branch 'rt/remove-hold-lockfile-for-append'
authorJunio C Hamano <gitster@pobox.com>
Tue, 1 Sep 2015 23:31:26 +0000 (16:31 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 1 Sep 2015 23:31:27 +0000 (16:31 -0700)
* rt/remove-hold-lockfile-for-append:
lockfile: remove function "hold_lock_file_for_append"

85 files changed:
.gitignore
Documentation/RelNotes/2.5.1.txt
Documentation/RelNotes/2.6.0.txt
Documentation/config.txt
Documentation/git-config.txt
Documentation/git-describe.txt
Documentation/git-notes.txt
Documentation/git-push.txt
Documentation/git-send-email.txt
Documentation/git-send-pack.txt
Documentation/git-svn.txt
Documentation/git.txt
Documentation/gitremote-helpers.txt
Documentation/pretty-formats.txt
Documentation/pretty-options.txt
Documentation/rev-list-options.txt
Documentation/technical/api-submodule-config.txt [new file with mode: 0644]
Makefile
alias.c
archive-zip.c
builtin/am.c
builtin/branch.c
builtin/checkout.c
builtin/config.c
builtin/describe.c
builtin/fetch.c
builtin/init-db.c
builtin/log.c
builtin/ls-files.c
builtin/notes.c
builtin/pack-objects.c
builtin/push.c
builtin/read-tree.c
builtin/reflog.c
builtin/rev-list.c
builtin/send-pack.c
builtin/worktree.c
cache.h
compat/mingw.c
config.c
contrib/completion/git-completion.bash
contrib/examples/git-pull.sh
daemon.c
diff.c
dir.c
generate-cmdlist.perl [deleted file]
generate-cmdlist.sh [new file with mode: 0755]
git-p4.py
git-send-email.perl
git-submodule.sh
http.c
notes-merge.h
notes-utils.c
notes-utils.h
pager.c
po/README
remote-curl.c
send-pack.c
send-pack.h
setup.c
sha1_file.c
submodule-config.c [new file with mode: 0644]
submodule-config.h [new file with mode: 0644]
submodule.c
submodule.h
t/t1300-repo-config.sh
t/t3020-ls-files-error-unmatch.sh
t/t3309-notes-merge-auto-resolve.sh
t/t3310-notes-merge-manual-resolve.sh
t/t4151-am-abort.sh
t/t5004-archive-corner-cases.sh
t/t6120-describe.sh
t/t7006-pager.sh
t/t7063-status-untracked-cache.sh
t/t7411-submodule-config.sh [new file with mode: 0755]
t/t7513-interpret-trailers.sh
t/t9821-git-p4-path-variations.sh [new file with mode: 0755]
test-submodule-config.c [new file with mode: 0644]
trailer.c
transport-helper.c
transport.c
transport.h
wrapper.c
wt-status.c
wt-status.h
index a685ec1fb0ca49607431a65f1ccf035bb9b95a3a..4fd81baf856669fb984a5a0b82a1115e840fc16d 100644 (file)
 /test-sha1-array
 /test-sigchain
 /test-string-list
+/test-submodule-config
 /test-subprocess
 /test-svn-fe
 /test-urlmatch-normalization
index 3c468519b92f9982dd4519ffa0916983cec9e956..b70553308af80bc526158d768c962cb075aec2b2 100644 (file)
@@ -45,5 +45,21 @@ Fixes since v2.5
    stable, which was a no-no.  Apply a workaround to force a
    particular date format.
 
+ * "git clone $URL" in recent releases of Git contains a regression in
+   the code that invents a new repository name incorrectly based on
+   the $URL.  This has been corrected.
+   (merge db2e220 jk/guess-repo-name-regression-fix later to maint).
+
+ * Running tests with the "-x" option to make them verbose had some
+   unpleasant interactions with other features of the test suite.
+   (merge 9b5fe78 jk/test-with-x later to maint).
+
+ * "git pull" in recent releases of Git has a regression in the code
+   that allows custom path to the --upload-pack=<program>.  This has
+   been corrected.
+
+ * pipe() emulation used in Git for Windows looked at a wrong variable
+   when checking for an error from an _open_osfhandle() call.
+
 Also contains typofixes, documentation updates and trivial code
 clean-ups.
index f938768b2a8b7d32ba39cdc7fd9f14f6bc6d9762..09ece6c0027b017e009c5ad6e0edc2caeb962557 100644 (file)
@@ -56,6 +56,34 @@ UI, Workflows & Features
  * A negative !ref entry in multi-value transfer.hideRefs
    configuration can be used to say "don't hide this one".
 
+ * After "git am" without "-3" stops, running "git am -" pays attention
+   to "-3" only for the patch that caused the original invocation
+   to stop.
+
+ * When linked worktree is used, simultaneous "notes merge" instances
+   for the same ref in refs/notes/* are prevented from stomping on
+   each other.
+
+ * "git send-email" learned a new option --smtp-auth to limit the SMTP
+   AUTH mechanisms to be used to a subset of what the system library
+   supports.
+
+ * A new configuration variable http.sslVersion can be used to specify
+   what specific version of SSL/TLS to use to make a connection.
+
+ * "git notes merge" can be told with "--strategy=<how>" option how to
+   automatically handle conflicts; this can now be configured by
+   setting notes.mergeStrategy configuration variable.
+
+ * "git log --cc" did not show any patch, even though most of the time
+   the user meant "git log --cc -p -m" to see patch output for commits
+   with a single parent, and combined diff for merge commits.  The
+   command is taught to DWIM "--cc" (without "--raw" and other forms
+   of output specification) to "--cc -p -m".
+
+ * "git config --list" output was hard to parse when values consist of
+   multiple lines.  "--name-only" option is added to help this.
+
 
 Performance, Internal Implementation, Development Support etc.
 
@@ -110,6 +138,16 @@ Performance, Internal Implementation, Development Support etc.
    to misuse, as the callers need to be careful to keep the number of
    active results below 4.  Their uses have been reduced.
 
+ * The "lockfile" API has been rebuilt on top of a new "tempfile" API.
+
+ * To prepare for allowing a different "ref" backend to be plugged in
+   to the system, update_ref()/delete_ref() have been taught about
+   ref-like things like MERGE_HEAD that are per-worktree (they will
+   always be written to the filesystem inside $GIT_DIR).
+
+ * The gitmodules API that is accessed from the C code learned to
+   cache stuff lazily.
+
 
 Also contains various documentation updates and code clean-ups.
 
@@ -212,6 +250,58 @@ notes for details).
    in C.
    (merge 22d6857 mm/pull-upload-pack later to maint).
 
+ * When trying to see that an object does not exist, a state errno
+   leaked from our "first try to open a packfile with O_NOATIME and
+   then if it fails retry without it" logic on a system that refuses
+   O_NOATIME.  This confused us and caused us to die, saying that the
+   packfile is unreadable, when we should have just reported that the
+   object does not exist in that packfile to the caller.
+   (merge dff6f28 cb/open-noatime-clear-errno later to maint).
+
+ * The codepath to produce error messages had a hard-coded limit to
+   the size of the message, primarily to avoid memory allocation while
+   calling die().
+   (merge f4c3edc jk/long-error-messages later to maint).
+
+ * strbuf_read() used to have one extra iteration (and an unnecessary
+   strbuf_grow() of 8kB), which was eliminated.
+   (merge 3ebbd00 jh/strbuf-read-use-read-in-full later to maint).
+
+ * We rewrote one of the build scripts in Perl but this reimplements
+   in Bourne shell.
+   (merge 82aec45 sg/help-group later to maint).
+
+ * The experimental untracked-cache feature were buggy when paths with
+   a few levels of subdirectories are involved.
+   (merge 73f9145 dt/untracked-subdir later to maint).
+
+ * "interpret-trailers" helper mistook a single-liner log message that
+   has a colon as the end of existing trailer.
+   (merge 6262fe9 cc/trailers-corner-case-fix later to maint).
+
+ * "git describe" without argument defaulted to describe the HEAD
+   commit, but "git describe --contains" didn't.  Arguably, in a
+   repository used for active development, such defaulting would not
+   be very useful as the tip of branch is typically not tagged, but it
+   is better to be consistent.
+   (merge 2bd0706 sg/describe-contains later to maint).
+
+ * The client side codepaths in "git push" have been cleaned up
+   and the user can request to perform an optional "signed push",
+   i.e. sign only when the other end accepts signed push.
+   (merge 68c757f db/push-sign-if-asked later to maint).
+
+ * Because the configuration system does not allow "alias.0foo" and
+   "pager.0foo" as the configuration key, the user cannot use '0foo'
+   as a custom command name anyway, but "git 0foo" tried to look these
+   keys up and emitted useless warnings before saying '0foo is not a
+   git command'.  These warning messages have been squelched.
+   (merge 9e9de18 jk/fix-alias-pager-config-key-warnings later to maint).
+
+ * "git rev-list" does not take "--notes" option, but did not complain
+   when one is given.
+   (merge 2aea7a5 jk/rev-list-has-no-notes later to maint).
+
  * Code cleanups and documentation updates.
    (merge 1c601af es/doc-clean-outdated-tools later to maint).
    (merge 3581304 kn/tag-doc-fix later to maint).
@@ -221,3 +311,10 @@ notes for details).
    (merge 4a6ada3 ad/bisect-cleanup later to maint).
    (merge da4c5ad ta/docfix-index-format-tech later to maint).
    (merge ae25fd3 sb/check-return-from-read-ref later to maint).
+   (merge b3325df nd/dwim-wildcards-as-pathspecs later to maint).
+   (merge 7aa9b9b sg/wt-status-header-inclusion later to maint).
+   (merge f04c690 as/docfix-reflog-expire-unreachable later to maint).
+   (merge 1269847 sg/t3020-typofix later to maint).
+   (merge 8b54c23 jc/calloc-pathspec later to maint).
+   (merge a6926b8 po/po-readme later to maint).
+   (merge 54d160e ss/fix-config-fd-leak later to maint).
index 75ec02e8e90a57a54a768677a272975487f664a8..0c351b9bcf77e872e0cca6da2ffc43db136d27a7 100644 (file)
@@ -1329,7 +1329,7 @@ gc.<pattern>.reflogExpire::
        the refs that match the <pattern>.
 
 gc.reflogExpireUnreachable::
-gc.<ref>.reflogExpireUnreachable::
+gc.<pattern>.reflogExpireUnreachable::
        'git reflog expire' removes reflog entries older than
        this time and are not reachable from the current tip;
        defaults to 30 days. The value "now" expires all entries
@@ -1609,6 +1609,29 @@ http.saveCookies::
        If set, store cookies received during requests to the file specified by
        http.cookieFile. Has no effect if http.cookieFile is unset.
 
+http.sslVersion::
+       The SSL version to use when negotiating an SSL connection, if you
+       want to force the default.  The available and default version
+       depend on whether libcurl was built against NSS or OpenSSL and the
+       particular configuration of the crypto library in use. Internally
+       this sets the 'CURLOPT_SSL_VERSION' option; see the libcurl
+       documentation for more details on the format of this option and
+       for the ssl version supported. Actually the possible values of
+       this option are:
+
+       - sslv2
+       - sslv3
+       - tlsv1
+       - tlsv1.0
+       - tlsv1.1
+       - tlsv1.2
+
++
+Can be overridden by the 'GIT_SSL_VERSION' environment variable.
+To force git to use libcurl's default ssl version and ignore any
+explicit http.sslversion option, set 'GIT_SSL_VERSION' to the
+empty string.
+
 http.sslCipherList::
   A list of SSL ciphers to use when negotiating an SSL connection.
   The available ciphers depend on whether libcurl was built against
@@ -1919,6 +1942,18 @@ mergetool.writeToTemp::
 mergetool.prompt::
        Prompt before each invocation of the merge resolution program.
 
+notes.mergeStrategy::
+       Which merge strategy to choose by default when resolving notes
+       conflicts.  Must be one of `manual`, `ours`, `theirs`, `union`, or
+       `cat_sort_uniq`.  Defaults to `manual`.  See "NOTES MERGE STRATEGIES"
+       section of linkgit:git-notes[1] for more information on each strategy.
+
+notes.<name>.mergeStrategy::
+       Which merge strategy to choose when doing a notes merge into
+       refs/notes/<name>.  This overrides the more general
+       "notes.mergeStrategy".  See the "NOTES MERGE STRATEGIES" section in
+       linkgit:git-notes[1] for more information on the available strategies.
+
 notes.displayRef::
        The (fully qualified) refname from which to show notes when
        showing commit messages.  The value of this variable can be set
@@ -1947,8 +1982,8 @@ notes.rewriteMode::
        When copying notes during a rewrite (see the
        "notes.rewrite.<command>" option), determines what to do if
        the target commit already has a note.  Must be one of
-       `overwrite`, `concatenate`, or `ignore`.  Defaults to
-       `concatenate`.
+       `overwrite`, `concatenate`, `cat_sort_uniq`, or `ignore`.
+       Defaults to `concatenate`.
 +
 This setting can be overridden with the `GIT_NOTES_REWRITE_MODE`
 environment variable.
@@ -2178,6 +2213,14 @@ push.followTags::
        may override this configuration at time of push by specifying
        '--no-follow-tags'.
 
+push.gpgSign::
+       May be set to a boolean value, or the string 'if-asked'. A true
+       value causes all pushes to be GPG signed, as if '--signed' is
+       passed to linkgit:git-push[1]. The string 'if-asked' causes
+       pushes to be signed if the server supports it, as if
+       '--signed=if-asked' is passed to 'git push'. A false value may
+       override a value from a lower-priority config file. An explicit
+       command-line flag always overrides this config option.
 
 rebase.stat::
        Whether to show a diffstat of what changed upstream since the last
index 02ec096faac77acace9b36d60e6b1889ac18e85e..2608ca74ac82f7e18531dc0d49a81c84e3155a5c 100644 (file)
@@ -14,13 +14,13 @@ SYNOPSIS
 'git config' [<file-option>] [type] --replace-all name value [value_regex]
 'git config' [<file-option>] [type] [-z|--null] --get name [value_regex]
 'git config' [<file-option>] [type] [-z|--null] --get-all name [value_regex]
-'git config' [<file-option>] [type] [-z|--null] --get-regexp name_regex [value_regex]
+'git config' [<file-option>] [type] [-z|--null] [--name-only] --get-regexp name_regex [value_regex]
 'git config' [<file-option>] [type] [-z|--null] --get-urlmatch name URL
 'git config' [<file-option>] --unset name [value_regex]
 'git config' [<file-option>] --unset-all name [value_regex]
 'git config' [<file-option>] --rename-section old_name new_name
 'git config' [<file-option>] --remove-section name
-'git config' [<file-option>] [-z|--null] -l | --list
+'git config' [<file-option>] [-z|--null] [--name-only] -l | --list
 'git config' [<file-option>] --get-color name [default]
 'git config' [<file-option>] --get-colorbool name [stdout-is-tty]
 'git config' [<file-option>] -e | --edit
@@ -159,7 +159,7 @@ See also <<FILES>>.
 
 -l::
 --list::
-       List all variables set in config file.
+       List all variables set in config file, along with their values.
 
 --bool::
        'git config' will ensure that the output is "true" or "false"
@@ -190,6 +190,10 @@ See also <<FILES>>.
        output without getting confused e.g. by values that
        contain line breaks.
 
+--name-only::
+       Output only the names of config variables for `--list` or
+       `--get-regexp`.
+
 --get-colorbool name [stdout-is-tty]::
 
        Find the color setting for `name` (e.g. `color.diff`) and output
index e045fc73f88ae63a20c18af1b146dc1211a266ec..c8f28c8c864523c948763d7554f49def36156336 100644 (file)
@@ -9,7 +9,7 @@ git-describe - Describe a commit using the most recent tag reachable from it
 SYNOPSIS
 --------
 [verse]
-'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] <commit-ish>...
+'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] [<commit-ish>...]
 'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>]
 
 DESCRIPTION
@@ -27,7 +27,7 @@ see the -a and -s options to linkgit:git-tag[1].
 OPTIONS
 -------
 <commit-ish>...::
-       Commit-ish object names to describe.
+       Commit-ish object names to describe.  Defaults to HEAD if omitted.
 
 --dirty[=<mark>]::
        Describe the working tree.
index 851518d531b53966dc6dca1321c71e8381f50e7b..a9a916f360ec9efb8a801acc982ba39a38f41cf5 100644 (file)
@@ -101,7 +101,7 @@ merge::
        any) into the current notes ref (called "local").
 +
 If conflicts arise and a strategy for automatically resolving
-conflicting notes (see the -s/--strategy option) is not given,
+conflicting notes (see the "NOTES MERGE STRATEGIES" section) is not given,
 the "manual" resolver is used. This resolver checks out the
 conflicting notes in a special worktree (`.git/NOTES_MERGE_WORKTREE`),
 and instructs the user to manually resolve the conflicts there.
@@ -183,6 +183,7 @@ OPTIONS
        When merging notes, resolve notes conflicts using the given
        strategy. The following strategies are recognized: "manual"
        (default), "ours", "theirs", "union" and "cat_sort_uniq".
+       This option overrides the "notes.mergeStrategy" configuration setting.
        See the "NOTES MERGE STRATEGIES" section below for more
        information on each notes merge strategy.
 
@@ -247,6 +248,9 @@ When done, the user can either finalize the merge with
 'git notes merge --commit', or abort the merge with
 'git notes merge --abort'.
 
+Users may select an automated merge strategy from among the following using
+either -s/--strategy option or configuring notes.mergeStrategy accordingly:
+
 "ours" automatically resolves conflicting notes in favor of the local
 version (i.e. the current notes ref).
 
@@ -310,6 +314,20 @@ core.notesRef::
        This setting can be overridden through the environment and
        command line.
 
+notes.mergeStrategy::
+       Which merge strategy to choose by default when resolving notes
+       conflicts.  Must be one of `manual`, `ours`, `theirs`, `union`, or
+       `cat_sort_uniq`.  Defaults to `manual`.  See "NOTES MERGE STRATEGIES"
+       section above for more information on each strategy.
++
+This setting can be overridden by passing the `--strategy` option.
+
+notes.<name>.mergeStrategy::
+       Which merge strategy to choose when doing a notes merge into
+       refs/notes/<name>.  This overrides the more general
+       "notes.mergeStrategy".  See the "NOTES MERGE STRATEGIES" section above
+       for more information on each available strategy.
+
 notes.displayRef::
        Which ref (or refs, if a glob or specified more than once), in
        addition to the default set by `core.notesRef` or
@@ -331,7 +349,8 @@ environment variable.
 notes.rewriteMode::
        When copying notes during a rewrite, what to do if the target
        commit already has a note.  Must be one of `overwrite`,
-       `concatenate`, and `ignore`.  Defaults to `concatenate`.
+       `concatenate`, `cat_sort_uniq`, or `ignore`.  Defaults to
+       `concatenate`.
 +
 This setting can be overridden with the `GIT_NOTES_REWRITE_MODE`
 environment variable.
@@ -368,7 +387,7 @@ does not match any refs is silently ignored.
 'GIT_NOTES_REWRITE_MODE'::
        When copying notes during a rewrite, what to do if the target
        commit already has a note.
-       Must be one of `overwrite`, `concatenate`, and `ignore`.
+       Must be one of `overwrite`, `concatenate`, `cat_sort_uniq`, or `ignore`.
        This overrides the `core.rewriteMode` setting.
 
 'GIT_NOTES_REWRITE_REF'::
index 135d810b7a9b7e36d1cb06ca49c185655a655bee..1495e3416c66331a9d70e4e298e346e099490ae4 100644 (file)
@@ -11,7 +11,8 @@ SYNOPSIS
 [verse]
 'git push' [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
           [--repo=<repository>] [-f | --force] [--prune] [-v | --verbose]
-          [-u | --set-upstream] [--signed]
+          [-u | --set-upstream]
+          [--[no-]signed|--sign=(true|false|if-asked)]
           [--force-with-lease[=<refname>[:<expect>]]]
           [--no-verify] [<repository> [<refspec>...]]
 
@@ -132,12 +133,16 @@ already exists on the remote side.
        with configuration variable 'push.followTags'.  For more
        information, see 'push.followTags' in linkgit:git-config[1].
 
-
---signed::
+--[no-]signed::
+--sign=(true|false|if-asked)::
        GPG-sign the push request to update refs on the receiving
        side, to allow it to be checked by the hooks and/or be
-       logged.  See linkgit:git-receive-pack[1] for the details
-       on the receiving end.
+       logged.  If `false` or `--no-signed`, no signing will be
+       attempted.  If `true` or `--signed`, the push will fail if the
+       server does not support signed pushes.  If set to `if-asked`,
+       sign if and only if the server supports signed pushes.  The push
+       will also fail if the actual call to `gpg --sign` fails.  See
+       linkgit:git-receive-pack[1] for the details on the receiving end.
 
 --[no-]atomic::
        Use an atomic transaction on the remote side if available.
index f14705ee04e491e698e63ab10d15d9ec427b56f4..b9134d234f538c5893fda4440d9ed7283ba8ba9a 100644 (file)
@@ -171,6 +171,19 @@ Sending
        to determine your FQDN automatically.  Default is the value of
        'sendemail.smtpDomain'.
 
+--smtp-auth=<mechanisms>::
+       Whitespace-separated list of allowed SMTP-AUTH mechanisms. This setting
+       forces using only the listed mechanisms. Example:
++
+------
+$ git send-email --smtp-auth="PLAIN LOGIN GSSAPI" ...
+------
++
+If at least one of the specified mechanisms matches the ones advertised by the
+SMTP server and if it is supported by the utilized SASL library, the mechanism
+is used for authentication. If neither 'sendemail.smtpAuth' nor '--smtp-auth'
+is specified, all mechanisms supported by the SASL library can be used.
+
 --smtp-pass[=<password>]::
        Password for SMTP-AUTH. The argument is optional: If no
        argument is specified, then the empty string is used as
index b5d09f79ee686d20b6e99196202546eac1ce2635..6aa91e830cbb033635d8c875e0ea5f8f487c7af4 100644 (file)
@@ -9,7 +9,10 @@ git-send-pack - Push objects over Git protocol to another repository
 SYNOPSIS
 --------
 [verse]
-'git send-pack' [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [--atomic] [<host>:]<directory> [<ref>...]
+'git send-pack' [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>]
+               [--verbose] [--thin] [--atomic]
+               [--[no-]signed|--sign=(true|false|if-asked)]
+               [<host>:]<directory> [<ref>...]
 
 DESCRIPTION
 -----------
@@ -67,6 +70,17 @@ be in a separate packet, and the list must end with a flush packet.
        fails to update then the entire push will fail without changing any
        refs.
 
+--[no-]signed::
+--sign=(true|false|if-asked)::
+       GPG-sign the push request to update refs on the receiving
+       side, to allow it to be checked by the hooks and/or be
+       logged.  If `false` or `--no-signed`, no signing will be
+       attempted.  If `true` or `--signed`, the push will fail if the
+       server does not support signed pushes.  If set to `if-asked`,
+       sign if and only if the server supports signed pushes.  The push
+       will also fail if the actual call to `gpg --sign` fails.  See
+       linkgit:git-receive-pack[1] for the details on the receiving end.
+
 <host>::
        A remote host to house the repository.  When this
        part is specified, 'git-receive-pack' is invoked via
index 11d1e2fc66bb6e92eb0c0f5a85f86fb38eca865a..0c0f60b20e32b11a3547450e79a4bff4f404916b 100644 (file)
@@ -174,6 +174,9 @@ Skip "branches" and "tags" of first level directories;;
        (including automatic fetches due to 'clone', 'dcommit',
        'rebase', etc) on a given repository. '--ignore-paths' takes
        precedence over '--include-paths'.
++
+[verse]
+config key: svn-remote.<name>.include-paths
 
 --log-window-size=<n>;;
        Fetch <n> log entries per request when scanning Subversion history.
index 2795340fb2e793b51f775e79defe52453adcdc9d..4e5d55be6a2b5db801e651b054160b393e148576 100644 (file)
@@ -43,9 +43,10 @@ unreleased) version of Git, that is available from the 'master'
 branch of the `git.git` repository.
 Documentation for older releases are available here:
 
-* link:v2.5.0/git.html[documentation for release 2.5]
+* link:v2.5.1/git.html[documentation for release 2.5.1]
 
 * release notes for
+  link:RelNotes/2.5.1.txt[2.5.1],
   link:RelNotes/2.5.0.txt[2.5].
 
 * link:v2.4.8/git.html[documentation for release 2.4.8]
index 82e2d154359de5dba6694ac7a844b34984e09300..78e0b27c18b73a5b93f39b611191f8d1aaf3d06c 100644 (file)
@@ -448,6 +448,9 @@ set by Git if the remote helper has the 'option' capability.
 'option update-shallow {'true'|'false'}::
        Allow to extend .git/shallow if the new refs require it.
 
+'option pushcert {'true'|'false'}::
+       GPG sign pushes.
+
 SEE ALSO
 --------
 linkgit:git-remote[1]
index dc865cbb2766004089f6bf49bca2638ed6f693d9..671cebd95c36f2dc6e17fb599219e305a567bc55 100644 (file)
@@ -139,7 +139,9 @@ The placeholders are:
 - '%f': sanitized subject line, suitable for a filename
 - '%b': body
 - '%B': raw body (unwrapped subject and body)
+ifndef::git-rev-list[]
 - '%N': commit notes
+endif::git-rev-list[]
 - '%GG': raw verification message from GPG for a signed commit
 - '%G?': show "G" for a Good signature, "B" for a Bad signature, "U" for a good,
   untrusted signature and "N" for no signature
index 642af6e42684602f5465fc3c61d83ca6309b34cb..8d6c5cec4c5edc904a5f2d7595fd8943457f550d 100644 (file)
@@ -42,6 +42,7 @@ people using 80-column terminals.
        verbatim; this means that invalid sequences in the original
        commit may be copied to the output.
 
+ifndef::git-rev-list[]
 --notes[=<ref>]::
        Show the notes (see linkgit:git-notes[1]) that annotate the
        commit, when showing the commit log message.  This is the default
@@ -73,6 +74,7 @@ being displayed. Examples: "--notes=foo" will show only notes from
 --[no-]standard-notes::
        These options are deprecated. Use the above --notes/--no-notes
        options instead.
+endif::git-rev-list[]
 
 --show-signature::
        Check the validity of a signed commit object by passing the signature
index a9b808fab321e8287806c0bca34f1e41af3d41d1..f1c52208f08c3dc9f50e8d18f546a96276a47fec 100644 (file)
@@ -58,9 +58,11 @@ endif::git-rev-list[]
        more than one `--grep=<pattern>`, commits whose message
        matches any of the given patterns are chosen (but see
        `--all-match`).
+ifndef::git-rev-list[]
 +
 When `--show-notes` is in effect, the message from the notes is
 matched as if it were part of the log message.
+endif::git-rev-list[]
 
 --all-match::
        Limit the commits output to ones that match all given `--grep`,
diff --git a/Documentation/technical/api-submodule-config.txt b/Documentation/technical/api-submodule-config.txt
new file mode 100644 (file)
index 0000000..941fa17
--- /dev/null
@@ -0,0 +1,62 @@
+submodule config cache API
+==========================
+
+The submodule config cache API allows to read submodule
+configurations/information from specified revisions. Internally
+information is lazily read into a cache that is used to avoid
+unnecessary parsing of the same .gitmodule files. Lookups can be done by
+submodule path or name.
+
+Usage
+-----
+
+To initialize the cache with configurations from the worktree the caller
+typically first calls `gitmodules_config()` to read values from the
+worktree .gitmodules and then to overlay the local git config values
+`parse_submodule_config_option()` from the config parsing
+infrastructure.
+
+The caller can look up information about submodules by using the
+`submodule_from_path()` or `submodule_from_name()` functions. They return
+a `struct submodule` which contains the values. The API automatically
+initializes and allocates the needed infrastructure on-demand. If the
+caller does only want to lookup values from revisions the initialization
+can be skipped.
+
+If the internal cache might grow too big or when the caller is done with
+the API, all internally cached values can be freed with submodule_free().
+
+Data Structures
+---------------
+
+`struct submodule`::
+
+       This structure is used to return the information about one
+       submodule for a certain revision. It is returned by the lookup
+       functions.
+
+Functions
+---------
+
+`void submodule_free()`::
+
+       Use these to free the internally cached values.
+
+`int parse_submodule_config_option(const char *var, const char *value)`::
+
+       Can be passed to the config parsing infrastructure to parse
+       local (worktree) submodule configurations.
+
+`const struct submodule *submodule_from_path(const unsigned char *commit_sha1, const char *path)`::
+
+       Lookup values for one submodule by its commit_sha1 and path.
+
+`const struct submodule *submodule_from_name(const unsigned char *commit_sha1, const char *name)`::
+
+       The same as above but lookup by name.
+
+If given the null_sha1 as commit_sha1 the local configuration of a
+submodule will be returned (e.g. consolidated values from local git
+configuration and the .gitmodules file in the worktree).
+
+For an example usage see test-submodule-config.c.
index 704f7e7c6ff55baa0172103506450489cf12cfe6..e326fa09c0ac3f1b8700495ea7a1bf007aa170d6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -593,6 +593,7 @@ TEST_PROGRAMS_NEED_X += test-sha1
 TEST_PROGRAMS_NEED_X += test-sha1-array
 TEST_PROGRAMS_NEED_X += test-sigchain
 TEST_PROGRAMS_NEED_X += test-string-list
+TEST_PROGRAMS_NEED_X += test-submodule-config
 TEST_PROGRAMS_NEED_X += test-subprocess
 TEST_PROGRAMS_NEED_X += test-svn-fe
 TEST_PROGRAMS_NEED_X += test-urlmatch-normalization
@@ -784,6 +785,7 @@ LIB_OBJS += strbuf.o
 LIB_OBJS += streaming.o
 LIB_OBJS += string-list.o
 LIB_OBJS += submodule.o
+LIB_OBJS += submodule-config.o
 LIB_OBJS += symlinks.o
 LIB_OBJS += tag.o
 LIB_OBJS += tempfile.o
@@ -1698,10 +1700,10 @@ $(BUILT_INS): git$X
        ln -s $< $@ 2>/dev/null || \
        cp $< $@
 
-common-cmds.h: generate-cmdlist.perl command-list.txt
+common-cmds.h: generate-cmdlist.sh command-list.txt
 
 common-cmds.h: $(wildcard Documentation/git-*.txt)
-       $(QUIET_GEN)$(PERL_PATH) generate-cmdlist.perl command-list.txt > $@+ && mv $@+ $@
+       $(QUIET_GEN)./generate-cmdlist.sh command-list.txt >$@+ && mv $@+ $@
 
 SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\
        $(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\
diff --git a/alias.c b/alias.c
index 6aa164a362427ffa5dc8616bcb01aec3f15b462b..a11229db9e67b7b651356be3fb1d4b3d1014a8bd 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -5,7 +5,8 @@ char *alias_lookup(const char *alias)
        char *v = NULL;
        struct strbuf key = STRBUF_INIT;
        strbuf_addf(&key, "alias.%s", alias);
-       git_config_get_string(key.buf, &v);
+       if (git_config_key_is_valid(key.buf))
+               git_config_get_string(key.buf, &v);
        strbuf_release(&key);
        return v;
 }
index ae3d67f9d310e2e34c6d2c5919eff467b951783f..9db47357b02d4c33fc4e2d1edb8d948b2b3a496f 100644 (file)
@@ -16,7 +16,9 @@ static unsigned int zip_dir_size;
 
 static unsigned int zip_offset;
 static unsigned int zip_dir_offset;
-static unsigned int zip_dir_entries;
+static uint64_t zip_dir_entries;
+
+static unsigned int max_creator_version;
 
 #define ZIP_DIRECTORY_MIN_SIZE (1024 * 1024)
 #define ZIP_STREAM     (1 <<  3)
@@ -86,6 +88,28 @@ struct zip_extra_mtime {
        unsigned char _end[1];
 };
 
+struct zip64_dir_trailer {
+       unsigned char magic[4];
+       unsigned char record_size[8];
+       unsigned char creator_version[2];
+       unsigned char version[2];
+       unsigned char disk[4];
+       unsigned char directory_start_disk[4];
+       unsigned char entries_on_this_disk[8];
+       unsigned char entries[8];
+       unsigned char size[8];
+       unsigned char offset[8];
+       unsigned char _end[1];
+};
+
+struct zip64_dir_trailer_locator {
+       unsigned char magic[4];
+       unsigned char disk[4];
+       unsigned char offset[8];
+       unsigned char number_of_disks[4];
+       unsigned char _end[1];
+};
+
 /*
  * On ARM, padding is added at the end of the struct, so a simple
  * sizeof(struct ...) reports two bytes more than the payload size
@@ -98,6 +122,12 @@ struct zip_extra_mtime {
 #define ZIP_EXTRA_MTIME_SIZE   offsetof(struct zip_extra_mtime, _end)
 #define ZIP_EXTRA_MTIME_PAYLOAD_SIZE \
        (ZIP_EXTRA_MTIME_SIZE - offsetof(struct zip_extra_mtime, flags))
+#define ZIP64_DIR_TRAILER_SIZE offsetof(struct zip64_dir_trailer, _end)
+#define ZIP64_DIR_TRAILER_RECORD_SIZE \
+       (ZIP64_DIR_TRAILER_SIZE - \
+        offsetof(struct zip64_dir_trailer, creator_version))
+#define ZIP64_DIR_TRAILER_LOCATOR_SIZE \
+       offsetof(struct zip64_dir_trailer_locator, _end)
 
 static void copy_le16(unsigned char *dest, unsigned int n)
 {
@@ -113,6 +143,31 @@ static void copy_le32(unsigned char *dest, unsigned int n)
        dest[3] = 0xff & (n >> 030);
 }
 
+static void copy_le64(unsigned char *dest, uint64_t n)
+{
+       dest[0] = 0xff & n;
+       dest[1] = 0xff & (n >> 010);
+       dest[2] = 0xff & (n >> 020);
+       dest[3] = 0xff & (n >> 030);
+       dest[4] = 0xff & (n >> 040);
+       dest[5] = 0xff & (n >> 050);
+       dest[6] = 0xff & (n >> 060);
+       dest[7] = 0xff & (n >> 070);
+}
+
+static uint64_t clamp_max(uint64_t n, uint64_t max, int *clamped)
+{
+       if (n <= max)
+               return n;
+       *clamped = 1;
+       return max;
+}
+
+static void copy_le16_clamp(unsigned char *dest, uint64_t n, int *clamped)
+{
+       copy_le16(dest, clamp_max(n, 0xffff, clamped));
+}
+
 static void *zlib_deflate_raw(void *data, unsigned long size,
                              int compression_level,
                              unsigned long *compressed_size)
@@ -223,6 +278,7 @@ static int write_zip_entry(struct archiver_args *args,
        unsigned long size;
        int is_binary = -1;
        const char *path_without_prefix = path + args->baselen;
+       unsigned int creator_version = 0;
 
        crc = crc32(0, NULL, 0);
 
@@ -251,6 +307,8 @@ static int write_zip_entry(struct archiver_args *args,
                method = 0;
                attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :
                        (mode & 0111) ? ((mode) << 16) : 0;
+               if (S_ISLNK(mode) || (mode & 0111))
+                       creator_version = 0x0317;
                if (S_ISREG(mode) && args->compression_level != 0 && size > 0)
                        method = 8;
 
@@ -279,6 +337,9 @@ static int write_zip_entry(struct archiver_args *args,
                                sha1_to_hex(sha1));
        }
 
+       if (creator_version > max_creator_version)
+               max_creator_version = creator_version;
+
        if (buffer && method == 8) {
                out = deflated = zlib_deflate_raw(buffer, size,
                                                  args->compression_level,
@@ -303,8 +364,7 @@ static int write_zip_entry(struct archiver_args *args,
        }
 
        copy_le32(dirent.magic, 0x02014b50);
-       copy_le16(dirent.creator_version,
-               S_ISLNK(mode) || (S_ISREG(mode) && (mode & 0111)) ? 0x0317 : 0);
+       copy_le16(dirent.creator_version, creator_version);
        copy_le16(dirent.version, 10);
        copy_le16(dirent.flags, flags);
        copy_le16(dirent.compression_method, method);
@@ -437,20 +497,49 @@ static int write_zip_entry(struct archiver_args *args,
        return 0;
 }
 
+static void write_zip64_trailer(void)
+{
+       struct zip64_dir_trailer trailer64;
+       struct zip64_dir_trailer_locator locator64;
+
+       copy_le32(trailer64.magic, 0x06064b50);
+       copy_le64(trailer64.record_size, ZIP64_DIR_TRAILER_RECORD_SIZE);
+       copy_le16(trailer64.creator_version, max_creator_version);
+       copy_le16(trailer64.version, 45);
+       copy_le32(trailer64.disk, 0);
+       copy_le32(trailer64.directory_start_disk, 0);
+       copy_le64(trailer64.entries_on_this_disk, zip_dir_entries);
+       copy_le64(trailer64.entries, zip_dir_entries);
+       copy_le64(trailer64.size, zip_dir_offset);
+       copy_le64(trailer64.offset, zip_offset);
+
+       copy_le32(locator64.magic, 0x07064b50);
+       copy_le32(locator64.disk, 0);
+       copy_le64(locator64.offset, zip_offset + zip_dir_offset);
+       copy_le32(locator64.number_of_disks, 1);
+
+       write_or_die(1, &trailer64, ZIP64_DIR_TRAILER_SIZE);
+       write_or_die(1, &locator64, ZIP64_DIR_TRAILER_LOCATOR_SIZE);
+}
+
 static void write_zip_trailer(const unsigned char *sha1)
 {
        struct zip_dir_trailer trailer;
+       int clamped = 0;
 
        copy_le32(trailer.magic, 0x06054b50);
        copy_le16(trailer.disk, 0);
        copy_le16(trailer.directory_start_disk, 0);
-       copy_le16(trailer.entries_on_this_disk, zip_dir_entries);
-       copy_le16(trailer.entries, zip_dir_entries);
+       copy_le16_clamp(trailer.entries_on_this_disk, zip_dir_entries,
+                       &clamped);
+       copy_le16_clamp(trailer.entries, zip_dir_entries, &clamped);
        copy_le32(trailer.size, zip_dir_offset);
        copy_le32(trailer.offset, zip_offset);
        copy_le16(trailer.comment_length, sha1 ? GIT_SHA1_HEXSZ : 0);
 
        write_or_die(1, zip_dir, zip_dir_offset);
+       if (clamped)
+               write_zip64_trailer();
        write_or_die(1, &trailer, ZIP_DIR_TRAILER_SIZE);
        if (sha1)
                write_or_die(1, sha1_to_hex(sha1), GIT_SHA1_HEXSZ);
index b9c62e3de37bbb76e80a21a6e5e5760e1ba04360..27165a6730ef04da2b4c22ee03eccadfa2e517b6 100644 (file)
@@ -194,6 +194,27 @@ static inline const char *am_path(const struct am_state *state, const char *path
        return mkpath("%s/%s", state->dir, path);
 }
 
+/**
+ * For convenience to call write_file()
+ */
+static int write_state_text(const struct am_state *state,
+                           const char *name, const char *string)
+{
+       return write_file(am_path(state, name), "%s", string);
+}
+
+static int write_state_count(const struct am_state *state,
+                            const char *name, int value)
+{
+       return write_file(am_path(state, name), "%d", value);
+}
+
+static int write_state_bool(const struct am_state *state,
+                           const char *name, int value)
+{
+       return write_state_text(state, name, value ? "t" : "f");
+}
+
 /**
  * If state->quiet is false, calls fprintf(fp, fmt, ...), and appends a newline
  * at the end.
@@ -363,7 +384,7 @@ static void write_author_script(const struct am_state *state)
        sq_quote_buf(&sb, state->author_date);
        strbuf_addch(&sb, '\n');
 
-       write_file(am_path(state, "author-script"), 1, "%s", sb.buf);
+       write_state_text(state, "author-script", sb.buf);
 
        strbuf_release(&sb);
 }
@@ -1001,13 +1022,10 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
        if (state->rebasing)
                state->threeway = 1;
 
-       write_file(am_path(state, "threeway"), 1, state->threeway ? "t" : "f");
-
-       write_file(am_path(state, "quiet"), 1, state->quiet ? "t" : "f");
-
-       write_file(am_path(state, "sign"), 1, state->signoff ? "t" : "f");
-
-       write_file(am_path(state, "utf8"), 1, state->utf8 ? "t" : "f");
+       write_state_bool(state, "threeway", state->threeway);
+       write_state_bool(state, "quiet", state->quiet);
+       write_state_bool(state, "sign", state->signoff);
+       write_state_bool(state, "utf8", state->utf8);
 
        switch (state->keep) {
        case KEEP_FALSE:
@@ -1023,9 +1041,8 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
                die("BUG: invalid value for state->keep");
        }
 
-       write_file(am_path(state, "keep"), 1, "%s", str);
-
-       write_file(am_path(state, "messageid"), 1, state->message_id ? "t" : "f");
+       write_state_text(state, "keep", str);
+       write_state_bool(state, "messageid", state->message_id);
 
        switch (state->scissors) {
        case SCISSORS_UNSET:
@@ -1040,24 +1057,23 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
        default:
                die("BUG: invalid value for state->scissors");
        }
-
-       write_file(am_path(state, "scissors"), 1, "%s", str);
+       write_state_text(state, "scissors", str);
 
        sq_quote_argv(&sb, state->git_apply_opts.argv, 0);
-       write_file(am_path(state, "apply-opt"), 1, "%s", sb.buf);
+       write_state_text(state, "apply-opt", sb.buf);
 
        if (state->rebasing)
-               write_file(am_path(state, "rebasing"), 1, "%s", "");
+               write_state_text(state, "rebasing", "");
        else
-               write_file(am_path(state, "applying"), 1, "%s", "");
+               write_state_text(state, "applying", "");
 
        if (!get_sha1("HEAD", curr_head)) {
-               write_file(am_path(state, "abort-safety"), 1, "%s", sha1_to_hex(curr_head));
+               write_state_text(state, "abort-safety", sha1_to_hex(curr_head));
                if (!state->rebasing)
                        update_ref("am", "ORIG_HEAD", curr_head, NULL, 0,
                                        UPDATE_REFS_DIE_ON_ERR);
        } else {
-               write_file(am_path(state, "abort-safety"), 1, "%s", "");
+               write_state_text(state, "abort-safety", "");
                if (!state->rebasing)
                        delete_ref("ORIG_HEAD", NULL, 0);
        }
@@ -1067,9 +1083,8 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
         * session is in progress, they should be written last.
         */
 
-       write_file(am_path(state, "next"), 1, "%d", state->cur);
-
-       write_file(am_path(state, "last"), 1, "%d", state->last);
+       write_state_count(state, "next", state->cur);
+       write_state_count(state, "last", state->last);
 
        strbuf_release(&sb);
 }
@@ -1102,12 +1117,12 @@ static void am_next(struct am_state *state)
        unlink(am_path(state, "original-commit"));
 
        if (!get_sha1("HEAD", head))
-               write_file(am_path(state, "abort-safety"), 1, "%s", sha1_to_hex(head));
+               write_state_text(state, "abort-safety", sha1_to_hex(head));
        else
-               write_file(am_path(state, "abort-safety"), 1, "%s", "");
+               write_state_text(state, "abort-safety", "");
 
        state->cur++;
-       write_file(am_path(state, "next"), 1, "%d", state->cur);
+       write_state_count(state, "next", state->cur);
 }
 
 /**
@@ -1480,8 +1495,7 @@ static int parse_mail_rebase(struct am_state *state, const char *mail)
        write_commit_patch(state, commit);
 
        hashcpy(state->orig_commit, commit_sha1);
-       write_file(am_path(state, "original-commit"), 1, "%s",
-                       sha1_to_hex(commit_sha1));
+       write_state_text(state, "original-commit", sha1_to_hex(commit_sha1));
 
        return 0;
 }
@@ -1783,7 +1797,7 @@ static void am_run(struct am_state *state, int resume)
        refresh_and_write_cache();
 
        if (index_has_changes(&sb)) {
-               write_file(am_path(state, "dirtyindex"), 1, "t");
+               write_state_bool(state, "dirtyindex", 1);
                die(_("Dirty index: cannot apply patches (dirty: %s)"), sb.buf);
        }
 
@@ -1962,16 +1976,49 @@ static int fast_forward_to(struct tree *head, struct tree *remote, int reset)
        return 0;
 }
 
+/**
+ * Merges a tree into the index. The index's stat info will take precedence
+ * over the merged tree's. Returns 0 on success, -1 on failure.
+ */
+static int merge_tree(struct tree *tree)
+{
+       struct lock_file *lock_file;
+       struct unpack_trees_options opts;
+       struct tree_desc t[1];
+
+       if (parse_tree(tree))
+               return -1;
+
+       lock_file = xcalloc(1, sizeof(struct lock_file));
+       hold_locked_index(lock_file, 1);
+
+       memset(&opts, 0, sizeof(opts));
+       opts.head_idx = 1;
+       opts.src_index = &the_index;
+       opts.dst_index = &the_index;
+       opts.merge = 1;
+       opts.fn = oneway_merge;
+       init_tree_desc(&t[0], tree->buffer, tree->size);
+
+       if (unpack_trees(1, t, &opts)) {
+               rollback_lock_file(lock_file);
+               return -1;
+       }
+
+       if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))
+               die(_("unable to write new index file"));
+
+       return 0;
+}
+
 /**
  * Clean the index without touching entries that are not modified between
  * `head` and `remote`.
  */
 static int clean_index(const unsigned char *head, const unsigned char *remote)
 {
-       struct lock_file *lock_file;
        struct tree *head_tree, *remote_tree, *index_tree;
        unsigned char index[GIT_SHA1_RAWSZ];
-       struct pathspec pathspec;
 
        head_tree = parse_tree_indirect(head);
        if (!head_tree)
@@ -1996,18 +2043,8 @@ static int clean_index(const unsigned char *head, const unsigned char *remote)
        if (fast_forward_to(index_tree, remote_tree, 0))
                return -1;
 
-       memset(&pathspec, 0, sizeof(pathspec));
-
-       lock_file = xcalloc(1, sizeof(struct lock_file));
-       hold_locked_index(lock_file, 1);
-
-       if (read_tree(remote_tree, 0, &pathspec)) {
-               rollback_lock_file(lock_file);
+       if (merge_tree(remote_tree))
                return -1;
-       }
-
-       if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))
-               die(_("unable to write new index file"));
 
        remove_branch_state();
 
@@ -2168,7 +2205,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
                OPT_BOOL('i', "interactive", &state.interactive,
                        N_("run interactively")),
                OPT_HIDDEN_BOOL('b', "binary", &binary,
-                       N_("(historical option -- no-op")),
+                       N_("historical option -- no-op")),
                OPT_BOOL('3', "3way", &state.threeway,
                        N_("allow fall back on 3way merging if needed")),
                OPT__QUIET(&state.quiet, N_("be quiet")),
index 58aa84f1e85212772d15175679e95263eae75123..ff05869949b7c5c4cd0034e7a0ba54e2adeae6b4 100644 (file)
@@ -776,7 +776,7 @@ static int edit_branch_description(const char *branch_name)
                    "  %s\n"
                    "Lines starting with '%c' will be stripped.\n",
                    branch_name, comment_line_char);
-       if (write_file(git_path(edit_description), 0, "%s", buf.buf)) {
+       if (write_file_gently(git_path(edit_description), "%s", buf.buf)) {
                strbuf_release(&buf);
                return error(_("could not write branch description template: %s"),
                             strerror(errno));
index e1403bec272c332160e0346782436167fa016d93..bc703c0f5ed9644b2380ed1f2e20b47238c80e5a 100644 (file)
@@ -18,6 +18,7 @@
 #include "xdiff-interface.h"
 #include "ll-merge.h"
 #include "resolve-undo.h"
+#include "submodule-config.h"
 #include "submodule.h"
 
 static const char * const checkout_usage[] = {
@@ -280,7 +281,7 @@ static int checkout_paths(const struct checkout_opts *opts,
        if (opts->source_tree)
                read_tree_some(opts->source_tree, &opts->pathspec);
 
-       ps_matched = xcalloc(1, opts->pathspec.nr);
+       ps_matched = xcalloc(opts->pathspec.nr, 1);
 
        /*
         * Make sure all pathspecs participated in locating the paths
index 7188405f7ef587d7b09b1cf2c6e422c8385ed794..71acc4414352e8d097447993937db96a1cc6efaa 100644 (file)
@@ -13,6 +13,7 @@ static char *key;
 static regex_t *key_regexp;
 static regex_t *regexp;
 static int show_keys;
+static int omit_values;
 static int use_key_regexp;
 static int do_all;
 static int do_not_match;
@@ -78,6 +79,7 @@ static struct option builtin_config_options[] = {
        OPT_BIT(0, "path", &types, N_("value is a path (file or directory name)"), TYPE_PATH),
        OPT_GROUP(N_("Other")),
        OPT_BOOL('z', "null", &end_null, N_("terminate values with NUL byte")),
+       OPT_BOOL(0, "name-only", &omit_values, N_("show variable names only")),
        OPT_BOOL(0, "includes", &respect_includes, N_("respect include directives on lookup")),
        OPT_END(),
 };
@@ -91,7 +93,7 @@ static void check_argc(int argc, int min, int max) {
 
 static int show_all_config(const char *key_, const char *value_, void *cb)
 {
-       if (value_)
+       if (!omit_values && value_)
                printf("%s%c%s%c", key_, delim, value_, term);
        else
                printf("%s%c", key_, term);
@@ -106,48 +108,40 @@ struct strbuf_list {
 
 static int format_config(struct strbuf *buf, const char *key_, const char *value_)
 {
-       int must_free_vptr = 0;
-       int must_print_delim = 0;
-       char value[256];
-       const char *vptr = value;
-
-       strbuf_init(buf, 0);
-
-       if (show_keys) {
+       if (show_keys)
                strbuf_addstr(buf, key_);
-               must_print_delim = 1;
-       }
-       if (types == TYPE_INT)
-               sprintf(value, "%"PRId64,
-                       git_config_int64(key_, value_ ? value_ : ""));
-       else if (types == TYPE_BOOL)
-               vptr = git_config_bool(key_, value_) ? "true" : "false";
-       else if (types == TYPE_BOOL_OR_INT) {
-               int is_bool, v;
-               v = git_config_bool_or_int(key_, value_, &is_bool);
-               if (is_bool)
-                       vptr = v ? "true" : "false";
-               else
-                       sprintf(value, "%d", v);
-       } else if (types == TYPE_PATH) {
-               if (git_config_pathname(&vptr, key_, value_) < 0)
-                       return -1;
-               must_free_vptr = 1;
-       } else if (value_) {
-               vptr = value_;
-       } else {
-               /* Just show the key name */
-               vptr = "";
-               must_print_delim = 0;
-       }
+       if (!omit_values) {
+               if (show_keys)
+                       strbuf_addch(buf, key_delim);
 
-       if (must_print_delim)
-               strbuf_addch(buf, key_delim);
-       strbuf_addstr(buf, vptr);
+               if (types == TYPE_INT)
+                       strbuf_addf(buf, "%"PRId64,
+                                   git_config_int64(key_, value_ ? value_ : ""));
+               else if (types == TYPE_BOOL)
+                       strbuf_addstr(buf, git_config_bool(key_, value_) ?
+                                     "true" : "false");
+               else if (types == TYPE_BOOL_OR_INT) {
+                       int is_bool, v;
+                       v = git_config_bool_or_int(key_, value_, &is_bool);
+                       if (is_bool)
+                               strbuf_addstr(buf, v ? "true" : "false");
+                       else
+                               strbuf_addf(buf, "%d", v);
+               } else if (types == TYPE_PATH) {
+                       const char *v;
+                       if (git_config_pathname(&v, key_, value_) < 0)
+                               return -1;
+                       strbuf_addstr(buf, v);
+                       free((char *)v);
+               } else if (value_) {
+                       strbuf_addstr(buf, value_);
+               } else {
+                       /* Just show the key name; back out delimiter */
+                       if (show_keys)
+                               strbuf_setlen(buf, buf->len - 1);
+               }
+       }
        strbuf_addch(buf, term);
-
-       if (must_free_vptr)
-               free((char *)vptr);
        return 0;
 }
 
@@ -164,6 +158,7 @@ static int collect_config(const char *key_, const char *value_, void *cb)
                return 0;
 
        ALLOC_GROW(values->items, values->nr + 1, values->alloc);
+       strbuf_init(&values->items[values->nr], 0);
 
        return format_config(&values->items[values->nr++], key_, value_);
 }
@@ -430,14 +425,11 @@ static int get_urlmatch(const char *var, const char *url)
 
        for_each_string_list_item(item, &values) {
                struct urlmatch_current_candidate_value *matched = item->util;
-               struct strbuf key = STRBUF_INIT;
                struct strbuf buf = STRBUF_INIT;
 
-               strbuf_addstr(&key, item->string);
-               format_config(&buf, key.buf,
+               format_config(&buf, item->string,
                              matched->value_is_null ? NULL : matched->value.buf);
                fwrite(buf.buf, 1, buf.len, stdout);
-               strbuf_release(&key);
                strbuf_release(&buf);
 
                strbuf_release(&matched->value);
@@ -549,7 +541,11 @@ int cmd_config(int argc, const char **argv, const char *prefix)
                default:
                        usage_with_options(builtin_config_usage, builtin_config_options);
                }
-
+       if (omit_values &&
+           !(actions == ACTION_LIST || actions == ACTION_GET_REGEXP)) {
+               error("--name-only is only applicable to --list or --get-regexp");
+               usage_with_options(builtin_config_usage, builtin_config_options);
+       }
        if (actions == ACTION_LIST) {
                check_argc(argc, 0, 0);
                if (git_config_with_options(show_all_config, NULL,
index a36c829e571e155c6b6b35c05ee2ef39ce37f406..7df554326b08581c49f391d061be14cd1164ea88 100644 (file)
@@ -443,10 +443,10 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
                        if (pattern)
                                argv_array_pushf(&args, "--refs=refs/tags/%s", pattern);
                }
-               while (*argv) {
-                       argv_array_push(&args, *argv);
-                       argv++;
-               }
+               if (argc)
+                       argv_array_pushv(&args, argv);
+               else
+                       argv_array_push(&args, "HEAD");
                return cmd_name_rev(args.argc, args.argv, prefix);
        }
 
index d3a08545ad66b518a88ff94d21af4234391a986f..9a3869f4ffd81f84f738e54c6405aaedb2514f18 100644 (file)
@@ -11,6 +11,7 @@
 #include "run-command.h"
 #include "parse-options.h"
 #include "sigchain.h"
+#include "submodule-config.h"
 #include "submodule.h"
 #include "connected.h"
 #include "argv-array.h"
index 49df78d2624d58a29173e4e3a881af0b0e37b7c5..69323e186cda73fe02658a535d8eae8387ff5444 100644 (file)
@@ -378,7 +378,7 @@ static void separate_git_dir(const char *git_dir)
                        die_errno(_("unable to move %s to %s"), src, git_dir);
        }
 
-       write_file(git_link, 1, "gitdir: %s\n", git_dir);
+       write_file(git_link, "gitdir: %s", git_dir);
 }
 
 int init_db(const char *template_dir, unsigned int flags)
index b50ef7510c721ed4f6c53b619aa60ccf3d3470a9..a491d3dea0e412624e7212060658e22a421cdfbf 100644 (file)
@@ -342,8 +342,7 @@ static int cmd_log_walk(struct rev_info *rev)
         * retain that state information if replacing rev->diffopt in this loop
         */
        while ((commit = get_revision(rev)) != NULL) {
-               if (!log_tree_commit(rev, commit) &&
-                   rev->max_count >= 0)
+               if (!log_tree_commit(rev, commit) && rev->max_count >= 0)
                        /*
                         * We decremented max_count in get_revision,
                         * but we didn't actually show the commit.
@@ -504,7 +503,8 @@ static int show_tree_object(const unsigned char *sha1,
        return 0;
 }
 
-static void show_rev_tweak_rev(struct rev_info *rev, struct setup_revision_opt *opt)
+static void show_setup_revisions_tweak(struct rev_info *rev,
+                                      struct setup_revision_opt *opt)
 {
        if (rev->ignore_merges) {
                /* There was no "-m" on the command line */
@@ -539,7 +539,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
 
        memset(&opt, 0, sizeof(opt));
        opt.def = "HEAD";
-       opt.tweak = show_rev_tweak_rev;
+       opt.tweak = show_setup_revisions_tweak;
        cmd_log_init(argc, argv, prefix, &rev, &opt);
 
        if (!rev.no_walk)
@@ -626,12 +626,20 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
        return cmd_log_walk(&rev);
 }
 
-static void default_follow_tweak(struct rev_info *rev,
-                                struct setup_revision_opt *opt)
+static void log_setup_revisions_tweak(struct rev_info *rev,
+                                     struct setup_revision_opt *opt)
 {
        if (DIFF_OPT_TST(&rev->diffopt, DEFAULT_FOLLOW_RENAMES) &&
            rev->prune_data.nr == 1)
                DIFF_OPT_SET(&rev->diffopt, FOLLOW_RENAMES);
+
+       /* Turn --cc/-c into -p --cc/-c when -p was not given */
+       if (!rev->diffopt.output_format && rev->combine_merges)
+               rev->diffopt.output_format = DIFF_FORMAT_PATCH;
+
+       /* Turn -m on when --cc/-c was given */
+       if (rev->combine_merges)
+               rev->ignore_merges = 0;
 }
 
 int cmd_log(int argc, const char **argv, const char *prefix)
@@ -647,7 +655,7 @@ int cmd_log(int argc, const char **argv, const char *prefix)
        memset(&opt, 0, sizeof(opt));
        opt.def = "HEAD";
        opt.revarg_opt = REVARG_COMMITTISH;
-       opt.tweak = default_follow_tweak;
+       opt.tweak = log_setup_revisions_tweak;
        cmd_log_init(argc, argv, prefix, &rev, &opt);
        return cmd_log_walk(&rev);
 }
@@ -1455,8 +1463,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                        continue;
                }
 
-               if (ignore_if_in_upstream &&
-                               has_commit_patch_id(commit, &ids))
+               if (ignore_if_in_upstream && has_commit_patch_id(commit, &ids))
                        continue;
 
                nr++;
index 6fa2205734e435c9db787193dcf8c0392d9d2a24..b6a7cb0c7c48293c6348806cb342a9289f146740 100644 (file)
@@ -516,7 +516,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
 
        /* Treat unmatching pathspec elements as errors */
        if (pathspec.nr && error_unmatch)
-               ps_matched = xcalloc(1, pathspec.nr);
+               ps_matched = xcalloc(pathspec.nr, 1);
 
        if ((dir.flags & DIR_SHOW_IGNORED) && !exc_given)
                die("ls-files --ignored needs some exclude pattern");
index 04234808270908ecc5a8b6e015749ceaa29bb081..3608c64785283ffe7cec6df425618a279d1616c5 100644 (file)
@@ -738,6 +738,19 @@ static int merge_commit(struct notes_merge_options *o)
        return ret;
 }
 
+static int git_config_get_notes_strategy(const char *key,
+                                        enum notes_merge_strategy *strategy)
+{
+       const char *value;
+
+       if (git_config_get_string_const(key, &value))
+               return 1;
+       if (parse_notes_merge_strategy(value, strategy))
+               git_die_config(key, "unknown notes merge strategy %s", value);
+
+       return 0;
+}
+
 static int merge(int argc, const char **argv, const char *prefix)
 {
        struct strbuf remote_ref = STRBUF_INIT, msg = STRBUF_INIT;
@@ -796,24 +809,28 @@ static int merge(int argc, const char **argv, const char *prefix)
        expand_notes_ref(&remote_ref);
        o.remote_ref = remote_ref.buf;
 
+       t = init_notes_check("merge");
+
        if (strategy) {
-               if (!strcmp(strategy, "manual"))
-                       o.strategy = NOTES_MERGE_RESOLVE_MANUAL;
-               else if (!strcmp(strategy, "ours"))
-                       o.strategy = NOTES_MERGE_RESOLVE_OURS;
-               else if (!strcmp(strategy, "theirs"))
-                       o.strategy = NOTES_MERGE_RESOLVE_THEIRS;
-               else if (!strcmp(strategy, "union"))
-                       o.strategy = NOTES_MERGE_RESOLVE_UNION;
-               else if (!strcmp(strategy, "cat_sort_uniq"))
-                       o.strategy = NOTES_MERGE_RESOLVE_CAT_SORT_UNIQ;
-               else {
+               if (parse_notes_merge_strategy(strategy, &o.strategy)) {
                        error("Unknown -s/--strategy: %s", strategy);
                        usage_with_options(git_notes_merge_usage, options);
                }
-       }
+       } else {
+               struct strbuf merge_key = STRBUF_INIT;
+               const char *short_ref = NULL;
 
-       t = init_notes_check("merge");
+               if (!skip_prefix(o.local_ref, "refs/notes/", &short_ref))
+                       die("BUG: local ref %s is outside of refs/notes/",
+                           o.local_ref);
+
+               strbuf_addf(&merge_key, "notes.%s.mergeStrategy", short_ref);
+
+               if (git_config_get_notes_strategy(merge_key.buf, &o.strategy))
+                       git_config_get_notes_strategy("notes.mergeStrategy", &o.strategy);
+
+               strbuf_release(&merge_key);
+       }
 
        strbuf_addf(&msg, "notes: Merged notes from %s into %s",
                    remote_ref.buf, default_notes_ref());
index 62cc16ddc24320273bba4732c4402e8f6221ab95..1c63f8f28c7d925ee5647f190d236e64fc6e05a2 100644 (file)
@@ -25,8 +25,8 @@
 #include "argv-array.h"
 
 static const char *pack_usage[] = {
-       N_("git pack-objects --stdout [options...] [< ref-list | < object-list]"),
-       N_("git pack-objects [options...] base-name [< ref-list | < object-list]"),
+       N_("git pack-objects --stdout [<options>...] [< <ref-list> | < <object-list>]"),
+       N_("git pack-objects [<options>...] <base-name> [< <ref-list> | < <object-list>]"),
        NULL
 };
 
index 57c138bd7bc972bfa337de4c615cbfffb99ecc71..3bda430b6b1cf455986afae537ee8429dae5a001 100644 (file)
@@ -9,6 +9,7 @@
 #include "transport.h"
 #include "parse-options.h"
 #include "submodule.h"
+#include "send-pack.h"
 
 static const char * const push_usage[] = {
        N_("git push [<options>] [<repository> [<refspec>...]]"),
@@ -471,6 +472,24 @@ static int option_parse_recurse_submodules(const struct option *opt,
        return 0;
 }
 
+static void set_push_cert_flags(int *flags, int v)
+{
+       switch (v) {
+       case SEND_PACK_PUSH_CERT_NEVER:
+               *flags &= ~(TRANSPORT_PUSH_CERT_ALWAYS | TRANSPORT_PUSH_CERT_IF_ASKED);
+               break;
+       case SEND_PACK_PUSH_CERT_ALWAYS:
+               *flags |= TRANSPORT_PUSH_CERT_ALWAYS;
+               *flags &= ~TRANSPORT_PUSH_CERT_IF_ASKED;
+               break;
+       case SEND_PACK_PUSH_CERT_IF_ASKED:
+               *flags |= TRANSPORT_PUSH_CERT_IF_ASKED;
+               *flags &= ~TRANSPORT_PUSH_CERT_ALWAYS;
+               break;
+       }
+}
+
+
 static int git_push_config(const char *k, const char *v, void *cb)
 {
        int *flags = cb;
@@ -486,6 +505,23 @@ static int git_push_config(const char *k, const char *v, void *cb)
                else
                        *flags &= ~TRANSPORT_PUSH_FOLLOW_TAGS;
                return 0;
+       } else if (!strcmp(k, "push.gpgsign")) {
+               const char *value;
+               if (!git_config_get_value("push.gpgsign", &value)) {
+                       switch (git_config_maybe_bool("push.gpgsign", value)) {
+                       case 0:
+                               set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_NEVER);
+                               break;
+                       case 1:
+                               set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_ALWAYS);
+                               break;
+                       default:
+                               if (value && !strcasecmp(value, "if-asked"))
+                                       set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_IF_ASKED);
+                               else
+                                       return error("Invalid value for '%s'", k);
+                       }
+               }
        }
 
        return git_default_config(k, v, NULL);
@@ -495,6 +531,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 {
        int flags = 0;
        int tags = 0;
+       int push_cert = -1;
        int rc;
        const char *repo = NULL;        /* default repository */
        struct option options[] = {
@@ -526,7 +563,9 @@ int cmd_push(int argc, const char **argv, const char *prefix)
                OPT_BIT(0, "no-verify", &flags, N_("bypass pre-push hook"), TRANSPORT_PUSH_NO_HOOK),
                OPT_BIT(0, "follow-tags", &flags, N_("push missing but relevant tags"),
                        TRANSPORT_PUSH_FOLLOW_TAGS),
-               OPT_BIT(0, "signed", &flags, N_("GPG sign the push"), TRANSPORT_PUSH_CERT),
+               { OPTION_CALLBACK,
+                 0, "signed", &push_cert, "yes|no|if-asked", N_("GPG sign the push"),
+                 PARSE_OPT_OPTARG, option_parse_push_signed },
                OPT_BIT(0, "atomic", &flags, N_("request atomic transaction on remote side"), TRANSPORT_PUSH_ATOMIC),
                OPT_END()
        };
@@ -534,6 +573,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
        packet_trace_identity("push");
        git_config(git_push_config, &flags);
        argc = parse_options(argc, argv, prefix, options, push_usage, 0);
+       set_push_cert_flags(&flags, push_cert);
 
        if (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))
                die(_("--delete is incompatible with --all, --mirror and --tags"));
index 43b47f72f1deffa8fa5e3fa5ac403d4c4a819355..2379e11069ef223a82580a9451ede8fbdb1eb8d9 100644 (file)
@@ -34,7 +34,7 @@ static int list_tree(unsigned char *sha1)
 }
 
 static const char * const read_tree_usage[] = {
-       N_("git read-tree [[-m [--trivial] [--aggressive] | --reset | --prefix=<prefix>] [-u [--exclude-per-directory=<gitignore>] | -i]] [--no-sparse-checkout] [--index-output=<file>] (--empty | <tree-ish1> [<tree-ish2> [<tree-ish3>]])"),
+       N_("git read-tree [(-m [--trivial] [--aggressive] | --reset | --prefix=<prefix>) [-u [--exclude-per-directory=<gitignore>] | -i]] [--no-sparse-checkout] [--index-output=<file>] (--empty | <tree-ish1> [<tree-ish2> [<tree-ish3>]])"),
        NULL
 };
 
index 7ed0e8501c149312676c0bce6fa52372a11b6fff..f96ca2a27dcb9ac6daa3aa110ff657981296502a 100644 (file)
@@ -429,7 +429,7 @@ static int parse_expire_cfg_value(const char *var, const char *value, unsigned l
        if (!value)
                return config_error_nonbool(var);
        if (parse_expiry_date(value, expire))
-               return error(_("%s' for '%s' is not a valid timestamp"),
+               return error(_("'%s' for '%s' is not a valid timestamp"),
                             value, var);
        return 0;
 }
index c0b4b53652a39049ec06ba69f2dfc50a8c0873f7..d80d1ed35944144aa0aeeeb1b0e08c9efdec6523 100644 (file)
@@ -350,6 +350,9 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
            revs.diff)
                usage(rev_list_usage);
 
+       if (revs.show_notes)
+               die(_("rev-list does not support display of notes"));
+
        save_commit_buffer = (revs.verbose_header ||
                              revs.grep_filter.pattern_list ||
                              revs.grep_filter.header_list);
index 23b2962cb0c1443b202bcab0b73023109e06999c..f6e5d643c193d28b14107bf9a9e4ee7aa36ca933 100644 (file)
 #include "version.h"
 #include "sha1-array.h"
 #include "gpg-interface.h"
+#include "gettext.h"
 
-static const char send_pack_usage[] =
-"git send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [--atomic] [<host>:]<directory> [<ref>...]\n"
-"  --all and explicit <ref> specification are mutually exclusive.";
+static const char * const send_pack_usage[] = {
+       N_("git send-pack [--all | --mirror] [--dry-run] [--force] "
+         "[--receive-pack=<git-receive-pack>] [--verbose] [--thin] [--atomic] "
+         "[<host>:]<directory> [<ref>...]\n"
+         "  --all and explicit <ref> specification are mutually exclusive."),
+       NULL,
+};
 
 static struct send_pack_args args;
 
@@ -92,6 +97,31 @@ static void print_helper_status(struct ref *ref)
        strbuf_release(&buf);
 }
 
+static int send_pack_config(const char *k, const char *v, void *cb)
+{
+       git_gpg_config(k, v, NULL);
+
+       if (!strcmp(k, "push.gpgsign")) {
+               const char *value;
+               if (!git_config_get_value("push.gpgsign", &value)) {
+                       switch (git_config_maybe_bool("push.gpgsign", value)) {
+                       case 0:
+                               args.push_cert = SEND_PACK_PUSH_CERT_NEVER;
+                               break;
+                       case 1:
+                               args.push_cert = SEND_PACK_PUSH_CERT_ALWAYS;
+                               break;
+                       default:
+                               if (value && !strcasecmp(value, "if-asked"))
+                                       args.push_cert = SEND_PACK_PUSH_CERT_IF_ASKED;
+                               else
+                                       return error("Invalid value for '%s'", k);
+                       }
+               }
+       }
+       return 0;
+}
+
 int cmd_send_pack(int argc, const char **argv, const char *prefix)
 {
        int i, nr_refspecs = 0;
@@ -107,116 +137,68 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
        int ret;
        int helper_status = 0;
        int send_all = 0;
+       int verbose = 0;
        const char *receivepack = "git-receive-pack";
+       unsigned dry_run = 0;
+       unsigned send_mirror = 0;
+       unsigned force_update = 0;
+       unsigned quiet = 0;
+       int push_cert = 0;
+       unsigned use_thin_pack = 0;
+       unsigned atomic = 0;
+       unsigned stateless_rpc = 0;
        int flags;
        unsigned int reject_reasons;
        int progress = -1;
        int from_stdin = 0;
        struct push_cas_option cas = {0};
 
-       git_config(git_gpg_config, NULL);
-
-       argv++;
-       for (i = 1; i < argc; i++, argv++) {
-               const char *arg = *argv;
-
-               if (*arg == '-') {
-                       if (starts_with(arg, "--receive-pack=")) {
-                               receivepack = arg + 15;
-                               continue;
-                       }
-                       if (starts_with(arg, "--exec=")) {
-                               receivepack = arg + 7;
-                               continue;
-                       }
-                       if (starts_with(arg, "--remote=")) {
-                               remote_name = arg + 9;
-                               continue;
-                       }
-                       if (!strcmp(arg, "--all")) {
-                               send_all = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "--dry-run")) {
-                               args.dry_run = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "--mirror")) {
-                               args.send_mirror = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "--force")) {
-                               args.force_update = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "--quiet")) {
-                               args.quiet = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "--verbose")) {
-                               args.verbose = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "--signed")) {
-                               args.push_cert = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "--progress")) {
-                               progress = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "--no-progress")) {
-                               progress = 0;
-                               continue;
-                       }
-                       if (!strcmp(arg, "--thin")) {
-                               args.use_thin_pack = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "--atomic")) {
-                               args.atomic = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "--stateless-rpc")) {
-                               args.stateless_rpc = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "--stdin")) {
-                               from_stdin = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "--helper-status")) {
-                               helper_status = 1;
-                               continue;
-                       }
-                       if (!strcmp(arg, "--" CAS_OPT_NAME)) {
-                               if (parse_push_cas_option(&cas, NULL, 0) < 0)
-                                       exit(1);
-                               continue;
-                       }
-                       if (!strcmp(arg, "--no-" CAS_OPT_NAME)) {
-                               if (parse_push_cas_option(&cas, NULL, 1) < 0)
-                                       exit(1);
-                               continue;
-                       }
-                       if (starts_with(arg, "--" CAS_OPT_NAME "=")) {
-                               if (parse_push_cas_option(&cas,
-                                                         strchr(arg, '=') + 1, 0) < 0)
-                                       exit(1);
-                               continue;
-                       }
-                       usage(send_pack_usage);
-               }
-               if (!dest) {
-                       dest = arg;
-                       continue;
-               }
-               refspecs = (const char **) argv;
-               nr_refspecs = argc - i;
-               break;
+       struct option options[] = {
+               OPT__VERBOSITY(&verbose),
+               OPT_STRING(0, "receive-pack", &receivepack, "receive-pack", N_("receive pack program")),
+               OPT_STRING(0, "exec", &receivepack, "receive-pack", N_("receive pack program")),
+               OPT_STRING(0, "remote", &remote_name, "remote", N_("remote name")),
+               OPT_BOOL(0, "all", &send_all, N_("push all refs")),
+               OPT_BOOL('n' , "dry-run", &dry_run, N_("dry run")),
+               OPT_BOOL(0, "mirror", &send_mirror, N_("mirror all refs")),
+               OPT_BOOL('f', "force", &force_update, N_("force updates")),
+               { OPTION_CALLBACK,
+                 0, "signed", &push_cert, "yes|no|if-asked", N_("GPG sign the push"),
+                 PARSE_OPT_OPTARG, option_parse_push_signed },
+               OPT_BOOL(0, "progress", &progress, N_("force progress reporting")),
+               OPT_BOOL(0, "thin", &use_thin_pack, N_("use thin pack")),
+               OPT_BOOL(0, "atomic", &atomic, N_("request atomic transaction on remote side")),
+               OPT_BOOL(0, "stateless-rpc", &stateless_rpc, N_("use stateless RPC protocol")),
+               OPT_BOOL(0, "stdin", &from_stdin, N_("read refs from stdin")),
+               OPT_BOOL(0, "helper-status", &helper_status, N_("print status from remote helper")),
+               { OPTION_CALLBACK,
+                 0, CAS_OPT_NAME, &cas, N_("refname>:<expect"),
+                 N_("require old value of ref to be at this value"),
+                 PARSE_OPT_OPTARG, parseopt_push_cas_option },
+               OPT_END()
+       };
+
+       git_config(send_pack_config, NULL);
+       argc = parse_options(argc, argv, prefix, options, send_pack_usage, 0);
+       if (argc > 0) {
+               dest = argv[0];
+               refspecs = (const char **)(argv + 1);
+               nr_refspecs = argc - 1;
        }
+
        if (!dest)
-               usage(send_pack_usage);
+               usage_with_options(send_pack_usage, options);
+
+       args.verbose = verbose;
+       args.dry_run = dry_run;
+       args.send_mirror = send_mirror;
+       args.force_update = force_update;
+       args.quiet = quiet;
+       args.push_cert = push_cert;
+       args.progress = progress;
+       args.use_thin_pack = use_thin_pack;
+       args.atomic = atomic;
+       args.stateless_rpc = stateless_rpc;
 
        if (from_stdin) {
                struct argv_array all_refspecs = ARGV_ARRAY_INIT;
@@ -245,7 +227,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
         */
        if ((refspecs && (send_all || args.send_mirror)) ||
            (send_all && args.send_mirror))
-               usage(send_pack_usage);
+               usage_with_options(send_pack_usage, options);
 
        if (remote_name) {
                remote = remote_get(remote_name);
index 430b51e7a74bb28ac1532ac836e9770121977096..71bb770f7a4b4b864efcbf4c3983bbd4a645f4e2 100644 (file)
@@ -238,7 +238,7 @@ static int add_worktree(const char *path, const char *refname,
         * after the preparation is over.
         */
        strbuf_addf(&sb, "%s/locked", sb_repo.buf);
-       write_file(sb.buf, 1, "initializing\n");
+       write_file(sb.buf, "initializing");
 
        strbuf_addf(&sb_git, "%s/.git", path);
        if (safe_create_leading_directories_const(sb_git.buf))
@@ -248,8 +248,8 @@ static int add_worktree(const char *path, const char *refname,
 
        strbuf_reset(&sb);
        strbuf_addf(&sb, "%s/gitdir", sb_repo.buf);
-       write_file(sb.buf, 1, "%s\n", real_path(sb_git.buf));
-       write_file(sb_git.buf, 1, "gitdir: %s/worktrees/%s\n",
+       write_file(sb.buf, "%s", real_path(sb_git.buf));
+       write_file(sb_git.buf, "gitdir: %s/worktrees/%s",
                   real_path(get_git_common_dir()), name);
        /*
         * This is to keep resolve_ref() happy. We need a valid HEAD
@@ -260,10 +260,10 @@ static int add_worktree(const char *path, const char *refname,
         */
        strbuf_reset(&sb);
        strbuf_addf(&sb, "%s/HEAD", sb_repo.buf);
-       write_file(sb.buf, 1, "0000000000000000000000000000000000000000\n");
+       write_file(sb.buf, "0000000000000000000000000000000000000000");
        strbuf_reset(&sb);
        strbuf_addf(&sb, "%s/commondir", sb_repo.buf);
-       write_file(sb.buf, 1, "../..\n");
+       write_file(sb.buf, "../..");
 
        fprintf_ln(stderr, _("Preparing %s (identifier %s)"), path, name);
 
diff --git a/cache.h b/cache.h
index 4e25271e596ae0b4929c74907c4eaf9003e8dfc6..79066e57dc806d118366d9807e0af338b72e2fb2 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1429,6 +1429,7 @@ extern int git_config_with_options(config_fn_t fn, void *,
                                   int respect_includes);
 extern int git_config_early(config_fn_t fn, void *, const char *repo_config);
 extern int git_parse_ulong(const char *, unsigned long *);
+extern int git_parse_maybe_bool(const char *);
 extern int git_config_int(const char *, const char *);
 extern int64_t git_config_int64(const char *, const char *);
 extern unsigned long git_config_ulong(const char *, const char *);
@@ -1440,6 +1441,7 @@ extern int git_config_pathname(const char **, const char *, const char *);
 extern int git_config_set_in_file(const char *, const char *, const char *);
 extern int git_config_set(const char *, const char *);
 extern int git_config_parse_key(const char *, char **, int *);
+extern int git_config_key_is_valid(const char *key);
 extern int git_config_set_multivar(const char *, const char *, const char *, int);
 extern int git_config_set_multivar_in_file(const char *, const char *, const char *, const char *, int);
 extern int git_config_rename_section(const char *, const char *);
@@ -1576,8 +1578,9 @@ static inline ssize_t write_str_in_full(int fd, const char *str)
 {
        return write_in_full(fd, str, strlen(str));
 }
-__attribute__((format (printf, 3, 4)))
-extern int write_file(const char *path, int fatal, const char *fmt, ...);
+
+extern int write_file(const char *path, const char *fmt, ...);
+extern int write_file_gently(const char *path, const char *fmt, ...);
 
 /* pager.c */
 extern void setup_pager(void);
index 496e6f8bb0217c40450c61e88fbf1e08fdb3f704..f74da235f598d8b0346fac8b48c4155f55ae5b81 100644 (file)
@@ -681,7 +681,7 @@ int pipe(int filedes[2])
                return -1;
        }
        filedes[1] = _open_osfhandle((int)h[1], O_NOINHERIT);
-       if (filedes[0] < 0) {
+       if (filedes[1] < 0) {
                close(filedes[0]);
                CloseHandle(h[1]);
                return -1;
index a34b850cdc3f6902882c04f925456b4877978729..248a21ab94116fabba95e01a8571a458efa99f76 100644 (file)
--- a/config.c
+++ b/config.c
@@ -618,7 +618,7 @@ unsigned long git_config_ulong(const char *name, const char *value)
        return ret;
 }
 
-static int git_config_maybe_bool_text(const char *name, const char *value)
+int git_parse_maybe_bool(const char *value)
 {
        if (!value)
                return 1;
@@ -637,7 +637,7 @@ static int git_config_maybe_bool_text(const char *name, const char *value)
 
 int git_config_maybe_bool(const char *name, const char *value)
 {
-       int v = git_config_maybe_bool_text(name, value);
+       int v = git_parse_maybe_bool(value);
        if (0 <= v)
                return v;
        if (git_parse_int(value, &v))
@@ -647,7 +647,7 @@ int git_config_maybe_bool(const char *name, const char *value)
 
 int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
 {
-       int v = git_config_maybe_bool_text(name, value);
+       int v = git_parse_maybe_bool(value);
        if (0 <= v) {
                *is_bool = 1;
                return v;
@@ -1848,7 +1848,7 @@ int git_config_set(const char *key, const char *value)
  * baselen - pointer to int which will hold the length of the
  *           section + subsection part, can be NULL
  */
-int git_config_parse_key(const char *key, char **store_key, int *baselen_)
+static int git_config_parse_key_1(const char *key, char **store_key, int *baselen_, int quiet)
 {
        int i, dot, baselen;
        const char *last_dot = strrchr(key, '.');
@@ -1859,12 +1859,14 @@ int git_config_parse_key(const char *key, char **store_key, int *baselen_)
         */
 
        if (last_dot == NULL || last_dot == key) {
-               error("key does not contain a section: %s", key);
+               if (!quiet)
+                       error("key does not contain a section: %s", key);
                return -CONFIG_NO_SECTION_OR_NAME;
        }
 
        if (!last_dot[1]) {
-               error("key does not contain variable name: %s", key);
+               if (!quiet)
+                       error("key does not contain variable name: %s", key);
                return -CONFIG_NO_SECTION_OR_NAME;
        }
 
@@ -1875,7 +1877,8 @@ int git_config_parse_key(const char *key, char **store_key, int *baselen_)
        /*
         * Validate the key and while at it, lower case it for matching.
         */
-       *store_key = xmalloc(strlen(key) + 1);
+       if (store_key)
+               *store_key = xmalloc(strlen(key) + 1);
 
        dot = 0;
        for (i = 0; key[i]; i++) {
@@ -1886,26 +1889,42 @@ int git_config_parse_key(const char *key, char **store_key, int *baselen_)
                if (!dot || i > baselen) {
                        if (!iskeychar(c) ||
                            (i == baselen + 1 && !isalpha(c))) {
-                               error("invalid key: %s", key);
+                               if (!quiet)
+                                       error("invalid key: %s", key);
                                goto out_free_ret_1;
                        }
                        c = tolower(c);
                } else if (c == '\n') {
-                       error("invalid key (newline): %s", key);
+                       if (!quiet)
+                               error("invalid key (newline): %s", key);
                        goto out_free_ret_1;
                }
-               (*store_key)[i] = c;
+               if (store_key)
+                       (*store_key)[i] = c;
        }
-       (*store_key)[i] = 0;
+       if (store_key)
+               (*store_key)[i] = 0;
 
        return 0;
 
 out_free_ret_1:
-       free(*store_key);
-       *store_key = NULL;
+       if (store_key) {
+               free(*store_key);
+               *store_key = NULL;
+       }
        return -CONFIG_INVALID_KEY;
 }
 
+int git_config_parse_key(const char *key, char **store_key, int *baselen)
+{
+       return git_config_parse_key_1(key, store_key, baselen, 0);
+}
+
+int git_config_key_is_valid(const char *key)
+{
+       return !git_config_parse_key_1(key, NULL, NULL, 1);
+}
+
 /*
  * If value==NULL, unset in (remove from) config,
  * if value_regex!=NULL, disregard key/value pairs where value does not match.
@@ -1935,7 +1954,7 @@ int git_config_set_multivar_in_file(const char *config_filename,
                                const char *key, const char *value,
                                const char *value_regex, int multi_replace)
 {
-       int fd = -1, in_fd;
+       int fd = -1, in_fd = -1;
        int ret;
        struct lock_file *lock = NULL;
        char *filename_buf = NULL;
@@ -2065,6 +2084,7 @@ int git_config_set_multivar_in_file(const char *config_filename,
                        goto out_free;
                }
                close(in_fd);
+               in_fd = -1;
 
                if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
                        error("chmod on %s failed: %s",
@@ -2148,6 +2168,8 @@ int git_config_set_multivar_in_file(const char *config_filename,
        free(filename_buf);
        if (contents)
                munmap(contents, contents_sz);
+       if (in_fd >= 0)
+               close(in_fd);
        return ret;
 
 write_err_out:
index 087771bb89d05b0353f6759cfd03da3a953a798b..482ca84b451ba7049b702cac7f737ecf4a65fa05 100644 (file)
@@ -744,9 +744,8 @@ __git_compute_porcelain_commands ()
 __git_get_config_variables ()
 {
        local section="$1" i IFS=$'\n'
-       for i in $(git --git-dir="$(__gitdir)" config --get-regexp "^$section\..*" 2>/dev/null); do
-               i="${i#$section.}"
-               echo "${i/ */}"
+       for i in $(git --git-dir="$(__gitdir)" config --name-only --get-regexp "^$section\..*" 2>/dev/null); do
+               echo "${i#$section.}"
        done
 }
 
@@ -1777,15 +1776,7 @@ __git_config_get_set_variables ()
                c=$((--c))
        done
 
-       git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
-       while read -r line
-       do
-               case "$line" in
-               *.*=*)
-                       echo "${line/=*/}"
-                       ;;
-               esac
-       done
+       git --git-dir="$(__gitdir)" config $config_file --name-only --list 2>/dev/null
 }
 
 _git_config ()
@@ -1890,6 +1881,7 @@ _git_config ()
                        --get --get-all --get-regexp
                        --add --unset --unset-all
                        --remove-section --rename-section
+                       --name-only
                        "
                return
                ;;
@@ -2121,6 +2113,7 @@ _git_config ()
                http.postBuffer
                http.proxy
                http.sslCipherList
+               http.sslVersion
                http.sslCAInfo
                http.sslCAPath
                http.sslCert
index 26c5e9ff61477ae523a63b34dcefbc322212a0a7..e8dc2e0e7d5d8fb37f818a05c3ef4c58f28850da 100755 (executable)
@@ -295,7 +295,7 @@ test true = "$rebase" && {
 }
 orig_head=$(git rev-parse -q --verify HEAD)
 git fetch $verbosity $progress $dry_run $recurse_submodules $all $append \
-${upload_pack+"$upload_pack"} $force $tags $prune $keep $depth $unshallow $update_shallow \
+${upload_pack:+"$upload_pack"} $force $tags $prune $keep $depth $unshallow $update_shallow \
 $refmap --update-head-ok "$@" || exit 1
 test -z "$dry_run" || exit 0
 
index d3d3e433e370e7a21dad829b5861172e92a6d72f..f9eb296888c37c8f2a523f3941be027ddb36df3c 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -1376,7 +1376,7 @@ int main(int argc, char **argv)
                sanitize_stdfds();
 
        if (pid_file)
-               write_file(pid_file, 1, "%"PRIuMAX"\n", (uintmax_t) getpid());
+               write_file(pid_file, "%"PRIuMAX, (uintmax_t) getpid());
 
        /* prepare argv for serving-processes */
        cld_argv = xmalloc(sizeof (char *) * (argc + 2));
diff --git a/diff.c b/diff.c
index 976362a8ce0ae46160d44fd8bbabef4050769dc9..08508f6a2017eb35a350268ea78a44cfc1d867e4 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -14,6 +14,7 @@
 #include "utf8.h"
 #include "userdiff.h"
 #include "sigchain.h"
+#include "submodule-config.h"
 #include "submodule.h"
 #include "ll-merge.h"
 #include "string-list.h"
diff --git a/dir.c b/dir.c
index c00c7e2b73603589ae1e3f49abcd931f4e761850..7b25634832716ade46686d118184c4d43d8c11e7 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -1297,7 +1297,7 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)
  */
 static enum path_treatment treat_directory(struct dir_struct *dir,
        struct untracked_cache_dir *untracked,
-       const char *dirname, int len, int exclude,
+       const char *dirname, int len, int baselen, int exclude,
        const struct path_simplify *simplify)
 {
        /* The "len-1" is to strip the final '/' */
@@ -1324,7 +1324,8 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
        if (!(dir->flags & DIR_HIDE_EMPTY_DIRECTORIES))
                return exclude ? path_excluded : path_untracked;
 
-       untracked = lookup_untracked(dir->untracked, untracked, dirname, len);
+       untracked = lookup_untracked(dir->untracked, untracked,
+                                    dirname + baselen, len - baselen);
        return read_directory_recursive(dir, dirname, len,
                                        untracked, 1, simplify);
 }
@@ -1444,6 +1445,7 @@ static int get_dtype(struct dirent *de, const char *path, int len)
 static enum path_treatment treat_one_path(struct dir_struct *dir,
                                          struct untracked_cache_dir *untracked,
                                          struct strbuf *path,
+                                         int baselen,
                                          const struct path_simplify *simplify,
                                          int dtype, struct dirent *de)
 {
@@ -1495,8 +1497,8 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
                return path_none;
        case DT_DIR:
                strbuf_addch(path, '/');
-               return treat_directory(dir, untracked, path->buf, path->len, exclude,
-                       simplify);
+               return treat_directory(dir, untracked, path->buf, path->len,
+                                      baselen, exclude, simplify);
        case DT_REG:
        case DT_LNK:
                return exclude ? path_excluded : path_untracked;
@@ -1557,7 +1559,7 @@ static enum path_treatment treat_path(struct dir_struct *dir,
                return path_none;
 
        dtype = DTYPE(de);
-       return treat_one_path(dir, untracked, path, simplify, dtype, de);
+       return treat_one_path(dir, untracked, path, baselen, simplify, dtype, de);
 }
 
 static void add_untracked(struct untracked_cache_dir *dir, const char *name)
@@ -1827,7 +1829,7 @@ static int treat_leading_path(struct dir_struct *dir,
                        break;
                if (simplify_away(sb.buf, sb.len, simplify))
                        break;
-               if (treat_one_path(dir, NULL, &sb, simplify,
+               if (treat_one_path(dir, NULL, &sb, baselen, simplify,
                                   DT_DIR, NULL) == path_none)
                        break; /* do not recurse into it */
                if (len <= baselen) {
@@ -2616,23 +2618,67 @@ struct untracked_cache *read_untracked_extension(const void *data, unsigned long
        return uc;
 }
 
+static void invalidate_one_directory(struct untracked_cache *uc,
+                                    struct untracked_cache_dir *ucd)
+{
+       uc->dir_invalidated++;
+       ucd->valid = 0;
+       ucd->untracked_nr = 0;
+}
+
+/*
+ * Normally when an entry is added or removed from a directory,
+ * invalidating that directory is enough. No need to touch its
+ * ancestors. When a directory is shown as "foo/bar/" in git-status
+ * however, deleting or adding an entry may have cascading effect.
+ *
+ * Say the "foo/bar/file" has become untracked, we need to tell the
+ * untracked_cache_dir of "foo" that "bar/" is not an untracked
+ * directory any more (because "bar" is managed by foo as an untracked
+ * "file").
+ *
+ * Similarly, if "foo/bar/file" moves from untracked to tracked and it
+ * was the last untracked entry in the entire "foo", we should show
+ * "foo/" instead. Which means we have to invalidate past "bar" up to
+ * "foo".
+ *
+ * This function traverses all directories from root to leaf. If there
+ * is a chance of one of the above cases happening, we invalidate back
+ * to root. Otherwise we just invalidate the leaf. There may be a more
+ * sophisticated way than checking for SHOW_OTHER_DIRECTORIES to
+ * detect these cases and avoid unnecessary invalidation, for example,
+ * checking for the untracked entry named "bar/" in "foo", but for now
+ * stick to something safe and simple.
+ */
+static int invalidate_one_component(struct untracked_cache *uc,
+                                   struct untracked_cache_dir *dir,
+                                   const char *path, int len)
+{
+       const char *rest = strchr(path, '/');
+
+       if (rest) {
+               int component_len = rest - path;
+               struct untracked_cache_dir *d =
+                       lookup_untracked(uc, dir, path, component_len);
+               int ret =
+                       invalidate_one_component(uc, d, rest + 1,
+                                                len - (component_len + 1));
+               if (ret)
+                       invalidate_one_directory(uc, dir);
+               return ret;
+       }
+
+       invalidate_one_directory(uc, dir);
+       return uc->dir_flags & DIR_SHOW_OTHER_DIRECTORIES;
+}
+
 void untracked_cache_invalidate_path(struct index_state *istate,
                                     const char *path)
 {
-       const char *sep;
-       struct untracked_cache_dir *d;
        if (!istate->untracked || !istate->untracked->root)
                return;
-       sep = strrchr(path, '/');
-       if (sep)
-               d = lookup_untracked(istate->untracked,
-                                    istate->untracked->root,
-                                    path, sep - path);
-       else
-               d = istate->untracked->root;
-       istate->untracked->dir_invalidated++;
-       d->valid = 0;
-       d->untracked_nr = 0;
+       invalidate_one_component(istate->untracked, istate->untracked->root,
+                                path, strlen(path));
 }
 
 void untracked_cache_remove_from_index(struct index_state *istate,
diff --git a/generate-cmdlist.perl b/generate-cmdlist.perl
deleted file mode 100755 (executable)
index 31516e3..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/perl
-use strict;
-use warnings;
-
-print <<"EOT";
-/* Automatically generated by $0 */
-
-struct cmdname_help {
-       char name[16];
-       char help[80];
-       unsigned char group;
-};
-
-static char *common_cmd_groups[] = {
-EOT
-
-my $n = 0;
-my %grp;
-while (<>) {
-       last if /^### command list/;
-       next if (1../^### common groups/) || /^#/ || /^\s*$/;
-       chop;
-       my ($k, $v) = split ' ', $_, 2;
-       $grp{$k} = $n++;
-       print "\tN_(\"$v\"),\n";
-}
-
-print "};\n\nstatic struct cmdname_help common_cmds[] = {\n";
-
-while (<>) {
-       next if /^#/ || /^\s*$/;
-       my @tags = split;
-       my $cmd = shift @tags;
-       for my $t (@tags) {
-               if (exists $grp{$t}) {
-                       my $s;
-                       open my $f, '<', "Documentation/$cmd.txt" or die;
-                       while (<$f>) {
-                               ($s) = /^$cmd - (.+)$/;
-                               last if $s;
-                       }
-                       close $f;
-                       $cmd =~ s/^git-//;
-                       print "\t{\"$cmd\", N_(\"$s\"), $grp{$t}},\n";
-                       last;
-               }
-       }
-}
-
-print "};\n";
diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
new file mode 100755 (executable)
index 0000000..ab0d1b0
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+echo "/* Automatically generated by $0 */
+struct cmdname_help {
+       char name[16];
+       char help[80];
+       unsigned char group;
+};
+
+static const char *common_cmd_groups[] = {"
+
+grps=grps$$.tmp
+match=match$$.tmp
+trap "rm -f '$grps' '$match'" 0 1 2 3 15
+
+sed -n '
+       1,/^### common groups/b
+       /^### command list/q
+       /^#/b
+       /^[     ]*$/b
+       h;s/^[^         ][^     ]*[     ][      ]*\(.*\)/       N_("\1"),/p
+       g;s/^\([^       ][^     ]*\)[   ].*/\1/w '$grps'
+       ' "$1"
+printf '};\n\n'
+
+n=0
+substnum=
+while read grp
+do
+       echo "^git-..*[         ]$grp"
+       substnum="$substnum${substnum:+;}s/[    ]$grp/$n/"
+       n=$(($n+1))
+done <"$grps" >"$match"
+
+printf 'static struct cmdname_help common_cmds[] = {\n'
+grep -f "$match" "$1" |
+sed 's/^git-//' |
+sort |
+while read cmd tags
+do
+       tag=$(echo "$tags" | sed "$substnum; s/[^0-9]//g")
+       sed -n '
+               /^NAME/,/git-'"$cmd"'/H
+               ${
+                       x
+                       s/.*git-'"$cmd"' - \(.*\)/      {"'"$cmd"'", N_("\1"), '$tag'},/
+                       p
+               }' "Documentation/git-$cmd.txt"
+done
+echo "};"
index 073f87bbfdc1dc7ebc3fe610e78709667f597d82..0093fa3d8391b4b56c5613b063996cc6dc5c7b60 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -1950,10 +1950,14 @@ def update_client_spec_path_cache(self, files):
             if "unmap" in res:
                 # it will list all of them, but only one not unmap-ped
                 continue
+            if gitConfigBool("core.ignorecase"):
+                res['depotFile'] = res['depotFile'].lower()
             self.client_spec_path_cache[res['depotFile']] = self.convert_client_path(res["clientFile"])
 
         # not found files or unmap files set to ""
         for depotFile in fileArgs:
+            if gitConfigBool("core.ignorecase"):
+                depotFile = depotFile.lower()
             if depotFile not in self.client_spec_path_cache:
                 self.client_spec_path_cache[depotFile] = ""
 
@@ -1962,6 +1966,9 @@ def map_in_client(self, depot_path):
            depot file should live.  Returns "" if the file should
            not be mapped in the client."""
 
+        if gitConfigBool("core.ignorecase"):
+            depot_path = depot_path.lower()
+
         if depot_path in self.client_spec_path_cache:
             return self.client_spec_path_cache[depot_path]
 
index b660cc238223b101762017c7effda67de6f70113..c5a3f766f7fd34a48b352f3cfbb901840b4c4d5b 100755 (executable)
@@ -75,6 +75,8 @@ sub usage {
                                      Pass an empty string to disable certificate
                                      verification.
     --smtp-domain           <str>  * The domain name sent to HELO/EHLO handshake
+    --smtp-auth             <str>  * Space-separated list of allowed AUTH mechanisms.
+                                     This setting forces to use one of the listed mechanisms.
     --smtp-debug            <0|1>  * Disable, enable Net::SMTP debug.
 
   Automating:
@@ -208,7 +210,7 @@ sub do_edit {
 my ($to_cmd, $cc_cmd);
 my ($smtp_server, $smtp_server_port, @smtp_server_options);
 my ($smtp_authuser, $smtp_encryption, $smtp_ssl_cert_path);
-my ($identity, $aliasfiletype, @alias_files, $smtp_domain);
+my ($identity, $aliasfiletype, @alias_files, $smtp_domain, $smtp_auth);
 my ($validate, $confirm);
 my (@suppress_cc);
 my ($auto_8bit_encoding);
@@ -239,6 +241,7 @@ sub do_edit {
     "smtppass" => \$smtp_authpass,
     "smtpsslcertpath" => \$smtp_ssl_cert_path,
     "smtpdomain" => \$smtp_domain,
+    "smtpauth" => \$smtp_auth,
     "to" => \@initial_to,
     "tocmd" => \$to_cmd,
     "cc" => \@initial_cc,
@@ -310,6 +313,7 @@ sub signal_handler {
                    "smtp-ssl-cert-path=s" => \$smtp_ssl_cert_path,
                    "smtp-debug:i" => \$debug_net_smtp,
                    "smtp-domain:s" => \$smtp_domain,
+                   "smtp-auth=s" => \$smtp_auth,
                    "identity=s" => \$identity,
                    "annotate!" => \$annotate,
                    "no-annotate" => sub {$annotate = 0},
@@ -1130,6 +1134,12 @@ sub smtp_auth_maybe {
                Authen::SASL->import(qw(Perl));
        };
 
+       # Check mechanism naming as defined in:
+       # https://tools.ietf.org/html/rfc4422#page-8
+       if ($smtp_auth !~ /^(\b[A-Z0-9-_]{1,20}\s*)*$/) {
+               die "invalid smtp auth: '${smtp_auth}'";
+       }
+
        # TODO: Authentication may fail not because credentials were
        # invalid but due to other reasons, in which we should not
        # reject credentials.
@@ -1142,6 +1152,20 @@ sub smtp_auth_maybe {
                'password' => $smtp_authpass
        }, sub {
                my $cred = shift;
+
+               if ($smtp_auth) {
+                       my $sasl = Authen::SASL->new(
+                               mechanism => $smtp_auth,
+                               callback => {
+                                       user => $cred->{'username'},
+                                       pass => $cred->{'password'},
+                                       authname => $cred->{'username'},
+                               }
+                       );
+
+                       return !!$smtp->auth($sasl);
+               }
+
                return !!$smtp->auth($cred->{'username'}, $cred->{'password'});
        });
 
index 36797c3c00f4890cfb6f176f298e050da7eb5a34..25b1ddf2520800af4f78f1b7b72be2e271dfd8e2 100755 (executable)
@@ -904,7 +904,7 @@ Maybe you want to use 'update --init'?")"
                                ;;
                        !*)
                                command="${update_module#!}"
-                               die_msg="$(eval_gettext "Execution of '\$command \$sha1' failed in submodule  path '\$prefix\$sm_path'")"
+                               die_msg="$(eval_gettext "Execution of '\$command \$sha1' failed in submodule path '\$prefix\$sm_path'")"
                                say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': '\$command \$sha1'")"
                                must_die_on_failure=yes
                                ;;
diff --git a/http.c b/http.c
index 8cd59f7f36a86b4d355bc6a3ff123c822bdc0078..9dce38025c7b35f7f5ad19121c0529b442aec92d 100644 (file)
--- a/http.c
+++ b/http.c
@@ -37,6 +37,20 @@ static int curl_ssl_verify = -1;
 static int curl_ssl_try;
 static const char *ssl_cert;
 static const char *ssl_cipherlist;
+static const char *ssl_version;
+static struct {
+       const char *name;
+       long ssl_version;
+} sslversions[] = {
+       { "sslv2", CURL_SSLVERSION_SSLv2 },
+       { "sslv3", CURL_SSLVERSION_SSLv3 },
+       { "tlsv1", CURL_SSLVERSION_TLSv1 },
+#if LIBCURL_VERSION_NUM >= 0x072200
+       { "tlsv1.0", CURL_SSLVERSION_TLSv1_0 },
+       { "tlsv1.1", CURL_SSLVERSION_TLSv1_1 },
+       { "tlsv1.2", CURL_SSLVERSION_TLSv1_2 },
+#endif
+};
 #if LIBCURL_VERSION_NUM >= 0x070903
 static const char *ssl_key;
 #endif
@@ -190,6 +204,8 @@ static int http_options(const char *var, const char *value, void *cb)
        }
        if (!strcmp("http.sslcipherlist", var))
                return git_config_string(&ssl_cipherlist, var, value);
+       if (!strcmp("http.sslversion", var))
+               return git_config_string(&ssl_version, var, value);
        if (!strcmp("http.sslcert", var))
                return git_config_string(&ssl_cert, var, value);
 #if LIBCURL_VERSION_NUM >= 0x070903
@@ -364,9 +380,24 @@ static CURL *get_curl_handle(void)
        if (http_proactive_auth)
                init_curl_http_auth(result);
 
+       if (getenv("GIT_SSL_VERSION"))
+               ssl_version = getenv("GIT_SSL_VERSION");
+       if (ssl_version && *ssl_version) {
+               int i;
+               for (i = 0; i < ARRAY_SIZE(sslversions); i++) {
+                       if (!strcmp(ssl_version, sslversions[i].name)) {
+                               curl_easy_setopt(result, CURLOPT_SSLVERSION,
+                                                sslversions[i].ssl_version);
+                               break;
+                       }
+               }
+               if (i == ARRAY_SIZE(sslversions))
+                       warning("unsupported ssl version %s: using default",
+                               ssl_version);
+       }
+
        if (getenv("GIT_SSL_CIPHER_LIST"))
                ssl_cipherlist = getenv("GIT_SSL_CIPHER_LIST");
-
        if (ssl_cipherlist != NULL && *ssl_cipherlist)
                curl_easy_setopt(result, CURLOPT_SSL_CIPHER_LIST,
                                ssl_cipherlist);
index 1d01f6aacf54b27a498d6071b5ec80fee5c35a47..0d890563b5f427fe6924e34b3931ade51e00e18d 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef NOTES_MERGE_H
 #define NOTES_MERGE_H
 
+#include "notes-utils.h"
+
 #define NOTES_MERGE_WORKTREE "NOTES_MERGE_WORKTREE"
 
 enum notes_merge_verbosity {
@@ -13,13 +15,7 @@ struct notes_merge_options {
        const char *remote_ref;
        struct strbuf commit_msg;
        int verbosity;
-       enum {
-               NOTES_MERGE_RESOLVE_MANUAL = 0,
-               NOTES_MERGE_RESOLVE_OURS,
-               NOTES_MERGE_RESOLVE_THEIRS,
-               NOTES_MERGE_RESOLVE_UNION,
-               NOTES_MERGE_RESOLVE_CAT_SORT_UNIQ
-       } strategy;
+       enum notes_merge_strategy strategy;
        unsigned has_worktree:1;
 };
 
index ccbf0737a34e466d39b2084c8a6d258b8235d8f6..299e34bccc5893529cb5db1abe061529304e6074 100644 (file)
@@ -54,6 +54,24 @@ void commit_notes(struct notes_tree *t, const char *msg)
        strbuf_release(&buf);
 }
 
+int parse_notes_merge_strategy(const char *v, enum notes_merge_strategy *s)
+{
+       if (!strcmp(v, "manual"))
+               *s = NOTES_MERGE_RESOLVE_MANUAL;
+       else if (!strcmp(v, "ours"))
+               *s = NOTES_MERGE_RESOLVE_OURS;
+       else if (!strcmp(v, "theirs"))
+               *s = NOTES_MERGE_RESOLVE_THEIRS;
+       else if (!strcmp(v, "union"))
+               *s = NOTES_MERGE_RESOLVE_UNION;
+       else if (!strcmp(v, "cat_sort_uniq"))
+               *s = NOTES_MERGE_RESOLVE_CAT_SORT_UNIQ;
+       else
+               return -1;
+
+       return 0;
+}
+
 static combine_notes_fn parse_combine_notes_fn(const char *v)
 {
        if (!strcasecmp(v, "overwrite"))
index 890ddb33e13ad6b9d43887216acbe5430ed534cc..fa538e1d9502c07fb1d72901c5939cd276fa1722 100644 (file)
@@ -19,6 +19,14 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
 
 void commit_notes(struct notes_tree *t, const char *msg);
 
+enum notes_merge_strategy {
+               NOTES_MERGE_RESOLVE_MANUAL = 0,
+               NOTES_MERGE_RESOLVE_OURS,
+               NOTES_MERGE_RESOLVE_THEIRS,
+               NOTES_MERGE_RESOLVE_UNION,
+               NOTES_MERGE_RESOLVE_CAT_SORT_UNIQ
+};
+
 struct notes_rewrite_cfg {
        struct notes_tree **trees;
        const char *cmd;
@@ -29,6 +37,7 @@ struct notes_rewrite_cfg {
        int mode_from_env;
 };
 
+int parse_notes_merge_strategy(const char *v, enum notes_merge_strategy *s);
 struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd);
 int copy_note_for_rewrite(struct notes_rewrite_cfg *c,
                          const unsigned char *from_obj, const unsigned char *to_obj);
diff --git a/pager.c b/pager.c
index 070dc11cb0c85abf07763de46a82e73dde6bded2..27d4c8a17aa17bb2cf31484227073e1a3204c17f 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -150,7 +150,8 @@ int check_pager_config(const char *cmd)
        struct strbuf key = STRBUF_INIT;
        const char *value = NULL;
        strbuf_addf(&key, "pager.%s", cmd);
-       if (!git_config_get_value(key.buf, &value)) {
+       if (git_config_key_is_valid(key.buf) &&
+           !git_config_get_value(key.buf, &value)) {
                int b = git_config_maybe_bool(key.buf, value);
                if (b >= 0)
                        want = b;
index d8c9111c82a541a39d71465c9b18a626d2dea94e..fef4c0f0b5ae15e98b8a5913afe60783a701f40a 100644 (file)
--- a/po/README
+++ b/po/README
@@ -10,10 +10,26 @@ coordinates our localization effort in the l10 coordinator repository:
 
         https://github.com/git-l10n/git-po/
 
+The two character language translation codes are defined by ISO_639-1, as
+stated in the gettext(1) full manual, appendix A.1, Usual Language Codes.
+
+
+Contributing to an existing translation
+---------------------------------------
 As a contributor for a language XX, you should first check TEAMS file in
 this directory to see whether a dedicated repository for your language XX
 exists. Fork the dedicated repository and start to work if it exists.
 
+Sometime, contributors may find that the translations of their Git
+distributions are quite different with the translations of the
+corresponding version from Git official. This is because some Git
+distributions (such as from Ubuntu, etc.) have their own l10n workflow.
+For this case, wrong translations should be reported and fixed through
+their workflows.
+
+
+Creating a new language translation
+-----------------------------------
 If you are the first contributor for the language XX, please fork this
 repository, prepare and/or update the translated message file po/XX.po
 (described later), and ask the l10n coordinator to pull your work.
@@ -23,6 +39,9 @@ coordinate among yourselves and nominate the team leader for your
 language, so that the l10n coordinator only needs to interact with one
 person per language.
 
+
+Translation Process Flow
+------------------------
 The overall data-flow looks like this:
 
     +-------------------+            +------------------+
index af7b6786dc091035e3216c710dbc0ebc3c234a8a..71fbbb694fc78471343f568a5e93b8013a7bb9cb 100644 (file)
@@ -11,6 +11,7 @@
 #include "argv-array.h"
 #include "credential.h"
 #include "sha1-array.h"
+#include "send-pack.h"
 
 static struct remote *remote;
 /* always ends with a trailing slash */
@@ -26,7 +27,8 @@ struct options {
                followtags : 1,
                dry_run : 1,
                thin : 1,
-               push_cert : 1;
+               /* One of the SEND_PACK_PUSH_CERT_* constants. */
+               push_cert : 2;
 };
 static struct options options;
 static struct string_list cas_options = STRING_LIST_INIT_DUP;
@@ -109,9 +111,11 @@ static int set_option(const char *name, const char *value)
                return 0;
        } else if (!strcmp(name, "pushcert")) {
                if (!strcmp(value, "true"))
-                       options.push_cert = 1;
+                       options.push_cert = SEND_PACK_PUSH_CERT_ALWAYS;
                else if (!strcmp(value, "false"))
-                       options.push_cert = 0;
+                       options.push_cert = SEND_PACK_PUSH_CERT_NEVER;
+               else if (!strcmp(value, "if-asked"))
+                       options.push_cert = SEND_PACK_PUSH_CERT_IF_ASKED;
                else
                        return -1;
                return 0;
@@ -880,8 +884,10 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)
                argv_array_push(&args, "--thin");
        if (options.dry_run)
                argv_array_push(&args, "--dry-run");
-       if (options.push_cert)
-               argv_array_push(&args, "--signed");
+       if (options.push_cert == SEND_PACK_PUSH_CERT_ALWAYS)
+               argv_array_push(&args, "--signed=yes");
+       else if (options.push_cert == SEND_PACK_PUSH_CERT_IF_ASKED)
+               argv_array_push(&args, "--signed=if-asked");
        if (options.verbosity == 0)
                argv_array_push(&args, "--quiet");
        else if (options.verbosity > 1)
index 2a64fec949ea9495b5b9512399cec7979319de1c..c6a40307381257c070714c778ea9d96f4c676387 100644 (file)
 #include "version.h"
 #include "sha1-array.h"
 #include "gpg-interface.h"
+#include "cache.h"
+
+int option_parse_push_signed(const struct option *opt,
+                            const char *arg, int unset)
+{
+       if (unset) {
+               *(int *)(opt->value) = SEND_PACK_PUSH_CERT_NEVER;
+               return 0;
+       }
+       switch (git_parse_maybe_bool(arg)) {
+       case 1:
+               *(int *)(opt->value) = SEND_PACK_PUSH_CERT_ALWAYS;
+               return 0;
+       case 0:
+               *(int *)(opt->value) = SEND_PACK_PUSH_CERT_NEVER;
+               return 0;
+       }
+       if (!strcasecmp("if-asked", arg)) {
+               *(int *)(opt->value) = SEND_PACK_PUSH_CERT_IF_ASKED;
+               return 0;
+       }
+       die("bad %s argument: %s", opt->long_name, arg);
+}
 
 static int feed_object(const unsigned char *sha1, int fd, int negative)
 {
@@ -370,14 +393,20 @@ int send_pack(struct send_pack_args *args,
                args->use_thin_pack = 0;
        if (server_supports("atomic"))
                atomic_supported = 1;
-       if (args->push_cert) {
-               int len;
 
+       if (args->push_cert != SEND_PACK_PUSH_CERT_NEVER) {
+               int len;
                push_cert_nonce = server_feature_value("push-cert", &len);
-               if (!push_cert_nonce)
+               if (push_cert_nonce) {
+                       reject_invalid_nonce(push_cert_nonce, len);
+                       push_cert_nonce = xmemdupz(push_cert_nonce, len);
+               } else if (args->push_cert == SEND_PACK_PUSH_CERT_ALWAYS) {
                        die(_("the receiving end does not support --signed push"));
-               reject_invalid_nonce(push_cert_nonce, len);
-               push_cert_nonce = xmemdupz(push_cert_nonce, len);
+               } else if (args->push_cert == SEND_PACK_PUSH_CERT_IF_ASKED) {
+                       warning(_("not sending a push certificate since the"
+                                 " receiving end does not support --signed"
+                                 " push"));
+               }
        }
 
        if (!remote_refs) {
@@ -413,7 +442,7 @@ int send_pack(struct send_pack_args *args,
        if (!args->dry_run)
                advertise_shallow_grafts_buf(&req_buf);
 
-       if (!args->dry_run && args->push_cert)
+       if (!args->dry_run && push_cert_nonce)
                cmds_sent = generate_push_cert(&req_buf, remote_refs, args,
                                               cap_buf.buf, push_cert_nonce);
 
@@ -452,7 +481,7 @@ int send_pack(struct send_pack_args *args,
        for (ref = remote_refs; ref; ref = ref->next) {
                char *old_hex, *new_hex;
 
-               if (args->dry_run || args->push_cert)
+               if (args->dry_run || push_cert_nonce)
                        continue;
 
                if (check_to_send_update(ref, args) < 0)
index b6646488aaf93814c5053d79528c1b5a4d19bcb5..57f222abccd7e77dad7e9a107e44971d16db79c2 100644 (file)
@@ -1,6 +1,11 @@
 #ifndef SEND_PACK_H
 #define SEND_PACK_H
 
+/* Possible values for push_cert field in send_pack_args. */
+#define SEND_PACK_PUSH_CERT_NEVER 0
+#define SEND_PACK_PUSH_CERT_IF_ASKED 1
+#define SEND_PACK_PUSH_CERT_ALWAYS 2
+
 struct send_pack_args {
        const char *url;
        unsigned verbose:1,
@@ -12,11 +17,16 @@ struct send_pack_args {
                use_thin_pack:1,
                use_ofs_delta:1,
                dry_run:1,
-               push_cert:1,
+               /* One of the SEND_PACK_PUSH_CERT_* constants. */
+               push_cert:2,
                stateless_rpc:1,
                atomic:1;
 };
 
+struct option;
+int option_parse_push_signed(const struct option *opt,
+                            const char *arg, int unset);
+
 int send_pack(struct send_pack_args *args,
              int fd[], struct child_process *conn,
              struct ref *remote_refs, struct sha1_array *extra_have);
diff --git a/setup.c b/setup.c
index 5f9f07dcdb059ad6aeac8d90ee18aedf56a8f85e..a17c51e61d75ac8280bf04d95c50d7bdfd6d7a0e 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -402,9 +402,9 @@ static void update_linked_gitdir(const char *gitfile, const char *gitdir)
        struct strbuf path = STRBUF_INIT;
        struct stat st;
 
-       strbuf_addf(&path, "%s/gitfile", gitdir);
+       strbuf_addf(&path, "%s/gitdir", gitdir);
        if (stat(path.buf, &st) || st.st_mtime + 24 * 3600 < time(NULL))
-               write_file(path.buf, 0, "%s\n", gitfile);
+               write_file(path.buf, "%s", gitfile);
        strbuf_release(&path);
 }
 
index ea78ba7cf062c92fe78e67ff4c0f5a0607e6aebd..08302f5857b8ad298809adf04a6bffc136f843a4 100644 (file)
@@ -1494,7 +1494,10 @@ int git_open_noatime(const char *name)
        static int sha1_file_open_flag = O_NOATIME;
 
        for (;;) {
-               int fd = open(name, O_RDONLY | sha1_file_open_flag);
+               int fd;
+
+               errno = 0;
+               fd = open(name, O_RDONLY | sha1_file_open_flag);
                if (fd >= 0)
                        return fd;
 
diff --git a/submodule-config.c b/submodule-config.c
new file mode 100644 (file)
index 0000000..393de53
--- /dev/null
@@ -0,0 +1,482 @@
+#include "cache.h"
+#include "submodule-config.h"
+#include "submodule.h"
+#include "strbuf.h"
+
+/*
+ * submodule cache lookup structure
+ * There is one shared set of 'struct submodule' entries which can be
+ * looked up by their sha1 blob id of the .gitmodule file and either
+ * using path or name as key.
+ * for_path stores submodule entries with path as key
+ * for_name stores submodule entries with name as key
+ */
+struct submodule_cache {
+       struct hashmap for_path;
+       struct hashmap for_name;
+};
+
+/*
+ * thin wrapper struct needed to insert 'struct submodule' entries to
+ * the hashmap
+ */
+struct submodule_entry {
+       struct hashmap_entry ent;
+       struct submodule *config;
+};
+
+enum lookup_type {
+       lookup_name,
+       lookup_path
+};
+
+static struct submodule_cache cache;
+static int is_cache_init;
+
+static int config_path_cmp(const struct submodule_entry *a,
+                          const struct submodule_entry *b,
+                          const void *unused)
+{
+       return strcmp(a->config->path, b->config->path) ||
+              hashcmp(a->config->gitmodules_sha1, b->config->gitmodules_sha1);
+}
+
+static int config_name_cmp(const struct submodule_entry *a,
+                          const struct submodule_entry *b,
+                          const void *unused)
+{
+       return strcmp(a->config->name, b->config->name) ||
+              hashcmp(a->config->gitmodules_sha1, b->config->gitmodules_sha1);
+}
+
+static void cache_init(struct submodule_cache *cache)
+{
+       hashmap_init(&cache->for_path, (hashmap_cmp_fn) config_path_cmp, 0);
+       hashmap_init(&cache->for_name, (hashmap_cmp_fn) config_name_cmp, 0);
+}
+
+static void free_one_config(struct submodule_entry *entry)
+{
+       free((void *) entry->config->path);
+       free((void *) entry->config->name);
+       free(entry->config);
+}
+
+static void cache_free(struct submodule_cache *cache)
+{
+       struct hashmap_iter iter;
+       struct submodule_entry *entry;
+
+       /*
+        * We iterate over the name hash here to be symmetric with the
+        * allocation of struct submodule entries. Each is allocated by
+        * their .gitmodule blob sha1 and submodule name.
+        */
+       hashmap_iter_init(&cache->for_name, &iter);
+       while ((entry = hashmap_iter_next(&iter)))
+               free_one_config(entry);
+
+       hashmap_free(&cache->for_path, 1);
+       hashmap_free(&cache->for_name, 1);
+}
+
+static unsigned int hash_sha1_string(const unsigned char *sha1,
+                                    const char *string)
+{
+       return memhash(sha1, 20) + strhash(string);
+}
+
+static void cache_put_path(struct submodule_cache *cache,
+                          struct submodule *submodule)
+{
+       unsigned int hash = hash_sha1_string(submodule->gitmodules_sha1,
+                                            submodule->path);
+       struct submodule_entry *e = xmalloc(sizeof(*e));
+       hashmap_entry_init(e, hash);
+       e->config = submodule;
+       hashmap_put(&cache->for_path, e);
+}
+
+static void cache_remove_path(struct submodule_cache *cache,
+                             struct submodule *submodule)
+{
+       unsigned int hash = hash_sha1_string(submodule->gitmodules_sha1,
+                                            submodule->path);
+       struct submodule_entry e;
+       struct submodule_entry *removed;
+       hashmap_entry_init(&e, hash);
+       e.config = submodule;
+       removed = hashmap_remove(&cache->for_path, &e, NULL);
+       free(removed);
+}
+
+static void cache_add(struct submodule_cache *cache,
+                     struct submodule *submodule)
+{
+       unsigned int hash = hash_sha1_string(submodule->gitmodules_sha1,
+                                            submodule->name);
+       struct submodule_entry *e = xmalloc(sizeof(*e));
+       hashmap_entry_init(e, hash);
+       e->config = submodule;
+       hashmap_add(&cache->for_name, e);
+}
+
+static const struct submodule *cache_lookup_path(struct submodule_cache *cache,
+               const unsigned char *gitmodules_sha1, const char *path)
+{
+       struct submodule_entry *entry;
+       unsigned int hash = hash_sha1_string(gitmodules_sha1, path);
+       struct submodule_entry key;
+       struct submodule key_config;
+
+       hashcpy(key_config.gitmodules_sha1, gitmodules_sha1);
+       key_config.path = path;
+
+       hashmap_entry_init(&key, hash);
+       key.config = &key_config;
+
+       entry = hashmap_get(&cache->for_path, &key, NULL);
+       if (entry)
+               return entry->config;
+       return NULL;
+}
+
+static struct submodule *cache_lookup_name(struct submodule_cache *cache,
+               const unsigned char *gitmodules_sha1, const char *name)
+{
+       struct submodule_entry *entry;
+       unsigned int hash = hash_sha1_string(gitmodules_sha1, name);
+       struct submodule_entry key;
+       struct submodule key_config;
+
+       hashcpy(key_config.gitmodules_sha1, gitmodules_sha1);
+       key_config.name = name;
+
+       hashmap_entry_init(&key, hash);
+       key.config = &key_config;
+
+       entry = hashmap_get(&cache->for_name, &key, NULL);
+       if (entry)
+               return entry->config;
+       return NULL;
+}
+
+static int name_and_item_from_var(const char *var, struct strbuf *name,
+                                 struct strbuf *item)
+{
+       const char *subsection, *key;
+       int subsection_len, parse;
+       parse = parse_config_key(var, "submodule", &subsection,
+                       &subsection_len, &key);
+       if (parse < 0 || !subsection)
+               return 0;
+
+       strbuf_add(name, subsection, subsection_len);
+       strbuf_addstr(item, key);
+
+       return 1;
+}
+
+static struct submodule *lookup_or_create_by_name(struct submodule_cache *cache,
+               const unsigned char *gitmodules_sha1, const char *name)
+{
+       struct submodule *submodule;
+       struct strbuf name_buf = STRBUF_INIT;
+
+       submodule = cache_lookup_name(cache, gitmodules_sha1, name);
+       if (submodule)
+               return submodule;
+
+       submodule = xmalloc(sizeof(*submodule));
+
+       strbuf_addstr(&name_buf, name);
+       submodule->name = strbuf_detach(&name_buf, NULL);
+
+       submodule->path = NULL;
+       submodule->url = NULL;
+       submodule->fetch_recurse = RECURSE_SUBMODULES_NONE;
+       submodule->ignore = NULL;
+
+       hashcpy(submodule->gitmodules_sha1, gitmodules_sha1);
+
+       cache_add(cache, submodule);
+
+       return submodule;
+}
+
+static int parse_fetch_recurse(const char *opt, const char *arg,
+                              int die_on_error)
+{
+       switch (git_config_maybe_bool(opt, arg)) {
+       case 1:
+               return RECURSE_SUBMODULES_ON;
+       case 0:
+               return RECURSE_SUBMODULES_OFF;
+       default:
+               if (!strcmp(arg, "on-demand"))
+                       return RECURSE_SUBMODULES_ON_DEMAND;
+
+               if (die_on_error)
+                       die("bad %s argument: %s", opt, arg);
+               else
+                       return RECURSE_SUBMODULES_ERROR;
+       }
+}
+
+int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
+{
+       return parse_fetch_recurse(opt, arg, 1);
+}
+
+static void warn_multiple_config(const unsigned char *commit_sha1,
+                                const char *name, const char *option)
+{
+       const char *commit_string = "WORKTREE";
+       if (commit_sha1)
+               commit_string = sha1_to_hex(commit_sha1);
+       warning("%s:.gitmodules, multiple configurations found for "
+                       "'submodule.%s.%s'. Skipping second one!",
+                       commit_string, name, option);
+}
+
+struct parse_config_parameter {
+       struct submodule_cache *cache;
+       const unsigned char *commit_sha1;
+       const unsigned char *gitmodules_sha1;
+       int overwrite;
+};
+
+static int parse_config(const char *var, const char *value, void *data)
+{
+       struct parse_config_parameter *me = data;
+       struct submodule *submodule;
+       struct strbuf name = STRBUF_INIT, item = STRBUF_INIT;
+       int ret = 0;
+
+       /* this also ensures that we only parse submodule entries */
+       if (!name_and_item_from_var(var, &name, &item))
+               return 0;
+
+       submodule = lookup_or_create_by_name(me->cache, me->gitmodules_sha1,
+                       name.buf);
+
+       if (!strcmp(item.buf, "path")) {
+               struct strbuf path = STRBUF_INIT;
+               if (!value) {
+                       ret = config_error_nonbool(var);
+                       goto release_return;
+               }
+               if (!me->overwrite && submodule->path != NULL) {
+                       warn_multiple_config(me->commit_sha1, submodule->name,
+                                       "path");
+                       goto release_return;
+               }
+
+               if (submodule->path)
+                       cache_remove_path(me->cache, submodule);
+               free((void *) submodule->path);
+               strbuf_addstr(&path, value);
+               submodule->path = strbuf_detach(&path, NULL);
+               cache_put_path(me->cache, submodule);
+       } else if (!strcmp(item.buf, "fetchrecursesubmodules")) {
+               /* when parsing worktree configurations we can die early */
+               int die_on_error = is_null_sha1(me->gitmodules_sha1);
+               if (!me->overwrite &&
+                   submodule->fetch_recurse != RECURSE_SUBMODULES_NONE) {
+                       warn_multiple_config(me->commit_sha1, submodule->name,
+                                       "fetchrecursesubmodules");
+                       goto release_return;
+               }
+
+               submodule->fetch_recurse = parse_fetch_recurse(var, value,
+                                                               die_on_error);
+       } else if (!strcmp(item.buf, "ignore")) {
+               struct strbuf ignore = STRBUF_INIT;
+               if (!me->overwrite && submodule->ignore != NULL) {
+                       warn_multiple_config(me->commit_sha1, submodule->name,
+                                       "ignore");
+                       goto release_return;
+               }
+               if (!value) {
+                       ret = config_error_nonbool(var);
+                       goto release_return;
+               }
+               if (strcmp(value, "untracked") && strcmp(value, "dirty") &&
+                   strcmp(value, "all") && strcmp(value, "none")) {
+                       warning("Invalid parameter '%s' for config option "
+                                       "'submodule.%s.ignore'", value, var);
+                       goto release_return;
+               }
+
+               free((void *) submodule->ignore);
+               strbuf_addstr(&ignore, value);
+               submodule->ignore = strbuf_detach(&ignore, NULL);
+       } else if (!strcmp(item.buf, "url")) {
+               struct strbuf url = STRBUF_INIT;
+               if (!value) {
+                       ret = config_error_nonbool(var);
+                       goto release_return;
+               }
+               if (!me->overwrite && submodule->url != NULL) {
+                       warn_multiple_config(me->commit_sha1, submodule->name,
+                                       "url");
+                       goto release_return;
+               }
+
+               free((void *) submodule->url);
+               strbuf_addstr(&url, value);
+               submodule->url = strbuf_detach(&url, NULL);
+       }
+
+release_return:
+       strbuf_release(&name);
+       strbuf_release(&item);
+
+       return ret;
+}
+
+static int gitmodule_sha1_from_commit(const unsigned char *commit_sha1,
+                                     unsigned char *gitmodules_sha1)
+{
+       struct strbuf rev = STRBUF_INIT;
+       int ret = 0;
+
+       if (is_null_sha1(commit_sha1)) {
+               hashcpy(gitmodules_sha1, null_sha1);
+               return 1;
+       }
+
+       strbuf_addf(&rev, "%s:.gitmodules", sha1_to_hex(commit_sha1));
+       if (get_sha1(rev.buf, gitmodules_sha1) >= 0)
+               ret = 1;
+
+       strbuf_release(&rev);
+       return ret;
+}
+
+/* This does a lookup of a submodule configuration by name or by path
+ * (key) with on-demand reading of the appropriate .gitmodules from
+ * revisions.
+ */
+static const struct submodule *config_from(struct submodule_cache *cache,
+               const unsigned char *commit_sha1, const char *key,
+               enum lookup_type lookup_type)
+{
+       struct strbuf rev = STRBUF_INIT;
+       unsigned long config_size;
+       char *config;
+       unsigned char sha1[20];
+       enum object_type type;
+       const struct submodule *submodule = NULL;
+       struct parse_config_parameter parameter;
+
+       /*
+        * If any parameter except the cache is a NULL pointer just
+        * return the first submodule. Can be used to check whether
+        * there are any submodules parsed.
+        */
+       if (!commit_sha1 || !key) {
+               struct hashmap_iter iter;
+               struct submodule_entry *entry;
+
+               hashmap_iter_init(&cache->for_name, &iter);
+               entry = hashmap_iter_next(&iter);
+               if (!entry)
+                       return NULL;
+               return entry->config;
+       }
+
+       if (!gitmodule_sha1_from_commit(commit_sha1, sha1))
+               return NULL;
+
+       switch (lookup_type) {
+       case lookup_name:
+               submodule = cache_lookup_name(cache, sha1, key);
+               break;
+       case lookup_path:
+               submodule = cache_lookup_path(cache, sha1, key);
+               break;
+       }
+       if (submodule)
+               return submodule;
+
+       config = read_sha1_file(sha1, &type, &config_size);
+       if (!config)
+               return NULL;
+
+       if (type != OBJ_BLOB) {
+               free(config);
+               return NULL;
+       }
+
+       /* fill the submodule config into the cache */
+       parameter.cache = cache;
+       parameter.commit_sha1 = commit_sha1;
+       parameter.gitmodules_sha1 = sha1;
+       parameter.overwrite = 0;
+       git_config_from_buf(parse_config, rev.buf, config, config_size,
+                       &parameter);
+       free(config);
+
+       switch (lookup_type) {
+       case lookup_name:
+               return cache_lookup_name(cache, sha1, key);
+       case lookup_path:
+               return cache_lookup_path(cache, sha1, key);
+       default:
+               return NULL;
+       }
+}
+
+static const struct submodule *config_from_path(struct submodule_cache *cache,
+               const unsigned char *commit_sha1, const char *path)
+{
+       return config_from(cache, commit_sha1, path, lookup_path);
+}
+
+static const struct submodule *config_from_name(struct submodule_cache *cache,
+               const unsigned char *commit_sha1, const char *name)
+{
+       return config_from(cache, commit_sha1, name, lookup_name);
+}
+
+static void ensure_cache_init(void)
+{
+       if (is_cache_init)
+               return;
+
+       cache_init(&cache);
+       is_cache_init = 1;
+}
+
+int parse_submodule_config_option(const char *var, const char *value)
+{
+       struct parse_config_parameter parameter;
+       parameter.cache = &cache;
+       parameter.commit_sha1 = NULL;
+       parameter.gitmodules_sha1 = null_sha1;
+       parameter.overwrite = 1;
+
+       ensure_cache_init();
+       return parse_config(var, value, &parameter);
+}
+
+const struct submodule *submodule_from_name(const unsigned char *commit_sha1,
+               const char *name)
+{
+       ensure_cache_init();
+       return config_from_name(&cache, commit_sha1, name);
+}
+
+const struct submodule *submodule_from_path(const unsigned char *commit_sha1,
+               const char *path)
+{
+       ensure_cache_init();
+       return config_from_path(&cache, commit_sha1, path);
+}
+
+void submodule_free(void)
+{
+       cache_free(&cache);
+       is_cache_init = 0;
+}
diff --git a/submodule-config.h b/submodule-config.h
new file mode 100644 (file)
index 0000000..9061e4e
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef SUBMODULE_CONFIG_CACHE_H
+#define SUBMODULE_CONFIG_CACHE_H
+
+#include "hashmap.h"
+#include "strbuf.h"
+
+/*
+ * Submodule entry containing the information about a certain submodule
+ * in a certain revision.
+ */
+struct submodule {
+       const char *path;
+       const char *name;
+       const char *url;
+       int fetch_recurse;
+       const char *ignore;
+       /* the sha1 blob id of the responsible .gitmodules file */
+       unsigned char gitmodules_sha1[20];
+};
+
+int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
+int parse_submodule_config_option(const char *var, const char *value);
+const struct submodule *submodule_from_name(const unsigned char *commit_sha1,
+               const char *name);
+const struct submodule *submodule_from_path(const unsigned char *commit_sha1,
+               const char *path);
+void submodule_free(void);
+
+#endif /* SUBMODULE_CONFIG_H */
index 700bbf4fcb4cd93b79304d934bed8901c63a853a..245ed4dfbb6a3d54adbd41d5de0ea64cf38dc8a3 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "submodule-config.h"
 #include "submodule.h"
 #include "dir.h"
 #include "diff.h"
@@ -12,9 +13,6 @@
 #include "argv-array.h"
 #include "blob.h"
 
-static struct string_list config_name_for_path;
-static struct string_list config_fetch_recurse_submodules_for_name;
-static struct string_list config_ignore_for_name;
 static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND;
 static struct string_list changed_submodule_paths;
 static int initialized_fetch_ref_tips;
@@ -41,7 +39,6 @@ static int gitmodules_is_unmerged;
  */
 static int gitmodules_is_modified;
 
-
 int is_staging_gitmodules_ok(void)
 {
        return !gitmodules_is_modified;
@@ -55,7 +52,7 @@ int is_staging_gitmodules_ok(void)
 int update_path_in_gitmodules(const char *oldpath, const char *newpath)
 {
        struct strbuf entry = STRBUF_INIT;
-       struct string_list_item *path_option;
+       const struct submodule *submodule;
 
        if (!file_exists(".gitmodules")) /* Do nothing without .gitmodules */
                return -1;
@@ -63,13 +60,13 @@ int update_path_in_gitmodules(const char *oldpath, const char *newpath)
        if (gitmodules_is_unmerged)
                die(_("Cannot change unmerged .gitmodules, resolve merge conflicts first"));
 
-       path_option = unsorted_string_list_lookup(&config_name_for_path, oldpath);
-       if (!path_option) {
+       submodule = submodule_from_path(null_sha1, oldpath);
+       if (!submodule || !submodule->name) {
                warning(_("Could not find section in .gitmodules where path=%s"), oldpath);
                return -1;
        }
        strbuf_addstr(&entry, "submodule.");
-       strbuf_addstr(&entry, path_option->util);
+       strbuf_addstr(&entry, submodule->name);
        strbuf_addstr(&entry, ".path");
        if (git_config_set_in_file(".gitmodules", entry.buf, newpath) < 0) {
                /* Maybe the user already did that, don't error out here */
@@ -89,7 +86,7 @@ int update_path_in_gitmodules(const char *oldpath, const char *newpath)
 int remove_path_from_gitmodules(const char *path)
 {
        struct strbuf sect = STRBUF_INIT;
-       struct string_list_item *path_option;
+       const struct submodule *submodule;
 
        if (!file_exists(".gitmodules")) /* Do nothing without .gitmodules */
                return -1;
@@ -97,13 +94,13 @@ int remove_path_from_gitmodules(const char *path)
        if (gitmodules_is_unmerged)
                die(_("Cannot change unmerged .gitmodules, resolve merge conflicts first"));
 
-       path_option = unsorted_string_list_lookup(&config_name_for_path, path);
-       if (!path_option) {
+       submodule = submodule_from_path(null_sha1, path);
+       if (!submodule || !submodule->name) {
                warning(_("Could not find section in .gitmodules where path=%s"), path);
                return -1;
        }
        strbuf_addstr(&sect, "submodule.");
-       strbuf_addstr(&sect, path_option->util);
+       strbuf_addstr(&sect, submodule->name);
        if (git_config_rename_section_in_file(".gitmodules", sect.buf, NULL) < 0) {
                /* Maybe the user already did that, don't error out here */
                warning(_("Could not remove .gitmodules entry for %s"), path);
@@ -165,12 +162,10 @@ static int add_submodule_odb(const char *path)
 void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,
                                             const char *path)
 {
-       struct string_list_item *path_option, *ignore_option;
-       path_option = unsorted_string_list_lookup(&config_name_for_path, path);
-       if (path_option) {
-               ignore_option = unsorted_string_list_lookup(&config_ignore_for_name, path_option->util);
-               if (ignore_option)
-                       handle_ignore_submodules_arg(diffopt, ignore_option->util);
+       const struct submodule *submodule = submodule_from_path(null_sha1, path);
+       if (submodule) {
+               if (submodule->ignore)
+                       handle_ignore_submodules_arg(diffopt, submodule->ignore);
                else if (gitmodules_is_unmerged)
                        DIFF_OPT_SET(diffopt, IGNORE_SUBMODULES);
        }
@@ -219,58 +214,6 @@ void gitmodules_config(void)
        }
 }
 
-int parse_submodule_config_option(const char *var, const char *value)
-{
-       struct string_list_item *config;
-       const char *name, *key;
-       int namelen;
-
-       if (parse_config_key(var, "submodule", &name, &namelen, &key) < 0 || !name)
-               return 0;
-
-       if (!strcmp(key, "path")) {
-               if (!value)
-                       return config_error_nonbool(var);
-
-               config = unsorted_string_list_lookup(&config_name_for_path, value);
-               if (config)
-                       free(config->util);
-               else
-                       config = string_list_append(&config_name_for_path, xstrdup(value));
-               config->util = xmemdupz(name, namelen);
-       } else if (!strcmp(key, "fetchrecursesubmodules")) {
-               char *name_cstr = xmemdupz(name, namelen);
-               config = unsorted_string_list_lookup(&config_fetch_recurse_submodules_for_name, name_cstr);
-               if (!config)
-                       config = string_list_append(&config_fetch_recurse_submodules_for_name, name_cstr);
-               else
-                       free(name_cstr);
-               config->util = (void *)(intptr_t)parse_fetch_recurse_submodules_arg(var, value);
-       } else if (!strcmp(key, "ignore")) {
-               char *name_cstr;
-
-               if (!value)
-                       return config_error_nonbool(var);
-
-               if (strcmp(value, "untracked") && strcmp(value, "dirty") &&
-                   strcmp(value, "all") && strcmp(value, "none")) {
-                       warning("Invalid parameter \"%s\" for config option \"submodule.%s.ignore\"", value, var);
-                       return 0;
-               }
-
-               name_cstr = xmemdupz(name, namelen);
-               config = unsorted_string_list_lookup(&config_ignore_for_name, name_cstr);
-               if (config) {
-                       free(config->util);
-                       free(name_cstr);
-               } else
-                       config = string_list_append(&config_ignore_for_name, name_cstr);
-               config->util = xstrdup(value);
-               return 0;
-       }
-       return 0;
-}
-
 void handle_ignore_submodules_arg(struct diff_options *diffopt,
                                  const char *arg)
 {
@@ -345,20 +288,6 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
        strbuf_release(&sb);
 }
 
-int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
-{
-       switch (git_config_maybe_bool(opt, arg)) {
-       case 1:
-               return RECURSE_SUBMODULES_ON;
-       case 0:
-               return RECURSE_SUBMODULES_OFF;
-       default:
-               if (!strcmp(arg, "on-demand"))
-                       return RECURSE_SUBMODULES_ON_DEMAND;
-               die("bad %s argument: %s", opt, arg);
-       }
-}
-
 void show_submodule_summary(FILE *f, const char *path,
                const char *line_prefix,
                unsigned char one[20], unsigned char two[20],
@@ -646,7 +575,7 @@ static void calculate_changed_submodule_paths(void)
        struct argv_array argv = ARGV_ARRAY_INIT;
 
        /* No need to check if there are no submodules configured */
-       if (!config_name_for_path.nr)
+       if (!submodule_from_path(NULL, NULL))
                return;
 
        init_revisions(&rev, NULL);
@@ -693,7 +622,6 @@ int fetch_populated_submodules(const struct argv_array *options,
        int i, result = 0;
        struct child_process cp = CHILD_PROCESS_INIT;
        struct argv_array argv = ARGV_ARRAY_INIT;
-       struct string_list_item *name_for_path;
        const char *work_tree = get_git_work_tree();
        if (!work_tree)
                goto out;
@@ -718,24 +646,26 @@ int fetch_populated_submodules(const struct argv_array *options,
                struct strbuf submodule_git_dir = STRBUF_INIT;
                struct strbuf submodule_prefix = STRBUF_INIT;
                const struct cache_entry *ce = active_cache[i];
-               const char *git_dir, *name, *default_argv;
+               const char *git_dir, *default_argv;
+               const struct submodule *submodule;
 
                if (!S_ISGITLINK(ce->ce_mode))
                        continue;
 
-               name = ce->name;
-               name_for_path = unsorted_string_list_lookup(&config_name_for_path, ce->name);
-               if (name_for_path)
-                       name = name_for_path->util;
+               submodule = submodule_from_path(null_sha1, ce->name);
+               if (!submodule)
+                       submodule = submodule_from_name(null_sha1, ce->name);
 
                default_argv = "yes";
                if (command_line_option == RECURSE_SUBMODULES_DEFAULT) {
-                       struct string_list_item *fetch_recurse_submodules_option;
-                       fetch_recurse_submodules_option = unsorted_string_list_lookup(&config_fetch_recurse_submodules_for_name, name);
-                       if (fetch_recurse_submodules_option) {
-                               if ((intptr_t)fetch_recurse_submodules_option->util == RECURSE_SUBMODULES_OFF)
+                       if (submodule &&
+                           submodule->fetch_recurse !=
+                                               RECURSE_SUBMODULES_NONE) {
+                               if (submodule->fetch_recurse ==
+                                               RECURSE_SUBMODULES_OFF)
                                        continue;
-                               if ((intptr_t)fetch_recurse_submodules_option->util == RECURSE_SUBMODULES_ON_DEMAND) {
+                               if (submodule->fetch_recurse ==
+                                               RECURSE_SUBMODULES_ON_DEMAND) {
                                        if (!unsorted_string_list_lookup(&changed_submodule_paths, ce->name))
                                                continue;
                                        default_argv = "on-demand";
@@ -1103,7 +1033,7 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)
 
        /* Update gitfile */
        strbuf_addf(&file_name, "%s/.git", work_tree);
-       write_file(file_name.buf, 1, "gitdir: %s\n",
+       write_file(file_name.buf, "gitdir: %s",
                   relative_path(git_dir, real_work_tree, &rel_path));
 
        /* Update core.worktree setting */
index 7beec4822b9a35a6286a303f6cf877be1c734568..5507c3d9a098b1da016855c1fa4233ffc6e0a8cf 100644 (file)
@@ -5,6 +5,8 @@ struct diff_options;
 struct argv_array;
 
 enum {
+       RECURSE_SUBMODULES_ERROR = -3,
+       RECURSE_SUBMODULES_NONE = -2,
        RECURSE_SUBMODULES_ON_DEMAND = -1,
        RECURSE_SUBMODULES_OFF = 0,
        RECURSE_SUBMODULES_DEFAULT = 1,
@@ -19,9 +21,7 @@ void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,
                const char *path);
 int submodule_config(const char *var, const char *value, void *cb);
 void gitmodules_config(void);
-int parse_submodule_config_option(const char *var, const char *value);
 void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *);
-int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
 void show_submodule_summary(FILE *f, const char *path,
                const char *line_prefix,
                unsigned char one[20], unsigned char two[20],
index 66dd28644f954eb91b5f05d5c6f00a8697c4d274..52678e7d0ac754bb678eb7c7a9203bc253085366 100755 (executable)
@@ -352,6 +352,18 @@ test_expect_success '--list without repo produces empty output' '
        test_cmp expect output
 '
 
+cat > expect << EOF
+beta.noindent
+nextsection.nonewline
+123456.a123
+version.1.2.3eX.alpha
+EOF
+
+test_expect_success '--name-only --list' '
+       git config --name-only --list >output &&
+       test_cmp expect output
+'
+
 cat > expect << EOF
 beta.noindent sillyValue
 nextsection.nonewline wow2 for me
@@ -362,6 +374,16 @@ test_expect_success '--get-regexp' '
        test_cmp expect output
 '
 
+cat > expect << EOF
+beta.noindent
+nextsection.nonewline
+EOF
+
+test_expect_success '--name-only --get-regexp' '
+       git config --name-only --get-regexp in >output &&
+       test_cmp expect output
+'
+
 cat > expect << EOF
 wow2 for me
 wow4 for you
index ca01053bcc88806aae9abde5892b8c163b3936d0..124e73b8e601ed3c714fe2857d2b227ee04e2ffc 100755 (executable)
@@ -22,7 +22,7 @@ test_expect_success \
     'test_must_fail git ls-files --error-unmatch foo bar-does-not-match'
 
 test_expect_success \
-    'git ls-files --error-unmatch should succeed eith matched paths.' \
+    'git ls-files --error-unmatch should succeed with matched paths.' \
     'git ls-files --error-unmatch foo bar'
 
 test_done
index 461fd84755d7acc0df346903e6ac1a74d4a9e458..14c2adf970d729463e1421356d27cc3b92b3c71d 100755 (executable)
@@ -298,6 +298,13 @@ test_expect_success 'merge z into y with invalid strategy => Fail/No changes' '
        verify_notes y y
 '
 
+test_expect_success 'merge z into y with invalid configuration option => Fail/No changes' '
+       git config core.notesRef refs/notes/y &&
+       test_must_fail git -c notes.mergeStrategy="foo" notes merge z &&
+       # Verify no changes (y)
+       verify_notes y y
+'
+
 cat <<EOF | sort >expect_notes_ours
 68b8630d25516028bed862719855b3d6768d7833 $commit_sha15
 5de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14
@@ -365,6 +372,28 @@ test_expect_success 'reset to pre-merge state (y)' '
        verify_notes y y
 '
 
+test_expect_success 'merge z into y with "ours" configuration option => Non-conflicting 3-way merge' '
+       git -c notes.mergeStrategy="ours" notes merge z &&
+       verify_notes y ours
+'
+
+test_expect_success 'reset to pre-merge state (y)' '
+       git update-ref refs/notes/y refs/notes/y^1 &&
+       # Verify pre-merge state
+       verify_notes y y
+'
+
+test_expect_success 'merge z into y with "ours" per-ref configuration option => Non-conflicting 3-way merge' '
+       git -c notes.y.mergeStrategy="ours" notes merge z &&
+       verify_notes y ours
+'
+
+test_expect_success 'reset to pre-merge state (y)' '
+       git update-ref refs/notes/y refs/notes/y^1 &&
+       # Verify pre-merge state
+       verify_notes y y
+'
+
 cat <<EOF | sort >expect_notes_theirs
 9b4b2c61f0615412da3c10f98ff85b57c04ec765 $commit_sha15
 5de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14
@@ -432,6 +461,17 @@ test_expect_success 'reset to pre-merge state (y)' '
        verify_notes y y
 '
 
+test_expect_success 'merge z into y with "theirs" strategy overriding configuration option "ours" => Non-conflicting 3-way merge' '
+       git -c notes.mergeStrategy="ours" notes merge --strategy=theirs z &&
+       verify_notes y theirs
+'
+
+test_expect_success 'reset to pre-merge state (y)' '
+       git update-ref refs/notes/y refs/notes/y^1 &&
+       # Verify pre-merge state
+       verify_notes y y
+'
+
 cat <<EOF | sort >expect_notes_union
 7c4e546efd0fe939f876beb262ece02797880b54 $commit_sha15
 5de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14
@@ -505,6 +545,34 @@ test_expect_success 'reset to pre-merge state (y)' '
        verify_notes y y
 '
 
+test_expect_success 'merge z into y with "union" strategy overriding per-ref configuration => Non-conflicting 3-way merge' '
+       git -c notes.y.mergeStrategy="theirs" notes merge --strategy=union z &&
+       verify_notes y union
+'
+
+test_expect_success 'reset to pre-merge state (y)' '
+       git update-ref refs/notes/y refs/notes/y^1 &&
+       # Verify pre-merge state
+       verify_notes y y
+'
+
+test_expect_success 'merge z into y with "union" per-ref overriding general configuration => Non-conflicting 3-way merge' '
+       git -c notes.y.mergeStrategy="union" -c notes.mergeStrategy="theirs" notes merge z &&
+       verify_notes y union
+'
+
+test_expect_success 'reset to pre-merge state (y)' '
+       git update-ref refs/notes/y refs/notes/y^1 &&
+       # Verify pre-merge state
+       verify_notes y y
+'
+
+test_expect_success 'merge z into y with "manual" per-ref only checks specific ref configuration => Conflicting 3-way merge' '
+       test_must_fail git -c notes.z.mergeStrategy="union" notes merge z &&
+       git notes merge --abort &&
+       verify_notes y y
+'
+
 cat <<EOF | sort >expect_notes_union2
 d682107b8bf7a7aea1e537a8d5cb6a12b60135f1 $commit_sha15
 5de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14
@@ -644,4 +712,15 @@ test_expect_success 'merge y into z with "cat_sort_uniq" strategy => Non-conflic
        verify_notes z cat_sort_uniq
 '
 
+test_expect_success 'reset to pre-merge state (z)' '
+       git update-ref refs/notes/z refs/notes/z^1 &&
+       # Verify pre-merge state
+       verify_notes z z
+'
+
+test_expect_success 'merge y into z with "cat_sort_uniq" strategy configuration option => Non-conflicting 3-way merge' '
+       git -c notes.mergeStrategy="cat_sort_uniq" notes merge y &&
+       verify_notes z cat_sort_uniq
+'
+
 test_done
index 195bb97f859d6a4990c292da46b9674be0f6153f..d5572121da69a90ffb1010b6136c3c1fa9fe07f2 100755 (executable)
@@ -314,6 +314,18 @@ y and z notes on 1st commit
 
 EOF
 
+test_expect_success 'do not allow mixing --commit and --abort' '
+       test_must_fail git notes merge --commit --abort
+'
+
+test_expect_success 'do not allow mixing --commit and --strategy' '
+       test_must_fail git notes merge --commit --strategy theirs
+'
+
+test_expect_success 'do not allow mixing --abort and --strategy' '
+       test_must_fail git notes merge --abort --strategy theirs
+'
+
 test_expect_success 'finalize conflicting merge (z => m)' '
        # Resolve conflicts and finalize merge
        cat >.git/NOTES_MERGE_WORKTREE/$commit_sha1 <<EOF &&
index 05bdc3ee49408ac1ab35fe54d0b3bfbe401bf7cf..ea5ace99a14f7f31b63dfd9cf25123725a525519 100755 (executable)
@@ -168,4 +168,28 @@ test_expect_success 'am --abort on unborn branch will keep local commits intact'
        test_cmp expect actual
 '
 
+test_expect_success 'am --skip leaves index stat info alone' '
+       git checkout -f --orphan skip-stat-info &&
+       git reset &&
+       test_commit skip-should-be-untouched &&
+       test-chmtime =0 skip-should-be-untouched.t &&
+       git update-index --refresh &&
+       git diff-files --exit-code --quiet &&
+       test_must_fail git am 0001-*.patch &&
+       git am --skip &&
+       git diff-files --exit-code --quiet
+'
+
+test_expect_success 'am --abort leaves index stat info alone' '
+       git checkout -f --orphan abort-stat-info &&
+       git reset &&
+       test_commit abort-should-be-untouched &&
+       test-chmtime =0 abort-should-be-untouched.t &&
+       git update-index --refresh &&
+       git diff-files --exit-code --quiet &&
+       test_must_fail git am 0001-*.patch &&
+       git am --abort &&
+       git diff-files --exit-code --quiet
+'
+
 test_done
index 654addaae3e7040bcb4ce1014ee327511f73c8e5..cca23383c584f3f63114f2bb0a4d74aaf45208c7 100755 (executable)
@@ -115,4 +115,44 @@ test_expect_success 'archive empty subtree by direct pathspec' '
        check_dir extract sub
 '
 
+ZIPINFO=zipinfo
+
+test_lazy_prereq ZIPINFO '
+       n=$("$ZIPINFO" "$TEST_DIRECTORY"/t5004/empty.zip | sed -n "2s/.* //p")
+       test "x$n" = "x0"
+'
+
+test_expect_success ZIPINFO 'zip archive with many entries' '
+       # add a directory with 256 files
+       mkdir 00 &&
+       for a in 0 1 2 3 4 5 6 7 8 9 a b c d e f
+       do
+               for b in 0 1 2 3 4 5 6 7 8 9 a b c d e f
+               do
+                       : >00/$a$b
+               done
+       done &&
+       git add 00 &&
+       git commit -m "256 files in 1 directory" &&
+
+       # duplicate it to get 65536 files in 256 directories
+       subtree=$(git write-tree --prefix=00/) &&
+       for c in 0 1 2 3 4 5 6 7 8 9 a b c d e f
+       do
+               for d in 0 1 2 3 4 5 6 7 8 9 a b c d e f
+               do
+                       echo "040000 tree $subtree      $c$d"
+               done
+       done >tree &&
+       tree=$(git mktree <tree) &&
+
+       # zip them
+       git archive -o many.zip $tree &&
+
+       # check the number of entries in the ZIP file directory
+       expr 65536 + 256 >expect &&
+       "$ZIPINFO" many.zip | head -2 | sed -n "2s/.* //p" >actual &&
+       test_cmp expect actual
+'
+
 test_done
index c0e5b2a6275df2d92172327b2d629cc73720423e..85f269411cb3aed461f6894dc5d1cc780debc24b 100755 (executable)
@@ -113,6 +113,14 @@ check_describe A-3-* --long HEAD^^2
 check_describe c-7-* --tags
 check_describe e-3-* --first-parent --tags
 
+test_expect_success 'describe --contains defaults to HEAD without commit-ish' '
+       echo "A^0" >expect &&
+       git checkout A &&
+       test_when_finished "git checkout -" &&
+       git describe --contains >actual &&
+       test_cmp expect actual
+'
+
 : >err.expect
 check_describe A --all A^0
 test_expect_success 'no warning was displayed for A' '
index 947b690fd7fcaae6f2584b0752adfecfc0c1af89..6ea7ac4c418d7ace719910c1730217a1ffe7532f 100755 (executable)
@@ -447,4 +447,13 @@ test_expect_success TTY 'external command pagers override sub-commands' '
        test_cmp expect actual
 '
 
+test_expect_success 'command with underscores does not complain' '
+       write_script git-under_score <<-\EOF &&
+       echo ok
+       EOF
+       git --exec-path=. under_score >actual 2>&1 &&
+       echo ok >expect &&
+       test_cmp expect actual
+'
+
 test_done
index ff23f4e94e9a67a2f327f45bb0557c051738800f..37a24c131240c46d0694e0a148ec7c15b89e17fe 100755 (executable)
@@ -375,7 +375,7 @@ EOF
 node creation: 0
 gitignore invalidation: 0
 directory invalidation: 0
-opendir: 1
+opendir: 2
 EOF
        test_cmp ../trace.expect ../trace
 '
@@ -402,13 +402,14 @@ test_expect_success 'set up sparse checkout' '
        echo "done/[a-z]*" >.git/info/sparse-checkout &&
        test_config core.sparsecheckout true &&
        git checkout master &&
-       git update-index --untracked-cache &&
+       git update-index --force-untracked-cache &&
        git status --porcelain >/dev/null && # prime the cache
        test_path_is_missing done/.gitignore &&
        test_path_is_file done/one
 '
 
-test_expect_success 'create files, some of which are gitignored' '
+test_expect_success 'create/modify files, some of which are gitignored' '
+       echo two bis >done/two &&
        echo three >done/three && # three is gitignored
        echo four >done/four && # four is gitignored at a higher level
        echo five >done/five # five is not gitignored
@@ -420,6 +421,7 @@ test_expect_success 'test sparse status with untracked cache' '
        GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
        git status --porcelain >../status.actual &&
        cat >../status.expect <<EOF &&
+ M done/two
 ?? .gitignore
 ?? done/five
 ?? dtwo/
@@ -459,12 +461,80 @@ test_expect_success 'test sparse status again with untracked cache' '
        GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
        git status --porcelain >../status.actual &&
        cat >../status.expect <<EOF &&
+ M done/two
+?? .gitignore
+?? done/five
+?? dtwo/
+EOF
+       test_cmp ../status.expect ../status.actual &&
+       cat >../trace.expect <<EOF &&
+node creation: 0
+gitignore invalidation: 0
+directory invalidation: 0
+opendir: 0
+EOF
+       test_cmp ../trace.expect ../trace
+'
+
+test_expect_success 'set up for test of subdir and sparse checkouts' '
+       mkdir done/sub &&
+       mkdir done/sub/sub &&
+       echo "sub" > done/sub/sub/file
+'
+
+test_expect_success 'test sparse status with untracked cache and subdir' '
+       avoid_racy &&
+       : >../trace &&
+       GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
+       git status --porcelain >../status.actual &&
+       cat >../status.expect <<EOF &&
+ M done/two
 ?? .gitignore
 ?? done/five
+?? done/sub/
 ?? dtwo/
 EOF
        test_cmp ../status.expect ../status.actual &&
        cat >../trace.expect <<EOF &&
+node creation: 2
+gitignore invalidation: 0
+directory invalidation: 1
+opendir: 3
+EOF
+       test_cmp ../trace.expect ../trace
+'
+
+test_expect_success 'verify untracked cache dump (sparse/subdirs)' '
+       test-dump-untracked-cache >../actual &&
+       cat >../expect <<EOF &&
+info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
+core.excludesfile 0000000000000000000000000000000000000000
+exclude_per_dir .gitignore
+flags 00000006
+/ e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
+.gitignore
+dtwo/
+/done/ 1946f0437f90c5005533cbe1736a6451ca301714 recurse valid
+five
+sub/
+/done/sub/ 0000000000000000000000000000000000000000 recurse check_only valid
+sub/
+/done/sub/sub/ 0000000000000000000000000000000000000000 recurse check_only valid
+file
+/dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
+/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
+two
+EOF
+       test_cmp ../expect ../actual
+'
+
+test_expect_success 'test sparse status again with untracked cache and subdir' '
+       avoid_racy &&
+       : >../trace &&
+       GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
+       git status --porcelain >../status.actual &&
+       test_cmp ../status.expect ../status.actual &&
+       cat >../trace.expect <<EOF &&
 node creation: 0
 gitignore invalidation: 0
 directory invalidation: 0
@@ -473,4 +543,30 @@ EOF
        test_cmp ../trace.expect ../trace
 '
 
+test_expect_success 'move entry in subdir from untracked to cached' '
+       git add dtwo/two &&
+       git status --porcelain >../status.actual &&
+       cat >../status.expect <<EOF &&
+ M done/two
+A  dtwo/two
+?? .gitignore
+?? done/five
+?? done/sub/
+EOF
+       test_cmp ../status.expect ../status.actual
+'
+
+test_expect_success 'move entry in subdir from cached to untracked' '
+       git rm --cached dtwo/two &&
+       git status --porcelain >../status.actual &&
+       cat >../status.expect <<EOF &&
+ M done/two
+?? .gitignore
+?? done/five
+?? done/sub/
+?? dtwo/
+EOF
+       test_cmp ../status.expect ../status.actual
+'
+
 test_done
diff --git a/t/t7411-submodule-config.sh b/t/t7411-submodule-config.sh
new file mode 100755 (executable)
index 0000000..fc97c33
--- /dev/null
@@ -0,0 +1,153 @@
+#!/bin/sh
+#
+# Copyright (c) 2014 Heiko Voigt
+#
+
+test_description='Test submodules config cache infrastructure
+
+This test verifies that parsing .gitmodules configurations directly
+from the database and from the worktree works.
+'
+
+TEST_NO_CREATE_REPO=1
+. ./test-lib.sh
+
+test_expect_success 'submodule config cache setup' '
+       mkdir submodule &&
+       (cd submodule &&
+               git init &&
+               echo a >a &&
+               git add . &&
+               git commit -ma
+       ) &&
+       mkdir super &&
+       (cd super &&
+               git init &&
+               git submodule add ../submodule &&
+               git submodule add ../submodule a &&
+               git commit -m "add as submodule and as a" &&
+               git mv a b &&
+               git commit -m "move a to b"
+       )
+'
+
+cat >super/expect <<EOF
+Submodule name: 'a' for path 'a'
+Submodule name: 'a' for path 'b'
+Submodule name: 'submodule' for path 'submodule'
+Submodule name: 'submodule' for path 'submodule'
+EOF
+
+test_expect_success 'test parsing and lookup of submodule config by path' '
+       (cd super &&
+               test-submodule-config \
+                       HEAD^ a \
+                       HEAD b \
+                       HEAD^ submodule \
+                       HEAD submodule \
+                               >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'test parsing and lookup of submodule config by name' '
+       (cd super &&
+               test-submodule-config --name \
+                       HEAD^ a \
+                       HEAD a \
+                       HEAD^ submodule \
+                       HEAD submodule \
+                               >actual &&
+               test_cmp expect actual
+       )
+'
+
+cat >super/expect_error <<EOF
+Submodule name: 'a' for path 'b'
+Submodule name: 'submodule' for path 'submodule'
+EOF
+
+test_expect_success 'error in one submodule config lets continue' '
+       (cd super &&
+               cp .gitmodules .gitmodules.bak &&
+               echo "  value = \"" >>.gitmodules &&
+               git add .gitmodules &&
+               mv .gitmodules.bak .gitmodules &&
+               git commit -m "add error" &&
+               test-submodule-config \
+                       HEAD b \
+                       HEAD submodule \
+                               >actual &&
+               test_cmp expect_error actual
+       )
+'
+
+cat >super/expect_url <<EOF
+Submodule url: 'git@somewhere.else.net:a.git' for path 'b'
+Submodule url: 'git@somewhere.else.net:submodule.git' for path 'submodule'
+EOF
+
+cat >super/expect_local_path <<EOF
+Submodule name: 'a' for path 'c'
+Submodule name: 'submodule' for path 'submodule'
+EOF
+
+test_expect_success 'reading of local configuration' '
+       (cd super &&
+               old_a=$(git config submodule.a.url) &&
+               old_submodule=$(git config submodule.submodule.url) &&
+               git config submodule.a.url git@somewhere.else.net:a.git &&
+               git config submodule.submodule.url git@somewhere.else.net:submodule.git &&
+               test-submodule-config --url \
+                       "" b \
+                       "" submodule \
+                               >actual &&
+               test_cmp expect_url actual &&
+               git config submodule.a.path c &&
+               test-submodule-config \
+                       "" c \
+                       "" submodule \
+                               >actual &&
+               test_cmp expect_local_path actual &&
+               git config submodule.a.url $old_a &&
+               git config submodule.submodule.url $old_submodule &&
+               git config --unset submodule.a.path c
+       )
+'
+
+cat >super/expect_fetchrecurse_die.err <<EOF
+fatal: bad submodule.submodule.fetchrecursesubmodules argument: blabla
+EOF
+
+test_expect_success 'local error in fetchrecursesubmodule dies early' '
+       (cd super &&
+               git config submodule.submodule.fetchrecursesubmodules blabla &&
+               test_must_fail test-submodule-config \
+                       "" b \
+                       "" submodule \
+                               >actual.out 2>actual.err &&
+               touch expect_fetchrecurse_die.out &&
+               test_cmp expect_fetchrecurse_die.out actual.out  &&
+               test_cmp expect_fetchrecurse_die.err actual.err  &&
+               git config --unset submodule.submodule.fetchrecursesubmodules
+       )
+'
+
+test_expect_success 'error in history in fetchrecursesubmodule lets continue' '
+       (cd super &&
+               git config -f .gitmodules \
+                       submodule.submodule.fetchrecursesubmodules blabla &&
+               git add .gitmodules &&
+               git config --unset -f .gitmodules \
+                       submodule.submodule.fetchrecursesubmodules &&
+               git commit -m "add error in fetchrecursesubmodules" &&
+               test-submodule-config \
+                       HEAD b \
+                       HEAD submodule \
+                               >actual &&
+               test_cmp expect_error actual  &&
+               git reset --hard HEAD^
+       )
+'
+
+test_done
index bd0ab4675089b54c336ccc9590c4b65bbd37138d..9577b4effb05904f9f6b29b4321b103ebdd52e7f 100755 (executable)
@@ -93,12 +93,25 @@ test_expect_success 'with config option on the command line' '
                Acked-by: Johan
                Reviewed-by: Peff
        EOF
-       echo "Acked-by: Johan" |
+       { echo; echo "Acked-by: Johan"; } |
        git -c "trailer.Acked-by.ifexists=addifdifferent" interpret-trailers \
                --trailer "Reviewed-by: Peff" --trailer "Acked-by: Johan" >actual &&
        test_cmp expected actual
 '
 
+test_expect_success 'with only a title in the message' '
+       cat >expected <<-\EOF &&
+               area: change
+
+               Reviewed-by: Peff
+               Acked-by: Johan
+       EOF
+       echo "area: change" |
+       git interpret-trailers --trailer "Reviewed-by: Peff" \
+               --trailer "Acked-by: Johan" >actual &&
+       test_cmp expected actual
+'
+
 test_expect_success 'with config setup' '
        git config trailer.ack.key "Acked-by: " &&
        cat >expected <<-\EOF &&
diff --git a/t/t9821-git-p4-path-variations.sh b/t/t9821-git-p4-path-variations.sh
new file mode 100755 (executable)
index 0000000..81e46ac
--- /dev/null
@@ -0,0 +1,200 @@
+#!/bin/sh
+
+test_description='Clone repositories with path case variations'
+
+. ./lib-git-p4.sh
+
+test_expect_success 'start p4d with case folding enabled' '
+       start_p4d -C1
+'
+
+test_expect_success 'Create a repo with path case variations' '
+       client_view "//depot/... //client/..." &&
+       (
+               cd "$cli" &&
+
+               mkdir -p Path/to &&
+               >Path/to/File2.txt &&
+               p4 add Path/to/File2.txt &&
+               p4 submit -d "Add file2" &&
+               rm -rf Path &&
+
+               mkdir -p path/TO &&
+               >path/TO/file1.txt &&
+               p4 add path/TO/file1.txt &&
+               p4 submit -d "Add file1" &&
+               rm -rf path &&
+
+               mkdir -p path/to &&
+               >path/to/file3.txt &&
+               p4 add path/to/file3.txt &&
+               p4 submit -d "Add file3" &&
+               rm -rf path &&
+
+               mkdir -p x-outside-spec &&
+               >x-outside-spec/file4.txt &&
+               p4 add x-outside-spec/file4.txt &&
+               p4 submit -d "Add file4" &&
+               rm -rf x-outside-spec
+       )
+'
+
+test_expect_success 'Clone root' '
+       client_view "//depot/... //client/..." &&
+       test_when_finished cleanup_git &&
+       (
+               cd "$git" &&
+               git init . &&
+               git config core.ignorecase false &&
+               git p4 clone --use-client-spec --destination="$git" //depot &&
+               # This method is used instead of "test -f" to ensure the case is
+               # checked even if the test is executed on case-insensitive file systems.
+               # All files are there as expected although the path cases look random.
+               cat >expect <<-\EOF &&
+               Path/to/File2.txt
+               path/TO/file1.txt
+               path/to/file3.txt
+               x-outside-spec/file4.txt
+               EOF
+               git ls-files >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'Clone root (ignorecase)' '
+       client_view "//depot/... //client/..." &&
+       test_when_finished cleanup_git &&
+       (
+               cd "$git" &&
+               git init . &&
+               git config core.ignorecase true &&
+               git p4 clone --use-client-spec --destination="$git" //depot &&
+               # This method is used instead of "test -f" to ensure the case is
+               # checked even if the test is executed on case-insensitive file systems.
+               # All files are there as expected although the path cases look random.
+               cat >expect <<-\EOF &&
+               path/TO/File2.txt
+               path/TO/file1.txt
+               path/TO/file3.txt
+               x-outside-spec/file4.txt
+               EOF
+               git ls-files >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'Clone root and ignore one file' '
+       client_view \
+               "//depot/... //client/..." \
+               "-//depot/path/TO/file1.txt //client/path/TO/file1.txt" &&
+       test_when_finished cleanup_git &&
+       (
+               cd "$git" &&
+               git init . &&
+               git config core.ignorecase false &&
+               git p4 clone --use-client-spec --destination="$git" //depot &&
+               # We ignore one file in the client spec and all path cases change from
+               # "TO" to "to"!
+               cat >expect <<-\EOF &&
+               Path/to/File2.txt
+               path/to/file3.txt
+               x-outside-spec/file4.txt
+               EOF
+               git ls-files >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'Clone root and ignore one file (ignorecase)' '
+       client_view \
+               "//depot/... //client/..." \
+               "-//depot/path/TO/file1.txt //client/path/TO/file1.txt" &&
+       test_when_finished cleanup_git &&
+       (
+               cd "$git" &&
+               git init . &&
+               git config core.ignorecase true &&
+               git p4 clone --use-client-spec --destination="$git" //depot &&
+               # We ignore one file in the client spec and all path cases change from
+               # "TO" to "to"!
+               cat >expect <<-\EOF &&
+               Path/to/File2.txt
+               Path/to/file3.txt
+               x-outside-spec/file4.txt
+               EOF
+               git ls-files >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'Clone path' '
+       client_view "//depot/Path/... //client/..." &&
+       test_when_finished cleanup_git &&
+       (
+               cd "$git" &&
+               git init . &&
+               git config core.ignorecase false &&
+               git p4 clone --use-client-spec --destination="$git" //depot &&
+               cat >expect <<-\EOF &&
+               to/File2.txt
+               EOF
+               git ls-files >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'Clone path (ignorecase)' '
+       client_view "//depot/Path/... //client/..." &&
+       test_when_finished cleanup_git &&
+       (
+               cd "$git" &&
+               git init . &&
+               git config core.ignorecase true &&
+               git p4 clone --use-client-spec --destination="$git" //depot &&
+               cat >expect <<-\EOF &&
+               TO/File2.txt
+               TO/file1.txt
+               TO/file3.txt
+               EOF
+               git ls-files >actual &&
+               test_cmp expect actual
+       )
+'
+
+# It looks like P4 determines the path case based on the first file in
+# lexicographical order. Please note the lower case "to" directory for all
+# files triggered through the addition of "File0.txt".
+test_expect_success 'Add a new file and clone path with new file (ignorecase)' '
+       client_view "//depot/... //client/..." &&
+       (
+               cd "$cli" &&
+               mkdir -p Path/to &&
+               >Path/to/File0.txt &&
+               p4 add Path/to/File0.txt &&
+               p4 submit -d "Add file" &&
+               rm -rf Path
+       ) &&
+
+       client_view "//depot/Path/... //client/..." &&
+       test_when_finished cleanup_git &&
+       (
+               cd "$git" &&
+               git init . &&
+               git config core.ignorecase true &&
+               git p4 clone --use-client-spec --destination="$git" //depot &&
+               cat >expect <<-\EOF &&
+               to/File0.txt
+               to/File2.txt
+               to/file1.txt
+               to/file3.txt
+               EOF
+               git ls-files >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'kill p4d' '
+       kill_p4d
+'
+
+test_done
diff --git a/test-submodule-config.c b/test-submodule-config.c
new file mode 100644 (file)
index 0000000..dab8c27
--- /dev/null
@@ -0,0 +1,76 @@
+#include "cache.h"
+#include "submodule-config.h"
+#include "submodule.h"
+
+static void die_usage(int argc, char **argv, const char *msg)
+{
+       fprintf(stderr, "%s\n", msg);
+       fprintf(stderr, "Usage: %s [<commit> <submodulepath>] ...\n", argv[0]);
+       exit(1);
+}
+
+static int git_test_config(const char *var, const char *value, void *cb)
+{
+       return parse_submodule_config_option(var, value);
+}
+
+int main(int argc, char **argv)
+{
+       char **arg = argv;
+       int my_argc = argc;
+       int output_url = 0;
+       int lookup_name = 0;
+
+       arg++;
+       my_argc--;
+       while (starts_with(arg[0], "--")) {
+               if (!strcmp(arg[0], "--url"))
+                       output_url = 1;
+               if (!strcmp(arg[0], "--name"))
+                       lookup_name = 1;
+               arg++;
+               my_argc--;
+       }
+
+       if (my_argc % 2 != 0)
+               die_usage(argc, argv, "Wrong number of arguments.");
+
+       setup_git_directory();
+       gitmodules_config();
+       git_config(git_test_config, NULL);
+
+       while (*arg) {
+               unsigned char commit_sha1[20];
+               const struct submodule *submodule;
+               const char *commit;
+               const char *path_or_name;
+
+               commit = arg[0];
+               path_or_name = arg[1];
+
+               if (commit[0] == '\0')
+                       hashcpy(commit_sha1, null_sha1);
+               else if (get_sha1(commit, commit_sha1) < 0)
+                       die_usage(argc, argv, "Commit not found.");
+
+               if (lookup_name) {
+                       submodule = submodule_from_name(commit_sha1, path_or_name);
+               } else
+                       submodule = submodule_from_path(commit_sha1, path_or_name);
+               if (!submodule)
+                       die_usage(argc, argv, "Submodule not found.");
+
+               if (output_url)
+                       printf("Submodule url: '%s' for path '%s'\n",
+                                       submodule->url, submodule->path);
+               else
+                       printf("Submodule name: '%s' for path '%s'\n",
+                                       submodule->name, submodule->path);
+
+               arg += 2;
+       }
+
+       submodule_free();
+
+       return 0;
+}
index 4b14a567b418acd3181fcf6e37f246c91d60eb60..b8088687d407eaafd6ac3f5680cebb2fe64dc80b 100644 (file)
--- a/trailer.c
+++ b/trailer.c
@@ -740,8 +740,10 @@ static int find_trailer_start(struct strbuf **lines, int count)
        /*
         * Get the start of the trailers by looking starting from the end
         * for a line with only spaces before lines with one separator.
+        * The first line must not be analyzed as the others as it
+        * should be either the message title or a blank line.
         */
-       for (start = count - 1; start >= 0; start--) {
+       for (start = count - 1; start >= 1; start--) {
                if (lines[start]->buf[0] == comment_line_char)
                        continue;
                if (contains_only_spaces(lines[start]->buf)) {
index 68e498eebdda08f992e11154039e2e94e58f10d1..99f1ace1f2b56c359eba6736d1f0ab0fb49ba980 100644 (file)
@@ -257,7 +257,6 @@ static const char *boolean_options[] = {
        TRANS_OPT_THIN,
        TRANS_OPT_KEEP,
        TRANS_OPT_FOLLOWTAGS,
-       TRANS_OPT_PUSH_CERT
        };
 
 static int set_helper_option(struct transport *transport,
@@ -764,6 +763,21 @@ static int push_update_refs_status(struct helper_data *data,
        return ret;
 }
 
+static void set_common_push_options(struct transport *transport,
+                                  const char *name, int flags)
+{
+       if (flags & TRANSPORT_PUSH_DRY_RUN) {
+               if (set_helper_option(transport, "dry-run", "true") != 0)
+                       die("helper %s does not support dry-run", name);
+       } else if (flags & TRANSPORT_PUSH_CERT_ALWAYS) {
+               if (set_helper_option(transport, TRANS_OPT_PUSH_CERT, "true") != 0)
+                       die("helper %s does not support --signed", name);
+       } else if (flags & TRANSPORT_PUSH_CERT_IF_ASKED) {
+               if (set_helper_option(transport, TRANS_OPT_PUSH_CERT, "if-asked") != 0)
+                       die("helper %s does not support --signed=if-asked", name);
+       }
+}
+
 static int push_refs_with_push(struct transport *transport,
                               struct ref *remote_refs, int flags)
 {
@@ -831,14 +845,7 @@ static int push_refs_with_push(struct transport *transport,
 
        for_each_string_list_item(cas_option, &cas_options)
                set_helper_option(transport, "cas", cas_option->string);
-
-       if (flags & TRANSPORT_PUSH_DRY_RUN) {
-               if (set_helper_option(transport, "dry-run", "true") != 0)
-                       die("helper %s does not support dry-run", data->name);
-       } else if (flags & TRANSPORT_PUSH_CERT) {
-               if (set_helper_option(transport, TRANS_OPT_PUSH_CERT, "true") != 0)
-                       die("helper %s does not support --signed", data->name);
-       }
+       set_common_push_options(transport, data->name, flags);
 
        strbuf_addch(&buf, '\n');
        sendline(data, &buf);
@@ -859,14 +866,7 @@ static int push_refs_with_export(struct transport *transport,
        if (!data->refspecs)
                die("remote-helper doesn't support push; refspec needed");
 
-       if (flags & TRANSPORT_PUSH_DRY_RUN) {
-               if (set_helper_option(transport, "dry-run", "true") != 0)
-                       die("helper %s does not support dry-run", data->name);
-       } else if (flags & TRANSPORT_PUSH_CERT) {
-               if (set_helper_option(transport, TRANS_OPT_PUSH_CERT, "true") != 0)
-                       die("helper %s does not support --signed", data->name);
-       }
-
+       set_common_push_options(transport, data->name, flags);
        if (flags & TRANSPORT_PUSH_FORCE) {
                if (set_helper_option(transport, "force", "true") != 0)
                        warning("helper %s does not support 'force'", data->name);
index 40692f8ae8aba65001bdee1300e525def1e1870d..2d51348f3f3a5be03b2d00ec6530ac4cabfbf7c6 100644 (file)
@@ -291,7 +291,7 @@ static int write_one_ref(const char *name, const struct object_id *oid,
 
        strbuf_addstr(buf, name);
        if (safe_create_leading_directories(buf->buf) ||
-           write_file(buf->buf, 0, "%s\n", oid_to_hex(oid)))
+           write_file_gently(buf->buf, "%s", oid_to_hex(oid)))
                return error("problems writing temporary file %s: %s",
                             buf->buf, strerror(errno));
        strbuf_setlen(buf, len);
@@ -476,9 +476,6 @@ static int set_git_option(struct git_transport_options *opts,
                                die("transport: invalid depth option '%s'", value);
                }
                return 0;
-       } else if (!strcmp(name, TRANS_OPT_PUSH_CERT)) {
-               opts->push_cert = !!value;
-               return 0;
        }
        return 1;
 }
@@ -829,10 +826,16 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
        args.progress = transport->progress;
        args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);
        args.porcelain = !!(flags & TRANSPORT_PUSH_PORCELAIN);
-       args.push_cert = !!(flags & TRANSPORT_PUSH_CERT);
        args.atomic = !!(flags & TRANSPORT_PUSH_ATOMIC);
        args.url = transport->url;
 
+       if (flags & TRANSPORT_PUSH_CERT_ALWAYS)
+               args.push_cert = SEND_PACK_PUSH_CERT_ALWAYS;
+       else if (flags & TRANSPORT_PUSH_CERT_IF_ASKED)
+               args.push_cert = SEND_PACK_PUSH_CERT_IF_ASKED;
+       else
+               args.push_cert = SEND_PACK_PUSH_CERT_NEVER;
+
        ret = send_pack(&args, data->fd, data->conn, remote_refs,
                        &data->extra_have);
 
index 18d2cf8275e1f5f6ff3d18afde55d06ed7586af9..d682b77b9e3be70954f3552813f66718d7262151 100644 (file)
@@ -12,7 +12,6 @@ struct git_transport_options {
        unsigned check_self_contained_and_connected : 1;
        unsigned self_contained_and_connected : 1;
        unsigned update_shallow : 1;
-       unsigned push_cert : 1;
        int depth;
        const char *uploadpack;
        const char *receivepack;
@@ -124,8 +123,9 @@ struct transport {
 #define TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND 256
 #define TRANSPORT_PUSH_NO_HOOK 512
 #define TRANSPORT_PUSH_FOLLOW_TAGS 1024
-#define TRANSPORT_PUSH_CERT 2048
-#define TRANSPORT_PUSH_ATOMIC 4096
+#define TRANSPORT_PUSH_CERT_ALWAYS 2048
+#define TRANSPORT_PUSH_CERT_IF_ASKED 4096
+#define TRANSPORT_PUSH_ATOMIC 8192
 
 #define TRANSPORT_SUMMARY_WIDTH (2 * DEFAULT_ABBREV + 3)
 #define TRANSPORT_SUMMARY(x) (int)(TRANSPORT_SUMMARY_WIDTH + strlen(x) - gettext_width(x)), (x)
index e4514634313c44354190e0c7e08a2b501aa0b098..0e22d4381438b2c262e1cd5ee0cc4effc2fb3c3d 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -621,19 +621,18 @@ char *xgetcwd(void)
        return strbuf_detach(&sb, NULL);
 }
 
-int write_file(const char *path, int fatal, const char *fmt, ...)
+static int write_file_v(const char *path, int fatal,
+                       const char *fmt, va_list params)
 {
        struct strbuf sb = STRBUF_INIT;
-       va_list params;
        int fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666);
        if (fd < 0) {
                if (fatal)
                        die_errno(_("could not open %s for writing"), path);
                return -1;
        }
-       va_start(params, fmt);
        strbuf_vaddf(&sb, fmt, params);
-       va_end(params);
+       strbuf_complete_line(&sb);
        if (write_in_full(fd, sb.buf, sb.len) != sb.len) {
                int err = errno;
                close(fd);
@@ -652,6 +651,28 @@ int write_file(const char *path, int fatal, const char *fmt, ...)
        return 0;
 }
 
+int write_file(const char *path, const char *fmt, ...)
+{
+       int status;
+       va_list params;
+
+       va_start(params, fmt);
+       status = write_file_v(path, 1, fmt, params);
+       va_end(params);
+       return status;
+}
+
+int write_file_gently(const char *path, const char *fmt, ...)
+{
+       int status;
+       va_list params;
+
+       va_start(params, fmt);
+       status = write_file_v(path, 0, fmt, params);
+       va_end(params);
+       return status;
+}
+
 void sleep_millisec(int millisec)
 {
        poll(NULL, 0, millisec);
index 717fd48d13eb75730ed44a786473c7662173891c..c327fe8128fdb2e380db15f526056a22862ac33f 100644 (file)
@@ -1,5 +1,4 @@
 #include "cache.h"
-#include "pathspec.h"
 #include "wt-status.h"
 #include "object.h"
 #include "dir.h"
index e0a99f75c745acd3e7fb6fd8aecd06a4d3bd5522..c9b3b744e923f2f559f64f1bf4a1f2159b5060d6 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdio.h>
 #include "string-list.h"
 #include "color.h"
+#include "pathspec.h"
 
 enum color_wt_status {
        WT_STATUS_HEADER = 0,