gitweb.git
Merge branch 'fc/completion-send-email-with-format... Jeff King Fri, 9 Nov 2012 17:50:45 +0000 (12:50 -0500)

Merge branch 'fc/completion-send-email-with-format-patch'

* fc/completion-send-email-with-format-patch:
completion: add format-patch options to send-email

Merge branch 'mo/cvs-server-cleanup'Jeff King Fri, 9 Nov 2012 17:50:36 +0000 (12:50 -0500)

Merge branch 'mo/cvs-server-cleanup'

Cleanups to prepare for mo/cvs-server-updates.

* mo/cvs-server-cleanup:
Use character class for sed expression instead of \s
cvsserver status: provide real sticky info
cvsserver: cvs add: do not expand directory arguments
cvsserver: use whole CVS rev number in-process; don't strip "1." prefix
cvsserver: split up long lines in req_{status,diff,log}
cvsserver: clean up client request handler map comments
cvsserver: remove unused functions _headrev and gethistory
cvsserver update: comment about how we shouldn't remove a user-modified file
cvsserver: add comments about database schema/usage
cvsserver: removed unused sha1Or-k mode from kopts_from_path
cvsserver t9400: add basic 'cvs log' test

Merge branch 'km/send-email-compose-encoding'Jeff King Fri, 9 Nov 2012 17:50:29 +0000 (12:50 -0500)

Merge branch 'km/send-email-compose-encoding'

"git send-email --compose" can let the user create a non-ascii
cover letter message, but there was not a way to mark it with
appropriate content type before sending it out.

Further updates fix subject quoting.

* km/send-email-compose-encoding:
git-send-email: add rfc2047 quoting for "=?"
git-send-email: introduce quote_subject()
git-send-email: skip RFC2047 quoting for ASCII subjects
git-send-email: use compose-encoding for Subject
git-send-email: introduce compose-encoding

Merge branch 'js/format-2047'Jeff King Fri, 9 Nov 2012 17:42:32 +0000 (12:42 -0500)

Merge branch 'js/format-2047'

Fixes many rfc2047 quoting issues in the output from format-patch.

* js/format-2047:
format-patch tests: check quoting/encoding in To: and Cc: headers
format-patch: fix rfc2047 address encoding with respect to rfc822 specials
format-patch: make rfc2047 encoding more strict
format-patch: introduce helper function last_line_length()
format-patch: do not wrap rfc2047 encoded headers too late
format-patch: do not wrap non-rfc2047 headers too early
utf8: fix off-by-one wrapping of text

Merge branch 'rs/lock-correct-ref-during-delete'Jeff King Fri, 9 Nov 2012 17:42:28 +0000 (12:42 -0500)

Merge branch 'rs/lock-correct-ref-during-delete'

When "update-ref -d --no-deref SYM" tried to delete a symbolic ref
SYM, it incorrectly locked the underlying reference pointed by SYM,
not the symbolic ref itself.

* rs/lock-correct-ref-during-delete:
refs: lock symref that is to be deleted, not its target

Merge branch 'nd/attr-match-optim-more'Jeff King Fri, 9 Nov 2012 17:42:25 +0000 (12:42 -0500)

Merge branch 'nd/attr-match-optim-more'

Start laying the foundation to build the "wildmatch" after we can
agree on its desired semantics.

* nd/attr-match-optim-more:
attr: more matching optimizations from .gitignore
gitignore: make pattern parsing code a separate function
exclude: split pathname matching code into a separate function
exclude: fix a bug in prefix compare optimization
exclude: split basename matching code into a separate function
exclude: stricten a length check in EXC_FLAG_ENDSWITH case

Merge branch 'mh/maint-parse-dirstat-fix'Jeff King Fri, 9 Nov 2012 17:42:21 +0000 (12:42 -0500)

Merge branch 'mh/maint-parse-dirstat-fix'

Cleans up some code and avoids a potential bug.

* mh/maint-parse-dirstat-fix:
parse_dirstat_params(): use string_list to split comma-separated string

doc/fast-import: clarify how content states are builtEric S. Raymond Mon, 5 Nov 2012 04:31:01 +0000 (23:31 -0500)

doc/fast-import: clarify how content states are built

Signed-off-by: Eric S. Raymond <esr@thyrsus.com>
Signed-off-by: Jeff King <peff@peff.net>

gitweb.perl: fix %highlight_ext mappingsRichard Hubbell Sun, 4 Nov 2012 17:45:55 +0000 (09:45 -0800)

gitweb.perl: fix %highlight_ext mappings

When commit 592ea41 refactored the list of extensions for
syntax highlighting, it failed to take into account perl's
operator precedence within lists. As a result, we end up
creating a dictionary of one-to-one elements when the intent
was to map mutliple related types to one main type (e.g.,
bash, ksh, zsh, and sh should all map to sh since they share
similar syntax, but we ended up just mapping "bash" to
"bash" and so forth).

This patch adds parentheses to make the mapping as the
original change intended. It also reorganizes the list to
keep mapped extensions together.

Signed-off-by: Richard Hubbell <richard_hubbe11@lavabit.com>
Signed-off-by: Jeff King <peff@peff.net>

git p4: RCS expansion should not span newlinesPete Wyckoff Sun, 4 Nov 2012 22:04:02 +0000 (17:04 -0500)

git p4: RCS expansion should not span newlines

This bug was introduced in cb585a9 (git-p4: keyword
flattening fixes, 2011-10-16). The newline character
is indeed special, and $File$ expansions should not try
to match across multiple lines.

Based-on-patch-by: Chris Goard <cgoard@gmail.com>
Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Jeff King <peff@peff.net>

link_alt_odb_entries(): take (char *, len) rather than... Michael Haggerty Mon, 5 Nov 2012 08:41:23 +0000 (09:41 +0100)

link_alt_odb_entries(): take (char *, len) rather than two pointers

Change link_alt_odb_entries() to take the length of the "alt"
parameter rather than a pointer to the end of the "alt" string. This
is the more common calling convention and simplifies the code a tiny
bit.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>

link_alt_odb_entries(): use string_list_split_in_place()Michael Haggerty Mon, 5 Nov 2012 08:41:22 +0000 (09:41 +0100)

link_alt_odb_entries(): use string_list_split_in_place()

Change link_alt_odb_entry() to take a NUL-terminated string instead of
(char *, len). Use string_list_split_in_place() rather than inline
code in link_alt_odb_entries().

This approach saves some code and also avoids the (probably harmless)
error of passing a non-NUL-terminated string to is_absolute_path().

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>

string_list_add_refs_from_colon_sep(): use string_list_... Michael Haggerty Sun, 4 Nov 2012 07:07:10 +0000 (08:07 +0100)

string_list_add_refs_from_colon_sep(): use string_list_split()

It makes for simpler code than strbuf_split().

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Acked-by: Johan Herland <johan@herland.net>
Signed-off-by: Jeff King <peff@peff.net>

notes: fix handling of colon-separated valuesMichael Haggerty Sun, 4 Nov 2012 07:07:09 +0000 (08:07 +0100)

notes: fix handling of colon-separated values

The substrings output by strbuf_split() include the ':' delimiters.
When processing GIT_NOTES_DISPLAY_REF and GIT_NOTES_REWRITE_REF, strip
off the delimiter character *before* checking whether the substring is
empty rather than after, so that empty strings within the list are
also skipped.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Acked-by: Johan Herland <johan@herland.net>
Signed-off-by: Jeff King <peff@peff.net>

combine_notes_cat_sort_uniq(): sort and dedup lines... Michael Haggerty Sun, 4 Nov 2012 07:07:08 +0000 (08:07 +0100)

combine_notes_cat_sort_uniq(): sort and dedup lines all at once

Instead of reading lines one by one and insertion-sorting them into a
string_list, read all of the lines, sort them, then remove duplicates.
Aside from being less code, this reduces the complexity from O(N^2) to
O(N lg N) in the total number of lines.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Acked-by: Johan Herland <johan@herland.net>
Signed-off-by: Jeff King <peff@peff.net>

Initialize sort_uniq_list using named constantMichael Haggerty Sun, 4 Nov 2012 07:07:07 +0000 (08:07 +0100)

Initialize sort_uniq_list using named constant

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Acked-by: Johan Herland <johan@herland.net>
Signed-off-by: Jeff King <peff@peff.net>

string_list: add a function string_list_remove_empty_it... Michael Haggerty Sun, 4 Nov 2012 07:07:06 +0000 (08:07 +0100)

string_list: add a function string_list_remove_empty_items()

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Acked-by: Johan Herland <johan@herland.net>
Signed-off-by: Jeff King <peff@peff.net>

push/pull: adjust missing upstream help text to changed... Michael J Gruber Tue, 6 Nov 2012 10:29:01 +0000 (11:29 +0100)

push/pull: adjust missing upstream help text to changed interface

In case of a missing upstream, the git-parse-remote script suggests:

If you wish to set tracking information for this branch you can do so
with:

git branch --set-upstream nsiv2 origin/<branch>

But --set-upstream is deprectated. Change the suggestion to:

git branch --set-upstream-to=origin/<branch> nsiv2

Reported-by: Jeroen van der Ham <vdham@uva.nl>
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Jeff King <peff@peff.net>

reencode_string(): introduce and use same_encoding()Junio C Hamano Fri, 19 Oct 2012 05:41:56 +0000 (22:41 -0700)

reencode_string(): introduce and use same_encoding()

Callers of reencode_string() that re-encodes a string from one
encoding to another all used ad-hoc way to bypass the case where the
input and the output encodings are the same. Some did strcmp(),
some did strcasecmp(), yet some others when converting to UTF-8 used
is_encoding_utf8().

Introduce same_encoding() helper function to make these callers use
the same logic. Notably, is_encoding_utf8() has a work-around for
common misconfiguration to use "utf8" to name UTF-8 encoding, which
does not match "UTF-8" hence strcasecmp() would not consider the
same. Make use of it in this helper function.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

cvsimport: work around perl tzset issueJeff King Sun, 4 Nov 2012 12:25:36 +0000 (07:25 -0500)

cvsimport: work around perl tzset issue

On many platforms, the first invocation of localtime_r will
check $TZ in the environment, but subsequent invocations
will use a cached value. That means that setting $ENV{TZ} in
the middle of the program may or may not have an effect on
later calls to localtime. Perl 5.10.0 and later handles
this automatically for us, but we try to remain portable
back to 5.8. Work around it by calling tzset ourselves.

Merge branch 'tj/maint-doc-commit-sign'Jeff King Sun, 4 Nov 2012 13:00:47 +0000 (08:00 -0500)

Merge branch 'tj/maint-doc-commit-sign'

* tj/maint-doc-commit-sign:
Add -S, --gpg-sign option to manpage of "git commit"

Merge branch 'pp/maint-doc-pager-config'Jeff King Sun, 4 Nov 2012 13:00:37 +0000 (08:00 -0500)

Merge branch 'pp/maint-doc-pager-config'

* pp/maint-doc-pager-config:
Documentation: improve the example of overriding LESS via core.pager

Merge branch 'km/maint-doc-git-reset'Jeff King Sun, 4 Nov 2012 13:00:33 +0000 (08:00 -0500)

Merge branch 'km/maint-doc-git-reset'

* km/maint-doc-git-reset:
doc: git-reset: make "<mode>" optional

Merge branch 'tb/maint-t9200-case-insensitive'Jeff King Sun, 4 Nov 2012 13:00:29 +0000 (08:00 -0500)

Merge branch 'tb/maint-t9200-case-insensitive'

* tb/maint-t9200-case-insensitive:
Fix t9200 on case insensitive file systems

Merge branch 'rf/maint-mailmap-off-by-one'Jeff King Sun, 4 Nov 2012 13:00:23 +0000 (08:00 -0500)

Merge branch 'rf/maint-mailmap-off-by-one'

* rf/maint-mailmap-off-by-one:
mailmap: avoid out-of-bounds memory access

Merge branch 'gb/maint-doc-svn-log-window-size'Jeff King Sun, 4 Nov 2012 13:00:21 +0000 (08:00 -0500)

Merge branch 'gb/maint-doc-svn-log-window-size'

* gb/maint-doc-svn-log-window-size:
Document git-svn fetch --log-window-size parameter

Merge branch 'sz/maint-submodule-reference-arg'Jeff King Sun, 4 Nov 2012 13:00:16 +0000 (08:00 -0500)

Merge branch 'sz/maint-submodule-reference-arg'

* sz/maint-submodule-reference-arg:
submodule add: fix handling of --reference=<repo> option

Merge branch 'sl/maint-configure-messages'Jeff King Sun, 4 Nov 2012 13:00:13 +0000 (08:00 -0500)

Merge branch 'sl/maint-configure-messages'

Minor message fixes for the configure script.

* sl/maint-configure-messages:
configure: fix some output message

Merge branch 'po/maint-refs-replace-docs'Jeff King Sun, 4 Nov 2012 13:00:11 +0000 (08:00 -0500)

Merge branch 'po/maint-refs-replace-docs'

The refs/replace hierarchy was not mentioned in the
repository-layout docs.

* po/maint-refs-replace-docs:
Doc repository-layout: Show refs/replace

Merge branch 'ph/pull-rebase-detached'Jeff King Sun, 4 Nov 2012 13:00:06 +0000 (08:00 -0500)

Merge branch 'ph/pull-rebase-detached'

Avoids spewing error messages when using "pull --rebase" on a
detached HEAD.

* ph/pull-rebase-detached:
git-pull: Avoid merge-base on detached head

Merge branch 'mm/maint-doc-remote-tracking'Jeff King Sun, 4 Nov 2012 12:59:57 +0000 (07:59 -0500)

Merge branch 'mm/maint-doc-remote-tracking'

We long ago hyphenated "remote-tracking branch"; this
catches some new instances added since then.

* mm/maint-doc-remote-tracking:
Documentation: remote tracking branch -> remote-tracking branch

strbuf_split*(): document functionsMichael Haggerty Sun, 4 Nov 2012 06:46:54 +0000 (07:46 +0100)

strbuf_split*(): document functions

Document strbuf_split_buf(), strbuf_split_str(), strbuf_split_max(),
strbuf_split(), and strbuf_list_free() in the header file and in
api-strbuf.txt. (These functions were previously completely
undocumented.)

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>

strbuf_split*(): rename "delim" parameter to "terminator"Michael Haggerty Sun, 4 Nov 2012 06:46:53 +0000 (07:46 +0100)

strbuf_split*(): rename "delim" parameter to "terminator"

The word "delimiter" suggests that the argument separates the
substrings, whereas in fact (1) the delimiter characters are included
in the output, and (2) if the input string ends with the delimiter,
then the output does not include a final empty string. So rename the
"delim" arguments of the strbuf_split() family of functions to
"terminator", which is more suggestive of how it is used.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>

strbuf_split_buf(): simplify iterationMichael Haggerty Sun, 4 Nov 2012 06:46:52 +0000 (07:46 +0100)

strbuf_split_buf(): simplify iteration

While iterating, update str and slen to keep track of the part of the
string that hasn't been processed yet rather than computing things
relative to the start of the original string. This eliminates one
local variable, reduces the scope of another, and reduces the amount
of arithmetic needed within the loop.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>

strbuf_split_buf(): use ALLOC_GROW()Michael Haggerty Sun, 4 Nov 2012 06:46:51 +0000 (07:46 +0100)

strbuf_split_buf(): use ALLOC_GROW()

Use ALLOC_GROW() rather than inline code to manage memory in
strbuf_split_buf(). Rename "pos" to "nr" because it better describes
the use of the variable and it better conforms to the "ALLOC_GROW"
idiom.

Also, instead of adding a sentinal NULL value after each entry is
added to the list, only add it once after all of the entries have been
added.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>

update-index/diff-index: use core.preloadindex to impro... Karsten Blees Tue, 30 Oct 2012 09:50:42 +0000 (10:50 +0100)

update-index/diff-index: use core.preloadindex to improve performance

'update-index --refresh' and 'diff-index' (without --cached) don't honor
the core.preloadindex setting yet. Porcelain commands using these (such as
git [svn] rebase) suffer from this, especially on Windows.

Use read_cache_preload to improve performance.

Additionally, in builtin/diff.c, don't preload index status if we don't
access the working copy (--cached).

Results with msysgit on WebKit repo (2GB in 200k files):

| update-index | diff-index | rebase
----------------+--------------+------------+---------
msysgit-v1.8.0 | 9.157s | 10.536s | 42.791s
+ preloadindex | 9.157s | 10.536s | 28.725s
+ this patch | 2.329s | 2.752s | 15.152s
+ fscache [1] | 0.731s | 1.171s | 8.877s

[1] https://github.com/kblees/git/tree/kb/fscache-v3

Thanks-to: Albert Krawczyk <pro-logic@optusnet.com.au>
Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Jeff King <peff@peff.net>

commit: fixup misplacement of --no-post-rewrite descriptionAndreas Schwab Fri, 2 Nov 2012 12:26:47 +0000 (13:26 +0100)

commit: fixup misplacement of --no-post-rewrite description

In e858af6 (commit: document a couple of options) the description of the
--no-post-rewrite option was put inside the paragraph for the --amend
option. Move it down after the paragraph.

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Jeff King <peff@peff.net>

Document 'git commit --no-edit' explicitlyMatthieu Moy Fri, 2 Nov 2012 10:39:30 +0000 (11:39 +0100)

Document 'git commit --no-edit' explicitly

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Jeff King <peff@peff.net>

remote-curl: retry failed requests for auth even with... Jeff King Wed, 31 Oct 2012 11:29:16 +0000 (07:29 -0400)

remote-curl: retry failed requests for auth even with gzip

Commit b81401c taught the post_rpc function to retry the
http request after prompting for credentials. However, it
did not handle two cases:

1. If we have a large request, we do not retry. That's OK,
since we would have sent a probe (with retry) already.

2. If we are gzipping the request, we do not retry. That
was considered OK, because the intended use was for
push (e.g., listing refs is OK, but actually pushing
objects is not), and we never gzip on push.

This patch teaches post_rpc to retry even a gzipped request.
This has two advantages:

1. It is possible to configure a "half-auth" state for
fetching, where the set of refs and their sha1s are
advertised, but one cannot actually fetch objects.

This is not a recommended configuration, as it leaks
some information about what is in the repository (e.g.,
an attacker can try brute-forcing possible content in
your repository and checking whether it matches your
branch sha1). However, it can be slightly more
convenient, since a no-op fetch will not require a
password at all.

2. It future-proofs us should we decide to ever gzip more
requests.

Signed-off-by: Jeff King <peff@peff.net>

remote-curl: hoist gzip buffer size to top of post_rpcJeff King Wed, 31 Oct 2012 11:20:15 +0000 (07:20 -0400)

remote-curl: hoist gzip buffer size to top of post_rpc

When we gzip the post data for a smart-http rpc request, we
compute the gzip body and its size inside the "use_gzip"
conditional. We keep track of the body after the conditional
ends, but not the size. Let's remember both, which will
enable us to retry failed gzip requests in a future patch.

Signed-off-by: Jeff King <peff@peff.net>

fix 'make test' for HP NonStopJoachim Schmitz Tue, 30 Oct 2012 09:21:40 +0000 (10:21 +0100)

fix 'make test' for HP NonStop

This fixes the vast majority of test failures on HP NonStop.
Some test don't work with /bin/diff, some fail with /bin/tar,
so let's put /usr/local/bin in PATH first.
Some tests fail with /bin/sh (link to /bin/ksh) so use bash instead

Signed-off-by: Joachim Schmitz <jojo@schmitz-digital.de>
Signed-off-by: Jeff King <peff@peff.net>

Add -S, --gpg-sign option to manpage of "git commit"Tom Jones Sun, 21 Oct 2012 19:46:37 +0000 (20:46 +0100)

Add -S, --gpg-sign option to manpage of "git commit"

git commit -S, --gpg-sign was mentioned in the program's help message,
but not in the manpage.

This adds an equivalent entry for the option in the manpage.

Signed-off-by: Tom Jones <tom@oxix.org>
Signed-off-by: Jeff King <peff@peff.net>

Merge branch 'rs/branch-del-symref'Jeff King Mon, 29 Oct 2012 08:15:04 +0000 (04:15 -0400)

Merge branch 'rs/branch-del-symref'

A symbolic ref refs/heads/SYM was not correctly removed with
"git branch -d SYM"; the command removed the ref pointed by
SYM instead.

* rs/branch-del-symref:
branch: show targets of deleted symrefs, not sha1s
branch: skip commit checks when deleting symref branches
branch: delete symref branch, not its target
branch: factor out delete_branch_config()
branch: factor out check_branch_commit()

Merge branch 'nd/status-long'Jeff King Mon, 29 Oct 2012 08:14:57 +0000 (04:14 -0400)

Merge branch 'nd/status-long'

Allow an earlier "--short" option on the command line to be
countermanded with the "--long" option for "git status" and "git
commit".

* nd/status-long:
status: add --long output format option

Merge branch 'jk/sh-setup-in-filter-branch'Jeff King Mon, 29 Oct 2012 08:13:49 +0000 (04:13 -0400)

Merge branch 'jk/sh-setup-in-filter-branch'

Refactoring to avoid code duplication in shell scripts.

* jk/sh-setup-in-filter-branch:
filter-branch: use git-sh-setup's ident parsing functions
git-sh-setup: refactor ident-parsing functions

Merge branch 'nd/grep-true-path'Jeff King Mon, 29 Oct 2012 08:13:16 +0000 (04:13 -0400)

Merge branch 'nd/grep-true-path'

"git grep -e pattern <tree>" asked the attribute system to read
"<tree>:.gitattributes" file in the working tree, which was
nonsense.

* nd/grep-true-path:
grep: stop looking at random places for .gitattributes

Merge branch 'jk/maint-http-init-not-in-result-handler'Jeff King Mon, 29 Oct 2012 08:13:09 +0000 (04:13 -0400)

Merge branch 'jk/maint-http-init-not-in-result-handler'

Further clean-up to the http codepath that picks up results after
cURL library is done with one request slot.

* jk/maint-http-init-not-in-result-handler:
http: do not set up curl auth after a 401
remote-curl: do not call run_slot repeatedly

Merge branch 'jc/grep-pcre-loose-ends'Jeff King Mon, 29 Oct 2012 08:12:15 +0000 (04:12 -0400)

Merge branch 'jc/grep-pcre-loose-ends'

"git log -F -E --grep='<ere>'" failed to use the given <ere>
pattern as extended regular expression, and instead looked for the
string literally. The early part of this series is a fix for it;
the latter part teaches log to respect the grep.* configuration.

* jc/grep-pcre-loose-ends:
log: honor grep.* configuration
log --grep: accept --basic-regexp and --perl-regexp
log --grep: use the same helper to set -E/-F options as "git grep"
revisions: initialize revs->grep_filter using grep_init()
grep: move pattern-type bits support to top-level grep.[ch]
grep: move the configuration parsing logic to grep.[ch]
builtin/grep.c: make configuration callback more reusable

Merge branch 'jl/submodule-add-by-name'Jeff King Mon, 29 Oct 2012 08:12:12 +0000 (04:12 -0400)

Merge branch 'jl/submodule-add-by-name'

If you remove a submodule, in order to keep the repository so that
"git checkout" to an older commit in the superproject history can
resurrect the submodule, the real repository will stay in $GIT_DIR
of the superproject. A later "git submodule add $path" to add a
different submodule at the same path will fail. Diagnose this case
a bit better, and if the user really wants to add an unrelated
submodule at the same path, give the "--name" option to give it a
place in $GIT_DIR of the superproject that does not conflict with
the original submodule.

* jl/submodule-add-by-name:
submodule add: Fail when .git/modules/<name> already exists unless forced
Teach "git submodule add" the --name option

Merge branch 'jl/submodule-rm'Jeff King Mon, 29 Oct 2012 08:12:07 +0000 (04:12 -0400)

Merge branch 'jl/submodule-rm'

"git rm submodule" cannot blindly remove a submodule directory as
its working tree may have local changes, and worse yet, it may even
have its repository embedded in it. Teach it some special cases
where it is safe to remove a submodule, specifically, when there is
no local changes in the submodule working tree, and its repository
is not embedded in its working tree but is elsewhere and uses the
gitfile mechanism to point at it.

* jl/submodule-rm:
submodule: teach rm to remove submodules unless they contain a git directory

fetch-pack: move core code to libgit.aNguyễn Thái Ngọc Duy Fri, 26 Oct 2012 15:53:55 +0000 (22:53 +0700)

fetch-pack: move core code to libgit.a

fetch_pack() is used by transport.c, part of libgit.a while it stays
in builtin/fetch-pack.c. Move it to fetch-pack.c so that we won't get
undefined reference if a program that uses libgit.a happens to pull it
in.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>

Add tests for submodule sync --recursivePhil Hord Fri, 26 Oct 2012 19:44:43 +0000 (15:44 -0400)

Add tests for submodule sync --recursive

Signed-off-by: Phil Hord <hordp@cisco.com>
Acked-By: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Jeff King <peff@peff.net>

Teach --recursive to submodule syncPhil Hord Fri, 26 Oct 2012 19:44:42 +0000 (15:44 -0400)

Teach --recursive to submodule sync

The submodule sync command was somehow left out when
--recursive was added to the other submodule commands.

Teach sync to handle the --recursive switch by recursing
when we're in a submodule we are sync'ing.

Change the report during sync to show submodule-path
instead of submodule-name to be consistent with the other
submodule commands and to help recursed paths make sense.

Signed-off-by: Phil Hord <hordp@cisco.com>
Acked-By: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Jeff King <peff@peff.net>

submodule status: remove unused orig_* variablesJens Lehmann Sun, 28 Oct 2012 21:37:16 +0000 (22:37 +0100)

submodule status: remove unused orig_* variables

When renaming orig_args to orig_flags in 98dbe63d (submodule: only
preserve flags across recursive status/update invocations) the call site
of the recursive cmd_status was forgotten. At that place orig_args is
still passed into the recursion, which is always empty since then. This
did not break anything because the orig_flags logic is not needed at all
when a function from the submodule script is called with eval, as that
inherits all the variables set by the option parsing done in the first
level of the recursion.

Now that we know that orig_flags and orig_args aren't needed at all,
let's just remove them from cmd_status().

Thanks-to: Phil Hord <hordp@cisco.com>
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Jeff King <peff@peff.net>

t7407: Fix recursive submodule testPhil Hord Fri, 26 Oct 2012 19:13:54 +0000 (15:13 -0400)

t7407: Fix recursive submodule test

A test in t7404-submodule-foreach purports to test that
the --cached flag is properly noticed by --recursive calls
to the foreach command as it descends into nested
submodules. However, the test really does not perform this
test since the change it looks for is in a top-level
submodule handled by the first invocation of the command.
To properly test for the flag being passed to recursive
invocations, the change must be buried deeper in the
hierarchy.

Move the change one level deeper so it properly verifies
the recursive machinery of the 'git submodule status'
command.

Signed-off-by: Phil Hord <hordp@cisco.com>
Signed-off-by: Jeff King <peff@peff.net>

fetch-pack: remove global (static) configuration variab... Nguyễn Thái Ngọc Duy Fri, 26 Oct 2012 15:53:54 +0000 (22:53 +0700)

fetch-pack: remove global (static) configuration variable "args"

This helps removes the hack in fetch_pack() that copies my_args to args.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>

send-pack: move core code to libgit.aNguyễn Thái Ngọc Duy Fri, 26 Oct 2012 15:53:53 +0000 (22:53 +0700)

send-pack: move core code to libgit.a

send_pack() is used by transport.c, part of libgit.a while it stays in
builtin/send-pack.c. Move it to send-pack.c so that we won't get
undefined reference if a program that uses libgit.a happens to pull it
in.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>

Move setup_diff_pager to libgit.aNguyễn Thái Ngọc Duy Fri, 26 Oct 2012 15:53:52 +0000 (22:53 +0700)

Move setup_diff_pager to libgit.a

This is used by diff-no-index.c, part of libgit.a while it stays in
builtin/diff.c. Move it to diff.c so that we won't get undefined
reference if a program that uses libgit.a happens to pull it in.

While at it, move check_pager from git.c to pager.c. It makes more
sense there and pager.c is also part of libgit.a

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>

Move print_commit_list to libgit.aNguyễn Thái Ngọc Duy Fri, 26 Oct 2012 15:53:51 +0000 (22:53 +0700)

Move print_commit_list to libgit.a

This is used by bisect.c, part of libgit.a while it stays in
builtin/rev-list.c. Move it to commit.c so that we won't get undefined
reference if a program that uses libgit.a happens to pull it in.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>

Move estimate_bisect_steps to libgit.aNguyễn Thái Ngọc Duy Fri, 26 Oct 2012 15:53:50 +0000 (22:53 +0700)

Move estimate_bisect_steps to libgit.a

This function is used by bisect.c, part of libgit.a while
estimate_bisect_steps stays in builtin/rev-list.c. Move it to bisect.a
so we won't have undefine reference if a standalone program that uses
libgit.a happens to pull it in.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>

Move try_merge_command and checkout_fast_forward to... Nguyễn Thái Ngọc Duy Fri, 26 Oct 2012 15:53:49 +0000 (22:53 +0700)

Move try_merge_command and checkout_fast_forward to libgit.a

These functions are called in sequencer.c, which is part of
libgit.a. This makes libgit.a potentially require builtin/merge.c for
external git commands.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>

parse_dirstat_params(): use string_list to split comma... Michael Haggerty Sun, 28 Oct 2012 16:50:54 +0000 (17:50 +0100)

parse_dirstat_params(): use string_list to split comma-separated string

Use string_list_split_in_place() to split the comma-separated
parameters string. This simplifies the code and also fixes a bug: the
old code made calls like

memcmp(p, "lines", p_len)

which needn't work if p_len is different than the length of the
constant string (and could illegally access memory if p_len is larger
than the length of the constant string).

When p_len was less than the length of the constant string, the old
code would have allowed some abbreviations to be accepted (e.g., "cha"
for "changes") but this seems to have been a bug rather than a
feature, because (1) it is not documented; (2) no attempt was made to
handle ambiguous abbreviations, like "c" for "changes" vs
"cumulative".

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>

Documentation: improve the example of overriding LESS... Patrick Palka Sun, 28 Oct 2012 20:12:46 +0000 (16:12 -0400)

Documentation: improve the example of overriding LESS via core.pager

You can override an option set in the LESS variable by simply prefixing
the command line option with `-+`. This is more robust than the previous
example if the default LESS options are to ever change.

Signed-off-by: Patrick Palka <patrick@parcs.ath.cx>
Signed-off-by: Jeff King <peff@peff.net>

builtin/config.c: Fix a sparse warningRamsay Jones Sun, 28 Oct 2012 21:05:25 +0000 (21:05 +0000)

builtin/config.c: Fix a sparse warning

Sparse issues an "Using plain integer as NULL pointer" warning while
checking a 'struct strbuf_list' initializer expression. The initial
field of the struct has pointer type, but the initializer expression
is given as '{0}'. In order to suppress the warning, we simply replace
the initializer with '{NULL}'.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Jeff King <peff@peff.net>

doc: git-reset: make "<mode>" optionalKrzysztof Mazur Sun, 28 Oct 2012 14:13:27 +0000 (15:13 +0100)

doc: git-reset: make "<mode>" optional

The git-reset's "<mode>" is an optional argument, however it was
documented as required.

The "<mode>" is documented as one of: --soft, --mixed, --hard, --merge
or --keep, so "<mode>" should be used instead of "--<mode>".

Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net>
Signed-off-by: Jeff King <peff@peff.net>

diff_grep: use textconv buffers for add/deleted filesJeff King Sun, 28 Oct 2012 11:40:00 +0000 (07:40 -0400)

diff_grep: use textconv buffers for add/deleted files

If you use "-G" to grep a diff, we will apply a configured
textconv filter to the data before generating the diff.
However, if the diff is an addition or deletion, we do not
bother running the diff at all, and just look for the token
in the added (or removed) content. This works because we
know that the diff must contain every line of content.

However, while we used the textconv-derived buffers in the
regular diff, we accidentally passed the original unmodified
buffers to regexec when checking the added or removed
content. This could lead to an incorrect answer.

Worse, in some cases we might have a textconv buffer but no
original buffer (e.g., if we pulled the textconv data from
cache, or if we reused a working tree file when generating
it). In that case, we could actually feed NULL to regexec
and segfault.

Reported-by: Peter Oberndorfer <kumbayo84@arcor.de>
Signed-off-by: Jeff King <peff@peff.net>

Fix t9200 on case insensitive file systemsTorsten Bögershausen Fri, 26 Oct 2012 16:18:24 +0000 (18:18 +0200)

Fix t9200 on case insensitive file systems

t9200 defines $CVSROOT where cvs should init its repository
$CVSROOT is set to $PWD/cvsroot.
cvs init is supposed to create the repository inside $PWD/cvsroot/CVSROOT

"cvs init" (e.g. version 1.11.23) checks if the last element of the path is
"CVSROOT", and if a directory with e.g. $PWD/cvsroot/CVSROOT already exists.

For such a $CVSROOT cvs refuses to init a repository here:
"Cannot initialize repository under existing CVSROOT:

On a case insenstive file system cvsroot and CVSROOT are the same directories
and t9200 fails.

Solution: use $PWD/tmpcvsroot instead of cvsroot $PWD/cvsroot

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Jeff King <peff@peff.net>

mailmap: avoid out-of-bounds memory accessRomain Francoise Sat, 27 Oct 2012 22:49:55 +0000 (00:49 +0200)

mailmap: avoid out-of-bounds memory access

AddressSanitizer (http://clang.llvm.org/docs/AddressSanitizer.html)
complains of a one-byte buffer underflow in parse_name_and_email() while
running the test suite. And indeed, if one of the lines in the mailmap
begins with '<', we dereference the address just before the beginning of
the buffer when looking for whitespace to remove, before checking that
we aren't going too far.

So reverse the order of the tests to make sure that we don't read
outside the buffer.

Signed-off-by: Romain Francoise <romain@orebokech.com>
Signed-off-by: Jeff King <peff@peff.net>

submodule add: fix handling of --reference=<repo> optionStefan Zager Thu, 25 Oct 2012 04:52:52 +0000 (21:52 -0700)

submodule add: fix handling of --reference=<repo> option

Doing a shift here is wrong because there is no extra
argument to consume when "--reference=<repo>" is used (note
the '=' instead of a space).

Signed-off-by: Stefan Zager <szager@google.com>
Signed-off-by: Jeff King <peff@peff.net>

Doc User-Manual: Patch cover letter, three dashes,... Philip Oakley Sun, 21 Oct 2012 21:34:08 +0000 (22:34 +0100)

Doc User-Manual: Patch cover letter, three dashes, and --notes

Show that git format-patch can have a cover letter, include patch
commentary below the three dashes, and notes can also be
included.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Jeff King <peff@peff.net>

Document git-svn fetch --log-window-size parameterGunnlaugur Þór Briem Tue, 23 Oct 2012 10:33:26 +0000 (10:33 +0000)

Document git-svn fetch --log-window-size parameter

The --log-window-size parameter to git-svn fetch is undocumented.

Minimally describe what it does and why the user might change it.

Signed-off-by: Gunnlaugur Þór Briem <gunnlaugur@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>

Doc format-patch: clarify --notes use casePhilip Oakley Sun, 21 Oct 2012 21:34:10 +0000 (22:34 +0100)

Doc format-patch: clarify --notes use case

Remove double negative, and include the repeat usage across
versions of a patch series.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Jeff King <peff@peff.net>

Use character class for sed expression instead of \sBen Walton Thu, 25 Oct 2012 15:58:19 +0000 (16:58 +0100)

Use character class for sed expression instead of \s

Sed on Mac OS X doesn't handle \s in a sed expressions so use a more
portable character set expression instead.

Signed-off-by: Ben Walton <bdwalton@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>

configure: fix some output messageStefano Lattarini Wed, 24 Oct 2012 15:34:27 +0000 (17:34 +0200)

configure: fix some output message

Before this change, output from ./configure could contain
botched wording like this:

checking Checking for POSIX Threads with '-pthread'... yes

instead of the intended:

checking for POSIX Threads with '-pthread'... yes

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>

Doc repository-layout: Show refs/replacePhilip Oakley Sun, 21 Oct 2012 20:52:37 +0000 (21:52 +0100)

Doc repository-layout: Show refs/replace

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Jeff King <peff@peff.net>

Documentation: remote tracking branch -> remote-trackin... Matthieu Moy Tue, 23 Oct 2012 11:34:05 +0000 (13:34 +0200)

Documentation: remote tracking branch -> remote-tracking branch

This change was already done by 0e615b252f3 (Matthieu Moy, Tue Nov 2
2010, Replace "remote tracking" with "remote-tracking"), but new
instances of remote tracking (without dash) were introduced in the
meantime.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Jeff King <peff@peff.net>

Merge branch 'jk/strbuf-detach-always-non-null'Jeff King Thu, 25 Oct 2012 10:43:03 +0000 (06:43 -0400)

Merge branch 'jk/strbuf-detach-always-non-null'

* jk/strbuf-detach-always-non-null:
strbuf: always return a non-NULL value from strbuf_detach

Merge branch 'js/mingw-fflush-errno'Jeff King Thu, 25 Oct 2012 10:43:01 +0000 (06:43 -0400)

Merge branch 'js/mingw-fflush-errno'

* js/mingw-fflush-errno:
maybe_flush_or_die: move a too-loose Windows specific error

Merge branch 'da/mergetools-p4'Jeff King Thu, 25 Oct 2012 10:42:57 +0000 (06:42 -0400)

Merge branch 'da/mergetools-p4'

* da/mergetools-p4:
mergetools/p4merge: Handle "/dev/null"

Merge branch 'jc/test-say-color-avoid-echo-escape'Jeff King Thu, 25 Oct 2012 10:42:49 +0000 (06:42 -0400)

Merge branch 'jc/test-say-color-avoid-echo-escape'

Recent nd/wildmatch series was the first to reveal this ancient bug
in the test scaffolding.

* jc/test-say-color-avoid-echo-escape:
test-lib: Fix say_color () not to interpret \a\b\c in the message

Merge branch 'nd/attr-match-optim'Jeff King Thu, 25 Oct 2012 10:42:36 +0000 (06:42 -0400)

Merge branch 'nd/attr-match-optim'

Trivial and obvious optimization for finding attributes that match
a given path.

* nd/attr-match-optim:
attr: avoid searching for basename on every match
attr: avoid strlen() on every match

Merge branch 'jk/peel-ref'Jeff King Thu, 25 Oct 2012 10:42:27 +0000 (06:42 -0400)

Merge branch 'jk/peel-ref'

Speeds up "git upload-pack" (what is invoked by "git fetch" on the
other side of the connection) by reducing the cost to advertise the
branches and tags that are available in the repository.

* jk/peel-ref:
upload-pack: use peel_ref for ref advertisements
peel_ref: check object type before loading
peel_ref: do not return a null sha1
peel_ref: use faster deref_tag_noverify

Merge branch 'bw/config-lift-variable-name-length-limit'Jeff King Thu, 25 Oct 2012 10:42:11 +0000 (06:42 -0400)

Merge branch 'bw/config-lift-variable-name-length-limit'

The configuration parser had an unnecessary hardcoded limit on
variable names that was not checked consistently. Lift the limit.

* bw/config-lift-variable-name-length-limit:
Remove the hard coded length limit on variable names in config files

Merge branch 'fa/remote-svn'Jeff King Thu, 25 Oct 2012 10:42:01 +0000 (06:42 -0400)

Merge branch 'fa/remote-svn'

A GSoC project.

* fa/remote-svn:
Add a test script for remote-svn
remote-svn: add marks-file regeneration
Add a svnrdump-simulator replaying a dump file for testing
remote-svn: add incremental import
remote-svn: Activate import/export-marks for fast-import
Create a note for every imported commit containing svn metadata
vcs-svn: add fast_export_note to create notes
Allow reading svn dumps from files via file:// urls
remote-svn, vcs-svn: Enable fetching to private refs
When debug==1, start fast-import with "--stats" instead of "--quiet"
Add documentation for the 'bidi-import' capability of remote-helpers
Connect fast-import to the remote-helper via pipe, adding 'bidi-import' capability
Add argv_array_detach and argv_array_free_detached
Add svndump_init_fd to allow reading dumps from arbitrary FDs
Add git-remote-testsvn to Makefile
Implement a remote helper for svn in C

Merge branch 'jm/diff-context-config'Jeff King Thu, 25 Oct 2012 10:41:57 +0000 (06:41 -0400)

Merge branch 'jm/diff-context-config'

Teaches a new configuration variable to "git diff" Porcelain and
its friends.

* jm/diff-context-config:
t4055: avoid use of sed 'a' command
diff: diff.context configuration gives default to -U

Merge branch 'jk/no-more-pre-exec-callback'Jeff King Thu, 25 Oct 2012 10:41:15 +0000 (06:41 -0400)

Merge branch 'jk/no-more-pre-exec-callback'

Removes a workaround for buggy version of less older than version
406.

* jk/no-more-pre-exec-callback:
pager: drop "wait for output to run less" hack

Doc notes: Include the format-patch --notes optionPhilip Oakley Sun, 21 Oct 2012 21:34:09 +0000 (22:34 +0100)

Doc notes: Include the format-patch --notes option

git format-patch gained a --notes option. Tell the notes user.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Jeff King <peff@peff.net>

Doc SubmittingPatches: Mention --notes option after... Philip Oakley Sun, 21 Oct 2012 21:34:07 +0000 (22:34 +0100)

Doc SubmittingPatches: Mention --notes option after "cover letter"

The git format-patch --notes option can now insert the commit notes
after the three dashes. Mention this after the regular cover letter
guidance for submitting patches.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Jeff King <peff@peff.net>

git-send-email: add rfc2047 quoting for "=?"Krzysztof Mazur Wed, 24 Oct 2012 21:28:29 +0000 (23:28 +0200)

git-send-email: add rfc2047 quoting for "=?"

For raw subjects rfc2047 quoting is needed not only for non-ASCII characters,
but also for any possible rfc2047 in it.

Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net>
Signed-off-by: Jeff King <peff@peff.net>

git-send-email: introduce quote_subject()Krzysztof Mazur Wed, 24 Oct 2012 21:08:26 +0000 (23:08 +0200)

git-send-email: introduce quote_subject()

The quote_rfc2047() always adds RFC2047 quoting. To avoid
quoting ASCII subjects, before calling quote_rfc2047()
subject must be tested for non-ASCII characters. This patch
introduces a new quote_subject() function, which performs
the test and calls quote_rfc2047 only if necessary.

Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net>
Signed-off-by: Jeff King <peff@peff.net>

git-send-email: skip RFC2047 quoting for ASCII subjectsKrzysztof Mazur Wed, 24 Oct 2012 08:03:35 +0000 (10:03 +0200)

git-send-email: skip RFC2047 quoting for ASCII subjects

The git-send-email always use RFC2047 subject quoting for
files with "broken" encoding - non-ASCII files without
Content-Transfer-Encoding, even for ASCII subjects. This is
harmless but unnecessarily ugly for people reading the raw
headers. This patch skips rfc2047 quoting when the subject
does not need it.

Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net>
Signed-off-by: Jeff King <peff@peff.net>

git-send-email: use compose-encoding for SubjectKrzysztof Mazur Mon, 22 Oct 2012 12:41:48 +0000 (14:41 +0200)

git-send-email: use compose-encoding for Subject

The commit "git-send-email: introduce compose-encoding" introduced
the compose-encoding option to specify the introduction email encoding
(--compose option), but the email Subject encoding was still hardcoded
to UTF-8.

Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net>
Signed-off-by: Jeff King <peff@peff.net>

Documentation: build html for all files in technical... Thomas Ackermann Tue, 23 Oct 2012 17:58:04 +0000 (19:58 +0200)

Documentation: build html for all files in technical and howto

These files were recently revised to be valid asciidoc, so
there is no reason not to build html versions.

Signed-off-by: Thomas Ackermann <th.acker66@arcor.de>
Signed-off-by: Jeff King <peff@peff.net>

git-pull: Avoid merge-base on detached headPhil Hord Tue, 23 Oct 2012 20:39:56 +0000 (16:39 -0400)

git-pull: Avoid merge-base on detached head

git pull --rebase does some clever tricks to find the base
for $upstream, but it forgets that we may not have any
branch at all. When this happens, git merge-base reports its
"usage" help in the middle of an otherwise successful
rebase operation, because git-merge is called with one too
few parameters.

Since we do not need the merge-base trick in the case of a
detached HEAD, detect this condition and bypass the clever
trick and the usage noise.

Signed-off-by: Phil Hord <hordp@cisco.com>
Signed-off-by: Jeff King <peff@peff.net>

git-submodule: wrap branch option with "<>" in usage... W. Trevor King Tue, 23 Oct 2012 21:00:21 +0000 (17:00 -0400)

git-submodule: wrap branch option with "<>" in usage strings.

Use "-b <branch>" instead of "-b branch". This brings the usage
strings in line with other options, e.g. "--reference <repository>".

Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Jeff King <peff@peff.net>

git-config: use git_config_with_optionsJeff King Tue, 23 Oct 2012 22:00:41 +0000 (18:00 -0400)

git-config: use git_config_with_options

The git-config command has always implemented its own file
lookup and parsing order. This was necessary because its
duplicate-entry handling did not match the way git's
internal callbacks worked. Now that this is no longer the
case, we are free to reuse the existing parsing code.

This saves us a few lines of code, but most importantly, it
means that the logic for which files are examined is
contained only in one place and cannot diverge.

Signed-off-by: Jeff King <peff@peff.net>

git-config: do not complain about duplicate entriesJeff King Tue, 23 Oct 2012 20:52:44 +0000 (16:52 -0400)

git-config: do not complain about duplicate entries

If git-config is asked for a single value, it will complain
and exit with an error if it finds multiple instances of
that value. This is unlike the usual internal config
parsing, however, which will generally overwrite previous
values, leaving only the final one. For example:

[set a multivar]
$ git config user.email one@example.com
$ git config --add user.email two@example.com

[use the internal parser to fetch it]
$ git var GIT_AUTHOR_IDENT
Your Name <two@example.com> ...

[use git-config to fetch it]
$ git config user.email
one@example.com
error: More than one value for the key user.email: two@example.com

This overwriting behavior is critical for the regular
parser, which starts with the lowest-priority file (e.g.,
/etc/gitconfig) and proceeds to the highest-priority file
($GIT_DIR/config). Overwriting yields the highest priority
value at the end.

Git-config solves this problem by implementing its own
parsing. It goes from highest to lowest priorty, but does
not proceed to the next file if it has seen a value.

So in practice, this distinction never mattered much,
because it only triggered for values in the same file. And
there was not much point in doing that; the real value is in
overwriting values from lower-priority files.

However, this changed with the implementation of config
include files. Now we might see an include overriding a
value from the parent file, which is a sensible thing to do,
but git-config will flag as a duplication.

This patch drops the duplicate detection for git-config and
switches to a pure-overwrite model (for the single case;
--get-all can still be used if callers want to do something
more fancy).

As is shown by the modifications to the test suite, this is
a user-visible change in behavior. An alternative would be
to just change the include case, but this is much cleaner
for a few reasons:

1. If you change the include case, then to what? If you
just stop parsing includes after getting a value, then
you will get a _different_ answer than the regular
config parser (you'll get the first value instead of
the last value). So you'd want to implement overwrite
semantics anyway.

2. Even though it is a change in behavior for git-config,
it is bringing us in line with what the internal
parsers already do.

3. The file-order reimplementation is the only thing
keeping us from sharing more code with the internal
config parser, which will help keep differences to a
minimum.

Going under the assumption that the primary purpose of
git-config is to behave identically to how git's internal
parsing works, this change can be seen as a bug-fix.

Signed-off-by: Jeff King <peff@peff.net>

git-config: collect values instead of immediately printingJeff King Tue, 23 Oct 2012 19:51:50 +0000 (15:51 -0400)

git-config: collect values instead of immediately printing

This is a refactor that will allow us to more easily tweak
the behavior for multi-valued variables, and it will
ultimately allow us to remove a lot git-config's custom code
in favor of the regular git_config code.

It does mean we're no longer streaming, and we're storing
more in memory for the --get-all case, but in practice it is
a tiny amount of data, and the results are instantaneous.

Signed-off-by: Jeff King <peff@peff.net>

git-config: fix regexp memory leaks on error conditionsJeff King Tue, 23 Oct 2012 19:40:06 +0000 (15:40 -0400)

git-config: fix regexp memory leaks on error conditions

The get_value function has a goto label for cleaning up on
errors, but it only cleans up half of what the function
might allocate. Let's also clean up the key and regexp
variables there.

Note that we need to take special care when compiling the
regex fails to clean it up ourselves, since it is in a
half-constructed state (we would want to free it, but not
regfree it).

Similarly, we fix git_config_parse_key to return NULL when
it fails, not a pointer to some already-freed memory.

Signed-off-by: Jeff King <peff@peff.net>

git-config: remove memory leak of key regexpJeff King Tue, 23 Oct 2012 19:36:12 +0000 (15:36 -0400)

git-config: remove memory leak of key regexp

This is only called once per invocation, so it's not a major
leak, but it's easy to fix.

Signed-off-by: Jeff King <peff@peff.net>