git
6 years agoMerge branch 'js/remote-archive-dwimfix'
Junio C Hamano [Tue, 6 Nov 2018 06:50:18 +0000 (15:50 +0900)] 
Merge branch 'js/remote-archive-dwimfix'

The logic to determine the archive type "git archive" uses did not
correctly kick in for "git archive --remote", which has been
corrected.

* js/remote-archive-dwimfix:
  archive: initialize archivers earlier

6 years agoMerge branch 'jc/http-curlver-warnings'
Junio C Hamano [Fri, 2 Nov 2018 15:53:59 +0000 (00:53 +0900)] 
Merge branch 'jc/http-curlver-warnings'

Warning message fix.

* jc/http-curlver-warnings:
  http: give curl version warnings consistently

6 years agoMerge branch 'js/mingw-http-ssl'
Junio C Hamano [Fri, 2 Nov 2018 15:53:58 +0000 (00:53 +0900)] 
Merge branch 'js/mingw-http-ssl'

On platforms with recent cURL library, http.sslBackend configuration
variable can be used to choose a different SSL backend at runtime.
The Windows port uses this mechanism to switch between OpenSSL and
Secure Channel while talking over the HTTPS protocol.

* js/mingw-http-ssl:
  http: when using Secure Channel, ignore sslCAInfo by default
  http: add support for disabling SSL revocation checks in cURL
  http: add support for selecting SSL backends at runtime

6 years agoMerge branch 'mg/gpg-fingerprint'
Junio C Hamano [Fri, 2 Nov 2018 15:53:58 +0000 (00:53 +0900)] 
Merge branch 'mg/gpg-fingerprint'

New "--pretty=format:" placeholders %GF and %GP that show the GPG
key fingerprints have been invented.

* mg/gpg-fingerprint:
  gpg-interface.c: obtain primary key fingerprint as well
  gpg-interface.c: support getting key fingerprint via %GF format
  gpg-interface.c: use flags to determine key/signer info presence

6 years agoMerge branch 'mg/gpg-parse-tighten'
Junio C Hamano [Fri, 2 Nov 2018 15:53:57 +0000 (00:53 +0900)] 
Merge branch 'mg/gpg-parse-tighten'

Detect and reject a signature block that has more than one GPG
signature.

* mg/gpg-parse-tighten:
  gpg-interface.c: detect and reject multiple signatures on commits

6 years agoMerge branch 'en/merge-cleanup-more'
Junio C Hamano [Fri, 2 Nov 2018 15:53:57 +0000 (00:53 +0900)] 
Merge branch 'en/merge-cleanup-more'

Further clean-up of merge-recursive machinery.

* en/merge-cleanup-more:
  merge-recursive: avoid showing conflicts with merge branch before HEAD
  merge-recursive: improve auto-merging messages with path collisions

6 years agoEighth batch for 2.20
Junio C Hamano [Thu, 1 Nov 2018 12:26:34 +0000 (21:26 +0900)] 
Eighth batch for 2.20

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorebase: apply cocci patch
Junio C Hamano [Thu, 1 Nov 2018 12:44:41 +0000 (21:44 +0900)] 
rebase: apply cocci patch

Favor oideq() over !oidcmp() when checking for equality.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'js/rebase-i-shortopt'
Junio C Hamano [Fri, 2 Nov 2018 02:04:59 +0000 (11:04 +0900)] 
Merge branch 'js/rebase-i-shortopt'

"git rebase -i" learned to take 'b' as the short form of 'break'
option in the todo list.

* js/rebase-i-shortopt:
  rebase -i: recognize short commands without arguments

6 years agoMerge branch 'js/rebase-i-break'
Junio C Hamano [Fri, 2 Nov 2018 02:04:58 +0000 (11:04 +0900)] 
Merge branch 'js/rebase-i-break'

"git rebase -i" learned a new insn, 'break', that the user can
insert in the to-do list.  Upon hitting it, the command returns
control back to the user.

* js/rebase-i-break:
  rebase -i: introduce the 'break' command
  rebase -i: clarify what happens on a failed `exec`

6 years agoMerge branch 'js/rebase-autostash-fix'
Junio C Hamano [Fri, 2 Nov 2018 02:04:58 +0000 (11:04 +0900)] 
Merge branch 'js/rebase-autostash-fix'

"git rebase" that has recently been rewritten in C had a few issues
in its "--autstash" feature, which have been corrected.

* js/rebase-autostash-fix:
  rebase --autostash: fix issue with dirty submodules
  rebase --autostash: demonstrate a problem with dirty submodules
  rebase (autostash): use an explicit OID to apply the stash
  rebase (autostash): store the full OID in <state-dir>/autostash
  rebase (autostash): avoid duplicate call to state_dir_path()

6 years agoMerge branch 'cb/printf-empty-format'
Junio C Hamano [Fri, 2 Nov 2018 02:04:57 +0000 (11:04 +0900)] 
Merge branch 'cb/printf-empty-format'

Build fix for a topic in flight.

* cb/printf-empty-format:
  sequencer: cleanup for gcc warning in non developer mode

6 years agoMerge branch 'jc/rebase-in-c-5-test-typofix'
Junio C Hamano [Fri, 2 Nov 2018 02:04:57 +0000 (11:04 +0900)] 
Merge branch 'jc/rebase-in-c-5-test-typofix'

Typofix.

* jc/rebase-in-c-5-test-typofix:
  rebase: fix typoes in error messages

6 years agoMerge branch 'pk/rebase-in-c-6-final'
Junio C Hamano [Fri, 2 Nov 2018 02:04:56 +0000 (11:04 +0900)] 
Merge branch 'pk/rebase-in-c-6-final'

The final step of rewriting "rebase -i" in C.

* pk/rebase-in-c-6-final:
  rebase: default to using the builtin rebase

6 years agoMerge branch 'js/rebase-in-c-5.5-work-with-rebase-i-in-c'
Junio C Hamano [Fri, 2 Nov 2018 02:04:56 +0000 (11:04 +0900)] 
Merge branch 'js/rebase-in-c-5.5-work-with-rebase-i-in-c'

"rebase" that has been rewritten learns the new calling convention
used by "rebase -i" that was rewritten in C, tying the loose end
between two GSoC topics that stomped on each other's toes.

* js/rebase-in-c-5.5-work-with-rebase-i-in-c:
  builtin rebase: prepare for builtin rebase -i

6 years agoMerge branch 'pk/rebase-in-c-5-test'
Junio C Hamano [Fri, 2 Nov 2018 02:04:55 +0000 (11:04 +0900)] 
Merge branch 'pk/rebase-in-c-5-test'

Rewrite "git rebase" in C.

* pk/rebase-in-c-5-test:
  builtin rebase: error out on incompatible option/mode combinations
  builtin rebase: use no-op editor when interactive is "implied"
  builtin rebase: show progress when connected to a terminal
  builtin rebase: fast-forward to onto if it is a proper descendant
  builtin rebase: optionally pass custom reflogs to reset_head()
  builtin rebase: optionally auto-detect the upstream

6 years agoMerge branch 'pk/rebase-in-c-4-opts'
Junio C Hamano [Fri, 2 Nov 2018 02:04:55 +0000 (11:04 +0900)] 
Merge branch 'pk/rebase-in-c-4-opts'

Rewrite "git rebase" in C.

* pk/rebase-in-c-4-opts:
  builtin rebase: support --root
  builtin rebase: add support for custom merge strategies
  builtin rebase: support `fork-point` option
  merge-base --fork-point: extract libified function
  builtin rebase: support --rebase-merges[=[no-]rebase-cousins]
  builtin rebase: support `--allow-empty-message` option
  builtin rebase: support `--exec`
  builtin rebase: support `--autostash` option
  builtin rebase: support `-C` and `--whitespace=<type>`
  builtin rebase: support `--gpg-sign` option
  builtin rebase: support `--autosquash`
  builtin rebase: support `keep-empty` option
  builtin rebase: support `ignore-date` option
  builtin rebase: support `ignore-whitespace` option
  builtin rebase: support --committer-date-is-author-date
  builtin rebase: support --rerere-autoupdate
  builtin rebase: support --signoff
  builtin rebase: allow selecting the rebase "backend"

6 years agoMerge branch 'pk/rebase-in-c-3-acts'
Junio C Hamano [Fri, 2 Nov 2018 02:04:54 +0000 (11:04 +0900)] 
Merge branch 'pk/rebase-in-c-3-acts'

Rewrite "git rebase" in C.

* pk/rebase-in-c-3-acts:
  builtin rebase: stop if `git am` is in progress
  builtin rebase: actions require a rebase in progress
  builtin rebase: support --edit-todo and --show-current-patch
  builtin rebase: support --quit
  builtin rebase: support --abort
  builtin rebase: support --skip
  builtin rebase: support --continue

6 years agoMerge branch 'pk/rebase-in-c-2-basic'
Junio C Hamano [Fri, 2 Nov 2018 02:04:53 +0000 (11:04 +0900)] 
Merge branch 'pk/rebase-in-c-2-basic'

Rewrite "git rebase" in C.

* pk/rebase-in-c-2-basic:
  builtin rebase: support `git rebase <upstream> <switch-to>`
  builtin rebase: only store fully-qualified refs in `options.head_name`
  builtin rebase: start a new rebase only if none is in progress
  builtin rebase: support --force-rebase
  builtin rebase: try to fast forward when possible
  builtin rebase: require a clean worktree
  builtin rebase: support the `verbose` and `diffstat` options
  builtin rebase: support --quiet
  builtin rebase: handle the pre-rebase hook and --no-verify
  builtin rebase: support `git rebase --onto A...B`
  builtin rebase: support --onto

6 years agoMerge branch 'ag/rebase-i-in-c'
Junio C Hamano [Fri, 2 Nov 2018 02:04:53 +0000 (11:04 +0900)] 
Merge branch 'ag/rebase-i-in-c'

Rewrite of the remaining "rebase -i" machinery in C.

* ag/rebase-i-in-c:
  rebase -i: move rebase--helper modes to rebase--interactive
  rebase -i: remove git-rebase--interactive.sh
  rebase--interactive2: rewrite the submodes of interactive rebase in C
  rebase -i: implement the main part of interactive rebase as a builtin
  rebase -i: rewrite init_basic_state() in C
  rebase -i: rewrite write_basic_state() in C
  rebase -i: rewrite the rest of init_revisions_and_shortrevisions() in C
  rebase -i: implement the logic to initialize $revisions in C
  rebase -i: remove unused modes and functions
  rebase -i: rewrite complete_action() in C
  t3404: todo list with commented-out commands only aborts
  sequencer: change the way skip_unnecessary_picks() returns its result
  sequencer: refactor append_todo_help() to write its message to a buffer
  rebase -i: rewrite checkout_onto() in C
  rebase -i: rewrite setup_reflog_action() in C
  sequencer: add a new function to silence a command, except if it fails
  rebase -i: rewrite the edit-todo functionality in C
  editor: add a function to launch the sequence editor
  rebase -i: rewrite append_todo_help() in C
  sequencer: make three functions and an enum from sequencer.c public

6 years agoMerge branch 'pk/rebase-in-c'
Junio C Hamano [Fri, 2 Nov 2018 02:04:52 +0000 (11:04 +0900)] 
Merge branch 'pk/rebase-in-c'

Rewrite of the "rebase" machinery in C.

* pk/rebase-in-c:
  builtin/rebase: support running "git rebase <upstream>"
  rebase: refactor common shell functions into their own file
  rebase: start implementing it as a builtin

6 years agoSeventh batch for 2.20
Junio C Hamano [Tue, 30 Oct 2018 06:44:45 +0000 (15:44 +0900)] 
Seventh batch for 2.20

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'jk/uploadpack-packobjectshook-fix'
Junio C Hamano [Tue, 30 Oct 2018 06:43:50 +0000 (15:43 +0900)] 
Merge branch 'jk/uploadpack-packobjectshook-fix'

Code clean-up that results in a small bugfix.

* jk/uploadpack-packobjectshook-fix:
  upload-pack: fix broken if/else chain in config callback

6 years agoMerge branch 'uk/merge-subtree-doc-update'
Junio C Hamano [Tue, 30 Oct 2018 06:43:49 +0000 (15:43 +0900)] 
Merge branch 'uk/merge-subtree-doc-update'

Belated documentation update to adjust to a new world order that
happened a yew years ago.

* uk/merge-subtree-doc-update:
  howto/using-merge-subtree: mention --allow-unrelated-histories

6 years agoMerge branch 'cb/compat-mmap-is-private-read-only'
Junio C Hamano [Tue, 30 Oct 2018 06:43:49 +0000 (15:43 +0900)] 
Merge branch 'cb/compat-mmap-is-private-read-only'

Code tightening.

* cb/compat-mmap-is-private-read-only:
  compat: make sure git_mmap is not expected to write

6 years agoMerge branch 'dl/mergetool-gui-option'
Junio C Hamano [Tue, 30 Oct 2018 06:43:48 +0000 (15:43 +0900)] 
Merge branch 'dl/mergetool-gui-option'

"git mergetool" learned to take the "--[no-]gui" option, just like
"git difftool" does.

* dl/mergetool-gui-option:
  doc: document diff/merge.guitool config keys
  completion: support `git mergetool --[no-]gui`
  mergetool: accept -g/--[no-]gui as arguments

6 years agoMerge branch 'js/mingw-load-sys-dll'
Junio C Hamano [Tue, 30 Oct 2018 06:43:48 +0000 (15:43 +0900)] 
Merge branch 'js/mingw-load-sys-dll'

The way DLLs are loaded on the Windows port has been improved.

* js/mingw-load-sys-dll:
  mingw: load system libraries the recommended way

6 years agoMerge branch 'js/mingw-getcwd'
Junio C Hamano [Tue, 30 Oct 2018 06:43:48 +0000 (15:43 +0900)] 
Merge branch 'js/mingw-getcwd'

The way the Windows port figures out the current directory has been
improved.

* js/mingw-getcwd:
  mingw: fix getcwd when the parent directory cannot be queried
  mingw: ensure `getcwd()` reports the correct case

6 years agoMerge branch 'cb/khash-maybe-unused-function'
Junio C Hamano [Tue, 30 Oct 2018 06:43:48 +0000 (15:43 +0900)] 
Merge branch 'cb/khash-maybe-unused-function'

Build fix.

* cb/khash-maybe-unused-function:
  khash: silence -Wunused-function for delta-islands
  commit-slabs: move MAYBE_UNUSED out

6 years agoMerge branch 'jc/cocci-preincr'
Junio C Hamano [Tue, 30 Oct 2018 06:43:48 +0000 (15:43 +0900)] 
Merge branch 'jc/cocci-preincr'

Code cleanup.

* jc/cocci-preincr:
  fsck: s/++i > 1/i++/
  cocci: simplify "if (++u > 1)" to "if (u++)"

6 years agoMerge branch 'ss/rename-tests'
Junio C Hamano [Tue, 30 Oct 2018 06:43:47 +0000 (15:43 +0900)] 
Merge branch 'ss/rename-tests'

Reorganize some tests and rename them; "ls t/" now gives a better
overview of what is tested for these scripts than before.

* ss/rename-tests:
  t7501: rename commit test to comply with naming convention
  t7500: rename commit tests script to comply with naming convention
  t7502: rename commit test script to comply with naming convention
  t7509: cleanup description and filename
  t2000: rename and combine checkout clash tests

6 years agoMerge branch 'ah/doc-updates'
Junio C Hamano [Tue, 30 Oct 2018 06:43:47 +0000 (15:43 +0900)] 
Merge branch 'ah/doc-updates'

Doc updates.

* ah/doc-updates:
  doc: fix formatting in git-update-ref
  doc: fix indentation of listing blocks in gitweb.conf.txt
  doc: fix descripion for 'git tag --format'
  doc: fix inappropriate monospace formatting
  doc: fix ASCII art tab spacing
  doc: clarify boundaries of 'git worktree list --porcelain'

6 years agoMerge branch 'ds/reachable'
Junio C Hamano [Tue, 30 Oct 2018 06:43:47 +0000 (15:43 +0900)] 
Merge branch 'ds/reachable'

Trivial bugfix.

* ds/reachable:
  commit-reach: fix cast in compare_commits_by_gen()

6 years agoMerge branch 'jc/receive-deny-current-branch-fix'
Junio C Hamano [Tue, 30 Oct 2018 06:43:46 +0000 (15:43 +0900)] 
Merge branch 'jc/receive-deny-current-branch-fix'

The receive.denyCurrentBranch=updateInstead codepath kicked in even
when the push should have been rejected due to other reasons, such
as it does not fast-forward or the update-hook rejects it, which
has been corrected.

* jc/receive-deny-current-branch-fix:
  receive: denyCurrentBranch=updateinstead should not blindly update

6 years agoMerge branch 'ds/ci-commit-graph-and-midx'
Junio C Hamano [Tue, 30 Oct 2018 06:43:46 +0000 (15:43 +0900)] 
Merge branch 'ds/ci-commit-graph-and-midx'

One of our CI tests to run with "unusual/experimental/random"
settings now also uses commit-graph and midx.

* ds/ci-commit-graph-and-midx:
  ci: add optional test variables

6 years agoMerge branch 'jk/unused-function'
Junio C Hamano [Tue, 30 Oct 2018 06:43:46 +0000 (15:43 +0900)] 
Merge branch 'jk/unused-function'

Developer support.

* jk/unused-function:
  config.mak.dev: enable -Wunused-function

6 years agoMerge branch 'cb/remove-dead-init'
Junio C Hamano [Tue, 30 Oct 2018 06:43:45 +0000 (15:43 +0900)] 
Merge branch 'cb/remove-dead-init'

Code clean-up.

* cb/remove-dead-init:
  multi-pack-index: avoid dead store for struct progress
  unpack-trees: avoid dead store for struct progress

6 years agoMerge branch 'js/diff-notice-has-drive-prefix'
Junio C Hamano [Tue, 30 Oct 2018 06:43:45 +0000 (15:43 +0900)] 
Merge branch 'js/diff-notice-has-drive-prefix'

Under certain circumstances, "git diff D:/a/b/c D:/a/b/d" on
Windows would strip initial parts from the paths because they
were not recognized as absolute, which has been corrected.

* js/diff-notice-has-drive-prefix:
  diff: don't attempt to strip prefix from absolute Windows paths

6 years agoMerge branch 'ot/ref-filter-plug-leaks'
Junio C Hamano [Tue, 30 Oct 2018 06:43:44 +0000 (15:43 +0900)] 
Merge branch 'ot/ref-filter-plug-leaks'

Plugging a handful of memory leaks in the ref-filter codepath.

* ot/ref-filter-plug-leaks:
  ref-filter: free item->value and item->value->s
  ls-remote: release memory instead of UNLEAK
  ref-filter: free memory from used_atom

6 years agoMerge branch 'ds/reachable-first-parent-fix'
Junio C Hamano [Tue, 30 Oct 2018 06:43:44 +0000 (15:43 +0900)] 
Merge branch 'ds/reachable-first-parent-fix'

Correct performance regression in commit ancestry computation when
generation numbers are involved.

* ds/reachable-first-parent-fix:
  commit-reach: fix first-parent heuristic

6 years agoMerge branch 'rj/header-guards'
Junio C Hamano [Tue, 30 Oct 2018 06:43:44 +0000 (15:43 +0900)] 
Merge branch 'rj/header-guards'

Code clean-up.

* rj/header-guards:
  headers: normalize the spelling of some header guards

6 years agoMerge branch 'jk/test-tool-help'
Junio C Hamano [Tue, 30 Oct 2018 06:43:44 +0000 (15:43 +0900)] 
Merge branch 'jk/test-tool-help'

Developer support.

* jk/test-tool-help:
  test-tool: show tool list on error

6 years agoMerge branch 'sg/doc-show-branch-typofix'
Junio C Hamano [Tue, 30 Oct 2018 06:43:44 +0000 (15:43 +0900)] 
Merge branch 'sg/doc-show-branch-typofix'

Docfix.

* sg/doc-show-branch-typofix:
  doc: fix small typo in git show-branch

6 years agoMerge branch 'sb/submodule-helper-remove-cruft'
Junio C Hamano [Tue, 30 Oct 2018 06:43:43 +0000 (15:43 +0900)] 
Merge branch 'sb/submodule-helper-remove-cruft'

Code clean-up.

* sb/submodule-helper-remove-cruft:
  builtin/submodule--helper: remove debugging leftover tracing

6 years agoMerge branch 'js/pack-objects-mutex-init-fix'
Junio C Hamano [Tue, 30 Oct 2018 06:43:43 +0000 (15:43 +0900)] 
Merge branch 'js/pack-objects-mutex-init-fix'

A mutex used in "git pack-objects" were not correctly initialized
and this caused "git repack" to dump core on Windows.

* js/pack-objects-mutex-init-fix:
  pack-objects (mingw): initialize `packing_data` mutex in the correct spot
  pack-objects (mingw): demonstrate a segmentation fault with large deltas
  pack-objects: fix typo 'detla' -> 'delta'

6 years agoMerge branch 'tq/branch-style-fix'
Junio C Hamano [Tue, 30 Oct 2018 06:43:43 +0000 (15:43 +0900)] 
Merge branch 'tq/branch-style-fix'

Code clean-up.

* tq/branch-style-fix:
  branch: trivial style fix

6 years agoMerge branch 'tq/branch-create-wo-branch-get'
Junio C Hamano [Tue, 30 Oct 2018 06:43:42 +0000 (15:43 +0900)] 
Merge branch 'tq/branch-create-wo-branch-get'

Code clean-up.

* tq/branch-create-wo-branch-get:
  builtin/branch.c: remove useless branch_get

6 years agoMerge branch 'bc/hash-transition-part-15'
Junio C Hamano [Tue, 30 Oct 2018 06:43:42 +0000 (15:43 +0900)] 
Merge branch 'bc/hash-transition-part-15'

More codepaths are moving away from hardcoded hash sizes.

* bc/hash-transition-part-15:
  rerere: convert to use the_hash_algo
  submodule: make zero-oid comparison hash function agnostic
  apply: rename new_sha1_prefix and old_sha1_prefix
  apply: replace hard-coded constants
  tag: express constant in terms of the_hash_algo
  transport: use parse_oid_hex instead of a constant
  upload-pack: express constants in terms of the_hash_algo
  refs/packed-backend: express constants using the_hash_algo
  packfile: express constants in terms of the_hash_algo
  pack-revindex: express constants in terms of the_hash_algo
  builtin/fetch-pack: remove constants with parse_oid_hex
  builtin/mktree: remove hard-coded constant
  builtin/repack: replace hard-coded constants
  pack-bitmap-write: use GIT_MAX_RAWSZ for allocation
  object_id.cocci: match only expressions of type 'struct object_id'

6 years agoMerge branch 'sb/strbuf-h-update'
Junio C Hamano [Tue, 30 Oct 2018 06:43:41 +0000 (15:43 +0900)] 
Merge branch 'sb/strbuf-h-update'

Code clean-up to serve as a BCP example.

* sb/strbuf-h-update:
  strbuf.h: format according to coding guidelines

6 years agoMerge branch 'jk/run-command-notdot'
Junio C Hamano [Tue, 30 Oct 2018 06:43:41 +0000 (15:43 +0900)] 
Merge branch 'jk/run-command-notdot'

The implementation of run_command() API on the UNIX platforms had a
bug that caused a command not on $PATH to be found in the current
directory.

* jk/run-command-notdot:
  run-command: mark path lookup errors with ENOENT

6 years agoMerge branch 'tb/filter-alternate-refs'
Junio C Hamano [Tue, 30 Oct 2018 06:43:41 +0000 (15:43 +0900)] 
Merge branch 'tb/filter-alternate-refs'

Test fix.

* tb/filter-alternate-refs:
  t5410: use longer path for sample script
  Documentation/config.txt: fix typo in core.alternateRefsCommand

6 years agoMerge branch 'rv/send-email-cc-misc-by'
Junio C Hamano [Tue, 30 Oct 2018 06:43:40 +0000 (15:43 +0900)] 
Merge branch 'rv/send-email-cc-misc-by'

"git send-email" learned to grab address-looking string on any
trailer whose name ends with "-by"; --suppress-cc=misc-by on the
command line, or setting sendemail.suppresscc configuration
variable to "misc-by", can be used to disable this behaviour.

This is a backward-incompatible change that may surprise existing
users.

* rv/send-email-cc-misc-by:
  send-email: also pick up cc addresses from -by trailers
  send-email: only consider lines containing @ or <> for automatic Cc'ing
  Documentation/git-send-email.txt: style fixes

6 years agoMerge branch 'lm/range-diff-submodule-fix'
Junio C Hamano [Tue, 30 Oct 2018 06:43:40 +0000 (15:43 +0900)] 
Merge branch 'lm/range-diff-submodule-fix'

"git range-diff" did not work well when the compared ranges had
changes in submodules and the "--submodule=log" was used.

* lm/range-diff-submodule-fix:
  range-diff: allow to diff files regardless of submodule config

6 years agoMerge branch 'ch/subtree-build'
Junio C Hamano [Tue, 30 Oct 2018 06:43:39 +0000 (15:43 +0900)] 
Merge branch 'ch/subtree-build'

Build update for "git subtree" (in contrib/) documentation pages.

* ch/subtree-build:
  Revert "subtree: make install targets depend on build targets"
  subtree: make install targets depend on build targets
  subtree: add build targets 'man' and 'html'

6 years agoMerge branch 'md/filter-trees'
Junio C Hamano [Tue, 30 Oct 2018 06:43:39 +0000 (15:43 +0900)] 
Merge branch 'md/filter-trees'

The "rev-list --filter" feature learned to exclude all trees via
"tree:0" filter.

* md/filter-trees:
  list-objects: support for skipping tree traversal
  filter-trees: code clean-up of tests
  list-objects-filter: implement filter tree:0
  list-objects-filter-options: do not over-strbuf_init
  list-objects-filter: use BUG rather than die
  revision: mark non-user-given objects instead
  rev-list: handle missing tree objects properly
  list-objects: always parse trees gently
  list-objects: refactor to process_tree_contents
  list-objects: store common func args in struct

6 years agosequencer: cleanup for gcc warning in non developer mode
Carlo Marcelo Arenas Belón [Thu, 25 Oct 2018 09:38:54 +0000 (02:38 -0700)] 
sequencer: cleanup for gcc warning in non developer mode

as shown by:

  sequencer.c: In function ‘write_basic_state’:
  sequencer.c:2392:37: warning: zero-length gnu_printf format string [-Wformat-zero-length]
     write_file(rebase_path_verbose(), "");

where write_file will create an empty file if told to write an empty string
as can be inferred by the previous call

the somehow more convoluted syntax works around the issue by providing a non
empty format string and is already being used for the abort safety file since
1e41229d96 ("sequencer: make sequencer abort safer", 2016-12-07)

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoSixth batch for 2.20
Junio C Hamano [Fri, 26 Oct 2018 05:53:16 +0000 (14:53 +0900)] 
Sixth batch for 2.20

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'js/mingw-default-ident'
Junio C Hamano [Fri, 26 Oct 2018 05:22:15 +0000 (14:22 +0900)] 
Merge branch 'js/mingw-default-ident'

The logic to select the default user name and e-mail on Windows has
been improved.

* js/mingw-default-ident:
  mingw: use domain information for default email
  getpwuid(mingw): provide a better default for the user name
  getpwuid(mingw): initialize the structure only once

6 years agoMerge branch 'ld/p4-unshelve'
Junio C Hamano [Fri, 26 Oct 2018 05:22:15 +0000 (14:22 +0900)] 
Merge branch 'ld/p4-unshelve'

"git p4 unshelve" improvements.

* ld/p4-unshelve:
  git-p4: fully support unshelving changelists
  git-p4: unshelve into refs/remotes/p4-unshelved, not refs/remotes/p4/unshelved
  git-p4: do not fail in verbose mode for missing 'fileSize' key

6 years agoMerge branch 'du/cherry-is-plumbing'
Junio C Hamano [Fri, 26 Oct 2018 05:22:14 +0000 (14:22 +0900)] 
Merge branch 'du/cherry-is-plumbing'

Doc update to mark "git cherry" as a plumbing command.

* du/cherry-is-plumbing:
  doc: move git-cherry to plumbing

6 years agoMerge branch 'ab/gc-doc-update'
Junio C Hamano [Fri, 26 Oct 2018 05:22:14 +0000 (14:22 +0900)] 
Merge branch 'ab/gc-doc-update'

The documentation of "git gc" has been updated to mention that it
is no longer limited to "pruning away crufts" but also updates
ancillary files like commit-graph as a part of repository
optimization.

* ab/gc-doc-update:
  gc doc: mention the commit-graph in the intro

6 years agoMerge branch 'js/fuzzer'
Junio C Hamano [Fri, 26 Oct 2018 05:22:13 +0000 (14:22 +0900)] 
Merge branch 'js/fuzzer'

An experiment to fuzz test a few areas, hopefully we can gain more
coverage to various areas.

* js/fuzzer:
  fuzz: add fuzz testing for packfile indices.
  fuzz: add basic fuzz testing target.

6 years agoMerge branch 'rv/alias-help'
Junio C Hamano [Fri, 26 Oct 2018 05:22:13 +0000 (14:22 +0900)] 
Merge branch 'rv/alias-help'

"git cmd --help" when "cmd" is aliased used to only say "cmd is
aliased to ...".  Now it shows that to the standard error stream
and runs "git $cmd --help" where $cmd is the first word of the
alias expansion.

This could be misleading for those who alias a command with options
(e.g. with "[alias] cpn = cherry-pick -n", "git cpn --help" would
show the manual of "cherry-pick", and the reader would not be told
to pay close attention to the part that describes the "--no-commit"
option until closing the pager that showed the contents of the
manual, if the pager is configured to restore the original screen,
or would not be told at all, if the pager simply makes the message
on the standard error scroll away.

* rv/alias-help:
  git-help.txt: document "git help cmd" vs "git cmd --help" for aliases
  git.c: handle_alias: prepend alias info when first argument is -h
  help: redirect to aliased commands for "git cmd --help"

6 years agoMerge branch 'sb/diff-emit-line-ws-markup-cleanup'
Junio C Hamano [Fri, 26 Oct 2018 05:22:13 +0000 (14:22 +0900)] 
Merge branch 'sb/diff-emit-line-ws-markup-cleanup'

Code clean-up.

* sb/diff-emit-line-ws-markup-cleanup:
  diff.c: pass sign_index to emit_line_ws_markup

6 years agoMerge branch 'du/get-tar-commit-id-is-plumbing'
Junio C Hamano [Fri, 26 Oct 2018 05:22:12 +0000 (14:22 +0900)] 
Merge branch 'du/get-tar-commit-id-is-plumbing'

Doc update to mark "git get-tar-commit-id" as a plumbing command.

* du/get-tar-commit-id-is-plumbing:
  doc: move git-get-tar-commit-id to plumbing

6 years agoMerge branch 'mm/doc-no-dashed-git'
Junio C Hamano [Fri, 26 Oct 2018 05:22:12 +0000 (14:22 +0900)] 
Merge branch 'mm/doc-no-dashed-git'

Doc update.

* mm/doc-no-dashed-git:
  doc: fix a typo and clarify a sentence

6 years agoMerge branch 'du/rev-parse-is-plumbing'
Junio C Hamano [Fri, 26 Oct 2018 05:22:11 +0000 (14:22 +0900)] 
Merge branch 'du/rev-parse-is-plumbing'

Doc update.

* du/rev-parse-is-plumbing:
  doc: move git-rev-parse from porcelain to plumbing

6 years agoMerge branch 'np/log-graph-octopus-fix'
Junio C Hamano [Fri, 26 Oct 2018 05:22:11 +0000 (14:22 +0900)] 
Merge branch 'np/log-graph-octopus-fix'

"git log --graph" showing an octopus merge sometimes miscounted the
number of display columns it is consuming to show the merge and its
parent commits, which has been corrected.

* np/log-graph-octopus-fix:
  log: fix coloring of certain octopus merge shapes

6 years agoMerge branch 'sg/split-index-racefix'
Junio C Hamano [Fri, 26 Oct 2018 05:22:10 +0000 (14:22 +0900)] 
Merge branch 'sg/split-index-racefix'

The codepath to support the experimental split-index mode had
remaining "racily clean" issues fixed.

* sg/split-index-racefix:
  split-index: BUG() when cache entry refers to non-existing shared entry
  split-index: smudge and add racily clean cache entries to split index
  split-index: don't compare cached data of entries already marked for split index
  split-index: count the number of deleted entries
  t1700-split-index: date back files to avoid racy situations
  split-index: add tests to demonstrate the racy split index problem
  t1700-split-index: document why FSMONITOR is disabled in this test script

6 years agoMerge branch 'ds/coverage-diff'
Junio C Hamano [Fri, 26 Oct 2018 05:22:10 +0000 (14:22 +0900)] 
Merge branch 'ds/coverage-diff'

The result of coverage test can be combined with "git blame" to
check the test coverage of code introduced recently with a new
'coverage-diff' tool (in contrib/).

* ds/coverage-diff:
  contrib: add coverage-diff script

6 years agoMerge branch 'bc/editorconfig'
Junio C Hamano [Fri, 26 Oct 2018 05:22:09 +0000 (14:22 +0900)] 
Merge branch 'bc/editorconfig'

To help developers, an EditorConfig file that attempts to follow
the project convention has been added.

* bc/editorconfig:
  editorconfig: indicate settings should be kept in sync
  editorconfig: provide editor settings for Git developers

6 years agoMerge branch 'ma/t7005-bash-workaround'
Junio C Hamano [Fri, 26 Oct 2018 05:22:09 +0000 (14:22 +0900)] 
Merge branch 'ma/t7005-bash-workaround'

Test fix.

* ma/t7005-bash-workaround:
  t7005-editor: quote filename to fix whitespace-issue

6 years agoMerge branch 'rs/subtree-fixes'
Junio C Hamano [Fri, 26 Oct 2018 05:22:08 +0000 (14:22 +0900)] 
Merge branch 'rs/subtree-fixes'

Various subtree fixes.

* rs/subtree-fixes:
  subtree: performance improvement for finding unexpected parent commits
  subtree: improve decision on merges kept in split
  subtree: use commits before rejoins for splits
  subtree: make --ignore-joins pay attention to adds
  subtree: refactor split of a commit into standalone method

6 years agohttp: give curl version warnings consistently
Junio C Hamano [Thu, 25 Oct 2018 03:22:22 +0000 (12:22 +0900)] 
http: give curl version warnings consistently

When a requested feature cannot be activated because the version of
cURL library used to build Git with is too old, most of the codepaths
give a warning like "$Feature is not supported with cURL < $Version",
marked for l10n.  A few of them, however, did not follow that pattern
and said things like "$Feature is not activated, your curl version is
too old (>= $Version)", and without marking them for l10n.

Update these to match the style of the majority of warnings and mark
them for l10n.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohttp: when using Secure Channel, ignore sslCAInfo by default
Johannes Schindelin [Thu, 25 Oct 2018 18:53:56 +0000 (11:53 -0700)] 
http: when using Secure Channel, ignore sslCAInfo by default

As of cURL v7.60.0, the Secure Channel backend can use the certificate
bundle provided via `http.sslCAInfo`, but that would override the
Windows Certificate Store. Since this is not desirable by default, let's
tell Git to not ask cURL to use that bundle by default when the `schannel`
backend was configured via `http.sslBackend`, unless
`http.schannelUseSSLCAInfo` overrides this behavior.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohttp: add support for disabling SSL revocation checks in cURL
Brendan Forster [Thu, 25 Oct 2018 18:53:55 +0000 (11:53 -0700)] 
http: add support for disabling SSL revocation checks in cURL

This adds support for a new http.schannelCheckRevoke config value.

This config value is only used if http.sslBackend is set to "schannel",
which forces cURL to use the Windows Certificate Store when validating
server certificates associated with a remote server.

This config value should only be set to "false" if you are in an
environment where revocation checks are blocked by the network, with
no alternative options.

This is only supported in cURL 7.44 or later.

Note: originally, we wanted to call the config setting
`http.schannel.checkRevoke`. This, however, does not work: the `http.*`
config settings can be limited to specific URLs via `http.<url>.*`
(and this feature would mistake `schannel` for a URL).

Helped by Agustín Martín Barbero.

Signed-off-by: Brendan Forster <github@brendanforster.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoupload-pack: fix broken if/else chain in config callback
Jeff King [Wed, 24 Oct 2018 07:27:52 +0000 (03:27 -0400)] 
upload-pack: fix broken if/else chain in config callback

The upload_pack_config() callback uses an if/else chain
like:

  if (!strcmp(var, "a"))
     ...
  else if (!strcmp(var, "b"))
     ...
  etc

This works as long as the conditions are mutually exclusive,
but one of them is not. 20b20a22f8 (upload-pack: provide a
hook for running pack-objects, 2016-05-18) added:

  else if (current_config_scope() != CONFIG_SCOPE_REPO) {
     ... check some more options ...
  }

That was fine in that commit, because it came at the end of
the chain.  But later, 10ac85c785 (upload-pack: add object
filtering for partial clone, 2017-12-08) did this:

  else if (current_config_scope() != CONFIG_SCOPE_REPO) {
     ... check some more options ...
  } else if (!strcmp("uploadpack.allowfilter", var))
     ...

We'd always check the scope condition first, meaning we'd
_only_ respect allowfilter when it's in the repo config. You
can see this with:

  git -c uploadpack.allowfilter=true upload-pack . | head -1

which will not advertise the filter capability (but will
after this patch). We never noticed because:

  - our tests always set it in the repo config

  - in protocol v2, we use a different code path that
    actually calls repo_config_get_bool() separately, so
    that _does_ work. Real-world people experimenting with
    this may be using v2.

The more recent uploadpack.allowrefinwant option is in the
same boat.

There are a few possible fixes:

  1. Bump the scope conditional back to the bottom of the
     chain. But that just means somebody else is likely to
     make the same mistake later.

  2. Make the conditional more like the others. I.e.:

       else if (!current_config_scope() != CONFIG_SCOPE_REPO &&
                !strcmp(var, "uploadpack.notallowedinrepo"))

     This works, but the idea of the original structure was
     that we may grow multiple sensitive options like this.

  3. Pull it out of the chain entirely. The chain mostly
     serves to avoid extra strcmp() calls after we've found
     a match. But it's not worth caring about those. In the
     worst case, when there isn't a match, we're already
     hitting every strcmp (and this happens regularly for
     stuff like "core.bare", etc).

This patch does (3).

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorebase -i: recognize short commands without arguments
Johannes Sixt [Thu, 25 Oct 2018 20:47:45 +0000 (22:47 +0200)] 
rebase -i: recognize short commands without arguments

The sequencer instruction 'b', short for 'break', is rejected:

  error: invalid line 2: b

The reason is that the parser expects all short commands to have
an argument. Permit short commands without arguments.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoarchive: initialize archivers earlier
Josh Steadmon [Thu, 25 Oct 2018 20:32:14 +0000 (13:32 -0700)] 
archive: initialize archivers earlier

Initialize archivers as soon as possible when running git-archive.
Various non-obvious behavior depends on having the archivers
initialized, such as determining the desired archival format from the
provided filename.

Since 08716b3c11 ("archive: refactor file extension format-guessing",
2011-06-21), archive_format_from_filename() has used the registered
archivers to match filenames (provided via --output) to archival
formats. However, when git-archive is executed with --remote, format
detection happens before the archivers have been registered. This causes
archives from remotes to always be generated as TAR files, regardless of
the actual filename (unless an explicit --format is provided).

This patch fixes that behavior; archival format is determined properly
from the output filename, even when --remote is used.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompat: make sure git_mmap is not expected to write
Carlo Marcelo Arenas Belón [Tue, 23 Oct 2018 12:35:19 +0000 (05:35 -0700)] 
compat: make sure git_mmap is not expected to write

in f48000fc ("Yank writing-back support from gitfakemmap.", 2005-10-08)
support for writting back changes was removed but the specific prot
flag that would be used was not checked for

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorange-diff: allow to diff files regardless of submodule config
Lucas De Marchi [Wed, 24 Oct 2018 19:46:17 +0000 (12:46 -0700)] 
range-diff: allow to diff files regardless of submodule config

If we have `submodule.diff = log' in the configuration file
or `--submodule=log' is given as argument, range-diff fails
to compare both diffs and we only get the following output:

    Submodule a 0000000...0000000 (new submodule)

Even if the repository doesn't have any submodule.

That's because the mode in diff_filespec is not correct and when
flushing the diff, down in builtin_diff() we will enter the condition:

if (o->submodule_format == DIFF_SUBMODULE_LOG &&
    (!one->mode || S_ISGITLINK(one->mode)) &&
    (!two->mode || S_ISGITLINK(two->mode))) {
show_submodule_summary(o, one->path ? one->path : two->path,
&one->oid, &two->oid,
two->dirty_submodule);
return;

It turns out that S_ISGITLINK will return true (mode == 0160000 here).
Similar thing happens if submodule.diff is "diff".

Do like it's done in grep.c when calling fill_filespec() and force it to
be recognized as a file by adding S_IFREG to the mode.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohowto/using-merge-subtree: mention --allow-unrelated-histories
Uwe Kleine-König [Wed, 24 Oct 2018 08:04:52 +0000 (10:04 +0200)] 
howto/using-merge-subtree: mention --allow-unrelated-histories

Without passing --allow-unrelated-histories the command sequence
fails as intended since commit e379fdf34fee ("merge: refuse to create
too cool a merge by default"). To setup a subtree merging unrelated
histories is normal, so add the option to the howto document.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodoc: document diff/merge.guitool config keys
Denton Liu [Wed, 24 Oct 2018 16:25:43 +0000 (12:25 -0400)] 
doc: document diff/merge.guitool config keys

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: support `git mergetool --[no-]gui`
Denton Liu [Wed, 24 Oct 2018 16:25:37 +0000 (12:25 -0400)] 
completion: support `git mergetool --[no-]gui`

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Anmol Mago <anmolmago@gmail.com>
Signed-off-by: Brian Ho <briankyho@gmail.com>
Signed-off-by: David Lu <david.lu97@outlook.com>
Signed-off-by: Ryan Wang <shirui.wang@hotmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agomergetool: accept -g/--[no-]gui as arguments
Denton Liu [Wed, 24 Oct 2018 16:25:31 +0000 (12:25 -0400)] 
mergetool: accept -g/--[no-]gui as arguments

In line with how difftool accepts a -g/--[no-]gui option, make mergetool
accept the same option in order to use the `merge.guitool` variable to
find the default mergetool instead of `merge.tool`.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Anmol Mago <anmolmago@gmail.com>
Signed-off-by: Brian Ho <briankyho@gmail.com>
Signed-off-by: David Lu <david.lu97@outlook.com>
Signed-off-by: Ryan Wang <shirui.wang@hotmail.com>
Acked-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot5410: use longer path for sample script
Jeff King [Wed, 24 Oct 2018 07:37:06 +0000 (03:37 -0400)] 
t5410: use longer path for sample script

t5410 creates a sample script "alternate-refs", and sets
core.alternateRefsCommand to just "alternate-refs". That
shouldn't work, as "." is not in our $PATH, and so we should
not find it.

However, due to a bug in run-command.c, we sometimes find it
anyway! Even more confusing, this bug is only in the
fork-based version of run-command. So the test passes on
Linux (etc), but fails on Windows.

In preparation for fixing the run-command bug, let's use a
more complete path here.

Reported-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot0061: adjust to test-tool transition
Junio C Hamano [Thu, 25 Oct 2018 02:41:09 +0000 (11:41 +0900)] 
t0061: adjust to test-tool transition

6 years agorun-command: mark path lookup errors with ENOENT
Jeff King [Wed, 24 Oct 2018 07:38:00 +0000 (03:38 -0400)] 
run-command: mark path lookup errors with ENOENT

Since commit e3a434468f (run-command: use the
async-signal-safe execv instead of execvp, 2017-04-19),
prepare_cmd() does its own PATH lookup for any commands we
run (on non-Windows platforms).

However, its logic does not match the old execvp call when
we fail to find a matching entry in the PATH. Instead of
feeding the name directly to execv, execvp would consider
that an ENOENT error. By continuing and passing the name
directly to execv, we effectively behave as if "." was
included at the end of the PATH. This can have confusing and
even dangerous results.

The fix itself is pretty straight-forward. There's a new
test in t0061 to cover this explicitly, and I've also added
a duplicate of the ENOENT test to ensure that we return the
correct errno for this case.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agokhash: silence -Wunused-function for delta-islands
Carlo Marcelo Arenas Belón [Tue, 23 Oct 2018 21:50:20 +0000 (14:50 -0700)] 
khash: silence -Wunused-function for delta-islands

showing the following when compiled with latest clang (OpenBSD, Fedors
and macOS):

delta-islands.c:23:1: warning: unused function 'kh_destroy_str'
      [-Wunused-function]
delta-islands.c:23:1: warning: unused function 'kh_clear_str'
      [-Wunused-function]
delta-islands.c:23:1: warning: unused function 'kh_del_str' [-Wunused-function]

Reported-by: René Scharfe <l.s.r@web.de>
Suggested-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocommit-slabs: move MAYBE_UNUSED out
Carlo Marcelo Arenas Belón [Tue, 23 Oct 2018 21:50:19 +0000 (14:50 -0700)] 
commit-slabs: move MAYBE_UNUSED out

after 36da893114 ("config.mak.dev: enable -Wunused-function", 2018-10-18)
it is expected to be used to prevent -Wunused-function warnings for code
that was macro generated

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agomingw: fix getcwd when the parent directory cannot be queried
Anton Serbulov [Tue, 23 Oct 2018 10:52:49 +0000 (03:52 -0700)] 
mingw: fix getcwd when the parent directory cannot be queried

`GetLongPathName()` function may fail when it is unable to query
the parent directory of a path component to determine the long name
for that component. It happens, because it uses `FindFirstFile()`
function for each next short part of path. The `FindFirstFile()`
requires `List Directory` and `Synchronize` desired access for a calling
process.

In case of lacking such permission for some part of path,
the `GetLongPathName()` returns 0 as result and `GetLastError()`
returns ERROR_ACCESS_DENIED.

`GetFinalPathNameByHandle()` function can help in such cases, because
it requires `Read Attributes` and `Synchronize` desired access to the
target path only.

The `GetFinalPathNameByHandle()` function was introduced on
`Windows Server 2008/Windows Vista`. So we need to load it dynamically.

`CreateFile()` parameters:
    `lpFileName` = path to the current directory
    `dwDesiredAccess` = 0 (it means `Read Attributes` and `Synchronize`)
    `dwShareMode` = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE
                    (it prevents `Sharing Violation`)
    `lpSecurityAttributes` = NULL (default security attributes)
    `dwCreationDisposition` = OPEN_EXISTING
                              (required to obtain a directory handle)
    `dwFlagsAndAttributes` = FILE_FLAG_BACKUP_SEMANTICS
                             (required to obtain a directory handle)
    `hTemplateFile` = NULL (when opening an existing file or directory,
                            `CreateFile` ignores this parameter)

The string that is returned by `GetFinalPathNameByHandle()` function
uses the \\?\ syntax. To skip the prefix and convert backslashes
to slashes, the `normalize_ntpath()` mingw function will be used.

Note: `GetFinalPathNameByHandle()` function returns a final path.
It is the path that is returned when a path is fully resolved.
For example, for a symbolic link named "C:\tmp\mydir" that points to
"D:\yourdir", the final path would be "D:\yourdir".

Signed-off-by: Anton Serbulov <aserbulov@plesk.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agomingw: ensure `getcwd()` reports the correct case
Johannes Schindelin [Tue, 23 Oct 2018 10:52:48 +0000 (03:52 -0700)] 
mingw: ensure `getcwd()` reports the correct case

When switching the current working directory, say, in PowerShell, it is
quite possible to use a different capitalization than the one that is
recorded on disk. While doing the same in `cmd.exe` adjusts the
capitalization magically, that does not happen in PowerShell so that
`getcwd()` returns the current directory in a different way than is
recorded on disk.

Typically this creates no problems except when you call

git log .

in a subdirectory called, say, "GIT/" but you switched to "Git/" and
your `getcwd()` reports the latter, then Git won't understand that you
wanted to see the history as per the `GIT/` subdirectory but it thinks you
wanted to see the history of some directory that may have existed in the
past (but actually never did).

So let's be extra careful to adjust the capitalization of the current
directory before working with it.

Reported by a few PowerShell power users ;-)

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agomingw: load system libraries the recommended way
Johannes Schindelin [Tue, 23 Oct 2018 10:51:49 +0000 (03:51 -0700)] 
mingw: load system libraries the recommended way

When we access IPv6-related functions, we load the corresponding system
library using the `LoadLibrary()` function, which is not the recommended
way to load system libraries.

In practice, it does not make a difference: the `ws2_32.dll` library
containing the IPv6 functions is already loaded into memory, so
LoadLibrary() simply reuses the already-loaded library.

Still, recommended way is recommended way, so let's use that instead.

While at it, also adjust the code in contrib/ that loads system libraries.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorebase --autostash: fix issue with dirty submodules
Johannes Schindelin [Tue, 23 Oct 2018 19:57:17 +0000 (12:57 -0700)] 
rebase --autostash: fix issue with dirty submodules

Since we cannot stash dirty submodules, there is no use in requiring
them to be clean (or stash them when they are not).

This brings the built-in rebase in line with the previous, scripted
version, which also did not care about dirty submodules (but it was
admittedly not very easy to figure that out).

This fixes https://github.com/git-for-windows/git/issues/1820

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorebase --autostash: demonstrate a problem with dirty submodules
Johannes Schindelin [Tue, 23 Oct 2018 19:57:16 +0000 (12:57 -0700)] 
rebase --autostash: demonstrate a problem with dirty submodules

It has been reported that dirty submodules cause problems with the
built-in rebase when it is asked to autostash. The symptom is:

fatal: Unexpected stash response: ''

This patch adds a regression test that demonstrates that bug.

Original report: https://github.com/git-for-windows/git/issues/1820

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoDocumentation/config.txt: fix typo in core.alternateRefsCommand
Taylor Blau [Tue, 23 Oct 2018 01:32:04 +0000 (18:32 -0700)] 
Documentation/config.txt: fix typo in core.alternateRefsCommand

In [1] Git learned about 'core.alternateRefsCommand', and with it, the
accompanying documentation. However, this documentation included a typo
involving the verb tense of "produced".

Match the tense of the surrounding bits by correcting this typo.

[1]: 89284c1d6c (transport.c: introduce core.alternateRefsCommand,
     2018-10-08)

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agofsck: s/++i > 1/i++/
Junio C Hamano [Wed, 24 Oct 2018 01:25:12 +0000 (10:25 +0900)] 
fsck: s/++i > 1/i++/

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agococci: simplify "if (++u > 1)" to "if (u++)"
Junio C Hamano [Wed, 24 Oct 2018 01:10:10 +0000 (10:10 +0900)] 
cocci: simplify "if (++u > 1)" to "if (u++)"

It is more common to use post-increment than pre-increment when the
side effect is the primary thing we want in our code and in C in
general (unlike C++).

Initializing a variable to 0, incrementing it every time we do
something, and checking if we have already done that thing to guard
the code to do that thing, is easier to understand when written

if (u++)
; /* we've done that! */
else
do_it(); /* just once. */

but if you try to use pre-increment, you end up with a less natural
looking

if (++u > 1)

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot7501: rename commit test to comply with naming convention
Stephen P. Smith [Tue, 23 Oct 2018 03:53:41 +0000 (20:53 -0700)] 
t7501: rename commit test to comply with naming convention

The naming convention was documented [1] but this script was not
renamed.

The original commit message indicates the script tests basic commit
functionality. Clean up the test name by changing the file name to
specify the intent as documented in the initial commit.

[1] f50c9f76c ("Rename some test scripts and describe the naming convention", 2005-05-15)

Signed-off-by: Stephen P. Smith <ischis2@cox.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot7500: rename commit tests script to comply with naming convention
Stephen P. Smith [Tue, 23 Oct 2018 03:53:40 +0000 (20:53 -0700)] 
t7500: rename commit tests script to comply with naming convention

When the test naming convention was documented[1] the commit script
was not renamed.

Update the test description to note that the tests fall into four
general categories: template, sign-off, -F and squash tests.

Chose to not add "File" to the new script name as that did not seem to
convey the current test contents for that switch.

[1] f50c9f76c ("Rename some test scripts and describe the naming convention", 2005-05-15)

Signed-off-by: Stephen P. Smith <ischis2@cox.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>