git
6 years agodaemon: handle NULs in extended attribute string
Jeff King [Thu, 25 Jan 2018 00:56:20 +0000 (19:56 -0500)] 
daemon: handle NULs in extended attribute string

If we receive a request with extended attributes after the
NUL, we try to write those attributes to the log. We do so
with a "%s" format specifier, which will only show
characters up to the first NUL.

That's enough for printing a "host=" specifier. But since
dfe422d04d (daemon: recognize hidden request arguments,
2017-10-16) we may have another NUL, followed by protocol
parameters, and those are not logged at all.

Let's cut out the attempt to show the whole string, and
instead log when we parse individual attributes. We could
leave the "extended attributes (%d bytes) exist" part of the
log, which in theory could alert us to attributes that fail
to parse. But anything we don't parse as a "host=" parameter
gets blindly added to the "protocol" attribute, so we'd see
it in that part of the log.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodaemon: fix off-by-one in logging extended attributes
Jeff King [Thu, 25 Jan 2018 00:56:07 +0000 (19:56 -0500)] 
daemon: fix off-by-one in logging extended attributes

If receive a request like:

  git-upload-pack /foo.git\0host=localhost

we mark the offset of the NUL byte as "len", and then log
the bytes after the NUL with a "%.*s" placeholder, using
"pktlen - len" as the length, and "line + len + 1" as the
start of the string.

This is off-by-one, since the start of the string skips past
the separating NUL byte, but the adjusted length includes
it. Fortunately this doesn't actually read past the end of
the buffer, since "%.*s" will stop when it hits a NUL. And
regardless of what is in the buffer, packet_read() will
always add an extra NUL terminator for safety.

As an aside, the git.git client sends an extra NUL after a
"host" field, too, so we'd generally hit that one first, not
the one added by packet_read(). You can see this in the test
output which reports 15 bytes, even though the string has
only 14 bytes of visible data. But the point is that even a
client sending unusual data could not get us to read past
the end of the buffer, so this is purely a cosmetic fix.

Reported-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot/lib-git-daemon: record daemon log
Jeff King [Thu, 25 Jan 2018 19:16:41 +0000 (14:16 -0500)] 
t/lib-git-daemon: record daemon log

When we start git-daemon for our tests, we send its stderr
log stream to a named pipe. We synchronously read the first
line to make sure that the daemon started, and then dump the
rest to descriptor 4. This is handy for debugging test
output with "--verbose", but the tests themselves can't
access the log data.

Let's dump the log into a file, as well, so that future
tests can check the log. There are a few subtleties worth
calling out here:

  - we'll continue to send output to descriptor 4 for
    viewing/debugging, which would imply swapping out "cat"
    for "tee". But we want to ensure that there's no
    buffering, and "tee" doesn't have a standard way to
    ask for that. So we'll use a shell loop around "read"
    and "printf" instead. That ensures that after a request
    has been served, the matching log entries will have made
    it to the file.

  - the existing first-line shell loop used read/echo. We'll
    switch to consistently using "read -r" and "printf" to
    relay data as faithfully as possible.

  - we open the logfile for append, rather than just output.
    That makes it OK for tests to truncate the logfile
    without restarting the daemon (the OS will atomically
    seek to the end of the file when outputting each line).
    That allows tests to look at the log without worrying
    about pollution from earlier tests.

Helped-by: Lucas Werkmeister <mail@lucaswerkmeister.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoDocs: split out long-running subprocess handshake
Jonathan Tan [Thu, 25 Jan 2018 18:53:24 +0000 (10:53 -0800)] 
Docs: split out long-running subprocess handshake

Separating out the implementation of the handshake when starting a
long-running subprocess (for example, as is done for a clean/smudge
filter) was done in commit fa64a2fdbeed ("sub-process: refactor
handshake to common function", 2017-07-26), but its documentation still
resides in gitattributes. Split out the documentation as well.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agobuiltin/pull: respect verbosity settings in submodules
Stefan Beller [Thu, 25 Jan 2018 19:08:17 +0000 (11:08 -0800)] 
builtin/pull: respect verbosity settings in submodules

In a6d7eb2c7a (pull: optionally rebase submodules (remote submodule
changes only), 2017-06-23), we taught Git how to rebase submodules in
a pull. However we missed to pass on the verbosity settings.

Reported-by: Robin H. Johnson <robbat2@gentoo.org>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoformat-patch: keep cover-letter diffstat wrapped in 72 columns
Nguyễn Thái Ngọc Duy [Thu, 25 Jan 2018 11:59:26 +0000 (18:59 +0700)] 
format-patch: keep cover-letter diffstat wrapped in 72 columns

We already wrap shortlog around 72 columns in cover letters. Do the same
for diffstat (also in cover letters).

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot5570: use ls-remote instead of clone for interp tests
Jeff King [Thu, 25 Jan 2018 00:55:05 +0000 (19:55 -0500)] 
t5570: use ls-remote instead of clone for interp tests

We don't actually care about the clone operation here; we
just want to know if we were able to actually contact the
remote repository. Using ls-remote does that more
efficiently, and without us having to worry about managing
the tmp.git directory.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohttp-push: improve error log
Patryk Obara [Wed, 24 Jan 2018 11:11:53 +0000 (12:11 +0100)] 
http-push: improve error log

When git push fails due to server-side WebDAV error, it's not easy to
point to the main culprit.  Additional information about exact cURL
error and HTTP server response is helpful for debugging purpose.

New error log helped me pinpoint failing test t5540-http-push-webdav
to a missing Apache dependency in Fedora 27:
https://bugzilla.redhat.com/show_bug.cgi?id=1491151

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoclang-format: adjust penalty for return type line break
Patryk Obara [Wed, 24 Jan 2018 11:11:54 +0000 (12:11 +0100)] 
clang-format: adjust penalty for return type line break

The penalty of 5 makes clang-format very eager to put even short type
declarations (e.g. "extern int") into a separate line, even when
breaking parameters list is sufficient.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agopacked_ref_cache: don't use mmap() for small files
Kim Gybels [Wed, 24 Jan 2018 11:14:16 +0000 (12:14 +0100)] 
packed_ref_cache: don't use mmap() for small files

Take a hint from commit ea68b0ce9f8 (hash-object: don't use mmap() for
small files, 2010-02-21) and use read() instead of mmap() for small
packed-refs files.

Signed-off-by: Kim Gybels <kgybels@infogroep.be>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoload_contents(): don't try to mmap an empty file
Michael Haggerty [Wed, 24 Jan 2018 11:14:15 +0000 (12:14 +0100)] 
load_contents(): don't try to mmap an empty file

We don't actually create zero-length `packed-refs` files, but they are
valid and we should handle them correctly. The old code `xmmap()`ed
such files, which led to an error when `munmap()` was called. So, if
the `packed-refs` file is empty, leave the snapshot at its zero values
and return 0 without trying to read or mmap the file.

Returning 0 also makes `create_snapshot()` exit early, which avoids
the technically undefined comparison `NULL < NULL`.

Reported-by: Kim Gybels <kgybels@infogroep.be>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agopacked_ref_iterator_begin(): make optimization more general
Michael Haggerty [Wed, 24 Jan 2018 11:14:14 +0000 (12:14 +0100)] 
packed_ref_iterator_begin(): make optimization more general

We can return an empty iterator not only if the `packed-refs` file is
missing, but also if it is empty or if there are no references whose
names succeed `prefix`. Optimize away those cases as well by moving
the call to `find_reference_location()` higher in the function and
checking whether the determined start position is the same as
`snapshot->eof`. (This is possible now because the previous commit
made `find_reference_location()` robust against empty snapshots.)

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agofind_reference_location(): make function safe for empty snapshots
Michael Haggerty [Wed, 24 Jan 2018 11:14:13 +0000 (12:14 +0100)] 
find_reference_location(): make function safe for empty snapshots

This function had two problems if called for an empty snapshot (i.e.,
`snapshot->start == snapshot->eof == NULL`):

* It checked `NULL < NULL`, which is undefined by C (albeit highly
  unlikely to fail in the real world).

* (Assuming the above comparison behaved as expected), it returned
  NULL when `mustexist` was false, contrary to its docstring.

Change the check and fix the docstring.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocreate_snapshot(): use `xmemdupz()` rather than a strbuf
Michael Haggerty [Wed, 24 Jan 2018 11:14:12 +0000 (12:14 +0100)] 
create_snapshot(): use `xmemdupz()` rather than a strbuf

It's lighter weight.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agostruct snapshot: store `start` rather than `header_len`
Michael Haggerty [Wed, 24 Jan 2018 11:14:11 +0000 (12:14 +0100)] 
struct snapshot: store `start` rather than `header_len`

Store a pointer to the start of the actual references within the
`packed-refs` contents rather than storing the length of the header.
This is more convenient for most users of this field.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosequencer: run 'prepare-commit-msg' hook
Phillip Wood [Wed, 24 Jan 2018 12:34:22 +0000 (12:34 +0000)] 
sequencer: run 'prepare-commit-msg' hook

Commit 356ee4659b ("sequencer: try to commit without forking 'git
commit'", 2017-11-24) forgot to run the 'prepare-commit-msg' hook when
creating the commit. Fix this by writing the commit message to a
different file and running the hook. Using a different file means that
if the commit is cancelled the original message file is
unchanged. Also move the checks for an empty commit so the order
matches 'git commit'.

Reported-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot7505: add tests for cherry-pick and rebase -i/-p
Phillip Wood [Wed, 24 Jan 2018 12:34:21 +0000 (12:34 +0000)] 
t7505: add tests for cherry-pick and rebase -i/-p

Check that cherry-pick and rebase call the 'prepare-commit-msg' hook
correctly. The expected values for the hook arguments are taken to
match the current master branch. I think there is scope for improving
the arguments passed so they make a bit more sense - for instance
cherry-pick currently passes different arguments depending on whether
the commit message is being edited. Also the arguments for rebase
could be improved. Commit 7c4188360ac ("rebase -i: proper
prepare-commit-msg hook argument when squashing", 2008-10-3) apparently
changed things so that when squashing rebase would pass 'squash' as
the argument to the hook but that has been lost.

I think that it would make more sense to pass 'message' for revert and
cherry-pick -x/-s (i.e. cases where there is a new message or the
current message in modified by the command), 'squash' when squashing
with a new message and 'commit HEAD/CHERRY_PICK_HEAD'
otherwise (picking and squashing without a new message).

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot7505: style fixes
Phillip Wood [Wed, 24 Jan 2018 12:34:20 +0000 (12:34 +0000)] 
t7505: style fixes

Fix the indentation and style of the hook script in preparation for
further changes.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agomailinfo: avoid segfault when can't open files
Juan F. Codagnone [Wed, 24 Jan 2018 16:56:47 +0000 (13:56 -0300)] 
mailinfo: avoid segfault when can't open files

If <msg> or <patch> files can't be opened, then mailinfo() returns an
error before it even initializes mi->p_hdr_data or mi->s_hdr_data.
When cmd_mailinfo() then calls clear_mailinfo(), we dereference the
NULL pointers trying to free their contents.

Signed-off-by: Juan F. Codagnone <jcodagnone@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoread-cache: don't write index twice if we can't write shared index
Nguyễn Thái Ngọc Duy [Wed, 24 Jan 2018 09:38:29 +0000 (16:38 +0700)] 
read-cache: don't write index twice if we can't write shared index

In a0a967568e ("update-index --split-index: do not split if $GIT_DIR is
read only", 2014-06-13), we tried to make sure we can still write an
index, even if the shared index can not be written.

We did so by just calling 'do_write_locked_index()' just before
'write_shared_index()'.  'do_write_locked_index()' always at least
closes the tempfile nowadays, and used to close or commit the lockfile
if COMMIT_LOCK or CLOSE_LOCK were given at the time this feature was
introduced.  COMMIT_LOCK or CLOSE_LOCK is passed in by most callers of
'write_locked_index()'.

After calling 'write_shared_index()', we call 'write_split_index()',
which calls 'do_write_locked_index()' again, which then tries to use the
closed lockfile again, but in fact fails to do so as it's already
closed. This eventually leads to a segfault.

Make sure to write the main index only once.

[nd: most of the commit message and investigation done by Thomas, I only
tweaked the solution a bit]

Helped-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agomru: Replace mru.[ch] with list.h implementation
Gargi Sharma [Tue, 23 Jan 2018 23:46:51 +0000 (18:46 -0500)] 
mru: Replace mru.[ch] with list.h implementation

Replace the custom calls to mru.[ch] with calls to list.h. This patch is
the final step in removing the mru API completely and inlining the logic.
This patch leads to significant code reduction and the mru API hence, is
not a useful abstraction anymore.

Signed-off-by: Gargi Sharma <gs051095@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'jh/partial-clone' into next
Junio C Hamano [Tue, 23 Jan 2018 21:49:51 +0000 (13:49 -0800)] 
Merge branch 'jh/partial-clone' into next

The machinery to clone & fetch, which in turn involves packing and
unpacking objects, have been told how to omit certain objects using
the filtering mechanism introduced by the jh/object-filtering
topic, and also mark the resulting pack as a promisor pack to
tolerate missing objects, taking advantage of the mechanism
introduced by the jh/fsck-promisors topic.

* jh/partial-clone:
  t5616: test bulk prefetch after partial fetch
  fetch: inherit filter-spec from partial clone
  t5616: end-to-end tests for partial clone
  fetch-pack: restore save_commit_buffer after use
  unpack-trees: batch fetching of missing blobs
  clone: partial clone
  partial-clone: define partial clone settings in config
  fetch: support filters
  fetch: refactor calculation of remote list
  fetch-pack: test support excluding large blobs
  fetch-pack: add --no-filter
  fetch-pack, index-pack, transport: partial clone
  upload-pack: add object filtering for partial clone

6 years agoMerge branch 'jh/fsck-promisors' into next
Junio C Hamano [Tue, 23 Jan 2018 21:49:51 +0000 (13:49 -0800)] 
Merge branch 'jh/fsck-promisors' into next

In preparation for implementing narrow/partial clone, the machinery
for checking object connectivity used by gc and fsck has been
taught that a missing object is OK when it is referenced by a
packfile specially marked as coming from trusted repository that
promises to make them available on-demand and lazily.

* jh/fsck-promisors:
  gc: do not repack promisor packfiles
  rev-list: support termination at promisor objects
  sha1_file: support lazily fetching missing objects
  introduce fetch-object: fetch one promisor object
  index-pack: refactor writing of .keep files
  fsck: support promisor objects as CLI argument
  fsck: support referenced promisor objects
  fsck: support refs pointing to promisor objects
  fsck: introduce partialclone extension
  extension.partialclone: introduce partial clone extension

6 years agoMerge branch 'ab/simplify-perl-makefile' into next
Junio C Hamano [Tue, 23 Jan 2018 21:49:50 +0000 (13:49 -0800)] 
Merge branch 'ab/simplify-perl-makefile' into next

The build procedure for perl/ part has been greatly simplified by
weaning ourselves off of MakeMaker.

* ab/simplify-perl-makefile:
  perl: treat PERLLIB_EXTRA as an extra path again
  perl: avoid *.pmc and fix Error.pm further
  Makefile: replace perl/Makefile.PL with simple make rules

6 years agoFirst batch after 2.16
Junio C Hamano [Tue, 23 Jan 2018 21:21:10 +0000 (13:21 -0800)] 
First batch after 2.16

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'nd/add-i-ignore-submodules'
Junio C Hamano [Tue, 23 Jan 2018 21:16:41 +0000 (13:16 -0800)] 
Merge branch 'nd/add-i-ignore-submodules'

"git add -p" was taught to ignore local changes to submodules as
they do not interfere with the partial addition of regular changes
anyway.

* nd/add-i-ignore-submodules:
  add--interactive: ignore submodule changes except HEAD

6 years agoMerge branch 'mm/send-email-fallback-to-local-mail-address'
Junio C Hamano [Tue, 23 Jan 2018 21:16:41 +0000 (13:16 -0800)] 
Merge branch 'mm/send-email-fallback-to-local-mail-address'

Instead of maintaining home-grown email address parsing code, ship
a copy of reasonably recent Mail::Address to be used as a fallback
in 'git send-email' when the platform lacks it.

* mm/send-email-fallback-to-local-mail-address:
  send-email: add test for Linux's get_maintainer.pl
  perl/Git: remove now useless email-address parsing code
  send-email: add and use a local copy of Mail::Address

6 years agoMerge branch 'ab/doc-cat-file-e-still-shows-errors'
Junio C Hamano [Tue, 23 Jan 2018 21:16:41 +0000 (13:16 -0800)] 
Merge branch 'ab/doc-cat-file-e-still-shows-errors'

Doc update.

* ab/doc-cat-file-e-still-shows-errors:
  cat-file doc: document that -e will return some output

6 years agoMerge branch 'as/read-tree-prefix-doc-fix'
Junio C Hamano [Tue, 23 Jan 2018 21:16:41 +0000 (13:16 -0800)] 
Merge branch 'as/read-tree-prefix-doc-fix'

Doc update.

* as/read-tree-prefix-doc-fix:
  doc/read-tree: remove obsolete remark

6 years agoMerge branch 'ys/bisect-object-id-missing-conversion-fix'
Junio C Hamano [Tue, 23 Jan 2018 21:16:40 +0000 (13:16 -0800)] 
Merge branch 'ys/bisect-object-id-missing-conversion-fix'

Fix for a commented-out code to adjust it to a rather old API change.

* ys/bisect-object-id-missing-conversion-fix:
  bisect: debug: convert struct object to object_id

6 years agoMerge branch 'tg/stash-with-pathspec-fix'
Junio C Hamano [Tue, 23 Jan 2018 21:16:39 +0000 (13:16 -0800)] 
Merge branch 'tg/stash-with-pathspec-fix'

"git stash -- <pathspec>" incorrectly blew away untracked files in
the directory that matched the pathspec, which has been corrected.

* tg/stash-with-pathspec-fix:
  stash: don't delete untracked files that match pathspec

6 years agoMerge branch 'sb/submodule-update-reset-fix'
Junio C Hamano [Tue, 23 Jan 2018 21:16:39 +0000 (13:16 -0800)] 
Merge branch 'sb/submodule-update-reset-fix'

When resetting the working tree files recursively, the working tree
of submodules are now also reset to match.

* sb/submodule-update-reset-fix:
  submodule: submodule_move_head omits old argument in forced case
  unpack-trees: oneway_merge to update submodules
  t/lib-submodule-update.sh: fix test ignoring ignored files in submodules
  t/lib-submodule-update.sh: clarify test

6 years agoMerge branch 'bw/oidmap-autoinit'
Junio C Hamano [Tue, 23 Jan 2018 21:16:39 +0000 (13:16 -0800)] 
Merge branch 'bw/oidmap-autoinit'

Code clean-up.

* bw/oidmap-autoinit:
  oidmap: ensure map is initialized

6 years agoMerge branch 'ab/commit-m-with-fixup'
Junio C Hamano [Tue, 23 Jan 2018 21:16:38 +0000 (13:16 -0800)] 
Merge branch 'ab/commit-m-with-fixup'

"git commit --fixup" did not allow "-m<message>" option to be used
at the same time; allow it to annotate resulting commit with more
text.

* ab/commit-m-with-fixup:
  commit: add support for --fixup <commit> -m"<extra message>"
  commit doc: document that -c, -C, -F and --fixup with -m error

6 years agoMerge branch 'cc/codespeed'
Junio C Hamano [Tue, 23 Jan 2018 21:16:38 +0000 (13:16 -0800)] 
Merge branch 'cc/codespeed'

"perf" test output can be sent to codespeed server.

* cc/codespeed:
  perf/run: read GIT_PERF_REPO_NAME from perf.repoName
  perf/run: learn to send output to codespeed server
  perf/run: learn about perf.codespeedOutput
  perf/run: add conf_opts argument to get_var_from_env_or_config()
  perf/aggregate: implement codespeed JSON output
  perf/aggregate: refactor printing results
  perf/aggregate: fix checking ENV{GIT_PERF_SUBSECTION}

6 years agoMerge branch 'ab/perf-grep-threads'
Junio C Hamano [Tue, 23 Jan 2018 21:16:37 +0000 (13:16 -0800)] 
Merge branch 'ab/perf-grep-threads'

More perf tests for threaded grep

* ab/perf-grep-threads:
  perf: amend the grep tests to test grep.threads

6 years agoMerge branch 'sb/diff-blobfind-pickaxe'
Junio C Hamano [Tue, 23 Jan 2018 21:16:37 +0000 (13:16 -0800)] 
Merge branch 'sb/diff-blobfind-pickaxe'

"diff" family of commands learned "--find-object=<object-id>" option
to limit the findings to changes that involve the named object.

* sb/diff-blobfind-pickaxe:
  diff: use HAS_MULTI_BITS instead of counting bits manually
  diff: properly error out when combining multiple pickaxe options
  diffcore: add a pickaxe option to find a specific blob
  diff: introduce DIFF_PICKAXE_KINDS_MASK
  diff: migrate diff_flags.pickaxe_ignore_case to a pickaxe_opts bit
  diff.h: make pickaxe_opts an unsigned bit field

6 years agoMerge branch 'jk/abort-clone-with-existing-dest'
Junio C Hamano [Tue, 23 Jan 2018 21:16:37 +0000 (13:16 -0800)] 
Merge branch 'jk/abort-clone-with-existing-dest'

"git clone $there $here" is allowed even when here directory exists
as long as it is an empty directory, but the command incorrectly
removed it upon a failure of the operation.

* jk/abort-clone-with-existing-dest:
  clone: do not clean up directories we didn't create
  clone: factor out dir_exists() helper
  t5600: modernize style
  t5600: fix outdated comment about unborn HEAD

6 years agoMerge branch 'jc/merge-symlink-ours-theirs'
Junio C Hamano [Tue, 23 Jan 2018 21:16:37 +0000 (13:16 -0800)] 
Merge branch 'jc/merge-symlink-ours-theirs'

"git merge -Xours/-Xtheirs" learned to use our/their version when
resolving a conflicting updates to a symbolic link.

* jc/merge-symlink-ours-theirs:
  merge: teach -Xours/-Xtheirs to symbolic link merge

6 years agoMerge branch 'rs/lose-leak-pending'
Junio C Hamano [Tue, 23 Jan 2018 21:16:36 +0000 (13:16 -0800)] 
Merge branch 'rs/lose-leak-pending'

API clean-up around revision traversal.

* rs/lose-leak-pending:
  commit: remove unused function clear_commit_marks_for_object_array()
  revision: remove the unused flag leak_pending
  checkout: avoid using the rev_info flag leak_pending
  bundle: avoid using the rev_info flag leak_pending
  bisect: avoid using the rev_info flag leak_pending
  object: add clear_commit_marks_all()
  ref-filter: use clear_commit_marks_many() in do_merge_filter()
  commit: use clear_commit_marks_many() in remove_redundant()
  commit: avoid allocation in clear_commit_marks_many()

6 years agoMerge branch 'jm/svn-pushmergeinfo-fix'
Junio C Hamano [Tue, 23 Jan 2018 21:16:36 +0000 (13:16 -0800)] 
Merge branch 'jm/svn-pushmergeinfo-fix'

"git svn dcommit" did not take into account the fact that a
svn+ssh:// URL with a username@ (typically used for pushing) refers
to the same SVN repository without the username@ and failed when
svn.pushmergeinfo option is set.

* jm/svn-pushmergeinfo-fix:
  git-svn: fix svn.pushmergeinfo handling of svn+ssh usernames.

6 years agoMerge branch 'nd/ita-wt-renames-in-status'
Junio C Hamano [Tue, 23 Jan 2018 21:16:28 +0000 (13:16 -0800)] 
Merge branch 'nd/ita-wt-renames-in-status'

"git status" after moving a path in the working tree (hence making
it appear "removed") and then adding with the -N option (hence
making that appear "added") detected it as a rename, but did not
report the  old and new pathnames correctly.

* nd/ita-wt-renames-in-status:
  wt-status.c: handle worktree renames
  wt-status.c: rename rename-related fields in wt_status_change_data
  wt-status.c: catch unhandled diff status codes
  wt-status.c: coding style fix
  Use DIFF_DETECT_RENAME for detect_rename assignments
  t2203: test status output with porcelain v2 format

6 years agoMerge branch 'dk/describe-all-output-fix'
Junio C Hamano [Tue, 23 Jan 2018 21:16:28 +0000 (13:16 -0800)] 
Merge branch 'dk/describe-all-output-fix'

An old regression in "git describe --all $annotated_tag^0" has been
fixed.

* dk/describe-all-output-fix:
  describe: prepend "tags/" when describing tags with embedded name

6 years agofsck: fix leak when traversing trees
Eric Wong [Sat, 20 Jan 2018 07:43:51 +0000 (07:43 +0000)] 
fsck: fix leak when traversing trees

While fsck_walk/fsck_walk_tree/parse_tree populates "struct tree"
idempotently, it is still up to the fsck_walk caller to call
free_tree_buffer.

Fixes: ad2db4030e42890e ("fsck: remove redundant parse_tree() invocation")

Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoUse MOVE_ARRAY
SZEDER Gábor [Mon, 22 Jan 2018 17:50:09 +0000 (18:50 +0100)] 
Use MOVE_ARRAY

Use the helper macro MOVE_ARRAY to move arrays.  This is shorter and
safer, as it automatically infers the size of elements.

Patch generated by Coccinelle and contrib/coccinelle/array.cocci in
Travis CI's static analysis build job.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoSync with v2.16.1
Junio C Hamano [Mon, 22 Jan 2018 05:14:54 +0000 (21:14 -0800)] 
Sync with v2.16.1

* maint:
  Git 2.16.1
  t5601-clone: test case-conflicting files on case-insensitive filesystem
  repository: pre-initialize hash algo pointer

6 years agoGit 2.16.1 v2.16.1
Junio C Hamano [Mon, 22 Jan 2018 05:14:25 +0000 (21:14 -0800)] 
Git 2.16.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoStart 2.17 cycle
Junio C Hamano [Mon, 22 Jan 2018 05:14:09 +0000 (21:14 -0800)] 
Start 2.17 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'bc/hash-algo' into maint
Junio C Hamano [Mon, 22 Jan 2018 05:12:37 +0000 (21:12 -0800)] 
Merge branch 'bc/hash-algo' into maint

* bc/hash-algo:
  t5601-clone: test case-conflicting files on case-insensitive filesystem
  repository: pre-initialize hash algo pointer

6 years agot5601-clone: test case-conflicting files on case-insensitive filesystem
Eric Sunshine [Sun, 21 Jan 2018 08:07:28 +0000 (03:07 -0500)] 
t5601-clone: test case-conflicting files on case-insensitive filesystem

A recently introduced regression caused a segfault at clone time on
case-insensitive filesystems when filenames differing only in case are
present. This bug has already been fixed (repository: pre-initialize
hash algo pointer, 2018-01-18), but it's not the first time similar
problems have arisen. Therefore, introduce a test to catch this case and
protect against future regressions.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agomerge-recursive: add explanation for src_entry and dst_entry
Elijah Newren [Fri, 5 Jan 2018 20:20:01 +0000 (12:20 -0800)] 
merge-recursive: add explanation for src_entry and dst_entry

If I have to walk through the debugger and inspect the values found in
here in order to figure out their meaning, despite having known these
things inside and out some years back, then they probably need a comment
for the casual reader to explain their purpose.

Reviewed-By: Stefan Beller <sbeller@google.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agomerge-recursive: fix logic ordering issue
Elijah Newren [Fri, 5 Jan 2018 20:20:00 +0000 (12:20 -0800)] 
merge-recursive: fix logic ordering issue

merge_trees() did a variety of work, including:
  * Calling get_unmerged() to get unmerged entries
  * Calling record_df_conflict_files() with all unmerged entries to
    do some work to ensure we could handle D/F conflicts correctly
  * Calling get_renames() to check for renames.

An easily overlooked issue is that get_renames() can create more
unmerged entries and add them to the list, which have the possibility of
being involved in D/F conflicts.  So the call to
record_df_conflict_files() should really be moved after all the rename
detection.  I didn't come up with any testcases demonstrating any bugs
with the old ordering, but I suspect there were some for both normal
renames and for directory renames.  Fix the ordering.

Reviewed-By: Stefan Beller <sbeller@google.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoTighten and correct a few testcases for merging and cherry-picking
Elijah Newren [Fri, 5 Jan 2018 20:19:59 +0000 (12:19 -0800)] 
Tighten and correct a few testcases for merging and cherry-picking

t3501 had a testcase originally added in 05f2dfb965 (cherry-pick:
demonstrate a segmentation fault, 2016-11-26) to ensure cherry-pick
wouldn't segfault when working with a dirty file involved in a rename.
While the segfault was fixed, there was another problem this test
demonstrated: namely, that git would overwrite a dirty file involved in a
rename.  Further, the test encoded a "successful merge" and overwriting of
this file as correct behavior.  Modify the test so that it would still
catch the segfault, but to require the correct behavior.  Mark it as
test_expect_failure for now too, since this second bug is not yet fixed.

t7607 had a test added in 30fd3a5425 (merge overwrites unstaged changes in
renamed file, 2012-04-15) specific to looking for a merge overwriting a
dirty file involved in a rename, but it too actually encoded what I would
term incorrect behavior: it expected the merge to succeed.  Fix that, and
add a few more checks to make sure that the merge really does produce the
expected results.

Reviewed-By: Stefan Beller <sbeller@google.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorepository: pre-initialize hash algo pointer
brian m. carlson [Fri, 19 Jan 2018 04:18:25 +0000 (04:18 +0000)] 
repository: pre-initialize hash algo pointer

There are various git subcommands (among them, clone) which don't set up
the repository (that is, they lack RUN_SETUP or RUN_SETUP_GENTLY) but
end up needing to have information about the hash algorithm in use.
Because the hash algorithm is part of struct repository and it's only
initialized in repository setup, we can end up dereferencing a NULL
pointer in some cases if we call one of these subcommands and look up
the empty blob or empty tree values.

A "git clone" of a project that has two paths that differ only in
case suffers from this if it is run on a case insensitive platform.
When the command attempts to check out one of these two paths after
checking out the other one, the checkout codepath needs to see if
the version that is already on the filesystem (which should not
happen if the FS were case sensitive) is dirty, and it needs to
exercise the hashing code at that point.

In the future, we can add a command line option for this or read it
from the configuration, but until we're ready to expose that
functionality to the user, simply initialize the repository
structure to use the current hash algorithm, SHA-1.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agofiles_initial_transaction_commit(): only unlock if locked
Mathias Rav [Thu, 18 Jan 2018 13:38:41 +0000 (14:38 +0100)] 
files_initial_transaction_commit(): only unlock if locked

Running git clone --single-branch --mirror -b TAGNAME previously
triggered the following error message:

fatal: multiple updates for ref 'refs/tags/TAGNAME' not allowed.

This error condition is handled in files_initial_transaction_commit().

42c7f7ff9 ("commit_packed_refs(): remove call to `packed_refs_unlock()`", 2017-06-23)
introduced incorrect unlocking in the error path of this function,
which changes the error message to

fatal: BUG: packed_refs_unlock() called when not locked

Move the call to packed_refs_unlock() above the "cleanup:" label
since the unlocking should only be done in the last error path.

Signed-off-by: Mathias Rav <m@git.strova.dk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: improve sha1_file_name() perfs
Christian Couder [Thu, 18 Jan 2018 10:08:54 +0000 (11:08 +0100)] 
sha1_file: improve sha1_file_name() perfs

As sha1_file_name() could be performance sensitive, let's
make it faster by using strbuf_addstr() and strbuf_addc()
instead of strbuf_addf().

Helped-by: Derrick Stolee <stolee@gmail.com>
Helped-by: Jeff Hostetler <git@jeffhostetler.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohttp: support omitting data from traces
Jonathan Tan [Fri, 19 Jan 2018 00:28:02 +0000 (16:28 -0800)] 
http: support omitting data from traces

GIT_TRACE_CURL provides a way to debug what is being sent and received
over HTTP, with automatic redaction of sensitive information. But it
also logs data transmissions, which significantly increases the log file
size, sometimes unnecessarily. Add an option "GIT_TRACE_CURL_NO_DATA" to
allow the user to omit such data transmissions.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohttp: support cookie redaction when tracing
Jonathan Tan [Fri, 19 Jan 2018 00:28:01 +0000 (16:28 -0800)] 
http: support cookie redaction when tracing

When using GIT_TRACE_CURL, Git already redacts the "Authorization:" and
"Proxy-Authorization:" HTTP headers. Extend this redaction to a
user-specified list of cookies, specified through the
"GIT_REDACT_COOKIES" environment variable.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agococci: use format keyword instead of a literal string
René Scharfe [Fri, 19 Jan 2018 17:05:59 +0000 (18:05 +0100)] 
cocci: use format keyword instead of a literal string

There's a rule in strbuf.cocci for converting trivial uses of
strbuf_addf() to strbuf_addstr() in order to simplify the code and
improve performance a bit.  Coccinelle 1.0.0~rc19.deb-3 on Travis CI
lets the "%s" in that rule match format strings like "%d" as well for
some reason, though, leading to invalid proposed patches.

Use the "format" keyword to let Coccinelle parse the format string and
match the conversion specifier with a trivial regular expression
instead.  This works fine with both Coccinelle 1.0.0~rc19.deb-3 and
1.0.4.deb-3+b3 (the current version on Debian testing).

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Tested-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agopackfile: use get_be64() for large offsets
Derrick Stolee [Wed, 17 Jan 2018 19:08:23 +0000 (14:08 -0500)] 
packfile: use get_be64() for large offsets

The pack-index version 2 format uses two 4-byte integers in
network-byte order to represent one 8-byte value. The current
implementation has several code clones for stitching these integers
together.

Use get_be64() to create an 8-byte integer from two 4-byte integers
represented this way.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorun-command.c: print new cwd in trace_run_command()
Nguyễn Thái Ngọc Duy [Thu, 18 Jan 2018 09:45:12 +0000 (16:45 +0700)] 
run-command.c: print new cwd in trace_run_command()

If a command sets a new env variable GIT_DIR=.git, we need more context
to know where that '.git' is related to.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorun-command.c: print env vars in trace_run_command()
Nguyễn Thái Ngọc Duy [Thu, 18 Jan 2018 09:45:11 +0000 (16:45 +0700)] 
run-command.c: print env vars in trace_run_command()

Occasionally submodule code could execute new commands with GIT_DIR set
to some submodule. GIT_TRACE prints just the command line which makes it
hard to tell that it's not really executed on this repository.

Print the env delta (compared to parent environment) in this case.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorun-command.c: print program 'git' when tracing git_cmd mode
Nguyễn Thái Ngọc Duy [Thu, 18 Jan 2018 09:45:10 +0000 (16:45 +0700)] 
run-command.c: print program 'git' when tracing git_cmd mode

We normally print full command line, including the program and its
argument. When git_cmd is set, we have a special code path to run the
right "git" program and child_process.argv[0] will not contain the
program name anymore. As a result, we print just the command
arguments.

I thought it was a regression when the code was refactored and git_cmd
added, but apparently it's not. git_cmd mode was introduced before
tracing was added in 8852f5d704 (run_command(): respect GIT_TRACE -
2008-07-07) so it's more like an oversight in 8852f5d704.

Fix it, print the program name "git" in git_cmd mode. It's nice to have
now. But it will be more important later when we start to print env
variables too, in shell syntax. The lack of a program name would look
confusing then.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorun-command.c: introduce trace_run_command()
Nguyễn Thái Ngọc Duy [Thu, 18 Jan 2018 09:45:09 +0000 (16:45 +0700)] 
run-command.c: introduce trace_run_command()

This is the same as the old code that uses trace_argv_printf() in
run-command.c. This function will be improved in later patches to
print more information from struct child_process.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotravis: run tests with GIT_TEST_SPLIT_INDEX
Thomas Gummerer [Sun, 7 Jan 2018 22:30:15 +0000 (22:30 +0000)] 
travis: run tests with GIT_TEST_SPLIT_INDEX

Split index mode only has a few dedicated tests, but as the index is
involved in nearly every git operation, this doesn't quite cover all the
ways repositories with split index can break.  To use split index mode
throughout the test suite a GIT_TEST_SPLIT_INDEX environment variable
can be set, which makes git split the index at random and thus
excercises the functionality much more thoroughly.

As this is not turned on by default, it is not executed nearly as often
as the test suite is run, so occationally breakages slip through.  Try
to counteract that by running the test suite with GIT_TEST_SPLIT_INDEX
mode turned on on travis.

To avoid using too many cycles on travis only run split index mode in
the linux-gcc target only.  The Linux build was chosen over the Mac OS
builds because it tends to be much faster to complete.

The linux gcc build was chosen over the linux clang build because the
linux clang build is the fastest build, so it can serve as an early
indicator if something is broken and we want to avoid spending the extra
cycles of running the test suite twice for that.

Helped-by: Lars Schneider <larsxschneider@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosplit-index: don't write cache tree with null oid entries
Thomas Gummerer [Sun, 7 Jan 2018 22:30:14 +0000 (22:30 +0000)] 
split-index: don't write cache tree with null oid entries

In a96d3cc3f6 ("cache-tree: reject entries with null sha1", 2017-04-21)
we made sure that broken cache entries do not get propagated to new
trees.  Part of that was making sure not to re-use an existing cache
tree that includes a null oid.

It did so by dropping the cache tree in 'do_write_index()' if one of
the entries contains a null oid.  In split index mode however, there
are two invocations to 'do_write_index()', one for the shared index
and one for the split index.  The cache tree is only written once, to
the split index.

As we only loop through the elements that are effectively being
written by the current invocation, that may not include the entry with
a null oid in the split index (when it is already written to the
shared index), where we write the cache tree.  Therefore in split
index mode we may still end up writing the cache tree, even though
there is an entry with a null oid in the index.

Fix this by checking for null oids in prepare_to_write_split_index,
where we loop the entries of the shared index as well as the entries for
the split index.

This fixes t7009 with GIT_TEST_SPLIT_INDEX.  Also add a new test that's
more specifically showing the problem.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoread-cache: fix reading the shared index for other repos
Thomas Gummerer [Sun, 7 Jan 2018 22:30:13 +0000 (22:30 +0000)] 
read-cache: fix reading the shared index for other repos

read_index_from() takes a path argument for the location of the index
file.  For reading the shared index in split index mode however it just
ignores that path argument, and reads it from the gitdir of the current
repository.

This works as long as an index in the_repository is read.  Once that
changes, such as when we read the index of a submodule, or of a
different working tree than the current one, the gitdir of
the_repository will no longer contain the appropriate shared index,
and git will fail to read it.

For example t3007-ls-files-recurse-submodules.sh was broken with
GIT_TEST_SPLIT_INDEX set in 188dce131f ("ls-files: use repository
object", 2017-06-22), and t7814-grep-recurse-submodules.sh was also
broken in a similar manner, probably by introducing struct repository
there, although I didn't track down the exact commit for that.

be489d02d2 ("revision.c: --indexed-objects add objects from all
worktrees", 2017-08-23) breaks with split index mode in a similar
manner, not erroring out when it can't read the index, but instead
carrying on with pruning, without taking the index of the worktree into
account.

Fix this by passing an additional gitdir parameter to read_index_from,
to indicate where it should look for and read the shared index from.

read_cache_from() defaults to using the gitdir of the_repository.  As it
is mostly a convenience macro, having to pass get_git_dir() for every
call seems overkill, and if necessary users can have more control by
using read_index_from().

Helped-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoGit 2.16 v2.16.0
Junio C Hamano [Wed, 17 Jan 2018 21:06:51 +0000 (13:06 -0800)] 
Git 2.16

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoworktree: say that "add" takes an arbitrary commit in short-help
Junio C Hamano [Wed, 17 Jan 2018 18:32:32 +0000 (10:32 -0800)] 
worktree: say that "add" takes an arbitrary commit in short-help

c4738aed ("worktree: add can be created from any commit-ish",
2017-11-26) taught "git worktree add" to start a new worktree
with an arbitrary commit-ish checked out, not limited to a tip
of a branch.

"git worktree --help" was updated to describe this, but we forgot to
update "git worktree -h".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: remove static strbuf from sha1_file_name()
Christian Couder [Wed, 17 Jan 2018 17:54:54 +0000 (18:54 +0100)] 
sha1_file: remove static strbuf from sha1_file_name()

Using a static buffer in sha1_file_name() is error prone
and the performance improvements it gives are not needed
in many of the callers.

So let's get rid of this static buffer and, if necessary
or helpful, let's use one in the caller.

Suggested-by: Jeff Hostetler <git@jeffhostetler.com>
Helped-by: Kevin Daudt <me@ikke.info>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge tag 'l10n-2.16.0-rnd2' of git://github.com/git-l10n/git-po
Junio C Hamano [Tue, 16 Jan 2018 22:49:58 +0000 (14:49 -0800)] 
Merge tag 'l10n-2.16.0-rnd2' of git://github.com/git-l10n/git-po

l10n for Git 2.16.0 round 2

* tag 'l10n-2.16.0-rnd2' of git://github.com/git-l10n/git-po: (24 commits)
  l10n: de.po: translate 72 new messages
  l10n: de.po: improve messages when a branch starts to track another ref
  l10n: bg.po: Updated Bulgarian translation (3288t)
  l10n: TEAMS: add zh_CN team members
  l10n: zh_CN: for git v2.16.0 l10n round 2
  l10n: sv.po: Update Swedish translation (3288t0f0u)
  l10n: ru.po: update Russian translation
  l10n: TEAMS: Add ko team members
  l10n: ko.po: Update Korean translation
  l10n: fr.po 2.16 round 2
  l10n: es.po: Spanish translation 2.16.0 round 2
  l10n: vi.po(3288t): Updated Vietnamese translation for v2.16.0 round 2
  l10n: git.pot: v2.16.0 round 2 (8 new, 4 removed)
  l10n: es.po: Update Spanish Translation v2.16.0
  l10n: fr.po v2.16.0 round 1
  l10n: bg.po: Updated Bulgarian translation (3284t)
  l10n: sv.po: Update Swedish translation (3284t0f0u)
  l10n: fr.po: "worktree list" mistranslated as prune
  l10n: git.pot: v2.16.0 round 1 (64 new, 25 removed)
  l10n: fixes to German translation
  ...

6 years agodiff.c: flush stdout before printing rename warnings
Nguyễn Thái Ngọc Duy [Tue, 16 Jan 2018 09:23:49 +0000 (16:23 +0700)] 
diff.c: flush stdout before printing rename warnings

The diff output is buffered in a FILE object and could still be
partially buffered when we print these warnings (directly to fd 2).
The output is messed up like this

 worktree.c                                   |   138 +-
 worktree.h        warning: inexact rename detection was skipped due to too many files.
                           |    12 +-
 wrapper.c                                    |    83 +-

It gets worse if the warning is printed after color codes for the graph
part are already printed. You'll get a warning in green or red.

Flush stdout first, so we can get something like this instead:

 xdiff/xutils.c                               |    42 +-
 xdiff/xutils.h                               |     4 +-
 1033 files changed, 150824 insertions(+), 69395 deletions(-)
warning: inexact rename detection was skipped due to too many files.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohashmap.h: remove unused variable
Randall S. Becker [Sun, 14 Jan 2018 18:07:48 +0000 (13:07 -0500)] 
hashmap.h: remove unused variable

In 'hashmap_enable_item_counting()', item is assigned but never
used.  This causes a warning on HP NonStop.  As the variable is
never used, fix this by just removing it.

Signed-off-by: Randall S. Becker <rsbecker@nexbridge.com>
Helped-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodescribe: use strbuf_add_unique_abbrev() for adding short hashes
René Scharfe [Mon, 15 Jan 2018 17:10:32 +0000 (18:10 +0100)] 
describe: use strbuf_add_unique_abbrev() for adding short hashes

Call strbuf_add_unique_abbrev() to add an abbreviated hash to a strbuf
instead of taking a detour through find_unique_abbrev() and its static
buffer.  This is shorter and a bit more efficient.

Patch generated by Coccinelle (and contrib/coccinelle/strbuf.cocci).

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoread-cache.c: move tempfile creation/cleanup out of write_shared_index
Nguyễn Thái Ngọc Duy [Sun, 14 Jan 2018 10:18:19 +0000 (17:18 +0700)] 
read-cache.c: move tempfile creation/cleanup out of write_shared_index

For one thing, we have more consistent cleanup procedure now and always
keep errno intact.

The real purpose is the ability to break out of write_locked_index()
early when mks_tempfile() fails in the next patch. It's more awkward to
do it if this mks_tempfile() is still inside write_shared_index().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoread-cache.c: change type of "temp" in write_shared_index()
Nguyễn Thái Ngọc Duy [Sun, 14 Jan 2018 10:18:18 +0000 (17:18 +0700)] 
read-cache.c: change type of "temp" in write_shared_index()

This local variable 'temp' will be passed in from the caller in the next
patch. To reduce patch noise, let's change its type now while it's still
a local variable and get all the trival conversion out of 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>
6 years agoconvert_to_git(): safe_crlf/checksafe becomes int conv_flags
Torsten Bögershausen [Sat, 13 Jan 2018 22:49:31 +0000 (23:49 +0100)] 
convert_to_git(): safe_crlf/checksafe becomes int conv_flags

When calling convert_to_git(), the checksafe parameter defined what
should happen if the EOL conversion (CRLF --> LF --> CRLF) does not
roundtrip cleanly. In addition, it also defined if line endings should
be renormalized (CRLF --> LF) or kept as they are.

checksafe was an safe_crlf enum with these values:
SAFE_CRLF_FALSE:       do nothing in case of EOL roundtrip errors
SAFE_CRLF_FAIL:        die in case of EOL roundtrip errors
SAFE_CRLF_WARN:        print a warning in case of EOL roundtrip errors
SAFE_CRLF_RENORMALIZE: change CRLF to LF
SAFE_CRLF_KEEP_CRLF:   keep all line endings as they are

In some cases the integer value 0 was passed as checksafe parameter
instead of the correct enum value SAFE_CRLF_FALSE. That was no problem
because SAFE_CRLF_FALSE is defined as 0.

FALSE/FAIL/WARN are different from RENORMALIZE and KEEP_CRLF. Therefore,
an enum is not ideal. Let's use a integer bit pattern instead and rename
the parameter to conv_flags to make it more generically usable. This
allows us to extend the bit pattern in a subsequent commit.

Reported-By: Randall S. Becker <rsbecker@nexbridge.com>
Helped-By: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoadd--interactive: ignore submodule changes except HEAD
Nguyễn Thái Ngọc Duy [Sat, 13 Jan 2018 12:10:38 +0000 (19:10 +0700)] 
add--interactive: ignore submodule changes except HEAD

For 'add -i' and 'add -p', the only action we can take on a dirty
submodule entry is update the index with a new value from its HEAD. The
content changes inside (from its own index, untracked files...) do not
matter, at least until 'git add -i' learns about launching a new
interactive add session inside a submodule.

Ignore all other submodules changes except HEAD. This reduces the number
of entries the user has to check through in 'git add -i', and the number
of 'no' they have to answer to 'git add -p' when dirty submodules are
present.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotrace.c: move strbuf_release() out of print_trace_line()
Nguyễn Thái Ngọc Duy [Mon, 15 Jan 2018 10:59:45 +0000 (17:59 +0700)] 
trace.c: move strbuf_release() out of print_trace_line()

The function is about printing a trace line, not releasing the buffer it
receives too. Move strbuf_release() back outside. This makes it easier
to see how strbuf is managed.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotrace: avoid unnecessary quoting
Jeff King [Mon, 15 Jan 2018 10:59:44 +0000 (17:59 +0700)] 
trace: avoid unnecessary quoting

Trace output which contains arbitrary strings (e.g., the
arguments to commands which we are running) is always passed
through sq_quote_buf(). That function always adds
single-quotes, even if the output consists of vanilla
characters. This can make the output a bit hard to read.

Let's avoid the quoting if there are no characters which a
shell would interpret. Trace output doesn't necessarily need
to be shell-compatible, but:

  - the shell language is a good ballpark for what humans
    consider readable (well, humans versed in command line
    tools)

  - the run_command bits can be cut-and-pasted to a shell,
    and we'll keep that property

  - it covers any cases which would make the output
    visually ambiguous (e.g., embedded whitespace or quotes)

Signed-off-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>
6 years agosq_quote_argv: drop maxlen parameter
Jeff King [Mon, 15 Jan 2018 10:59:43 +0000 (17:59 +0700)] 
sq_quote_argv: drop maxlen parameter

No caller passes anything but "0" for this parameter, which
requests that the function ignore it completely. In fact, in
all of history there was only one such caller, and it went
away in 7f51f8bc2b (alias: use run_command api to execute
aliases, 2011-01-07).

Signed-off-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>
6 years agoDoc/git-submodule: improve readability and grammar of a sentence
Kaartic Sivaraam [Sun, 14 Jan 2018 17:37:37 +0000 (23:07 +0530)] 
Doc/git-submodule: improve readability and grammar of a sentence

While at it, correctly quote important words.

Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoDoc/gitsubmodules: make some changes to improve readability and syntax
Kaartic Sivaraam [Sun, 14 Jan 2018 17:37:36 +0000 (23:07 +0530)] 
Doc/gitsubmodules: make some changes to improve readability and syntax

* Only mention porcelain commands in examples

* Split a sentence for better readability

* Add missing apostrophes

* Clearly specify the advantages of using submodules

* Avoid abbreviations

* Use "Git" consistently

* Improve readability of certain lines

* Clarify when a submodule is considered active

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosubmodule: port submodule subcommand 'deinit' from shell to C
Prathamesh Chavan [Sun, 14 Jan 2018 21:15:29 +0000 (02:45 +0530)] 
submodule: port submodule subcommand 'deinit' from shell to C

The same mechanism is used even for porting this submodule
subcommand, as used in the ported subcommands till now.
The function cmd_deinit in split up after porting into four
functions: module_deinit(), for_each_listed_submodule(),
deinit_submodule() and deinit_submodule_cb().

Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Prathamesh Chavan <pc44800@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosubmodule: port submodule subcommand 'sync' from shell to C
Prathamesh Chavan [Sun, 14 Jan 2018 21:15:28 +0000 (02:45 +0530)] 
submodule: port submodule subcommand 'sync' from shell to C

Port the submodule subcommand 'sync' from shell to C using the same
mechanism as that used for porting submodule subcommand 'status'.
Hence, here the function cmd_sync() is ported from shell to C.
This is done by introducing four functions: module_sync(),
sync_submodule(), sync_submodule_cb() and print_default_remote().

The function print_default_remote() is introduced for getting
the default remote as stdout.

Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Prathamesh Chavan <pc44800@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agol10n: de.po: translate 72 new messages
Ralf Thielow [Tue, 2 Jan 2018 09:14:40 +0000 (10:14 +0100)] 
l10n: de.po: translate 72 new messages

Translate 72 new messages came from git.pot update in 18a907225 (l10n:
git.pot: v2.16.0 round 1 (64 new, 25 removed)) and 005c62fe4 (l10n:
git.pot: v2.16.0 round 2 (8 new, 4 removed)).

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Acked-by: Matthias Rüster <matthias.ruester@gmail.com>
6 years agol10n: de.po: improve messages when a branch starts to track another ref
Ralf Thielow [Sat, 16 Dec 2017 19:32:16 +0000 (20:32 +0100)] 
l10n: de.po: improve messages when a branch starts to track another ref

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
6 years agoRelNotes: minor typofix
SZEDER Gábor [Fri, 12 Jan 2018 10:47:36 +0000 (11:47 +0100)] 
RelNotes: minor typofix

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot9001: use existing helper in send-email test
Christian Ludwig [Fri, 12 Jan 2018 10:37:24 +0000 (11:37 +0100)] 
t9001: use existing helper in send-email test

Use the wrapper function around the sed statement like everywhere
else in the test. Unfortunately the wrapper function is defined
pretty late.

Move the wrapper to the top of the test file, so future users have it
available right away.

Signed-off-by: Christian Ludwig <chrissicool@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoGit 2.16-rc2 v2.16.0-rc2
Junio C Hamano [Thu, 11 Jan 2018 21:20:41 +0000 (13:20 -0800)] 
Git 2.16-rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'jh/object-filtering'
Junio C Hamano [Thu, 11 Jan 2018 21:16:37 +0000 (13:16 -0800)] 
Merge branch 'jh/object-filtering'

Hotfix for a topic already in 'master'.

* jh/object-filtering:
  oidset: don't return value from oidset_init

6 years agoMerge branch 'tg/worktree-create-tracking'
Junio C Hamano [Thu, 11 Jan 2018 21:16:36 +0000 (13:16 -0800)] 
Merge branch 'tg/worktree-create-tracking'

Doc hotfix.

* tg/worktree-create-tracking:
  Documentation/git-worktree.txt: add missing `

6 years agoMerge branch 'js/test-with-ws-in-path'
Junio C Hamano [Thu, 11 Jan 2018 21:16:36 +0000 (13:16 -0800)] 
Merge branch 'js/test-with-ws-in-path'

Hot fix to a test.

* js/test-with-ws-in-path:
  t3900: add some more quotes

6 years agol10n: bg.po: Updated Bulgarian translation (3288t)
Alexander Shopov [Thu, 11 Jan 2018 20:59:37 +0000 (21:59 +0100)] 
l10n: bg.po: Updated Bulgarian translation (3288t)

Signed-off-by: Alexander Shopov <ash@kambanaria.org>
6 years agoDocumentation/git-worktree.txt: add missing `
Ralf Thielow [Thu, 11 Jan 2018 18:18:21 +0000 (19:18 +0100)] 
Documentation/git-worktree.txt: add missing `

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocat-file doc: document that -e will return some output
Ævar Arnfjörð Bjarmason [Wed, 10 Jan 2018 12:55:53 +0000 (12:55 +0000)] 
cat-file doc: document that -e will return some output

The -e option added in 7950571ad7 ("A few more options for
git-cat-file", 2005-12-03) has always errored out with message on
stderr saying that the provided object is malformed, like this:

    $ git cat-file -e malformed; echo $?
    fatal: Not a valid object name malformed
    128

A reader of this documentation may be misled into thinking that

    if ! git cat-file -e "$object" [...]

as opposed to:

    if ! git cat-file -e "$object" 2>/dev/null [...]

is sufficient to implement a truly silent test that checks whether
some arbitrary $object string was both valid, and pointed to an
object that exists.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot3900: add some more quotes
Beat Bolli [Wed, 10 Jan 2018 09:58:32 +0000 (10:58 +0100)] 
t3900: add some more quotes

In 89a70b80 ("t0302 & t3900: add forgotten quotes", 2018-01-03), quotes
were added to protect against spaces in $HOME. In the test_when_finished
command, two files are deleted which must be quoted individually.

[jc: with \$HOME in the test_when_finished command quoted, as
pointed out by j6t].

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
Helped-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoRelNotes update before -rc2
Junio C Hamano [Wed, 10 Jan 2018 22:01:50 +0000 (14:01 -0800)] 
RelNotes update before -rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'js/perl-path-workaround-in-tests'
Junio C Hamano [Wed, 10 Jan 2018 22:01:31 +0000 (14:01 -0800)] 
Merge branch 'js/perl-path-workaround-in-tests'

* js/perl-path-workaround-in-tests:
  mingw: handle GITPERLLIB in t0021 in a Windows-compatible way

6 years agoMerge branch 'ew/empty-merge-with-dirty-index'
Junio C Hamano [Wed, 10 Jan 2018 22:01:25 +0000 (14:01 -0800)] 
Merge branch 'ew/empty-merge-with-dirty-index'

"git merge -s recursive" did not correctly abort when the index is
dirty, if the merged tree happened to be the same as the current
HEAD, which has been fixed.

* ew/empty-merge-with-dirty-index:
  merge-recursive: do not look at the index during recursive merge