git.git
6 years agorebase --abort/--quit: cleanup refs/rewritten
Phillip Wood [Tue, 14 May 2019 18:03:49 +0000 (19:03 +0100)]
rebase --abort/--quit: cleanup refs/rewritten

When `rebase -r` finishes it removes any refs under refs/rewritten that
it has created. However if the user aborts or quits the rebase refs are
not removed. This can cause problems for future rebases. For example I
recently wanted to merge a updated version of a topic branch into an
integration branch so ran `rebase -ir` and removed the picks and label
for the topic branch from the todo list so that

    merge -C <old-merge> topic

would pick up the new version of topic. Unfortunately
refs/rewritten/topic already existed from a previous rebase that had
been aborted so the rebase just used the old topic, not the new one.

The logic for the non-interactive quit case is changed to ensure
`buf` is always freed.

Signed-off-by: Phillip Wood <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agosequencer: return errors from sequencer_remove_state()
Phillip Wood [Tue, 14 May 2019 18:03:48 +0000 (19:03 +0100)]
sequencer: return errors from sequencer_remove_state()

If there is an error when removing the state directory then we should
report it. This matches what the non-interactive rebase does.

Signed-off-by: Phillip Wood <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agorebase: warn if state directory cannot be removed
Phillip Wood [Tue, 14 May 2019 18:03:47 +0000 (19:03 +0100)]
rebase: warn if state directory cannot be removed

If rebase --quit cannot remove the state directory then it dies. However
when rebase finishes normally or the user runs rebase --abort any errors
that occur when removing the state directory are ignored. That is fixed
by this commit.

All of the callers of finish_rebase() except the code
that handles --abort are careful to make sure they get a postive return
value, do the same for --abort.

Signed-off-by: Phillip Wood <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agorebase: fix a memory leak
Phillip Wood [Tue, 14 May 2019 18:03:46 +0000 (19:03 +0100)]
rebase: fix a memory leak

buf was never freed.

Signed-off-by: Phillip Wood <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agohelp_unknown_ref(): check for refname ambiguity
Jeff King [Tue, 14 May 2019 12:05:05 +0000 (08:05 -0400)]
help_unknown_ref(): check for refname ambiguity

When the user asks to merge "foo" and we suggest "origin/foo" instead,
we do so by simply chopping off "refs/remotes/" from the front of the
suggested ref. This is usually fine, but it's possible that the
resulting name is ambiguous (e.g., you have "refs/heads/origin/foo",
too).

Let's use shorten_unambiguous_ref() to do this the right way, which
should usually yield the same "origin/foo", but "remotes/origin/foo" if
necessary.

Note that in this situation there may be other options (e.g., we could
suggest "heads/origin/foo" as well). I'll leave that up for debate; the
focus here is just to avoid giving advice that does not actually do what
we expect.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agohelp_unknown_ref(): duplicate collected refnames
Jeff King [Tue, 14 May 2019 12:04:31 +0000 (08:04 -0400)]
help_unknown_ref(): duplicate collected refnames

When "git merge" sees an unknown refname, we iterate through the refs to
try to suggest some possible alternates. We do so with for_each_ref(),
and in the callback we add some of the refnames we get to a
string_list that is declared with NODUP, directly adding a pointer into
the refname string our callback received.

But the for_each_ref() machinery does not promise that the refname
string will remain valid, and as a result we may print garbage memory.

The code in question dates back to its inception in e56181060e (help:
add help_unknown_ref(), 2013-05-04). But back then, the refname strings
generally did remain stable, at least immediately after the
for_each_ref() call. Later, in d1cf15516f (packed_ref_iterator_begin():
iterate using `mmapped_ref_iterator`, 2017-09-25), we started
consistently re-using a separate buffer for packed refs.

The fix is simple: duplicate the strings we intend to collect. We
already call string_list_clear(), so the memory is correctly freed.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agorebase: fold git-rebase--common into the -p backend
Johannes Schindelin [Tue, 14 May 2019 11:22:34 +0000 (04:22 -0700)]
rebase: fold git-rebase--common into the -p backend

The only remaining scripted part of `git rebase` is the
`--preserve-merges` backend. Meaning: there is little reason to keep the
"library of common rebase functions" as a separate file.

While moving the functions to `git-rebase--preserve-merges.sh`, we also
drop the `move_to_original_branch` function that is no longer used.

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agosequencer: the `am` and `rebase--interactive` scripts are gone
Johannes Schindelin [Tue, 14 May 2019 11:22:33 +0000 (04:22 -0700)]
sequencer: the `am` and `rebase--interactive` scripts are gone

Update a code comment that referred to those files as if they were still
there.

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years ago.gitignore: there is no longer a built-in `git-rebase--interactive`
Johannes Schindelin [Tue, 14 May 2019 11:22:32 +0000 (04:22 -0700)]
.gitignore: there is no longer a built-in `git-rebase--interactive`

This went away in 0609b741a4 (rebase -i: combine rebase--interactive.c
with rebase.c, 2019-04-17).

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot3400: stop referring to the scripted rebase
Johannes Schindelin [Tue, 14 May 2019 11:22:31 +0000 (04:22 -0700)]
t3400: stop referring to the scripted rebase

One test case's title mentioned the then-current implementation detail
that the `--am` backend was implemented in `git-rebase--am.sh`.

This is no longer the case, so let's update the title to reflect the
current reality.

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoDrop unused git-rebase--am.sh
Johannes Schindelin [Tue, 14 May 2019 11:22:31 +0000 (04:22 -0700)]
Drop unused git-rebase--am.sh

Since 21853626ea (built-in rebase: call `git am` directly, 2019-01-18),
the built-in rebase already uses the built-in `git am` directly.

Now that d03ebd411c (rebase: remove the rebase.useBuiltin setting,
2019-03-18) even removed the scripted rebase, there is no longer any
user of `git-rebase--am.sh`, so let's just remove it.

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agostash: document stash.useBuiltin
Johannes Schindelin [Tue, 14 May 2019 09:19:15 +0000 (02:19 -0700)]
stash: document stash.useBuiltin

The stash.useBuiltin variable introduced in 90a462725e ("stash:
optionally use the scripted version again", 2019-02-25) was turned on by
default, but had no documentation.

Let's document it so that users who run into any stability issues with
the C rewrite know there's an escape hatch, and spell out that the
user should please report the bug when they have to turn off the
built-in stash.

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agol10n: sv.po: Update Swedish translation (4577t0f0u)
Peter Krefting [Tue, 14 May 2019 14:46:15 +0000 (15:46 +0100)]
l10n: sv.po: Update Swedish translation (4577t0f0u)

Signed-off-by: Peter Krefting <redacted>
6 years agol10n: sv.po: Update Swedish translation
Peter Krefting [Sun, 17 Mar 2019 15:52:33 +0000 (16:52 +0100)]
l10n: sv.po: Update Swedish translation

Fix mistakes reported by Mattias Engdegård <redacted>.

Signed-off-by: Peter Krefting <redacted>
6 years agol10n: git.pot: v2.22.0 round 1 (270 new, 56 removed)
Jiang Xin [Tue, 14 May 2019 09:09:58 +0000 (17:09 +0800)]
l10n: git.pot: v2.22.0 round 1 (270 new, 56 removed)

Generate po/git.pot from v2.22.0-rc0 for git v2.22.0 l10n round 1.

Signed-off-by: Jiang Xin <redacted>
6 years agofast-export: do automatic reencoding of commit messages only if requested
Elijah Newren [Tue, 14 May 2019 04:31:02 +0000 (21:31 -0700)]
fast-export: do automatic reencoding of commit messages only if requested

Automatic re-encoding of commit messages (and dropping of the encoding
header) hurts attempts to do reversible history rewrites (e.g. sha1sum
<-> sha256sum transitions, some subtree rewrites), and seems
inconsistent with the general principle followed elsewhere in
fast-export of requiring explicit user requests to modify the output
(e.g. --signed-tags=strip, --tag-of-filtered-object=rewrite).  Add a
--reencode flag that the user can use to specify, and like other
fast-export flags, default it to 'abort'.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agofast-export: differentiate between explicitly UTF-8 and implicitly UTF-8
Elijah Newren [Tue, 14 May 2019 04:31:01 +0000 (21:31 -0700)]
fast-export: differentiate between explicitly UTF-8 and implicitly UTF-8

The find_encoding() function returned the encoding used by a commit
message, returning a default of git_commit_encoding (usually UTF-8).
Although the current code does not differentiate between a commit which
explicitly requested UTF-8 and one where we just assume UTF-8 because no
encoding is set, it will become important when we try to preserve the
encoding header.  Since is_encoding_utf8() returns true when passed
NULL, we can just return NULL from find_encoding() instead of returning
git_commit_encoding.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agofast-export: avoid stripping encoding header if we cannot reencode
Elijah Newren [Tue, 14 May 2019 04:31:00 +0000 (21:31 -0700)]
fast-export: avoid stripping encoding header if we cannot reencode

When fast-export encounters a commit with an 'encoding' header, it tries
to reencode in UTF-8 and then drops the encoding header.  However, if it
fails to reencode in UTF-8 because e.g. one of the characters in the
commit message was invalid in the old encoding, then we need to retain
the original encoding or otherwise we lose information needed to
understand all the other (valid) characters in the original commit
message.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agofast-import: support 'encoding' commit header
Elijah Newren [Tue, 14 May 2019 04:30:59 +0000 (21:30 -0700)]
fast-import: support 'encoding' commit header

Since git supports commit messages with an encoding other than UTF-8,
allow fast-import to import such commits.  This may be useful for folks
who do not want to reencode commit messages from an external system, and
may also be useful to achieve reversible history rewrites (e.g. sha1sum
<-> sha256sum transitions or subtree work) with git repositories that
have used specialized encodings in their commit history.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot9350: fix encoding test to actually test reencoding
Elijah Newren [Tue, 14 May 2019 04:30:58 +0000 (21:30 -0700)]
t9350: fix encoding test to actually test reencoding

This test used an author with non-ascii characters in the name, but no
special commit message.  It then grep'ed for those non-ascii characters,
but those are guaranteed to exist regardless of the reencoding process
since the reencoding only affects the commit message, not the author or
committer names.  As such, the test would work even if the re-encoding
process simply stripped the commit message entirely.  Modify the test to
actually check that the reencoding into UTF-8 worked.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agotests: add a special setup where prerequisites fail
Ævar Arnfjörð Bjarmason [Mon, 13 May 2019 18:32:42 +0000 (20:32 +0200)]
tests: add a special setup where prerequisites fail

As discussed in [1] there's a regression in the "pu" branch now
because a new test implicitly assumed that a previous test guarded by
a prerequisite had been run. Add a "GIT_TEST_FAIL_PREREQS" special
test setup where we'll skip (nearly) all tests guarded by
prerequisites, allowing us to easily emulate those platform where we
don't run these tests.

As noted in the documentation I'm adding I'm whitelisting the SYMLINKS
prerequisite for now. A lot of tests started failing if we lied about
not supporting symlinks. It's also unlikely that we'll have a failing
test due to a hard dependency on symlinks without that being the
obvious cause, so for now it's not worth the effort to make it work.

1. https://public-inbox.org/git/nycvar.QRO.7.76.6.1905131531000.44@tvgsbejvaqbjf.bet/

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agosha1dc: update from upstream
Ævar Arnfjörð Bjarmason [Mon, 13 May 2019 22:17:01 +0000 (00:17 +0200)]
sha1dc: update from upstream

Update sha1dc from the latest version by the upstream
maintainer[1]. See 07a20f569b ("Makefile: fix unaligned loads in
sha1dc with UBSan", 2019-03-12) for the last update.

This fixes an issue where HP-UX IA64 was wrongly detected as a
Little-endian instead of a Big-endian system, see [2] and [3].

1. https://github.com/cr-marcstevens/sha1collisiondetection/commit/855827c583bc30645ba427885caa40c5b81764d2
2. https://public-inbox.org/git/603989bd-f86d-c61d-c6f5-fb6748a65ba9@siemens.com/
3. https://github.com/cr-marcstevens/sha1collisiondetection/pull/50

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoparse-options: adjust `parse_opt_unknown_cb()`s declared return type
Johannes Schindelin [Mon, 13 May 2019 22:43:17 +0000 (15:43 -0700)]
parse-options: adjust `parse_opt_unknown_cb()`s declared return type

In f41179f16ba2 (parse-options: avoid magic return codes, 2019-01-27),
the signature of the low-level parse-opt callback function was changed
to return an `enum`.

And while the implementations were changed, one declaration was left
unchanged, still claiming to return `int`.

This can potentially lead to problems, as compilers are free to choose
any integral type for an `enum` as long as it can represent all declared
values.

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoGit 2.22-rc0
Junio C Hamano [Mon, 13 May 2019 14:40:13 +0000 (23:40 +0900)]
Git 2.22-rc0

Signed-off-by: Junio C Hamano <redacted>
6 years agoMerge branch 'jh/trace2'
Junio C Hamano [Mon, 13 May 2019 14:50:35 +0000 (23:50 +0900)]
Merge branch 'jh/trace2'

A few embarrassing bugfixes.

* jh/trace2:
  trace2: fix up a missing "leave" entry point
  trace2: fix incorrect function pointer check

6 years agoMerge branch 'cc/access-on-aix-workaround'
Junio C Hamano [Mon, 13 May 2019 14:50:35 +0000 (23:50 +0900)]
Merge branch 'cc/access-on-aix-workaround'

Workaround for standard-compliant but less-than-useful behaviour of
access(2) for the root user.

* cc/access-on-aix-workaround:
  git-compat-util: work around for access(X_OK) under root

6 years agoMerge branch 'pw/clean-sequencer-state-upon-final-commit'
Junio C Hamano [Mon, 13 May 2019 14:50:35 +0000 (23:50 +0900)]
Merge branch 'pw/clean-sequencer-state-upon-final-commit'

"git chery-pick" (and "revert" that shares the same runtime engine)
that deals with multiple commits got confused when the final step
gets stopped with a conflict and the user concluded the sequence
with "git commit".  Attempt to fix it by cleaning up the state
files used by these commands in such a situation.

* pw/clean-sequencer-state-upon-final-commit:
  fix cherry-pick/revert status after commit
  commit/reset: try to clean up sequencer state

6 years agoMerge branch 'pw/rebase-i-internal'
Junio C Hamano [Mon, 13 May 2019 14:50:34 +0000 (23:50 +0900)]
Merge branch 'pw/rebase-i-internal'

The internal implementation of "git rebase -i" has been updated to
avoid forking a separate "rebase--interactive" process.

* pw/rebase-i-internal:
  rebase -i: run without forking rebase--interactive
  rebase: use a common action enum
  rebase -i: use struct rebase_options in do_interactive_rebase()
  rebase -i: use struct rebase_options to parse args
  rebase -i: use struct object_id for squash_onto
  rebase -i: use struct commit when parsing options
  rebase -i: remove duplication
  rebase -i: combine rebase--interactive.c with rebase.c
  rebase: use OPT_RERERE_AUTOUPDATE()
  rebase: rename write_basic_state()
  rebase: don't translate trace strings
  sequencer: always discard index after checkout

6 years agoMerge branch 'jk/perf-aggregate-wo-libjson'
Junio C Hamano [Mon, 13 May 2019 14:50:34 +0000 (23:50 +0900)]
Merge branch 'jk/perf-aggregate-wo-libjson'

The script to aggregate perf result unconditionally depended on
libjson-perl even though it did not have to, which has been
corrected.

* jk/perf-aggregate-wo-libjson:
  t/perf: depend on perl JSON only when using --codespeed

6 years agoMerge branch 'dl/rev-tilde-doc-clarify'
Junio C Hamano [Mon, 13 May 2019 14:50:33 +0000 (23:50 +0900)]
Merge branch 'dl/rev-tilde-doc-clarify'

Docfix.

* dl/rev-tilde-doc-clarify:
  revisions.txt: remove ambibuity between <rev>:<path> and :<path>
  revisions.txt: mention <rev>~ form
  revisions.txt: mark optional rev arguments with []
  revisions.txt: change "rev" to "<rev>"

6 years agoMerge branch 'jc/make-dedup-ls-files-output'
Junio C Hamano [Mon, 13 May 2019 14:50:33 +0000 (23:50 +0900)]
Merge branch 'jc/make-dedup-ls-files-output'

A "ls-files" that emulates "find" to enumerate files in the working
tree resulted in duplicated Makefile rules that caused the build to
issue an unnecessary warning during a trial build after merge
conflicts are resolved in working tree *.h files but before the
resolved results are added to the index.  This has been corrected.

* jc/make-dedup-ls-files-output:
  Makefile: dedup list of files obtained from ls-files

6 years agoMerge branch 'jk/ls-files-doc-markup-fix'
Junio C Hamano [Mon, 13 May 2019 14:50:33 +0000 (23:50 +0900)]
Merge branch 'jk/ls-files-doc-markup-fix'

Docfix.

* jk/ls-files-doc-markup-fix:
  doc/ls-files: put nested list for "-t" option into block

6 years agoMerge branch 'jk/p5302-avoid-collision-check-cost'
Junio C Hamano [Mon, 13 May 2019 14:50:32 +0000 (23:50 +0900)]
Merge branch 'jk/p5302-avoid-collision-check-cost'

Fix index-pack perf test so that the repeated invocations always
run in an empty repository, which emulates the initial clone
situation better.

* jk/p5302-avoid-collision-check-cost:
  p5302: create the repo in each index-pack test

6 years agoMerge branch 'dl/no-extern-in-func-decl'
Junio C Hamano [Mon, 13 May 2019 14:50:32 +0000 (23:50 +0900)]
Merge branch 'dl/no-extern-in-func-decl'

Mechanically and systematically drop "extern" from function
declarlation.

* dl/no-extern-in-func-decl:
  *.[ch]: manually align parameter lists
  *.[ch]: remove extern from function declarations using sed
  *.[ch]: remove extern from function declarations using spatch

6 years agoMerge branch 'ew/repack-with-bitmaps-by-default'
Junio C Hamano [Mon, 13 May 2019 14:50:32 +0000 (23:50 +0900)]
Merge branch 'ew/repack-with-bitmaps-by-default'

The connectivity bitmaps are created by default in bare
repositories now; also the pathname hash-cache is created by
default to avoid making crappy deltas when repacking.

* ew/repack-with-bitmaps-by-default:
  pack-objects: default to writing bitmap hash-cache
  t5310: correctly remove bitmaps for jgit test
  repack: enable bitmaps by default on bare repos

6 years agoMerge branch 'js/partial-clone-connectivity-check'
Junio C Hamano [Mon, 13 May 2019 14:50:31 +0000 (23:50 +0900)]
Merge branch 'js/partial-clone-connectivity-check'

During an initial "git clone --depth=..." partial clone, it is
pointless to spend cycles for a large portion of the connectivity
check that enumerates and skips promisor objects (which by
definition is all objects fetched from the other side).  This has
been optimized out.

* js/partial-clone-connectivity-check:
  t/perf: add perf script for partial clones
  clone: do faster object check for partial clones

6 years agoMerge branch 'jh/trace2-sid-fix'
Junio C Hamano [Mon, 13 May 2019 14:50:31 +0000 (23:50 +0900)]
Merge branch 'jh/trace2-sid-fix'

Polishing of the new trace2 facility continues.  The system-level
configuration can specify site-wide trace2 settings, which can be
overridden with per-user configuration and environment variables.

* jh/trace2-sid-fix:
  trace2: fixup access problem on /etc/gitconfig in read_very_early_config
  trace2: update docs to describe system/global config settings
  trace2: make SIDs more unique
  trace2: clarify UTC datetime formatting
  trace2: report peak memory usage of the process
  trace2: use system/global config for default trace2 settings
  config: add read_very_early_config()
  trace2: find exec-dir before trace2 initialization
  trace2: add absolute elapsed time to start event
  trace2: refactor setting process starting time
  config: initialize opts structure in repo_read_config()

6 years agodifftool: fallback on merge.guitool
Denton Liu [Mon, 29 Apr 2019 06:21:20 +0000 (02:21 -0400)]
difftool: fallback on merge.guitool

In git-difftool.txt, it says

'git difftool' falls back to 'git mergetool' config variables when the
difftool equivalents have not been defined.

However, when `diff.guitool` is missing, it doesn't fallback to
anything. Make git-difftool fallback to `merge.guitool` when `diff.guitool` is
missing.

Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agodifftool: make --gui, --tool and --extcmd mutually exclusive
Denton Liu [Mon, 29 Apr 2019 06:21:17 +0000 (02:21 -0400)]
difftool: make --gui, --tool and --extcmd mutually exclusive

In git-difftool, these options specify which tool to ultimately run. As
a result, they are logically conflicting. Explicitly disallow these
options from being used together.

Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agomergetool: fallback to tool when guitool unavailable
Denton Liu [Mon, 29 Apr 2019 06:21:14 +0000 (02:21 -0400)]
mergetool: fallback to tool when guitool unavailable

In git-difftool, if the tool is called with --gui but `diff.guitool` is
not set, it falls back to `diff.tool`. Make git-mergetool also fallback
from `merge.guitool` to `merge.tool` if the former is undefined.

If git-difftool, when called with `--gui`, were to use
`get_configured_mergetool` in a future patch, it would also get the
fallback behavior in the following precedence:

1. diff.guitool
2. merge.guitool
3. diff.tool
4. merge.tool

The behavior for when difftool or mergetool are called without `--gui`
should be identical with or without this patch.

Note that the search loop could be written as

sections="merge"
keys="tool"
if diff_mode
then
sections="diff $sections"
fi
if gui_mode
then
keys="guitool $keys"
fi

merge_tool=$(
IFS=' '
for key in $keys
do
for section in $sections
do
selected=$(git config $section.$key)
if test -n "$selected"
then
echo "$selected"
return
fi
done
done)

which would make adding a mode in the future much easier. However,
adding a new mode will likely never happen as it is highly discouraged
so, as a result, it is written in its current form so that it is more
readable for future readers.

Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agomergetool--lib: create gui_mode function
Denton Liu [Mon, 29 Apr 2019 06:21:11 +0000 (02:21 -0400)]
mergetool--lib: create gui_mode function

Before, in `get_configured_merge_tool`, we would test the value of the
first argument directly, which corresponded to whether we were using
guitool. However, since `$GIT_MERGETOOL_GUI` is available as an
environment variable, create the `gui_mode` function which increases the
clarify of functions which use it.

While we're at it, add a space before `()` in function definitions to
fix the style.

Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agomergetool: use get_merge_tool function
Denton Liu [Mon, 29 Apr 2019 06:21:08 +0000 (02:21 -0400)]
mergetool: use get_merge_tool function

In git-mergetool, the logic for getting which merge tool to use is
duplicated in git-mergetool--lib, except for the fact that it needs to
know whether the tool was guessed or not.

Rewrite `get_merge_tool` to return whether or not the tool was guessed
through the return code and make git-mergetool call this function
instead of duplicating the logic. Note that 1 was chosen to be the
return code of when a tool is guessed because it seems like a slightly
more abnormal condition than getting a tool that's explicitly specified
but this is completely arbitrary.

Also, let `$GIT_MERGETOOL_GUI` be set to determine whether or not the
guitool will be selected.

This change is not completely backwards compatible as there may be
external users of git-mergetool--lib. However, only one user,
git-diffall[1], was found from searching GitHub and Google, and this
tool is superseded by `git difftool --dir-diff` anyway. It seems very
unlikely that there exists an external caller that would take into
account the return code of `get_merge_tool` as it would always return 0
before this change so this change probably does not affect any external
users.

[1]: https://github.com/thenigan/git-diffall

Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agotrace2: add variable description to git.txt
Derrick Stolee [Fri, 10 May 2019 19:44:26 +0000 (12:44 -0700)]
trace2: add variable description to git.txt

Documentation/technical/api-trace2.txt contains the full details
of the trace2 API and the GIT_TR2* environment variables. However,
most environment variables are included in Documentation/git.txt,
including the GIT_TRACE* variables.

Add a brief description of the GIT_TR2* variables with links to
the full technical details. The biggest difference from the
original variables is that we can specify a Unix Domain Socket.
Mention this difference, but leave the details to the technical
documents.

Reported-by: Szeder Gábor <redacted>
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agosend-email: do defaults -> config -> getopt in that order
Ævar Arnfjörð Bjarmason [Thu, 9 May 2019 11:48:30 +0000 (13:48 +0200)]
send-email: do defaults -> config -> getopt in that order

Change the git-send-email command-line argument parsing and config
reading code to parse those two in the right order. I.e. first we set
our hardcoded defaults, then we read our config, and finally we read
the command-line, with later sets overriding earlier sets.

This fixes a bug introduced in e67a228cd8 ("send-email:
automatically determine transfer-encoding", 2018-07-08). That change
broke the reading of sendmail.transferencoding because it wasn't
careful to update the code to parse them in the previous "defaults
-> getopt -> config" order.

But as we can see from the history for this file doing it this way was
never what we actually wanted, it's just something we grew organically
as of 5483c71d7a ("git-send-email: make options easier to configure.",
2007-06-27) and have been dealing with the fallout since, e.g. in
463b0ea22b ("send-email: Fix %config_path_settings handling",
2011-10-14).

As can be seen in this change the only place where we actually want to
do something clever is with the to/cc/bcc variables, where setting
them on the command-line (or using --no-{to,cc,bcc}) should clear out
values we grab from the config.

All the rest are things where the command-line should simply override
the config values, and by reading the config first the config code
doesn't need all this "let's not set it, if it was on the command-line"
special-casing, as [1] shows we'd otherwise need to care about the
difference between whether something was a default or present in
config to fix the bug in e67a228cd8.

1. https://public-inbox.org/git/20190508105607.178244-2-gitster@pobox.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agosend-email: rename the @bcclist variable for consistency
Ævar Arnfjörð Bjarmason [Thu, 9 May 2019 11:48:29 +0000 (13:48 +0200)]
send-email: rename the @bcclist variable for consistency

The "to" and "cc" variables are named @initial_{to,cc}, let's rename
this one to match them.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agosend-email: move the read_config() function above getopts
Ævar Arnfjörð Bjarmason [Thu, 9 May 2019 11:48:28 +0000 (13:48 +0200)]
send-email: move the read_config() function above getopts

This is in preparation for a later change where we'll read the config
first before parsing command-line options. As the move detection will
show no lines (except one line of comment) is changed here, just moved
around.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agostatus: fix display of rebase -ir's `label` command
Johannes Schindelin [Fri, 10 May 2019 20:23:14 +0000 (13:23 -0700)]
status: fix display of rebase -ir's `label` command

The argument of a `label` command does *not* want to be turned into an
abbreviated SHA-1.

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agotrace2: fix up a missing "leave" entry point
Ævar Arnfjörð Bjarmason [Fri, 10 May 2019 13:37:38 +0000 (15:37 +0200)]
trace2: fix up a missing "leave" entry point

Fix a trivial bug that's been here since the shared/do_write_index
tracing was added in 42fee7a388 ("trace2:data: add trace2
instrumentation to index read/write", 2019-02-22). We should have
enter/leave points, not two enter/enter points. This resulted in an
"enter" event without a corresponding "leave" event.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Acked-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoinit: make --template path relative to $CWD
Nguyễn Thái Ngọc Duy [Fri, 10 May 2019 10:46:57 +0000 (17:46 +0700)]
init: make --template path relative to $CWD

During git-init we chdir() to the target directory, but --template is
not adjusted. So it's relative to the target directory instead of
current directory.

It would be ok if it's documented, but --template in git-init.txt
mentions nothing about this behavior. Change it to be relative to $CWD,
which is much more intuitive.

The changes in the test suite show that this relative-to-target behavior
is actually used. I just hope that it's only used in the test suite and
it's safe to change. Otherwise, the other option is just document
it (i.e. relative to target dir) and move on.

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoverify-commit: simplify parameters to run_gpg_verify()
Jeff King [Thu, 9 May 2019 21:32:29 +0000 (17:32 -0400)]
verify-commit: simplify parameters to run_gpg_verify()

The buf/len parameters of run_gpg_verify() have never been used since
the function was added in d07b00b7f3 (verify-commit: scriptable commit
signature verification, 2014-06-23). Instead, check_commit_signature()
accesses the commit struct directly.

Worse, we read the whole object just to check its type and do not attach
it to the "struct commit". Meaning we end up loading the object from
disk twice for no good reason.

And to further confuse matters, our type check is comes from what we
read from disk, but we later assume that lookup_commit() will return
non-NULL. This might not be true if some other object previously
referenced the same oid as a non-commit (though this may be impossible
to trigger in practice since we don't generally parse any other objects
in this command).

Instead, let's do our type check by loading the object via
parse_object(). That will attach the buffer to the struct so it can be
used later by check_commit_signature(). And it ensures that
lookup_commit() will return something sane.

And then we can just drop the unused "buf" and "len" parameters
entirely.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoshow-branch: drop unused parameter from show_independent()
Jeff King [Thu, 9 May 2019 21:32:14 +0000 (17:32 -0400)]
show-branch: drop unused parameter from show_independent()

This ref_name parameter was never used since the inception of
show_independent() in 1f8af483df (show-branch: --list and --independent,
2005-09-09). Let's drop it.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agorev-list: drop unused void pointer from finish_commit()
Jeff King [Thu, 9 May 2019 21:32:03 +0000 (17:32 -0400)]
rev-list: drop unused void pointer from finish_commit()

Our finish_commit() function used to be passed directly to the revision
machinery as a callback. But after 989937221a (rev-list: fix
--verify-objects --quiet becoming --objects, 2012-02-28), it is used
only as a helper in show_commit().

It doesn't use its void "data" parameter, and we no longer have to
conform to the callback interface. Let's drop it.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoremove_all_fetch_refspecs(): drop unused "remote" parameter
Jeff King [Thu, 9 May 2019 21:31:46 +0000 (17:31 -0400)]
remove_all_fetch_refspecs(): drop unused "remote" parameter

This function already takes a "key" parameter which uniquely identifies
the config key that we need to remove. There's no need for it to look at
the "remote" parameter at all. Let's drop it in the name of simplicity.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoreceive-pack: drop unused "commands" from prepare_shallow_update()
Jeff King [Thu, 9 May 2019 21:31:39 +0000 (17:31 -0400)]
receive-pack: drop unused "commands" from prepare_shallow_update()

We pass in the list of proposed ref updates to prepare_shallow_update(),
but that function doesn't actually need it (and never has since its
inception in 0a1bc12b6e4). Only its caller, update_shallow_info(), needs
to look at the command list.

Let's drop the unused parameter to reduce confusion.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agopack-objects: drop unused rev_info parameters
Jeff King [Thu, 9 May 2019 21:31:16 +0000 (17:31 -0400)]
pack-objects: drop unused rev_info parameters

When collecting the list of objects to pack in get_object_list(), we
pass our rev_info struct around to some functions that don't need it.
This is due to 03a9683d22 (Simplify is_kept_pack(), 2009-02-28), where
the kept-pack handling was moved out of the revision machinery.

Let's drop these unused parameters.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoname-rev: drop unused parameters from is_better_name()
Jeff King [Thu, 9 May 2019 21:30:56 +0000 (17:30 -0400)]
name-rev: drop unused parameters from is_better_name()

When this function was extracted in 0041bf6544 (name-rev: refactor logic
to see if a new candidate is a better name, 2017-03-29), it ended up
getting more arguments than it needs.

It's possible we may later use these values to evaluate the name, but
since it's a static function with a single caller, it will be easy to
add them back then.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agomktree: drop unused length parameter
Jeff King [Thu, 9 May 2019 21:30:37 +0000 (17:30 -0400)]
mktree: drop unused length parameter

The mktree_line() function does not actually look at the "len" parameter
it is passed, and assumes the buffer it receives is NUL-terminated.
Since the caller always passes a strbuf, this will be true. Let's drop
the useless parameter.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agowt-status: drop unused status parameter
Jeff King [Thu, 9 May 2019 21:30:19 +0000 (17:30 -0400)]
wt-status: drop unused status parameter

The v2_fix_up_changed() function doesn't actually need to see the
wt_status struct. It's possible that could change in the future, but
this is a static-local function with one caller. It would be easy to
read-add it back then. Let's drop the unused parameter.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoread-cache: drop unused parameter from threaded load
Jeff King [Thu, 9 May 2019 21:29:44 +0000 (17:29 -0400)]
read-cache: drop unused parameter from threaded load

The load_cache_entries_threaded() function takes a src_offset parameter
that it doesn't use. This has been there since its inception in
77ff1127a4 (read-cache: load cache entries on worker threads,
2018-10-10).

Digging on the mailing list, that parameter was part of an earlier
iteration of the series[1], but became unnecessary when the code
switched to using the IEOT extension.

[1] https://public-inbox.org/git/20180906210227.54368-5-benpeart@microsoft.com/

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoclone: drop dest parameter from copy_alternates()
Jeff King [Thu, 9 May 2019 21:29:22 +0000 (17:29 -0400)]
clone: drop dest parameter from copy_alternates()

Ever since the inception of this function in e6baf4a1ae (clone: clone
from a repository with relative alternates, 2011-08-22), the "dest"
parameter has been unused. Instead, we use add_to_alternates_file(),
which relies on git_pathdup() to find the right file. That in turn works
because we will have initialized and entered the destination repo by
this point.

It's a bit subtle, but this is how it has always worked. And if our
assumptions change, the test in t5601 from e6baf4a1ae should let us
know.

In the meantime, let's drop this unused and confusing parameter from
copy_alternates().

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agosubmodule: drop unused prefix parameter from some functions
Jeff King [Thu, 9 May 2019 21:27:31 +0000 (17:27 -0400)]
submodule: drop unused prefix parameter from some functions

We stopped using the "prefix" parameter of
relocate_single_git_dir_into_superproject() and its callers in
202275b96b (submodule.c: get_super_prefix_or_empty, 2017-03-14), where
we switched to using the environment global directly.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agobuiltin: consistently pass cmd_* prefix to parse_options
Jeff King [Thu, 9 May 2019 21:28:51 +0000 (17:28 -0400)]
builtin: consistently pass cmd_* prefix to parse_options

If a builtin uses RUN_SETUP to request that git.c enter the repository
directory, we'll get passed in a "prefix" variable with the path to the
original directory.  It's important to pass this to parse_options(),
since we may use it to fix up relative OPT_FILENAME() options. Some
builtins don't bother; let's make sure we do so consistently.

There may not be any particular bugs fixed here; OPT_FILENAME is
actually pretty rare, and none of these commands use it directly.
However, this does future-proof us against somebody adding an option
that uses it and creating a subtle bug that only shows up when you're in
a subdirectory of the repository.

In some cases, like hash-object and upload-pack, we don't specify
RUN_SETUP, so we know the prefix will always be empty. It's still worth
passing the variable along to keep the idiom consistent across all
builtins (and of course it protects us if they ever _did_ switch to
using RUN_SETUP).

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agocmd_{read,write}_tree: rename "unused" variable that is used
Jeff King [Thu, 9 May 2019 21:27:24 +0000 (17:27 -0400)]
cmd_{read,write}_tree: rename "unused" variable that is used

The "prefix" variable passed by git.c into the builtin cmd_read_tree()
and cmd_write_tree() functions is named "unused_prefix". But we do in
fact pass it to parse_options(), which may use the prefix to adjust any
filename options. Let's get rid of this confusing name.

However, we can't just call it "prefix". The reason these variables were
renamed in the first place is that they shadowed local variables named
"prefix", because these commands both take a "--prefix" option.

So let's rename the parameters, but try to reduce further confusion:

  1. In both cases we'll call them "cmd_prefix" to mark that they're
     part of the cmd_* interface.

  2. In cmd_write_tree(), we'll rename the local prefix variable to
     "tree_prefix" to make it more clear that we're talking about the
     prefix to be used for the tree we're writing.

  3. In cmd_read_tree(), the "prefix" local has since migrated into
     "struct unpack_trees_options". We'll leave that alone, as the
     context within the struct makes its meaning clear (we actually
     _could_ just call the parameter "prefix" now, but that invites
     confusion in the other direction).

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agocommit-graph: fix the_repository reference
Derrick Stolee [Thu, 9 May 2019 14:22:31 +0000 (07:22 -0700)]
commit-graph: fix the_repository reference

The parse_commit_buffer() method takes a repository pointer, so it
should not refer to the_repository anymore.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agocheck-non-portable-shell: support Perl versions older than 5.10
Eric Sunshine [Sat, 11 May 2019 00:18:53 +0000 (20:18 -0400)]
check-non-portable-shell: support Perl versions older than 5.10

For thoroughness when checking for one-shot environment variable
assignments at shell function call sites, check-non-portable-shell
stitches together incomplete lines (those ending with backslash). This
allows it to correctly flag such undesirable usage even when the
variable assignment and function call are split across lines, for
example:

    FOO=bar \
    func

where 'func' is a shell function.

The stitching is accomplished like this:

    while (<>) {
        chomp;
        # stitch together incomplete lines (those ending with "\")
        while (s/\\$//) {
            $_ .= readline;
            chomp;
        }
        # detect unportable/undesirable shell constructs
        ...
    }

Although this implementation is well supported in reasonably modern Perl
versions (5.10 and later), it fails with older versions (such as Perl
5.8 shipped with ancient Mac OS 10.5). In particular, in older Perl
versions, 'readline' is not connected to the file handle associated with
the "magic" while (<>) {...} construct, so 'readline' throws a
"readline() on unopened filehandle" error. Work around this problem by
dropping readline() and instead incorporating the stitching of
incomplete lines directly into the existing while (<>) {...} loop.

Helped-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Eric Sunshine <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agomerge: remove drop_save() in favor of remove_merge_branch_state()
Nguyễn Thái Ngọc Duy [Thu, 9 May 2019 10:10:27 +0000 (17:10 +0700)]
merge: remove drop_save() in favor of remove_merge_branch_state()

Both remove_branch_state() and drop_save() delete almost the same set of
files about the current merge state. The only difference is MERGE_RR but
it should also be cleaned up after a successful merge, which is what
drop_save() is for.

Make a new function that deletes all merge-related state files and use
it instead of drop_save(). This function will also be used in the next
patch that introduces --quit.

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agogit-format-patch.txt: document --no-notes option
Denton Liu [Fri, 10 May 2019 18:37:03 +0000 (14:37 -0400)]
git-format-patch.txt: document --no-notes option

Internally, git-format-patch uses the `handle_revision_opt` parser. The
parser handles the `--no-notes` option to negate an earlier `--notes`
option, but it isn't documented. Document this option so that users are
aware of it.

Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agomingw: enable DEP and ASLR
İsmail Dönmez [Wed, 8 May 2019 11:30:59 +0000 (04:30 -0700)]
mingw: enable DEP and ASLR

Enable DEP (Data Execution Prevention) and ASLR (Address Space Layout
Randomization) support. This applies to both 32bit and 64bit builds
and makes it substantially harder to exploit security holes in Git by
offering a much more unpredictable attack surface.

ASLR interferes with GDB's ability to set breakpoints. A similar issue
holds true when compiling with -O2 (in which case single-stepping is
messed up because GDB cannot map the code back to the original source
code properly). Therefore we simply enable ASLR only when an
optimization flag is present in the CFLAGS, using it as an indicator
that the developer does not want to debug in GDB anyway.

Signed-off-by: İsmail Dönmez <redacted>
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agomingw: do not let ld strip relocations
İsmail Dönmez [Wed, 8 May 2019 11:30:58 +0000 (04:30 -0700)]
mingw: do not let ld strip relocations

This is the first step for enabling ASLR (Address Space Layout
Randomization) support. We want to enable ASLR for better protection
against exploiting security holes in Git: it makes it harder to attack
software by making code addresses unpredictable.

The problem fixed by this commit is that `ld.exe` seems to be stripping
relocations which in turn will break ASLR support. We just make sure
it's not stripping the main executable entry.

Signed-off-by: İsmail Dönmez <redacted>
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agotrace2: fix up a missing "leave" entry point
Ævar Arnfjörð Bjarmason [Fri, 10 May 2019 13:37:38 +0000 (15:37 +0200)]
trace2: fix up a missing "leave" entry point

Fix a trivial bug that's been here since the shared/do_write_index
tracing was added in 42fee7a388 ("trace2:data: add trace2
instrumentation to index read/write", 2019-02-22). We should have
enter/leave points, not two enter/enter points. This resulted in an
"enter" event without a corresponding "leave" event.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Acked-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agodifftool --no-index: error out on --dir-diff (and don't crash)
Johannes Schindelin [Wed, 8 May 2019 21:52:41 +0000 (14:52 -0700)]
difftool --no-index: error out on --dir-diff (and don't crash)

In `--no-index` mode, we now no longer require a worktree nor a
repository. But some code paths in `difftool` expect those to be
present.

The most notable such code path is the `--dir-diff` one: we use the
existing checkout machinery to copy the files, and that machinery looks
up replacement refs, looks at alternate ODBs, wants to use the worktree
path, etc.

Rather than running into segmentation faults, let's die with an
informative error message.

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agotag: fix typo in nested tagging hint
Denton Liu [Wed, 8 May 2019 19:16:41 +0000 (15:16 -0400)]
tag: fix typo in nested tagging hint

In eea9c1e78f (tag: advise on nested tags, 2019-04-04), tag was taught
to hint at the user if a nested tag is made. However, this message had a
typo and it said "The object referred to by your new is...", which was
missing a "tag" after "new". Fix this message by adding the "tag".

Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agodiff-highlight: use correct /dev/null for UNIX and Windows
Chris. Webster [Wed, 31 Oct 2018 14:58:00 +0000 (23:58 +0900)]
diff-highlight: use correct /dev/null for UNIX and Windows

Use File::Spec->devnull() for output redirection to avoid messages
when Windows version of Perl is first in path.  The message 'The
system cannot find the path specified.' is displayed each time git is
run to get colors.

Signed-off-by: Chris. Webster <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoThe eighth batch
Junio C Hamano [Wed, 8 May 2019 15:37:54 +0000 (00:37 +0900)]
The eighth batch

Signed-off-by: Junio C Hamano <redacted>
6 years agoMerge branch 'vk/autoconf-gettext'
Junio C Hamano [Wed, 8 May 2019 15:37:29 +0000 (00:37 +0900)]
Merge branch 'vk/autoconf-gettext'

The autoconf generated configure script failed to use the right
gettext() implementations from -libintl by ignoring useless stub
implementations shipped in some C library, which has been
corrected.

* vk/autoconf-gettext:
  autoconf: #include <libintl.h> when checking for gettext()

6 years agoMerge branch 'cc/aix-has-fileno-as-a-macro'
Junio C Hamano [Wed, 8 May 2019 15:37:28 +0000 (00:37 +0900)]
Merge branch 'cc/aix-has-fileno-as-a-macro'

AIX shared the same build issues with other BSDs around fileno(fp),
which has been corrected.

* cc/aix-has-fileno-as-a-macro:
  Makefile: use fileno macro work around on AIX

6 years agoMerge branch 'jt/submodule-repo-is-with-worktree'
Junio C Hamano [Wed, 8 May 2019 15:37:28 +0000 (00:37 +0900)]
Merge branch 'jt/submodule-repo-is-with-worktree'

The logic to tell if a Git repository has a working tree protects
"git branch -D" from removing the branch that is currently checked
out by mistake.  The implementation of this logic was broken for
repositories with unusual name, which unfortunately is the norm for
submodules these days.  This has been fixed.

* jt/submodule-repo-is-with-worktree:
  worktree: update is_bare heuristics

6 years agoMerge branch 'jk/untracked-cache-more-fixes'
Junio C Hamano [Wed, 8 May 2019 15:37:28 +0000 (00:37 +0900)]
Merge branch 'jk/untracked-cache-more-fixes'

Code clean-up.

* jk/untracked-cache-more-fixes:
  untracked-cache: simplify parsing by dropping "len"
  untracked-cache: simplify parsing by dropping "next"
  untracked-cache: be defensive about missing NULs in index

6 years agoMerge branch 'jk/prune-optim'
Junio C Hamano [Wed, 8 May 2019 15:37:27 +0000 (00:37 +0900)]
Merge branch 'jk/prune-optim'

A follow-up test for an earlier "git prune" improvements.

* jk/prune-optim:
  t5304: add a test for pruning with bitmaps

6 years agoMerge branch 'js/misc-doc-fixes'
Junio C Hamano [Wed, 8 May 2019 15:37:27 +0000 (00:37 +0900)]
Merge branch 'js/misc-doc-fixes'

"make check-docs", "git help -a", etc. did not account for cases
where a particular build may deliberately omit some subcommands,
which has been corrected.

* js/misc-doc-fixes:
  Turn `git serve` into a test helper
  test-tool: handle the `-C <directory>` option just like `git`
  check-docs: do not bother checking for legacy scripts' documentation
  docs: exclude documentation for commands that have been excluded
  check-docs: allow command-list.txt to contain excluded commands
  help -a: do not list commands that are excluded from the build
  Makefile: drop the NO_INSTALL variable
  remote-testgit: move it into the support directory for t5801

6 years agoMerge branch 'dr/ref-filter-push-track-fix'
Junio C Hamano [Wed, 8 May 2019 15:37:26 +0000 (00:37 +0900)]
Merge branch 'dr/ref-filter-push-track-fix'

%(push:track) token used in the --format option to "git
for-each-ref" and friends was not showing the right branch, which
has been fixed.

* dr/ref-filter-push-track-fix:
  ref-filter: use correct branch for %(push:track)

6 years agoMerge branch 'ss/msvc-path-utils-fix'
Junio C Hamano [Wed, 8 May 2019 15:37:26 +0000 (00:37 +0900)]
Merge branch 'ss/msvc-path-utils-fix'

An earlier update for MinGW and Cygwin accidentally broke MSVC build,
which has been fixed.

* ss/msvc-path-utils-fix:
  MSVC: include compat/win32/path-utils.h for MSVC, too, for real_path()

6 years agoMerge branch 'jt/clone-server-option'
Junio C Hamano [Wed, 8 May 2019 15:37:25 +0000 (00:37 +0900)]
Merge branch 'jt/clone-server-option'

"git clone" learned a new --server-option option when talking over
the protocol version 2.

* jt/clone-server-option:
  clone: send server options when using protocol v2
  transport: die if server options are unsupported

6 years agoMerge branch 'tb/unexpected'
Junio C Hamano [Wed, 8 May 2019 15:37:25 +0000 (00:37 +0900)]
Merge branch 'tb/unexpected'

Code tightening against a "wrong" object appearing where an object
of a different type is expected, instead of blindly assuming that
the connection between objects are correctly made.

* tb/unexpected:
  rev-list: detect broken root trees
  rev-list: let traversal die when --missing is not in use
  get_commit_tree(): return NULL for broken tree
  list-objects.c: handle unexpected non-tree entries
  list-objects.c: handle unexpected non-blob entries
  t: introduce tests for unexpected object types
  t: move 'hex2oct' into test-lib-functions.sh

6 years agoMerge branch 'nd/sha1-name-c-wo-the-repository'
Junio C Hamano [Wed, 8 May 2019 15:37:24 +0000 (00:37 +0900)]
Merge branch 'nd/sha1-name-c-wo-the-repository'

Further code clean-up to allow the lowest level of name-to-object
mapping layer to work with a passed-in repository other than the
default one.

* nd/sha1-name-c-wo-the-repository: (34 commits)
  sha1-name.c: remove the_repo from get_oid_mb()
  sha1-name.c: remove the_repo from other get_oid_*
  sha1-name.c: remove the_repo from maybe_die_on_misspelt_object_name
  submodule-config.c: use repo_get_oid for reading .gitmodules
  sha1-name.c: add repo_get_oid()
  sha1-name.c: remove the_repo from get_oid_with_context_1()
  sha1-name.c: remove the_repo from resolve_relative_path()
  sha1-name.c: remove the_repo from diagnose_invalid_index_path()
  sha1-name.c: remove the_repo from handle_one_ref()
  sha1-name.c: remove the_repo from get_oid_1()
  sha1-name.c: remove the_repo from get_oid_basic()
  sha1-name.c: remove the_repo from get_describe_name()
  sha1-name.c: remove the_repo from get_oid_oneline()
  sha1-name.c: add repo_interpret_branch_name()
  sha1-name.c: remove the_repo from interpret_branch_mark()
  sha1-name.c: remove the_repo from interpret_nth_prior_checkout()
  sha1-name.c: remove the_repo from get_short_oid()
  sha1-name.c: add repo_for_each_abbrev()
  sha1-name.c: store and use repo in struct disambiguate_state
  sha1-name.c: add repo_find_unique_abbrev_r()
  ...

6 years agoMerge branch 'cc/replace-graft-peel-tags'
Junio C Hamano [Wed, 8 May 2019 15:37:24 +0000 (00:37 +0900)]
Merge branch 'cc/replace-graft-peel-tags'

When given a tag that points at a commit-ish, "git replace --graft"
failed to peel the tag before writing a replace ref, which did not
make sense because the old graft mechanism the feature wants to
mimick only allowed to replace one commit object with another.
This has been fixed.

* cc/replace-graft-peel-tags:
  replace: peel tag when passing a tag first to --graft
  replace: peel tag when passing a tag as parent to --graft
  t6050: redirect expected error output to a file
  t6050: use test_line_count instead of wc -l

6 years agoMerge branch 'js/trace2-to-directory'
Junio C Hamano [Wed, 8 May 2019 15:37:24 +0000 (00:37 +0900)]
Merge branch 'js/trace2-to-directory'

The trace2 tracing facility learned to auto-generate a filename
when told to log to a directory.

* js/trace2-to-directory:
  trace2: write to directory targets

6 years agoMerge branch 'dl/merge-cleanup-scissors-fix'
Junio C Hamano [Wed, 8 May 2019 15:37:24 +0000 (00:37 +0900)]
Merge branch 'dl/merge-cleanup-scissors-fix'

The list of conflicted paths shown in the editor while concluding a
conflicted merge was shown above the scissors line when the
clean-up mode is set to "scissors", even though it was commented
out just like the list of updated paths and other information to
help the user explain the merge better.

* dl/merge-cleanup-scissors-fix:
  cherry-pick/revert: add scissors line on merge conflict
  sequencer.c: save and restore cleanup mode
  merge: add scissors line on merge conflict
  merge: cleanup messages like commit
  parse-options.h: extract common --cleanup option
  commit: extract cleanup_mode functions to sequencer
  t7502: clean up style
  t7604: clean up style
  t3507: clean up style
  t7600: clean up style

6 years agoMerge branch 'pw/sequencer-cleanup-with-signoff-x-fix'
Junio C Hamano [Wed, 8 May 2019 15:37:23 +0000 (00:37 +0900)]
Merge branch 'pw/sequencer-cleanup-with-signoff-x-fix'

"git cherry-pick" run with the "-x" or the "--signoff" option used
to (and more importantly, ought to) clean up the commit log message
with the --cleanup=space option by default, but this has been
broken since late 2017.  This has been fixed.

* pw/sequencer-cleanup-with-signoff-x-fix:
  sequencer: fix cleanup with --signoff and -x

6 years agoMerge branch 'jk/pack-objects-reports-num-objects-to-trace2'
Junio C Hamano [Wed, 8 May 2019 15:37:23 +0000 (00:37 +0900)]
Merge branch 'jk/pack-objects-reports-num-objects-to-trace2'

The "git pack-objects" command learned to report the number of
objects it packed via the trace2 mechanism.

* jk/pack-objects-reports-num-objects-to-trace2:
  pack-objects: write objects packed to trace2

6 years agoMerge branch 'tz/git-svn-doc-markup-fix'
Junio C Hamano [Wed, 8 May 2019 15:37:23 +0000 (00:37 +0900)]
Merge branch 'tz/git-svn-doc-markup-fix'

Doc formatting fix.

* tz/git-svn-doc-markup-fix:
  Documentation/git-svn: improve asciidoctor compatibility

6 years agoMerge branch 'km/empty-repo-is-still-a-repo'
Junio C Hamano [Wed, 8 May 2019 15:37:23 +0000 (00:37 +0900)]
Merge branch 'km/empty-repo-is-still-a-repo'

Running "git add" on a repository created inside the current
repository is an explicit indication that the user wants to add it
as a submodule, but when the HEAD of the inner repository is on an
unborn branch, it cannot be added as a submodule.  Worse, the files
in its working tree can be added as if they are a part of the outer
repository, which is not what the user wants.  These problems are
being addressed.

* km/empty-repo-is-still-a-repo:
  add: error appropriately on repository with no commits
  dir: do not traverse repositories with no commits
  submodule: refuse to add repository with no commits

6 years agoMerge branch 'dl/warn-tagging-a-tag'
Junio C Hamano [Wed, 8 May 2019 15:37:22 +0000 (00:37 +0900)]
Merge branch 'dl/warn-tagging-a-tag'

"git tag" learned to give an advice suggesting it might be a
mistake when creating an annotated or signed tag that points at
another tag.

* dl/warn-tagging-a-tag:
  tag: advise on nested tags
  tag: fix formatting

6 years agoMerge branch 'en/merge-directory-renames'
Junio C Hamano [Wed, 8 May 2019 15:37:22 +0000 (00:37 +0900)]
Merge branch 'en/merge-directory-renames'

"git merge-recursive" backend recently learned a new heuristics to
infer file movement based on how other files in the same directory
moved.  As this is inherently less robust heuristics than the one
based on the content similarity of the file itself (rather than
based on what its neighbours are doing), it sometimes gives an
outcome unexpected by the end users.  This has been toned down to
leave the renamed paths in higher/conflicted stages in the index so
that the user can examine and confirm the result.

* en/merge-directory-renames:
  merge-recursive: switch directory rename detection default
  merge-recursive: give callers of handle_content_merge() access to contents
  merge-recursive: track information associated with directory renames
  t6043: fix copied test description to match its purpose
  merge-recursive: switch from (oid,mode) pairs to a diff_filespec
  merge-recursive: cleanup handle_rename_* function signatures
  merge-recursive: track branch where rename occurred in rename struct
  merge-recursive: remove ren[12]_other fields from rename_conflict_info
  merge-recursive: shrink rename_conflict_info
  merge-recursive: move some struct declarations together
  merge-recursive: use 'ci' for rename_conflict_info variable name
  merge-recursive: rename locals 'o' and 'a' to 'obuf' and 'abuf'
  merge-recursive: rename diff_filespec 'one' to 'o'
  merge-recursive: rename merge_options argument from 'o' to 'opt'
  Use 'unsigned short' for mode, like diff_filespec does

6 years agosubmodule--helper: add a missing \n
Nguyễn Thái Ngọc Duy [Tue, 7 May 2019 09:50:37 +0000 (16:50 +0700)]
submodule--helper: add a missing \n

This is a complete line. We're not expecting the next function to add
anything to the same line.

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoformat-patch: make --base patch-id output stable
Stephen Boyd [Fri, 26 Apr 2019 23:51:57 +0000 (16:51 -0700)]
format-patch: make --base patch-id output stable

We weren't flushing the context each time we processed a hunk in the
patch-id generation code in diff.c, but we were doing that when we
generated "stable" patch-ids with the 'patch-id' tool. Let's port that
similar logic over from patch-id.c into diff.c so we can get the same
hash when we're generating patch-ids for 'format-patch --base=' types of
command invocations.

Cc: Xiaolong Ye <redacted>
Signed-off-by: Stephen Boyd <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoformat-patch: inform user that patch-id generation is unstable
Stephen Boyd [Fri, 26 Apr 2019 23:51:56 +0000 (16:51 -0700)]
format-patch: inform user that patch-id generation is unstable

I tried out 'git format-patch --base' with a set of commits that
modifies more than one file. It turns out that the way this command is
implemented it actually uses the unstable version of patch-id instead of
the stable version that's documented. When I tried to modify the
existing test to use 'git patch-id --stable' vs. 'git patch-id
--unstable' I found that it didn't matter, the test still passed.

Let's expand on the test here so it is a little more complicated and
then use that to show that the patch-id generation is actually unstable
vs. stable. Update the documentation as well.

Cc: Xiaolong Ye <redacted>
Signed-off-by: Stephen Boyd <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agococcicheck: make batch size of 0 mean "unlimited"
Jeff King [Wed, 8 May 2019 07:07:54 +0000 (03:07 -0400)]
coccicheck: make batch size of 0 mean "unlimited"

If you have the memory to handle it, the ideal case is to run a single
spatch invocation with all of the source files. But the only way to do
so now is to pick an arbitrarily large batch size. Let's make "0" do
this, which is a little friendlier (and doesn't otherwise have a useful
meaning).

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot6500(mingw): use the Windows PID of the shell
Johannes Schindelin [Tue, 7 May 2019 21:51:30 +0000 (14:51 -0700)]
t6500(mingw): use the Windows PID of the shell

In Git for Windows, we use the MSYS2 Bash which inherits a non-standard
PID model from Cygwin's POSIX emulation layer: every MSYS2 process has a
regular Windows PID, and in addition it has an MSYS2 PID (which
corresponds to a shadow process that emulates Unix-style signal
handling).

With the upgrade to the MSYS2 runtime v3.x, this shadow process cannot
be accessed via `OpenProcess()` any longer, and therefore t6500 thought
incorrectly that the process referenced in `gc.pid` (which is not
actually a real `gc` process in this context, but the current shell) no
longer exists.

Let's fix this by making sure that the Windows PID is written into
`gc.pid` in this test script so that `git.exe` is able to understand
that that process does indeed still exist.

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot/lib-httpd: pass LSAN_OPTIONS through apache
Jeff King [Tue, 7 May 2019 22:30:46 +0000 (18:30 -0400)]
t/lib-httpd: pass LSAN_OPTIONS through apache

Just as we instruct Apache to pass through ASAN_OPTIONS (so that
server-side Git programs it spawns will respect our options while
running the tests), we should do the same with LSAN_OPTIONS. Otherwise
trying to collect a list of leaks like:

    export LSAN_OPTIONS=exitcode=0:log_path=/tmp/lsan
    make SANITIZE=leak test

won't work for http tests (the server-side programs won't log their
leaks to the right place, and they'll prematurely die, producing a
spurious test failure).

Signed-off-by: Jeff King <redacted>
Acked-by: Josh Steadmon <redacted>
Signed-off-by: Junio C Hamano <redacted>
git clone https://git.99rst.org/PROJECT