gitweb.git
packfile: add repository argument to packed_to_object_typeStefan Beller Wed, 25 Apr 2018 18:21:01 +0000 (11:21 -0700)

packfile: add repository argument to packed_to_object_type

Add a repository argument to allow the callers of packed_to_object_type
to be more specific about which repository to handle. This is a small
mechanical change; it doesn't change the implementation to handle
repositories other than the_repository yet.

As with the previous commits, use a macro to catch callers passing a
repository other than the_repository at compile time.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

packfile: add repository argument to retry_bad_packed_o... Stefan Beller Wed, 25 Apr 2018 18:21:00 +0000 (11:21 -0700)

packfile: add repository argument to retry_bad_packed_offset

Add a repository argument to allow the callers of retry_bad_packed_offset
to be more specific about which repository to handle. This is a small
mechanical change; it doesn't change the implementation to handle
repositories other than the_repository yet.

As with the previous commits, use a macro to catch callers passing a
repository other than the_repository at compile time.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

cache.h: add repository argument to oid_object_infoStefan Beller Wed, 25 Apr 2018 18:20:59 +0000 (11:20 -0700)

cache.h: add repository argument to oid_object_info

Add a repository argument to allow the callers of oid_object_info
to be more specific about which repository to handle. This is a small
mechanical change; it doesn't change the implementation to handle
repositories other than the_repository yet.

As with the previous commits, use a macro to catch callers passing a
repository other than the_repository at compile time.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

cache.h: add repository argument to oid_object_info_ext... Stefan Beller Wed, 25 Apr 2018 18:20:58 +0000 (11:20 -0700)

cache.h: add repository argument to oid_object_info_extended

Add a repository argument to allow oid_object_info_extended callers
to be more specific about which repository to act on. This is a small
mechanical change; it doesn't change the implementation to handle
repositories other than the_repository yet.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

The fourth batch for 2.18Junio C Hamano Wed, 25 Apr 2018 04:44:42 +0000 (13:44 +0900)

The fourth batch for 2.18

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

Merge branch 'jm/mem-pool'Junio C Hamano Wed, 25 Apr 2018 04:29:06 +0000 (13:29 +0900)

Merge branch 'jm/mem-pool'

An reusable "memory pool" implementation has been extracted from
fast-import.c, which in turn has become the first user of the
mem-pool API.

* jm/mem-pool:
mem-pool: move reusable parts of memory pool into its own file
fast-import: introduce mem_pool type
fast-import: rename mem_pool type to mp_block

Merge branch 'tg/use-git-contacts'Junio C Hamano Wed, 25 Apr 2018 04:29:05 +0000 (13:29 +0900)

Merge branch 'tg/use-git-contacts'

Doc update.

* tg/use-git-contacts:
SubmittingPatches: mention the git contacts command

Merge branch 'sb/filenames-with-dashes'Junio C Hamano Wed, 25 Apr 2018 04:29:05 +0000 (13:29 +0900)

Merge branch 'sb/filenames-with-dashes'

Rename bunch of source files to more consistently use dashes
instead of underscores to connect words.

* sb/filenames-with-dashes:
replace_object.c: rename to use dash in file name
sha1_file.c: rename to use dash in file name
sha1_name.c: rename to use dash in file name
exec_cmd: rename to use dash in file name
unicode_width.h: rename to use dash in file name
write_or_die.c: rename to use dashes in file name

Merge branch 'cc/perf-bisect'Junio C Hamano Wed, 25 Apr 2018 04:29:04 +0000 (13:29 +0900)

Merge branch 'cc/perf-bisect'

Performance measuring framework in t/perf learned to help bisecting
performance regressions.

* cc/perf-bisect:
t/perf: add scripts to bisect performance regressions
perf/run: add --subsection option

Merge branch 'bp/fsmonitor-prime-index'Junio C Hamano Wed, 25 Apr 2018 04:29:04 +0000 (13:29 +0900)

Merge branch 'bp/fsmonitor-prime-index'

The index file is updated to record the fsmonitor section after a
full scan was made, to avoid wasting the effort that has already
spent.

* bp/fsmonitor-prime-index:
fsmonitor: force index write after full scan

Merge branch 'bp/fsmonitor-bufsize-fix'Junio C Hamano Wed, 25 Apr 2018 04:29:03 +0000 (13:29 +0900)

Merge branch 'bp/fsmonitor-bufsize-fix'

Fix an unexploitable (because the oversized contents are not under
attacker's control) buffer overflow.

* bp/fsmonitor-bufsize-fix:
fsmonitor: fix incorrect buffer size when printing version number

Merge branch 'cb/bash-completion-ls-files-processing'Junio C Hamano Wed, 25 Apr 2018 04:29:02 +0000 (13:29 +0900)

Merge branch 'cb/bash-completion-ls-files-processing'

Shell completion (in contrib) that gives list of paths have been
optimized somewhat.

* cb/bash-completion-ls-files-processing:
completion: improve ls-files filter performance

Merge branch 'es/worktree-docs'Junio C Hamano Wed, 25 Apr 2018 04:29:02 +0000 (13:29 +0900)

Merge branch 'es/worktree-docs'

Doc updates.

* es/worktree-docs:
git-worktree.txt: unify command-line prompt in example blocks
git-worktree.txt: recommend 'git worktree remove' over manual deletion

Merge branch 'es/fread-reads-dir-autoconf-fix'Junio C Hamano Wed, 25 Apr 2018 04:29:01 +0000 (13:29 +0900)

Merge branch 'es/fread-reads-dir-autoconf-fix'

Small fix to the autoconf build procedure.

* es/fread-reads-dir-autoconf-fix:
configure.ac: fix botched FREAD_READS_DIRECTORIES check

Merge branch 'ps/test-chmtime-get'Junio C Hamano Wed, 25 Apr 2018 04:29:00 +0000 (13:29 +0900)

Merge branch 'ps/test-chmtime-get'

Test cleanup.

* ps/test-chmtime-get:
t/helper: 'test-chmtime (--get|-g)' to print only the mtime

Merge branch 'js/t5404-path-fix'Junio C Hamano Wed, 25 Apr 2018 04:29:00 +0000 (13:29 +0900)

Merge branch 'js/t5404-path-fix'

Test fix.

* js/t5404-path-fix:
t5404: relax overzealous test

Merge branch 'jk/ref-array-push'Junio C Hamano Wed, 25 Apr 2018 04:28:59 +0000 (13:28 +0900)

Merge branch 'jk/ref-array-push'

API clean-up aournd ref-filter code.

* jk/ref-array-push:
ref-filter: factor ref_array pushing into its own function
ref-filter: make ref_array_item allocation more consistent
ref-filter: use "struct object_id" consistently

Merge branch 'en/doc-typoes'Junio C Hamano Wed, 25 Apr 2018 04:28:58 +0000 (13:28 +0900)

Merge branch 'en/doc-typoes'

Docfix.

* en/doc-typoes:
Documentation: normalize spelling of 'normalised'
Documentation: fix several one-character-off spelling errors

Merge branch 'lw/daemon-log-destination'Junio C Hamano Wed, 25 Apr 2018 04:28:58 +0000 (13:28 +0900)

Merge branch 'lw/daemon-log-destination'

Recent introduction of "--log-destination" option to "git daemon"
did not work well when the daemon was run under "--inetd" mode.

* lw/daemon-log-destination:
daemon.c: fix condition for redirecting stderr

Merge branch 'mn/send-email-credential-doc'Junio C Hamano Wed, 25 Apr 2018 04:28:57 +0000 (13:28 +0900)

Merge branch 'mn/send-email-credential-doc'

Doc update.

* mn/send-email-credential-doc:
send-email: simplify Gmail example in the documentation

Merge branch 'ak/bisect-doc-typofix'Junio C Hamano Wed, 25 Apr 2018 04:28:56 +0000 (13:28 +0900)

Merge branch 'ak/bisect-doc-typofix'

Docfix.

* ak/bisect-doc-typofix:
Documentation/git-bisect.txt: git bisect term → git bisect terms

Merge branch 'br/mergetools-guiffy'Junio C Hamano Wed, 25 Apr 2018 04:28:54 +0000 (13:28 +0900)

Merge branch 'br/mergetools-guiffy'

"git mergetools" learned talking to guiffy.

* br/mergetools-guiffy:
mergetools: add support for guiffy

Merge branch 'nd/worktree-move'Junio C Hamano Wed, 25 Apr 2018 04:28:54 +0000 (13:28 +0900)

Merge branch 'nd/worktree-move'

Test update.

* nd/worktree-move:
t2028: tighten grep expression to make "move worktree" test more robust

Merge branch 'ks/branch-list-detached-rebase-i'Junio C Hamano Wed, 25 Apr 2018 04:28:53 +0000 (13:28 +0900)

Merge branch 'ks/branch-list-detached-rebase-i'

"git branch --list" during an interrupted "rebase -i" now lets
users distinguish the case where a detached HEAD is being rebased
and a normal branch is being rebased.

* ks/branch-list-detached-rebase-i:
t3200: verify "branch --list" sanity when rebasing from detached HEAD
branch --list: print useful info whilst interactive rebasing a detached HEAD

Merge branch 'jk/t5561-missing-curl'Junio C Hamano Wed, 25 Apr 2018 04:28:53 +0000 (13:28 +0900)

Merge branch 'jk/t5561-missing-curl'

Test fixes.

* jk/t5561-missing-curl:
t5561: skip tests if curl is not available
t5561: drop curl stderr redirects

Merge branch 'bw/commit-partial-from-subdirectory-fix'Junio C Hamano Wed, 25 Apr 2018 04:28:53 +0000 (13:28 +0900)

Merge branch 'bw/commit-partial-from-subdirectory-fix'

"cd sub/dir && git commit ../path" ought to record the changes to
the file "sub/path", but this regressed long time ago.

* bw/commit-partial-from-subdirectory-fix:
commit: allow partial commits with relative paths

Merge branch 'jk/relative-directory-fix'Junio C Hamano Wed, 25 Apr 2018 04:28:52 +0000 (13:28 +0900)

Merge branch 'jk/relative-directory-fix'

Some codepaths, including the refs API, get and keep relative
paths, that go out of sync when the process does chdir(2). The
chdir-notify API is introduced to let these codepaths adjust these
cached paths to the new current directory.

* jk/relative-directory-fix:
refs: use chdir_notify to update cached relative paths
set_work_tree: use chdir_notify
add chdir-notify API
trace.c: export trace_setup_key
set_git_dir: die when setenv() fails

Merge branch 'jk/flockfile-stdio'Junio C Hamano Wed, 25 Apr 2018 04:28:52 +0000 (13:28 +0900)

Merge branch 'jk/flockfile-stdio'

Code clean-up.

* jk/flockfile-stdio:
config: move flockfile() closer to unlocked functions

Merge branch 'pw/rebase-signoff'Junio C Hamano Wed, 25 Apr 2018 04:28:51 +0000 (13:28 +0900)

Merge branch 'pw/rebase-signoff'

"git rebase" has learned to honor "--signoff" option when using
backends other than "am" (but not "--preserve-merges").

* pw/rebase-signoff:
rebase --keep-empty: always use interactive rebase
rebase -p: error out if --signoff is given
rebase: extend --signoff support

Merge branch 'pw/rebase-keep-empty-fixes'Junio C Hamano Wed, 25 Apr 2018 04:28:49 +0000 (13:28 +0900)

Merge branch 'pw/rebase-keep-empty-fixes'

"git rebase --keep-empty" still removed an empty commit if the
other side contained an empty commit (due to the "does an
equivalent patch exist already?" check), which has been corrected.

* pw/rebase-keep-empty-fixes:
rebase: respect --no-keep-empty
rebase -i --keep-empty: don't prune empty commits
rebase --root: stop assuming squash_onto is unset

Merge branch 'cb/git-gui-ttk-style'Junio C Hamano Wed, 25 Apr 2018 04:28:49 +0000 (13:28 +0900)

Merge branch 'cb/git-gui-ttk-style'

"git gui" has been taught to work with old versions of tk (like
8.5.7) that do not support "ttk::style theme use" as a way to query
the current theme.

* cb/git-gui-ttk-style:
git-gui: workaround ttk:style theme use

Merge branch 'bp/git-gui-bind-kp-enter'Junio C Hamano Wed, 25 Apr 2018 04:28:48 +0000 (13:28 +0900)

Merge branch 'bp/git-gui-bind-kp-enter'

"git gui" performs commit upon CTRL/CMD+ENTER but the
CTRL/CMD+KP_ENTER (i.e. enter key on the numpad) did not have the
same key binding. It now does.

* bp/git-gui-bind-kp-enter:
git-gui: bind CTRL/CMD+numpad ENTER to do_commit

Merge branch 'bb/git-gui-ssh-key-files'Junio C Hamano Wed, 25 Apr 2018 04:28:48 +0000 (13:28 +0900)

Merge branch 'bb/git-gui-ssh-key-files'

"git gui" learned that "~/.ssh/id_ecdsa.pub" and
"~/.ssh/id_ed25519.pub" are also possible SSH key files.

* bb/git-gui-ssh-key-files:
git-gui: search for all current SSH key types

Make running git under other debugger-like programs... Elijah Newren Tue, 24 Apr 2018 23:46:45 +0000 (16:46 -0700)

Make running git under other debugger-like programs easy

This allows us to run git, when using the script from bin-wrappers, under
other programs. A few examples for usage within testsuite scripts:

debug git checkout master
debug --debugger=nemiver git $ARGS
debug -d "valgrind --tool-memcheck --track-origins=yes" git $ARGS

Or, if someone has bin-wrappers/ in their $PATH and is executing git
outside the testsuite:

GIT_DEBUGGER="gdb --args" git $ARGS
GIT_DEBUGGER=nemiver git $ARGS
GIT_DEBUGGER="valgrind --tool=memcheck --track-origins=yes" git $ARGS

There is also a handy shortcut of GIT_DEBUGGER=1 meaning the same as
GIT_DEBUGGER="gdb --args"

Original-patch-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fetch: send server options when using protocol v2Brandon Williams Mon, 23 Apr 2018 22:46:24 +0000 (15:46 -0700)

fetch: send server options when using protocol v2

Teach fetch to optionally accept server options by specifying them on
the cmdline via '-o' or '--server-option'. These server options are
sent to the remote end when performing a fetch communicating using
protocol version 2.

If communicating using a protocol other than v2 the provided options are
ignored and not sent to the remote end.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-remote: send server options when using protocol v2Brandon Williams Mon, 23 Apr 2018 22:46:23 +0000 (15:46 -0700)

ls-remote: send server options when using protocol v2

Teach ls-remote to optionally accept server options by specifying them
on the cmdline via '-o' or '--server-option'. These server options are
sent to the remote end when querying for the remote end's refs using
protocol version 2.

If communicating using a protocol other than v2 the provided options are
ignored and not sent to the remote end.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

serve: introduce the server-option capabilityBrandon Williams Mon, 23 Apr 2018 22:46:22 +0000 (15:46 -0700)

serve: introduce the server-option capability

Introduce the "server-option" capability to protocol version 2. This
enables future clients the ability to send server specific options in
command requests when using protocol version 2.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'bw/protocol-v2' into HEADJunio C Hamano Tue, 24 Apr 2018 02:24:22 +0000 (11:24 +0900)

Merge branch 'bw/protocol-v2' into HEAD

* bw/protocol-v2: (35 commits)
remote-curl: don't request v2 when pushing
remote-curl: implement stateless-connect command
http: eliminate "# service" line when using protocol v2
http: don't always add Git-Protocol header
http: allow providing extra headers for http requests
remote-curl: store the protocol version the server responded with
remote-curl: create copy of the service name
pkt-line: add packet_buf_write_len function
transport-helper: introduce stateless-connect
transport-helper: refactor process_connect_service
transport-helper: remove name parameter
connect: don't request v2 when pushing
connect: refactor git_connect to only get the protocol version once
fetch-pack: support shallow requests
fetch-pack: perform a fetch using v2
upload-pack: introduce fetch server command
push: pass ref prefixes when pushing
fetch: pass ref prefixes when fetching
ls-remote: pass ref prefixes when requesting a remote's refs
transport: convert transport_get_remote_refs to take a list of ref prefixes
...

Avoid multiple PREFIX definitionsPhilip Oakley Sat, 21 Apr 2018 11:18:42 +0000 (13:18 +0200)

Avoid multiple PREFIX definitions

The short and sweet PREFIX can be confused when used in many places.

Rename both usages to better describe their purpose. EXEC_CMD_PREFIX is
used in full to disambiguate it from the nearby GIT_EXEC_PATH.

The PREFIX in sideband.c, while nominally independant of the exec_cmd
PREFIX, does reside within libgit[1], so the definitions would clash
when taken together with a PREFIX given on the command line for use by
exec_cmd.c.

Noticed when compiling Git for Windows using MSVC/Visual Studio [1] which
reports the conflict beteeen the command line definition and the
definition in sideband.c within the libgit project.

[1] the libgit functions are brought into a single sub-project
within the Visual Studio construction script provided in contrib,
and hence uses a single command for both exec_cmd.c and sideband.c.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git_setup_gettext: plug memory leakJohannes Schindelin Sat, 21 Apr 2018 11:14:28 +0000 (13:14 +0200)

git_setup_gettext: plug memory leak

The system_path() function returns a freshly-allocated string. We need
to release it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gettext: avoid initialization if the locale dir is... Johannes Schindelin Sat, 21 Apr 2018 11:14:08 +0000 (13:14 +0200)

gettext: avoid initialization if the locale dir is not present

The runtime of a simple `git.exe version` call on Windows is currently
dominated by the gettext setup, adding a whopping ~150ms to the ~210ms
total.

Given that this cost is added to each and every git.exe invocation goes
through common-main's invocation of git_setup_gettext(), and given that
scripts have to call git.exe dozens, if not hundreds, of times, this is
a substantial performance penalty.

This is particularly pointless when considering that Git for Windows
ships without localization (to keep the installer's size to a bearable
~34MB): all that time setting up gettext is for naught.

To be clear, Git for Windows *needs* to be compiled with localization,
for the following reasons:

- to allow users to copy add-on localization in case they want it, and

- to fix the nasty error message

BUG: your vsnprintf is broken (returned -1)

by using libgettext's override of vsnprintf() that does not share the
behavior of msvcrt.dll's version of vsnprintf().

So let's be smart about it and skip setting up gettext if the locale
directory is not even present.

Since localization might be missing for not-yet-supported locales, this
will not break anything.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Makefile: quote $INSTLIBDIR when passing it to sedJonathan Nieder Mon, 23 Apr 2018 23:25:35 +0000 (16:25 -0700)

Makefile: quote $INSTLIBDIR when passing it to sed

f6a0ad4b (Makefile: generate Perl header from template file,
2018-04-10) moved code for generating the 'use lib' lines at the top
of perl scripts from the $(SCRIPT_PERL_GEN) rule to a separate
GIT-PERL-HEADER rule.

This rule first populates INSTLIBDIR and then substitutes it into the
GIT-PERL-HEADER using sed:

INSTLIBDIR=... something ...
sed -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' $< > $@

Because $INSTLIBDIR is not surrounded by double quotes, the shell
splits it at each space, causing errors if INSTLIBDIR contains an $IFS
character:

sed: 1: "s=@@INSTLIBDIR@@=/usr/l ...": unescaped newline inside substitute pattern

Add back the missing double-quotes to make it work again.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Makefile: remove unused @@PERLLIBDIR@@ substitution... Jonathan Nieder Mon, 23 Apr 2018 23:24:22 +0000 (16:24 -0700)

Makefile: remove unused @@PERLLIBDIR@@ substitution variable

Junio noticed that this variable is not quoted correctly when it is
passed to sed. As a shell-quoted string, it should be inside
single-quotes like $(perllibdir_relative_SQ), not outside them like
$INSTLIBDIR.

In fact, this substitution variable is not used. Simplify by removing
it.

Reported-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

walker: drop fields of `struct walker` which are always 1Martin Ågren Sun, 22 Apr 2018 18:12:50 +0000 (20:12 +0200)

walker: drop fields of `struct walker` which are always 1

After the previous commit, both users of `struct walker` set `get_tree`,
`get_history` and `get_all` to 1. Drop those fields and simplify the
walker implementation accordingly.

Let's hope that any out-of-tree users will not mind this change. They
should notice that the compilation fails as they try to set these
fields. (If they do not set them, note that `get_http_walker()` leaves
them undefined, so the behavior will have been undefined all the time.)

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

http-fetch: make `-a` standard behaviourMartin Ågren Sun, 22 Apr 2018 18:12:49 +0000 (20:12 +0200)

http-fetch: make `-a` standard behaviour

This is a follow-up to a6c786fce8 (Mark http-fetch without -a as
deprecated, 2011-08-23). For more than six years, we have been warning
when `-a` is not provided, and the documentation has been saying that
`-a` will become the default.

It is a bit unclear what "default" means here. There is no such thing as
`http-fetch --no-a`. But according to my searches, no-one has been
asking on the mailing list how they should silence the warning and
prepare for overriding the flipped default. So let's assume that
everybody is happy with `-a`. They should be, since not using it may
break the repo in such a way that Git itself is unable to fix it.

Always behave as if `-a` was given. Since `-a` implies `-c` (get commit
objects) and `-t` (get trees), all three options are now unnecessary.
Document all of these as historical artefacts that have no effect.

Leave no-op code for handling these options in http-fetch.c. The
options-handling is currently rather loose. If someone tightens it, we
will not want these ignored options to accidentally turn into hard
errors.

Since `-a` was the only safe and sane usage and we have been pushing
people towards it for a long time, refrain from warning when it is used
"unnecessarily" now. Similarly, do not add anything scary-looking to the
man-page about how it will be removed in the future. We can always do so
later. (It is not like we are in desperate need of freeing up
one-letter arguments.)

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: document the settings to colorize push errors... Johannes Schindelin Sat, 21 Apr 2018 10:10:07 +0000 (12:10 +0200)

config: document the settings to colorize push errors/hints

Let's make it easier for users to find out how to customize these colors.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

push: test to verify that push errors are coloredJohannes Schindelin Sat, 21 Apr 2018 10:10:04 +0000 (12:10 +0200)

push: test to verify that push errors are colored

This actually only tests whether the push errors/hints are colored if
the respective color.* config settings are `always`, but in the regular
case they default to `auto` (in which case we color the messages when
stderr is connected to an interactive terminal), therefore these tests
should suffice.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

push: colorize errorsRyan Dammrose Sat, 21 Apr 2018 10:10:00 +0000 (12:10 +0200)

push: colorize errors

This is an attempt to resolve an issue I experience with people that are
new to Git -- especially colleagues in a team setting -- where they miss
that their push to a remote location failed because the failure and
success both return a block of white text.

An example is if I push something to a remote repository and then a
colleague attempts to push to the same remote repository and the push
fails because it requires them to pull first, but they don't notice
because a success and failure both return a block of white text. They
then continue about their business, thinking it has been successfully
pushed.

This patch colorizes the errors and hints (in red and yellow,
respectively) so whenever there is a failure when pushing to a remote
repository that fails, it is more noticeable.

[jes: fixed a couple bugs, added the color.{advice,push,transport}
settings, refactored to use want_color_stderr().]

Signed-off-by: Ryan Dammrose ryandammrose@gmail.com
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

color: introduce support for colorizing stderrJohannes Schindelin Sat, 21 Apr 2018 10:09:57 +0000 (12:09 +0200)

color: introduce support for colorizing stderr

So far, we only ever asked whether stdout wants to be colorful. In the
upcoming patches, we will want to make push errors more prominent, which
are printed to stderr, though.

So let's refactor the want_color() function into a want_color_fd()
function (which expects to be called with fd == 1 or fd == 2 for stdout
and stderr, respectively), and then define the macro `want_color()` to
use the want_color_fd() function.

And then also add a macro `want_color_stderr()`, for convenience and
for documentation.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

builtin/config: introduce `color` type specifierTaylor Blau Tue, 10 Apr 2018 00:18:31 +0000 (17:18 -0700)

builtin/config: introduce `color` type specifier

As of this commit, the canonical way to retreive an ANSI-compatible
color escape sequence from a configuration file is with the
`--get-color` action.

This is to allow Git to "fall back" on a default value for the color
should the given section not exist in the specified configuration(s).

With the addition of `--default`, this is no longer needed since:

$ git config --default red --type=color core.section

will be have exactly as:

$ git config --get-color core.section red

For consistency, let's introduce `--type=color` and encourage its use
with `--default` together over `--get-color` alone.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config.c: introduce 'git_config_color' to parse ANSI... Taylor Blau Tue, 10 Apr 2018 00:18:28 +0000 (17:18 -0700)

config.c: introduce 'git_config_color' to parse ANSI colors

In preparation for adding `--type=color` to the `git-config(1)` builtin,
let's introduce a color parsing utility, `git_config_color` in a similar
fashion to `git_config_<type>`.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

builtin/config: introduce `--default`Taylor Blau Tue, 10 Apr 2018 00:18:26 +0000 (17:18 -0700)

builtin/config: introduce `--default`

For some use cases, callers of the `git-config(1)` builtin would like to
fallback to default values when the variable asked for does not exist.
In addition, users would like to use existing type specifiers to ensure
that values are parsed correctly when they do exist in the
configuration.

For example, to fetch a value without a type specifier and fallback to
`$fallback`, the following is required:

$ git config core.foo || echo "$fallback"

This is fine for most values, but can be tricky for difficult-to-express
`$fallback`'s, like ANSI color codes.

This motivates `--get-color`, which is a one-off exception to the normal
type specifier rules wherein a user specifies both the configuration
variable and an optional fallback. Both are formatted according to their
type specifier, which eases the burden on the user to ensure that values
are correctly formatted.

This commit (and those following it in this series) aim to eventually
replace `--get-color` with a consistent alternative. By introducing
`--default`, we allow the `--get-color` action to be promoted to a
`--type=color` type specifier, retaining the "fallback" behavior via the
`--default` flag introduced in this commit.

For example, we aim to replace:

$ git config --get-color variable [default] [...]

with:

$ git config --default default --type=color variable [...]

Values filled by `--default` behave exactly as if they were present in
the affected configuration file; they will be parsed by type specifiers
without the knowledge that they are not themselves present in the
configuration.

Specifically, this means that the following will work:

$ git config --int --default 1M does.not.exist
1048576

In subsequent commits, we will offer `--type=color`, which (in
conjunction with `--default`) will be sufficient to replace
`--get-color`.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

parseopt: handle malformed --expire arguments more... Junio C Hamano Sat, 21 Apr 2018 03:13:13 +0000 (12:13 +0900)

parseopt: handle malformed --expire arguments more nicely

A few commands that parse --expire=<time> command line option behave
sillily when given nonsense input. For example

$ git prune --no-expire
Segmentation falut
$ git prune --expire=npw; echo $?
129

Both come from parse_opt_expiry_date_cb().

The former is because the function is not prepared to see arg==NULL
(for "--no-expire", it is a norm; "--expire" at the end of the
command line could be made to pass NULL, if it is told that the
argument is optional, but we don't so we do not have to worry about
that case).

The latter is because it does not check the value returned from the
underlying parse_expiry_date().

This seems to be a recent regression introduced while we attempted
to avoid spewing the entire usage message when given a correct
option but with an invalid value at 3bb0923f ("parse-options: do not
show usage upon invalid option value", 2018-03-22). Before that, we
didn't fail silently but showed a full usage help (which arguably is
not all that better).

Also catch this error early when "git gc --prune=<expiration>" is
misspelled by doing a dummy parsing before the main body of "gc"
that is time consuming even begins. Otherwise, we'd spend time to
pack objects and then later have "git prune" first notice the error.
Aborting "gc" in the middle that way is not harmful but is ugly and
can be avoided.

Helped-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gc: do not upcase error message shown with die()Junio C Hamano Mon, 23 Apr 2018 13:36:14 +0000 (22:36 +0900)

gc: do not upcase error message shown with die()

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

fast-export: fix regression skipping some merge-commitsMartin Ågren Fri, 20 Apr 2018 22:12:31 +0000 (00:12 +0200)

fast-export: fix regression skipping some merge-commits

7199203937 (object_array: add and use `object_array_pop()`, 2017-09-23)
noted that the pattern `object = array.objects[--array.nr].item` could
be abstracted as `object = object_array_pop(&array)`.

Unfortunately, one of the conversions was horribly wrong. Between
grabbing the last object (i.e., peeking at it) and decreasing the object
count, the original code would sometimes return early. The updated code
on the other hand, will always pop the last element, then maybe do the
early return without doing anything with the object.

The end result is that merge commits where all the parents have still
not been exported will simply be dropped, meaning that they will be
completely missing from the exported data.

Re-add a commit when it is not yet time to handle it. An alternative
that was considered was to peek-then-pop. That carries some risk with it
since the peeking and popping need to act on the same object, in a
concerted fashion.

Add a test that would have caught this.

Reported-by: Isaac Chou <Isaac.Chou@microfocus.com>
Analyzed-by: Isaac Chou <Isaac.Chou@microfocus.com>
Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

completion: make stash -p and alias for stash push -pThomas Gummerer Thu, 19 Apr 2018 23:25:14 +0000 (00:25 +0100)

completion: make stash -p and alias for stash push -p

We define 'git stash -p' as an alias for 'git stash push -p' in the
manpage. Do the same in the completion script, so all options that
can be given to 'git stash push' are being completed when the user is
using 'git stash -p --<tab>'. Currently the only additional option
the user will get is '--message', but there may be more in the future.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

completion: stop showing 'save' for stash by defaultThomas Gummerer Thu, 19 Apr 2018 23:25:13 +0000 (00:25 +0100)

completion: stop showing 'save' for stash by default

The 'save' subcommand in git stash has been deprecated in
fd2ebf14db ("stash: mark "git stash save" deprecated in the man page",
2017-10-22).

Stop showing it when the users enters 'git stash <tab>' or 'git stash
s<tab>'. Keep showing it however when the user enters 'git stash sa<tab>'
or any more characters of the 'save' subcommand. This is designed to
not encourage users to use 'git stash save', but still leaving the
completion option once it's clear that's what the user means.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

doc/clone: update caption for GIT URLS cross-referenceTodd Zullinger Thu, 19 Apr 2018 17:32:30 +0000 (13:32 -0400)

doc/clone: update caption for GIT URLS cross-reference

The description of the <repository> argument directs readers to "See the
URLS section below". When generating HTML this becomes a link to the
"GIT URLS" section. When reading the man page in a terminal, the
caption is slightly misleading. Use "GIT URLS" as the caption to avoid
any confusion.

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

builtin/config.c: support `--type=<type>` as preferred... Taylor Blau Wed, 18 Apr 2018 21:43:35 +0000 (14:43 -0700)

builtin/config.c: support `--type=<type>` as preferred alias for `--<type>`

`git config` has long allowed the ability for callers to provide a 'type
specifier', which instructs `git config` to (1) ensure that incoming
values can be interpreted as that type, and (2) that outgoing values are
canonicalized under that type.

In another series, we propose to extend this functionality with
`--type=color` and `--default` to replace `--get-color`.

However, we traditionally use `--color` to mean "colorize this output",
instead of "this value should be treated as a color".

Currently, `git config` does not support this kind of colorization, but
we should be careful to avoid squatting on this option too soon, so that
`git config` can support `--color` (in the traditional sense) in the
future, if that is desired.

In this patch, we support `--type=<int|bool|bool-or-int|...>` in
addition to `--int`, `--bool`, and etc. This allows the aforementioned
upcoming patch to support querying a color value with a default via
`--type=color --default=...`, without squandering `--color`.

We retain the historic behavior of complaining when multiple,
legacy-style `--<type>` flags are given, as well as extend this to
conflicting new-style `--type=<type>` flags. `--int --type=int` (and its
commutative pair) does not complain, but `--bool --type=int` (and its
commutative pair) does.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sequencer: reset the committer date before commitsJohannes Sixt Wed, 18 Apr 2018 18:15:04 +0000 (20:15 +0200)

sequencer: reset the committer date before commits

Now that the sequencer commits without forking when the commit message
isn't edited all the commits that are picked have the same committer
date. If a commit is reworded it's committer date will be a later time
as it is created by running an separate instance of 'git commit'. If
the reworded commit is follow by further picks, those later commits
will have an earlier committer date than the reworded one. This is
caused by git caching the default date used when GIT_COMMITTER_DATE is
not set. Reset the cached date before a commit is generated
in-process.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

send-email: avoid duplicate In-Reply-To/ReferencesStefan Agner Tue, 17 Apr 2018 21:16:30 +0000 (23:16 +0200)

send-email: avoid duplicate In-Reply-To/References

In case a patch already has In-Reply-To or References in the header
(e.g. when the patch has been created with format-patch --thread)
git-send-email should not add another pair of those headers.
This is also not allowed according to RFC 5322 Section 3.6:
https://tools.ietf.org/html/rfc5322#section-3.6

Avoid the second pair by reading the current headers into the
appropriate variables.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Makefile: mark perllibdir as a .PHONY targetChristian Hesse Wed, 18 Apr 2018 21:44:40 +0000 (06:44 +0900)

Makefile: mark perllibdir as a .PHONY target

This target should be marked as .PHONY, just like other targets that
exist only for their side effects that do not create filesystem
entities with the same name.

Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule--helper: don't print null in 'submodule status'Nguyễn Thái Ngọc Duy Wed, 18 Apr 2018 14:53:37 +0000 (16:53 +0200)

submodule--helper: don't print null in 'submodule status'

The function compute_rev_name() can return NULL sometimes (e.g. right
after 'submodule init'). The current code makes 'submodule status'
print this:

19d97bf5af05312267c2e874ee6bcf584d9e9681 sha1collisiondetection ((null))

This ugly 'null' adds no value to the user using this command. More
importantly printf() on some platform can't handle NULL as a string
and will crash instead of printing '(null)'.

Check for this and skip printing this part (the alternative is
printing '(n/a)' or something but I think that is just noise).

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Reviewed-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-submodule.txt: quote usage in monospace, drop backslashMartin Ågren Tue, 17 Apr 2018 19:15:29 +0000 (21:15 +0200)

git-submodule.txt: quote usage in monospace, drop backslash

We tend to quote command line examples using `` to set them in a
monospace font. The immediate motivation for this patch is to get rid of
another instance of \--. As noted in the previous commits, \-- has a
tendency of rendering badly. Here, it renders ok (at least with
AsciiDoc 8.6.9 and Asciidoctor 1.5.4), but by getting rid of this
instance, we reduce the chances of \-- cropping up in places where it
matters more.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>

git-[short]log.txt: unify quoted standalone --Martin Ågren Tue, 17 Apr 2018 19:15:28 +0000 (21:15 +0200)

git-[short]log.txt: unify quoted standalone --

In git-log.txt, we have an instance of \--, which is known to sometimes
render badly. This one is even worse than normal though, since ``\-- ''
(with or without that trailing space) appears to be entirely broken,
both in HTML and manpages, both with AsciiDoc (version 8.6.9) and
Asciidoctor (version 1.5.4).

Further down in git-log.txt we have a ``--'', which renders good. In
git-shortlog.txt, we use "\-- " (including the quotes and the space),
which happens to look fairly good. I failed to find any other similar
instances. So all in all, we quote a double-dash in three different
places and do it differently each time, with various degrees of success.

Switch all of these to `--`. This sets the double-dash in monospace and
matches what we usually do with example command line usages and options.
Note that we drop the trailing space as well, since `-- ` does not
render well. These should still be clear enough since just a few lines
above each instance, the space is clearly visible in a longer context.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>

doc: convert [\--] to [--]Martin Ågren Tue, 17 Apr 2018 19:15:27 +0000 (21:15 +0200)

doc: convert [\--] to [--]

Commit 1c262bb7b (doc: convert \--option to --option, 2015-05-13)
explains that we used to need to write \--option to play well with older
versions of AsciiDoc, but that we do not support such versions anymore
anyway, and that Asciidoctor literally renders \--.

With [\--], which is used to denote the optional separator between
revisions and paths, Asciidoctor renders the backslash literally.
Change all [\--] to [--]. This changes nothing for AsciiDoc version
8.6.9, but is an improvement for Asciidoctor version 1.5.4.

We use double-dashes in several list entries (\--::). In my testing, it
appears that we do need to use the backslash there, so leave those.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>

doc: convert \--option to --optionMartin Ågren Tue, 17 Apr 2018 19:15:26 +0000 (21:15 +0200)

doc: convert \--option to --option

Rather than using a backslash in \--foo, with or without ''-quoting,
write `--foo` for better rendering. As explained in commit 1c262bb7b
(doc: convert \--option to --option, 2015-05-13), the backslash is not
needed for the versions of AsciiDoc that we support, but is rendered
literally by Asciidoctor.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>

docs/git-gc: fix minor rendering issueSZEDER Gábor Tue, 17 Apr 2018 21:36:28 +0000 (23:36 +0200)

docs/git-gc: fix minor rendering issue

An unwanted single quote character in the paragraph documenting the
'gc.aggressiveWindow' config variable prevented the name of that
config variable from being rendered correctly, ever since that piece
of docs was added in 0d7566a5ba (Add --aggressive option to 'git gc',
2007-05-09).

Remove that single quote.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

worktree: accept -f as short for --force for removalStefan Beller Tue, 17 Apr 2018 18:19:39 +0000 (11:19 -0700)

worktree: accept -f as short for --force for removal

Many commands support a "--force" option, frequently abbreviated as
"-f", however, "git worktree remove"'s hand-rolled OPT_BOOL forgets
to recognize the short form, despite git-worktree.txt documenting
"-f" as supported. Replace OPT_BOOL with OPT__FORCE, which provides
"-f" for free, and makes 'remove' consistent with 'add' option
parsing (which also specifies the PARSE_OPT_NOCOMPLETE flag).

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

completion: reduce overhead of clearing cached --optionsSZEDER Gábor Tue, 17 Apr 2018 22:02:19 +0000 (00:02 +0200)

completion: reduce overhead of clearing cached --options

To get the names of all '$__git_builtin_*' variables caching --options
of builtin commands in order to unset them, 8b0eaa41f2 (completion:
clear cached --options when sourcing the completion script,
2018-03-22) runs a 'set |sed s///' pipeline. This works both in Bash
and in ZSH, but has a higher than necessary overhead with the extra
processes.

In Bash we can do better: run the 'compgen -v __gitcomp_builtin_'
builtin command, which lists the same variables, but without a
pipeline and 'sed' it can do so with lower overhead.
ZSH will still continue to run that pipeline.

This change also happens to work around an issue in the default Bash
version shipped in macOS (3.2.57), reported by users of the Powerline
shell prompt, which was triggered by the same commit 8b0eaa41f2 as
well. Powerline uses several Unicode Private Use Area code points to
represent some of its pretty text UI elements (arrows and what not),
and these are stored in the $PS1 variable. Apparently the 'set'
builtin of said Bash version on macOS has issues with these code
points, and produces garbled output where Powerline's special symbols
should be in the $PS1 variable. This, in turn, triggers the following
error message in the downstream 'sed' process:

sed: RE error: illegal byte sequence

Other Bash versions, notably 4.4.19 on macOS via homebrew (i.e. a
newer version on the same platform) and 3.2.25 on CentOS (i.e. a
slightly earlier version, though on a different platform) are not
affected. ZSH in macOS (the versions shipped by default or installed
via homebrew) or on other platforms isn't affected either.

With this patch neither the 'set' builtin is invoked to print garbage,
nor 'sed' to choke on it.

Issue-on-macOS-reported-by: Stephon Harris <theonestep4@gmail.com>
Issue-on-macOS-explained-by: Matthew Coleman <matt@1eanda.com>
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

glossary: substitute "ancestor" for "direct ancestor... Sergey Organov Mon, 16 Apr 2018 05:43:16 +0000 (08:43 +0300)

glossary: substitute "ancestor" for "direct ancestor" in 'push' description.

Even though "direct ancestor" is not defined in the glossary, the
common meaning of the term is simply "parent", parents being the only
direct ancestors, and the rest of ancestors being indirect ancestors.

As "parent" is obviously wrong in this place in the description, we
should simply say "ancestor", as everywhere else.

Signed-off-by: Sergey Organov <sorganov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t1510-repo-setup.sh: remove useless mkdirTao Qingyun Sun, 15 Apr 2018 02:45:04 +0000 (10:45 +0800)

t1510-repo-setup.sh: remove useless mkdir

Signed-off-by: Tao Qingyun <845767657@qq.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git{,-blame}.el: remove old bitrotting Emacs codeÆvar Arnfjörð Bjarmason Wed, 11 Apr 2018 20:42:05 +0000 (20:42 +0000)

git{,-blame}.el: remove old bitrotting Emacs code

The git-blame.el mode has been superseded by Emacs's own
vc-annotate (invoked by C-x v g). Users of the git.el mode are now
much better off using either Magit or the Git backend for Emacs's own
VC mode.

These modes were added over 10 years ago when Emacs's own Git support
was much less mature, and there weren't other mature modes in the wild
or shipped with Emacs itself.

These days these modes have few if any users, and users of git aren't
well served by us shipping these (some OS's install them alongside git
by default, which is confusing and leads users astray).

So let's remove these per Alexandre Julliard's message to the
ML[1]. If someone still wants these for some reason they're better
served by hosting these elsewhere (e.g. on ELPA), instead of us
distributing them with git.

However, since downstream packagers such as Debian are packaging this
as git-el it's less disruptive to still carry these files as Elisp
code that'll error out with a message suggesting alternatives, rather
than drop the files entirely[2].

Then rather than receive a cryptic load error when they upgrade
existing users will get an error directing them to the README file, or
to just stop requiring these modes. I think it makes sense to link to
GitHub's hosting of contrib/emacs/README (which'll be updated by the
time users see this) so they don't have to hunt down the packaged
README on their local system.

1. "Re: [PATCH] git.el: handle default excludesfile
properly" (87muzlwhb0.fsf@winehq.org) --
https://public-inbox.org/git/87muzlwhb0.fsf@winehq.org/

2. "Re: [PATCH v3] git{,-blame}.el: remove old bitrotting Emacs
code" (20180327165751.GA4343@aiede.svl.corp.google.com) --
https://public-inbox.org/git/20180327165751.GA4343@aiede.svl.corp.google.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gpg-interface: find the last gpg signature lineJeff King Fri, 13 Apr 2018 21:18:35 +0000 (15:18 -0600)

gpg-interface: find the last gpg signature line

A signed tag has a detached signature like this:

object ...
[...more header...]

This is the tag body.

-----BEGIN PGP SIGNATURE-----
[opaque gpg data]
-----END PGP SIGNATURE-----

Our parser finds the _first_ line that appears to start a
PGP signature block, meaning we may be confused by a
signature (or a signature-like line) in the actual body.
Let's keep parsing and always find the final block, which
should be the detached signature over all of the preceding
content.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gpg-interface: extract gpg line matching helperJeff King Fri, 13 Apr 2018 21:18:34 +0000 (15:18 -0600)

gpg-interface: extract gpg line matching helper

Let's separate the actual line-by-line parsing of signatures
from the notion of "is this a gpg signature line". That will
make it easier to do more refactoring of this loop in future
patches.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gpg-interface: fix const-correctness of "eol" pointerJeff King Fri, 13 Apr 2018 21:18:33 +0000 (15:18 -0600)

gpg-interface: fix const-correctness of "eol" pointer

We accidentally shed the "const" of our buffer by passing it
through memchr. Let's fix that, and while we're at it, move
our variable declaration inside the loop, which is the only
place that uses it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gpg-interface: use size_t for signature buffer sizeJeff King Fri, 13 Apr 2018 21:18:32 +0000 (15:18 -0600)

gpg-interface: use size_t for signature buffer size

Even though our object sizes (from which these buffers would
come) are typically "unsigned long", this is something we'd
like to eventually fix (since it's only 32-bits even on
64-bit Windows). It makes more sense to use size_t when
taking an in-memory buffer.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gpg-interface: modernize function declarationsJeff King Fri, 13 Apr 2018 21:18:31 +0000 (15:18 -0600)

gpg-interface: modernize function declarations

Let's drop "extern" from our declarations, which brings us
in line with our modern style guidelines. While we're
here, let's wrap some of the overly long lines, and move
docstrings for public functions to their declarations, since
they document the interface.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gpg-interface: handle bool user.signingkeyJeff King Fri, 13 Apr 2018 21:18:30 +0000 (15:18 -0600)

gpg-interface: handle bool user.signingkey

The config handler for user.signingkey does not check for a
boolean value, and thus:

git -c user.signingkey tag

will segfault. We could fix this and even shorten the code
by using git_config_string(). But our set_signing_key()
helper is used by other code outside of gpg-interface.c, so
we must keep it (and we may as well use it, because unlike
git_config_string() it does not leak when we overwrite an
old value).

Ironically, the handler for gpg.program just below _could_
use git_config_string() but doesn't. But since we're going
to touch that in a future patch, we'll leave it alone for
now. We will add some whitespace and returns in preparation
for adding more config keys, though.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7004: fix mistaken tag nameJeff King Fri, 13 Apr 2018 21:18:29 +0000 (15:18 -0600)

t7004: fix mistaken tag name

We have a series of tests which create signed tags with
various properties, but one test accidentally verifies a tag
from much earlier in the series.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Makefile: add a DEVOPTS to get all of -WextraÆvar Arnfjörð Bjarmason Sat, 14 Apr 2018 19:19:46 +0000 (19:19 +0000)

Makefile: add a DEVOPTS to get all of -Wextra

Change DEVOPTS to understand a "extra-all" option. When the DEVELOPER
flag is enabled we turn on -Wextra, but manually switch some of the
warnings it turns on off.

This is because we have many existing occurrences of them in the code
base. This mode will stop the suppression, let the developer see and
decide whether to fix them.

This change is a slight alteration of Nguyễn Thái Ngọc Duy
EAGER_DEVELOPER mode patch[1]

1. "[PATCH v3 3/3] Makefile: add EAGER_DEVELOPER
mode" (<20180329150322.10722-4-pclouds@gmail.com>;
https://public-inbox.org/git/20180329150322.10722-4-pclouds@gmail.com/)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Makefile: add a DEVOPTS to suppress -Werror under DEVELOPERÆvar Arnfjörð Bjarmason Sat, 14 Apr 2018 19:19:45 +0000 (19:19 +0000)

Makefile: add a DEVOPTS to suppress -Werror under DEVELOPER

Add a DEVOPTS variable that'll be used to tweak the behavior of
DEVELOPER.

I've long wanted to use DEVELOPER=1 in my production builds, but on
some old systems I still get warnings, and thus the build would
fail. However if the build/tests fail for some other reason, it would
still be useful to scroll up and see what the relevant code is warning
about.

This change allows for that. Now setting DEVELOPER will set -Werror as
before, but if DEVOPTS=no-error is provided is set you'll get the same
warnings, but without -Werror.

Helped-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Makefile: detect compiler and enable more warnings... Nguyễn Thái Ngọc Duy Sat, 14 Apr 2018 19:19:44 +0000 (19:19 +0000)

Makefile: detect compiler and enable more warnings in DEVELOPER=1

The set of extra warnings we enable when DEVELOPER has to be
conservative because we can't assume any compiler version the
developer may use. Detect the compiler version so we know when it's
safe to enable -Wextra and maybe more.

These warning settings are mostly from my custom config.mak a long
time ago when I tried to enable as many warnings as possible that can
still build without showing warnings. Some of those warnings are
probably worth fixing instead of just suppressing in future.

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

connect.c: mark die_initial_contact() NORETURNNguyễn Thái Ngọc Duy Sat, 14 Apr 2018 19:19:43 +0000 (19:19 +0000)

connect.c: mark die_initial_contact() NORETURN

There is a series running in parallel with this one that adds code
like this

switch (...) {
case ...:
die_initial_contact();
case ...:

There is nothing wrong with this. There is no actual falling
through. But since gcc is not that smart and gcc 7.x introduces
-Wimplicit-fallthrough, it raises a false alarm in this case.

This class of warnings may be useful elsewhere, so instead of
suppressing the whole class, let's try to fix just this code. gcc is
smart enough to realize that no execution can continue after a
NORETURN function call and no longer raises the warning.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pack-objects: show some progress when counting kept... Nguyễn Thái Ngọc Duy Sun, 15 Apr 2018 15:36:18 +0000 (17:36 +0200)

pack-objects: show some progress when counting kept objects

We only show progress when there are new objects to be packed. But
when --keep-pack is specified on the base pack, we will exclude most
of objects. This makes 'pack-objects' stay silent for a long time
while the counting phase is going.

Let's show some progress whenever we visit an object instead. The old
"Counting objects" is renamed to "Enumerating objects" and a new
progress "Counting objects" line is added.

This new "Counting objects" line should progress pretty quick when the
system is beefy. But when the system is under pressure, the reading
object header done in this phase could be slow and showing progress is
an improvement over staying silent in the current code.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gc --auto: exclude base pack if not enough mem to ... Nguyễn Thái Ngọc Duy Sun, 15 Apr 2018 15:36:17 +0000 (17:36 +0200)

gc --auto: exclude base pack if not enough mem to "repack -ad"

pack-objects could be a big memory hog especially on large repos,
everybody knows that. The suggestion to stick a .keep file on the
giant base pack to avoid this problem is also known for a long time.

Recent patches add an option to do just this, but it has to be either
configured or activated manually. This patch lets `git gc --auto`
activate this mode automatically when it thinks `repack -ad` will use
a lot of memory and start affecting the system due to swapping or
flushing OS cache.

gc --auto decides to do this based on an estimation of pack-objects
memory usage, which is quite accurate at least for the heap part, and
whether that fits in half of system memory (the assumption here is for
desktop environment where there are many other applications running).

This mechanism only kicks in if gc.bigBasePackThreshold is not configured.
If it is, it is assumed that the user already knows what they want.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gc: handle a corner case in gc.bigPackThresholdNguyễn Thái Ngọc Duy Sun, 15 Apr 2018 15:36:16 +0000 (17:36 +0200)

gc: handle a corner case in gc.bigPackThreshold

This config allows us to keep <N> packs back if their size is larger
than a limit. But if this N >= gc.autoPackLimit, we may have a
problem. We are supposed to reduce the number of packs after a
threshold because it affects performance.

We could tell the user that they have incompatible gc.bigPackThreshold
and gc.autoPackLimit, but it's kinda hard when 'git gc --auto' runs in
background. Instead let's fall back to the next best stategy: try to
reduce the number of packs anyway, but keep the base pack out. This
reduces the number of packs to two and hopefully won't take up too
much resources to repack (the assumption still is the base pack takes
most resources to handle).

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gc: add gc.bigPackThreshold configNguyễn Thái Ngọc Duy Sun, 15 Apr 2018 15:36:15 +0000 (17:36 +0200)

gc: add gc.bigPackThreshold config

The --keep-largest-pack option is not very convenient to use because
you need to tell gc to do this explicitly (and probably on just a few
large repos).

Add a config key that enables this mode when packs larger than a limit
are found. Note that there's a slight behavior difference compared to
--keep-largest-pack: all packs larger than the threshold are kept, not
just the largest one.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gc: add --keep-largest-pack optionNguyễn Thái Ngọc Duy Sun, 15 Apr 2018 15:36:14 +0000 (17:36 +0200)

gc: add --keep-largest-pack option

This adds a new repack mode that combines everything into a secondary
pack, leaving the largest pack alone.

This could help reduce memory pressure. On linux-2.6.git, valgrind
massif reports 1.6GB heap in "pack all" case, and 535MB in "pack
all except the base pack" case. We save roughly 1GB memory by
excluding the base pack.

This should also lower I/O because we don't have to rewrite a giant
pack every time (e.g. for linux-2.6.git that's a 1.4GB pack file)..

PS. The use of string_list here seems overkill, but we'll need it in
the next patch...

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

repack: add --keep-pack optionNguyễn Thái Ngọc Duy Sun, 15 Apr 2018 15:36:13 +0000 (17:36 +0200)

repack: add --keep-pack option

We allow to keep existing packs by having companion .keep files. This
is helpful when a pack is permanently kept. In the next patch, git-gc
just wants to keep a pack temporarily, for one pack-objects
run. git-gc can use --keep-pack for this use case.

A note about why the pack_keep field cannot be reused and
pack_keep_in_core has to be added. This is about the case when
--keep-pack is specified together with either --keep-unreachable or
--unpack-unreachable, but --honor-pack-keep is NOT specified.

In this case, we want to exclude objects from the packs specified on
command line, not from ones with .keep files. If only one bit flag is
used, we have to clear pack_keep on pack files with the .keep file.

But we can't make any assumption about unreachable objects in .keep
packs. If "pack_keep" field is false for .keep packs, we could
potentially pull lots of unreachable objects into the new pack, or
unpack them loose. The safer approach is ignore all packs with either
.keep file or --keep-pack.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7700: have closing quote of a test at the beginning... Nguyễn Thái Ngọc Duy Sun, 15 Apr 2018 15:36:12 +0000 (17:36 +0200)

t7700: have closing quote of a test at the beginning of line

The closing quote of a test body by convention is always at the start
of line.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

convert: add round trip check based on 'core.checkRound... Lars Schneider Sun, 15 Apr 2018 18:16:10 +0000 (20:16 +0200)

convert: add round trip check based on 'core.checkRoundtripEncoding'

UTF supports lossless conversion round tripping and conversions between
UTF and other encodings are mostly round trip safe as Unicode aims to be
a superset of all other character encodings. However, certain encodings
(e.g. SHIFT-JIS) are known to have round trip issues [1].

Add 'core.checkRoundtripEncoding', which contains a comma separated
list of encodings, to define for what encodings Git should check the
conversion round trip if they are used in the 'working-tree-encoding'
attribute.

Set SHIFT-JIS as default value for 'core.checkRoundtripEncoding'.

[1] https://support.microsoft.com/en-us/help/170559/prb-conversion-problem-between-shift-jis-and-unicode

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

convert: add tracing for 'working-tree-encoding' attributeLars Schneider Sun, 15 Apr 2018 18:16:09 +0000 (20:16 +0200)

convert: add tracing for 'working-tree-encoding' attribute

Add the GIT_TRACE_WORKING_TREE_ENCODING environment variable to enable
tracing for content that is reencoded with the 'working-tree-encoding'
attribute. This is useful to debug encoding issues.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

convert: check for detectable errors in UTF encodingsLars Schneider Sun, 15 Apr 2018 18:16:08 +0000 (20:16 +0200)

convert: check for detectable errors in UTF encodings

Check that new content is valid with respect to the user defined
'working-tree-encoding' attribute.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

convert: add 'working-tree-encoding' attributeLars Schneider Sun, 15 Apr 2018 18:16:07 +0000 (20:16 +0200)

convert: add 'working-tree-encoding' attribute

Git recognizes files encoded with ASCII or one of its supersets (e.g.
UTF-8 or ISO-8859-1) as text files. All other encodings are usually
interpreted as binary and consequently built-in Git text processing
tools (e.g. 'git diff') as well as most Git web front ends do not
visualize the content.

Add an attribute to tell Git what encoding the user has defined for a
given file. If the content is added to the index, then Git reencodes
the content to a canonical UTF-8 representation. On checkout Git will
reverse this operation.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

utf8: add function to detect a missing UTF-16/32 BOMLars Schneider Sun, 15 Apr 2018 18:16:06 +0000 (20:16 +0200)

utf8: add function to detect a missing UTF-16/32 BOM

If the endianness is not defined in the encoding name, then let's
be strict and require a BOM to avoid any encoding confusion. The
is_missing_required_utf_bom() function returns true if a required BOM
is missing.

The Unicode standard instructs to assume big-endian if there in no BOM
for UTF-16/32 [1][2]. However, the W3C/WHATWG encoding standard used
in HTML5 recommends to assume little-endian to "deal with deployed
content" [3]. Strictly requiring a BOM seems to be the safest option
for content in Git.

This function is used in a subsequent commit.

[1] http://unicode.org/faq/utf_bom.html#gen6
[2] http://www.unicode.org/versions/Unicode10.0.0/ch03.pdf
Section 3.10, D98, page 132
[3] https://encoding.spec.whatwg.org/#utf-16le

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

utf8: add function to detect prohibited UTF-16/32 BOMLars Schneider Sun, 15 Apr 2018 18:16:05 +0000 (20:16 +0200)

utf8: add function to detect prohibited UTF-16/32 BOM

Whenever a data stream is declared to be UTF-16BE, UTF-16LE, UTF-32BE
or UTF-32LE a BOM must not be used [1]. The function returns true if
this is the case.

This function is used in a subsequent commit.

[1] http://unicode.org/faq/utf_bom.html#bom10

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

utf8: teach same_encoding() alternative UTF encoding... Lars Schneider Sun, 15 Apr 2018 18:16:04 +0000 (20:16 +0200)

utf8: teach same_encoding() alternative UTF encoding names

The function same_encoding() could only recognize alternative names for
UTF-8 encodings. Teach it to recognize all kinds of alternative UTF
encoding names (e.g. utf16).

While we are at it, fix a crash that would occur if same_encoding() was
called with a NULL argument and a non-NULL argument.

This function is used in a subsequent commit.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

mem-pool: move reusable parts of memory pool into its... Jameson Miller Wed, 11 Apr 2018 18:37:55 +0000 (18:37 +0000)

mem-pool: move reusable parts of memory pool into its own file

This moves the reusable parts of the memory pool logic used by
fast-import.c into its own file for use by other components.

Signed-off-by: Jameson Miller <jamill@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

replace-object: allow lookup_replace_object to handle... Stefan Beller Thu, 12 Apr 2018 00:21:18 +0000 (17:21 -0700)

replace-object: allow lookup_replace_object to handle arbitrary repositories

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>