OSDN Git Service

git-core/git.git
7 years agoMerge branch 'js/travis-32bit-linux'
Junio C Hamano [Tue, 14 Mar 2017 22:23:20 +0000 (15:23 -0700)]
Merge branch 'js/travis-32bit-linux'

Add 32-bit Linux variant to the set of platforms to be tested with
Travis CI.

* js/travis-32bit-linux:
  Travis: also test on 32-bit Linux

7 years agoMerge branch 'ew/http-alternates-as-redirects-warning'
Junio C Hamano [Tue, 14 Mar 2017 22:23:19 +0000 (15:23 -0700)]
Merge branch 'ew/http-alternates-as-redirects-warning'

Recent versions of Git treats http alternates (used in dumb http
transport) just like HTTP redirects and requires the client to
enable following it, due to security concerns.  But we forgot to
give a warning when we decide not to honor the alternates.

* ew/http-alternates-as-redirects-warning:
  http: release strbuf on disabled alternates
  http: inform about alternates-as-redirects behavior

7 years agoMerge branch 'dp/filter-branch-prune-empty'
Junio C Hamano [Tue, 14 Mar 2017 22:23:19 +0000 (15:23 -0700)]
Merge branch 'dp/filter-branch-prune-empty'

"git filter-branch --prune-empty" drops a single-parent commit that
becomes a no-op, but did not drop a root commit whose tree is empty.

* dp/filter-branch-prune-empty:
  p7000: add test for filter-branch with --prune-empty
  filter-branch: fix --prune-empty on parentless commits
  t7003: ensure --prune-empty removes entire branch when applicable
  t7003: ensure --prune-empty can prune root commit

7 years agoMerge branch 'jt/perf-updates'
Junio C Hamano [Tue, 14 Mar 2017 22:23:18 +0000 (15:23 -0700)]
Merge branch 'jt/perf-updates'

The t/perf performance test suite was not prepared to test not so
old versions of Git, but now it covers versions of Git that are not
so ancient.

* jt/perf-updates:
  t/perf: add fallback for pre-bin-wrappers versions of git
  t/perf: use $MODERN_GIT for all repo-copying steps
  t/perf: export variable used in other blocks

7 years agoMerge branch 'mm/fetch-show-error-message-on-unadvertised-object'
Junio C Hamano [Tue, 14 Mar 2017 22:23:18 +0000 (15:23 -0700)]
Merge branch 'mm/fetch-show-error-message-on-unadvertised-object'

"git fetch" that requests a commit by object name, when the other
side does not allow such an request, failed without much
explanation.

* mm/fetch-show-error-message-on-unadvertised-object:
  fetch-pack: add specific error for fetching an unadvertised object
  fetch_refs_via_pack: call report_unmatched_refs
  fetch-pack: move code to report unmatched refs to a function

7 years agoMerge branch 'jk/interpret-branch-name'
Junio C Hamano [Tue, 14 Mar 2017 22:23:18 +0000 (15:23 -0700)]
Merge branch 'jk/interpret-branch-name'

"git branch @" created refs/heads/@ as a branch, and in general the
code that handled @{-1} and @{upstream} was a bit too loose in
disambiguating.

* jk/interpret-branch-name:
  checkout: restrict @-expansions when finding branch
  strbuf_check_ref_format(): expand only local branches
  branch: restrict @-expansions when deleting
  t3204: test git-branch @-expansion corner cases
  interpret_branch_name: allow callers to restrict expansions
  strbuf_branchname: add docstring
  strbuf_branchname: drop return value
  interpret_branch_name: move docstring to header file
  interpret_branch_name(): handle auto-namelen for @{-1}

7 years agoMerge branch 'ab/cond-skip-tests'
Junio C Hamano [Tue, 14 Mar 2017 22:23:17 +0000 (15:23 -0700)]
Merge branch 'ab/cond-skip-tests'

A few tests were run conditionally under (rare) conditions where
they cannot be run (like running cvs tests under 'root' account).

* ab/cond-skip-tests:
  gitweb tests: skip tests when we don't have Time::HiRes
  gitweb tests: change confusing "skip_all" phrasing
  cvs tests: skip tests that call "cvs commit" when running as root

7 years agoThird batch after 2.12
Junio C Hamano [Mon, 13 Mar 2017 06:24:14 +0000 (23:24 -0700)]
Third batch after 2.12

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'ah/doc-ls-files-quotepath'
Junio C Hamano [Mon, 13 Mar 2017 06:21:36 +0000 (23:21 -0700)]
Merge branch 'ah/doc-ls-files-quotepath'

Documentation for "git ls-files" did not refer to core.quotePath

* ah/doc-ls-files-quotepath:
  Documentation: improve description for core.quotePath

7 years agoMerge branch 'jc/diff-populate-filespec-size-only-fix'
Junio C Hamano [Mon, 13 Mar 2017 06:21:36 +0000 (23:21 -0700)]
Merge branch 'jc/diff-populate-filespec-size-only-fix'

"git diff --quiet" relies on the size field in diff_filespec to be
correctly populated, but diff_populate_filespec() helper function
made an incorrect short-cut when asked only to populate the size
field for paths that need to go through convert_to_git() (e.g. CRLF
conversion).

* jc/diff-populate-filespec-size-only-fix:
  diff: do not short-cut CHECK_SIZE_ONLY check in diff_populate_filespec()

7 years agoMerge branch 'vn/line-log-memcpy-size-fix'
Junio C Hamano [Mon, 13 Mar 2017 06:21:35 +0000 (23:21 -0700)]
Merge branch 'vn/line-log-memcpy-size-fix'

The command-line parsing of "git log -L" copied internal data
structures using incorrect size on ILP32 systems.

* vn/line-log-memcpy-size-fix:
  line-log: use COPY_ARRAY to fix mis-sized memcpy

7 years agoMerge branch 'jk/ewah-use-right-type-in-sizeof'
Junio C Hamano [Mon, 13 Mar 2017 06:21:35 +0000 (23:21 -0700)]
Merge branch 'jk/ewah-use-right-type-in-sizeof'

Code clean-up.

* jk/ewah-use-right-type-in-sizeof:
  ewah: fix eword_t/uint64_t confusion

7 years agoMerge branch 'ax/line-log-range-merge-fix'
Junio C Hamano [Mon, 13 Mar 2017 06:21:34 +0000 (23:21 -0700)]
Merge branch 'ax/line-log-range-merge-fix'

The code to parse "git log -L..." command line was buggy when there
are many ranges specified with -L; overrun of the allocated buffer
has been fixed.

* ax/line-log-range-merge-fix:
  line-log.c: prevent crash during union of too many ranges

7 years agoMerge branch 'ss/remote-bzr-hg-placeholder-wo-python'
Junio C Hamano [Mon, 13 Mar 2017 06:21:33 +0000 (23:21 -0700)]
Merge branch 'ss/remote-bzr-hg-placeholder-wo-python'

There is no need for Python only to give a few messages to the
standard error stream, but we somehow did.

* ss/remote-bzr-hg-placeholder-wo-python:
  contrib: git-remote-{bzr,hg} placeholders don't need Python

7 years agoMerge branch 'js/realpath-pathdup-fix'
Junio C Hamano [Mon, 13 Mar 2017 06:21:33 +0000 (23:21 -0700)]
Merge branch 'js/realpath-pathdup-fix'

Git v2.12 was shipped with an embarrassing breakage where various
operations that verify paths given from the user stopped dying when
seeing an issue, and instead later triggering segfault.

* js/realpath-pathdup-fix:
  real_pathdup(): fix callsites that wanted it to die on error
  t1501: demonstrate NULL pointer access with invalid GIT_WORK_TREE

7 years agoMerge branch 'jk/add-i-patch-do-prompt'
Junio C Hamano [Mon, 13 Mar 2017 06:21:33 +0000 (23:21 -0700)]
Merge branch 'jk/add-i-patch-do-prompt'

The patch subcommand of "git add -i" was meant to have paths
selection prompt just like other subcommand, unlike "git add -p"
directly jumps to hunk selection.  Recently, this was broken and
"add -i" lost the paths selection dialog, but it now has been
fixed.

* jk/add-i-patch-do-prompt:
  add--interactive: fix missing file prompt for patch mode with "-i"

7 years agoMerge branch 'jh/mingw-openssl-sha1'
Junio C Hamano [Mon, 13 Mar 2017 06:21:33 +0000 (23:21 -0700)]
Merge branch 'jh/mingw-openssl-sha1'

Windows port wants to use OpenSSL's implementation of SHA-1
routines, so let them.

* jh/mingw-openssl-sha1:
  mingw: use OpenSSL's SHA-1 routines

7 years agoSecond batch after 2.12
Junio C Hamano [Fri, 10 Mar 2017 21:24:59 +0000 (13:24 -0800)]
Second batch after 2.12

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'rs/log-email-subject'
Junio C Hamano [Fri, 10 Mar 2017 21:24:24 +0000 (13:24 -0800)]
Merge branch 'rs/log-email-subject'

Code clean-up.

* rs/log-email-subject:
  pretty: use fmt_output_email_subject()
  log-tree: factor out fmt_output_email_subject()

7 years agoMerge branch 'tg/stash-push'
Junio C Hamano [Fri, 10 Mar 2017 21:24:24 +0000 (13:24 -0800)]
Merge branch 'tg/stash-push'

"git stash save" takes a pathspec so that the local changes can be
stashed away only partially.

* tg/stash-push:
  stash: allow pathspecs in the no verb form
  stash: use stash_push for no verb form
  stash: teach 'push' (and 'create_stash') to honor pathspec
  stash: refactor stash_create
  stash: add test for the create command line arguments
  stash: introduce push verb

7 years agoMerge branch 'sb/submodule-init-url-selection'
Junio C Hamano [Fri, 10 Mar 2017 21:24:24 +0000 (13:24 -0800)]
Merge branch 'sb/submodule-init-url-selection'

When "git submodule init" decides that the submodule in the working
tree is its upstream, it now gives a warning as it is not a very
common setup.

* sb/submodule-init-url-selection:
  submodule init: warn about falling back to a local path

7 years agoMerge branch 'rj/remove-unused-mktemp'
Junio C Hamano [Fri, 10 Mar 2017 21:24:24 +0000 (13:24 -0800)]
Merge branch 'rj/remove-unused-mktemp'

Code cleanup.

* rj/remove-unused-mktemp:
  wrapper.c: remove unused gitmkstemps() function
  wrapper.c: remove unused git_mkstemp() function

7 years agoMerge branch 'ew/markdown-url-in-readme'
Junio C Hamano [Fri, 10 Mar 2017 21:24:24 +0000 (13:24 -0800)]
Merge branch 'ew/markdown-url-in-readme'

Doc update.

* ew/markdown-url-in-readme:
  README: create HTTP/HTTPS links from URLs in Markdown

7 years agoMerge branch 'ps/docs-diffcore'
Junio C Hamano [Fri, 10 Mar 2017 21:24:23 +0000 (13:24 -0800)]
Merge branch 'ps/docs-diffcore'

Doc update.

* ps/docs-diffcore:
  docs/diffcore: unquote "Complete Rewrites" in headers
  docs/diffcore: fix grammar in diffcore-rename header

7 years agoMerge branch 'jt/http-base-url-update-upon-redirect'
Junio C Hamano [Fri, 10 Mar 2017 21:24:23 +0000 (13:24 -0800)]
Merge branch 'jt/http-base-url-update-upon-redirect'

When a redirected http transport gets an error during the
redirected request, we ignored the error we got from the server,
and ended up giving a not-so-useful error message.

* jt/http-base-url-update-upon-redirect:
  http: attempt updating base URL only if no error

7 years agoMerge branch 'jk/http-auth'
Junio C Hamano [Fri, 10 Mar 2017 21:24:23 +0000 (13:24 -0800)]
Merge branch 'jk/http-auth'

Reduce authentication round-trip over HTTP when the server supports
just a single authentication method.

* jk/http-auth:
  http: add an "auto" mode for http.emptyauth
  http: restrict auth methods to what the server advertises

7 years agoMerge branch 'jh/send-email-one-cc'
Junio C Hamano [Fri, 10 Mar 2017 21:24:23 +0000 (13:24 -0800)]
Merge branch 'jh/send-email-one-cc'

"Cc:" on the trailer part does not have to conform to RFC strictly,
unlike in the e-mail header.  "git send-email" has been updated to
ignore anything after '>' when picking addresses, to allow non-address
cruft like " # stable 4.4" after the address.

* jh/send-email-one-cc:
  send-email: only allow one address per body tag

7 years agoMerge branch 'rs/strbuf-add-real-path'
Junio C Hamano [Fri, 10 Mar 2017 21:24:23 +0000 (13:24 -0800)]
Merge branch 'rs/strbuf-add-real-path'

An helper function to make it easier to append the result from
real_path() to a strbuf has been added.

* rs/strbuf-add-real-path:
  strbuf: add strbuf_add_real_path()
  cocci: use ALLOC_ARRAY

7 years agoMerge branch 'rs/sha1-file-plug-fallback-base-leak'
Junio C Hamano [Fri, 10 Mar 2017 21:24:22 +0000 (13:24 -0800)]
Merge branch 'rs/sha1-file-plug-fallback-base-leak'

A leak in a codepath to read from a packed object in (rare) cases
has been plugged.

* rs/sha1-file-plug-fallback-base-leak:
  sha1_file: release fallback base's memory in unpack_entry()

7 years agoMerge branch 'rs/commit-parsing-optim'
Junio C Hamano [Fri, 10 Mar 2017 21:24:22 +0000 (13:24 -0800)]
Merge branch 'rs/commit-parsing-optim'

The code that parses header fields in the commit object has been
updated for (micro)performance and code hygiene.

* rs/commit-parsing-optim:
  commit: don't check for space twice when looking for header
  commit: be more precise when searching for headers

7 years agoMerge branch 'jk/t6300-cleanup'
Junio C Hamano [Fri, 10 Mar 2017 21:24:22 +0000 (13:24 -0800)]
Merge branch 'jk/t6300-cleanup'

A test that creates a confusing branch whose name is HEAD has been
corrected not to do so.

* jk/t6300-cleanup:
  t6300: avoid creating refs/heads/HEAD

7 years agoMerge branch 'jk/parse-config-key-cleanup'
Junio C Hamano [Fri, 10 Mar 2017 21:24:22 +0000 (13:24 -0800)]
Merge branch 'jk/parse-config-key-cleanup'

The "parse_config_key()" API function has been cleaned up.

* jk/parse-config-key-cleanup:
  parse_hide_refs_config: tell parse_config_key we don't want a subsection
  parse_config_key: allow matching single-level config
  parse_config_key: use skip_prefix instead of starts_with

7 years agoMerge branch 'sb/parse-hide-refs-config-cleanup'
Junio C Hamano [Fri, 10 Mar 2017 21:24:21 +0000 (13:24 -0800)]
Merge branch 'sb/parse-hide-refs-config-cleanup'

Code clean-up.

* sb/parse-hide-refs-config-cleanup:
  refs: parse_hide_refs_config to use parse_config_key

7 years agoMerge branch 'jt/upload-pack-error-report'
Junio C Hamano [Fri, 10 Mar 2017 21:24:21 +0000 (13:24 -0800)]
Merge branch 'jt/upload-pack-error-report'

"git upload-pack", which is a counter-part of "git fetch", did not
report a request for a ref that was not advertised as invalid.
This is generally not a problem (because "git fetch" will stop
before making such a request), but is the right thing to do.

* jt/upload-pack-error-report:
  upload-pack: report "not our ref" to client

7 years agoMerge branch 'jk/ident-empty'
Junio C Hamano [Fri, 10 Mar 2017 21:24:21 +0000 (13:24 -0800)]
Merge branch 'jk/ident-empty'

user.email that consists of only cruft chars should consistently
error out, but didn't.

* jk/ident-empty:
  ident: do not ignore empty config name/email
  ident: reject all-crud ident name
  ident: handle NULL email when complaining of empty name
  ident: mark error messages for translation

7 years agoMerge branch 'jc/config-case-cmdline-take-2'
Junio C Hamano [Fri, 10 Mar 2017 21:24:20 +0000 (13:24 -0800)]
Merge branch 'jc/config-case-cmdline-take-2'

The code to parse "git -c VAR=VAL cmd" and set configuration
variable for the duration of cmd had two small bugs, which have
been fixed.

* jc/config-case-cmdline-take-2:
  config: use git_config_parse_key() in git_config_parse_parameter()
  config: move a few helper functions up

7 years agoreal_pathdup(): fix callsites that wanted it to die on error
Johannes Schindelin [Wed, 8 Mar 2017 15:43:40 +0000 (16:43 +0100)]
real_pathdup(): fix callsites that wanted it to die on error

In 4ac9006f832 (real_path: have callers use real_pathdup and
strbuf_realpath, 2016-12-12), we changed the xstrdup(real_path())
pattern to use real_pathdup() directly.

The problem with this change is that real_path() calls
strbuf_realpath() with die_on_error = 1 while real_pathdup() calls
it with die_on_error = 0. Meaning that in cases where real_path()
causes Git to die() with an error message, real_pathdup() is silent
and returns NULL instead.

The callers, however, are ill-prepared for that change, as they expect
the return value to be non-NULL (and otherwise the function died
with an appropriate error message).

Fix this by extending real_pathdup()'s signature to accept the
die_on_error flag and simply pass it through to strbuf_realpath(),
and then adjust all callers after a careful audit whether they would
handle NULLs well.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot1501: demonstrate NULL pointer access with invalid GIT_WORK_TREE
Johannes Schindelin [Wed, 8 Mar 2017 15:43:34 +0000 (16:43 +0100)]
t1501: demonstrate NULL pointer access with invalid GIT_WORK_TREE

When GIT_WORK_TREE does not specify a valid path, we should error
out, instead of crashing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogit svn: fix authentication with 'branch'
Hiroshi Shirosaki [Mon, 6 Mar 2017 05:59:07 +0000 (14:59 +0900)]
git svn: fix authentication with 'branch'

Authentication fails with svn branch while svn rebase and
svn dcommit work fine without authentication failures.

$ git svn branch v7_3
Copying https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx at r27519
to https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/v7_3...
Can't create session: Unable to connect to a repository at URL
'https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': No more
credentials or we tried too many times.
Authentication failed at
C:\Program Files\Git\mingw64/libexec/git-core\git-svn line 1200.

We add auth configuration to SVN::Client->new() to fix the issue.

Signed-off-by: Hiroshi Shirosaki <h.shirosaki@gmail.com>
Signed-off-by: Eric Wong <e@80x24.org>
7 years agoewah: fix eword_t/uint64_t confusion
Jeff King [Sun, 5 Mar 2017 11:46:38 +0000 (06:46 -0500)]
ewah: fix eword_t/uint64_t confusion

The ewah subsystem typedefs eword_t to be uint64_t, but some
code uses a bare uint64_t. This isn't a bug now, but it's a
potential maintenance problem if the definition of eword_t
ever changes. Let's use the correct type.

Note that we can't use COPY_ARRAY() here because the source
and destination point to objects of different sizes. For
that reason we'll also skip the usual "sizeof(*dst)" and use
the real type, which should make it more clear that there's
something tricky going on.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoline-log: use COPY_ARRAY to fix mis-sized memcpy
Vegard Nossum [Sun, 5 Mar 2017 11:44:46 +0000 (06:44 -0500)]
line-log: use COPY_ARRAY to fix mis-sized memcpy

This memcpy meant to get the sizeof a "struct range", not a
"range_set", as the former is what our array holds. Rather
than swap out the types, let's convert this site to
COPY_ARRAY, which avoids the problem entirely (and confirms
that the src and dst types match).

Note for curiosity's sake that this bug doesn't trigger on
I32LP64 systems, but does on ILP32 systems. The mistaken
"struct range_set" has two ints and a pointer. That's 16
bytes on LP64, or 12 on ILP32. The correct "struct range"
type has two longs, which is also 16 on LP64, but only 8 on
ILP32.

Likewise an IL32P64 system would experience the bug.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoTravis: also test on 32-bit Linux
Johannes Schindelin [Sun, 5 Mar 2017 18:25:19 +0000 (19:25 +0100)]
Travis: also test on 32-bit Linux

When Git v2.9.1 was released, it had a bug that showed only on Windows
and on 32-bit systems: our assumption that `unsigned long` can hold
64-bit values turned out to be wrong.

This could have been caught earlier if we had a Continuous Testing
set up that includes a build and test run on 32-bit Linux.

Let's do this (and take care of the Windows build later). This patch
asks Travis CI to install a Docker image with 32-bit libraries and then
goes on to build and test Git using this 32-bit setup.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agohttp: release strbuf on disabled alternates
Eric Wong [Sat, 4 Mar 2017 01:50:16 +0000 (01:50 +0000)]
http: release strbuf on disabled alternates

This likely has no real-world impact on memory usage,
but it is cleaner for future readers.

Fixes: abcbdc03895f ("http: respect protocol.*.allow=user for http-alternates")
Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agohttp: inform about alternates-as-redirects behavior
Eric Wong [Sat, 4 Mar 2017 08:36:45 +0000 (08:36 +0000)]
http: inform about alternates-as-redirects behavior

It is disconcerting for users to not notice the behavior
change in handling alternates from commit cb4d2d35c4622ec2
("http: treat http-alternates like redirects")

Give the user a hint about the config option so they can
see the URL and decide whether or not they want to enable
http.followRedirects in their config.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agop7000: add test for filter-branch with --prune-empty
Devin J. Pohly [Thu, 23 Feb 2017 08:27:36 +0000 (02:27 -0600)]
p7000: add test for filter-branch with --prune-empty

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofilter-branch: fix --prune-empty on parentless commits
Devin J. Pohly [Thu, 23 Feb 2017 08:27:35 +0000 (02:27 -0600)]
filter-branch: fix --prune-empty on parentless commits

Previously, the git_commit_non_empty_tree function would always pass any
commit with no parents to git-commit-tree, regardless of whether the
tree was nonempty.  The new commit would then be recorded in the
filter-branch revision map, and subsequent commits which leave the tree
untouched would be correctly filtered.

With this change, parentless commits with an empty tree are correctly
pruned, and an empty file is recorded in the revision map, signifying
that it was rewritten to "no commits."  This works naturally with the
parent mapping for subsequent commits.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7003: ensure --prune-empty removes entire branch when applicable
Devin J. Pohly [Thu, 23 Feb 2017 08:27:34 +0000 (02:27 -0600)]
t7003: ensure --prune-empty removes entire branch when applicable

Sanity check before changing the logic in git_commit_non_empty_tree.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7003: ensure --prune-empty can prune root commit
Devin J. Pohly [Thu, 23 Feb 2017 08:27:33 +0000 (02:27 -0600)]
t7003: ensure --prune-empty can prune root commit

New test to expose a bug in filter-branch whereby the root commit is
never pruned, even though its tree is empty and --prune-empty is given.

The setup isn't exactly pretty, but I couldn't think of a simpler way to
create a parallel commit graph sans the first commit.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoline-log.c: prevent crash during union of too many ranges
Allan Xavier [Thu, 2 Mar 2017 17:29:02 +0000 (17:29 +0000)]
line-log.c: prevent crash during union of too many ranges

The existing implementation of range_set_union does not correctly
reallocate memory, leading to a heap overflow when it attempts to union
more than 24 separate line ranges.

For struct range_set *out to grow correctly it must have out->nr set to
the current size of the buffer when it is passed to range_set_grow.
However, the existing implementation of range_set_union only updates
out->nr at the end of the function, meaning that it is always zero
before this. This results in range_set_grow never growing the buffer, as
well as some of the union logic itself being incorrect as !out->nr is
always true.

The reason why 24 is the limit is that the first allocation of size 1
ends up allocating a buffer of size 24 (due to the call to alloc_nr in
ALLOC_GROW). This goes some way to explain why this hasn't been
caught before.

Fix the problem by correctly updating out->nr after reallocating the
range_set. As this results in out->nr containing the same value as the
variable o, replace o with out->nr as well.

Finally, add a new test to help prevent the problem reoccurring in the
future. Thanks to Vegard Nossum for writing the test.

Signed-off-by: Allan Xavier <allan.x.xavier@oracle.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocontrib: git-remote-{bzr,hg} placeholders don't need Python
Sebastian Schuberth [Fri, 3 Mar 2017 10:57:46 +0000 (10:57 +0000)]
contrib: git-remote-{bzr,hg} placeholders don't need Python

It does not make sense for these placeholder scripts to depend on Python
just because the real scripts do. At the example of Git for Windows, we
would not even be able to see those warnings as it does not ship with
Python. So just use plain shell scripts instead.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot/perf: add fallback for pre-bin-wrappers versions of git
Jeff King [Fri, 3 Mar 2017 07:36:33 +0000 (02:36 -0500)]
t/perf: add fallback for pre-bin-wrappers versions of git

It's tempting to say:

  ./run v1.0.0 HEAD

to see how we've sped up Git over the years. Unfortunately,
this doesn't quite work because versions of Git prior to
v1.7.0 lack bin-wrappers, so our "run" script doesn't
correctly put them in the PATH.

Worse, it means we silently find whatever other "git" is in
the PATH, and produce test results that have no bearing on
what we asked for.

Let's fallback to the main git directory when bin-wrappers
isn't present. Many modern perf scripts won't run with such
an antique version of Git, of course, but at least those
failures are detected and reported (and you're free to write
a limited perf script that works across many versions).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot/perf: use $MODERN_GIT for all repo-copying steps
Jeff King [Fri, 3 Mar 2017 07:14:03 +0000 (02:14 -0500)]
t/perf: use $MODERN_GIT for all repo-copying steps

Since 1a0962dee (t/perf: fix regression in testing older
versions of git, 2016-06-22), we point "$MODERN_GIT" to a
copy of git that matches the t/perf script itself, and which
can be used for tasks outside of the actual timings. This is
needed because the setup done by perf scripts keeps moving
forward in time, and may use features that the older
versions of git we are testing do not have.

That commit used $MODERN_GIT to fix a case where we relied
on the relatively recent --git-path option. But if you go
back further still, there are more problems.

Since 7501b5921 (perf: make the tests work in worktrees,
2016-05-13), we use "git -C", but versions of git older than
44e1e4d67 (git: run in a directory given with -C option,
2013-09-09) don't know about "-C". So testing an old version
of git with a new version of t/perf will fail the setup
step.

We can fix this by using $MODERN_GIT during the setup;
there's no need to use the antique version, since it doesn't
affect the timings. Likewise, we'll adjust the "init"
invocation; antique versions of git called this "init-db".

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot/perf: export variable used in other blocks
Jonathan Tan [Thu, 2 Mar 2017 19:50:41 +0000 (11:50 -0800)]
t/perf: export variable used in other blocks

In p0001, a variable was created in a test_expect_success block to be
used in later test_perf blocks, but was not exported. This caused the
variable to not appear in those blocks (this can be verified by writing
'test -n "$commit"' in those blocks), resulting in a slightly different
invocation than what was intended. Export that variable.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoDocumentation: improve description for core.quotePath
Andreas Heiduk [Thu, 2 Mar 2017 19:03:52 +0000 (20:03 +0100)]
Documentation: improve description for core.quotePath

Linking the description for pathname quoting to the configuration
variable "core.quotePath" removes inconstistent and incomplete
sections while also giving two hints how to deal with it: Either with
"-c core.quotePath=false" or with "-z".

Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofetch-pack: add specific error for fetching an unadvertised object
Matt McCutchen [Wed, 22 Feb 2017 16:05:57 +0000 (11:05 -0500)]
fetch-pack: add specific error for fetching an unadvertised object

Enhance filter_refs (which decides whether a request for an unadvertised
object should be sent to the server) to record a new match status on the
"struct ref" when a request is not allowed, and have
report_unmatched_refs check for this status and print a special error
message, "Server does not allow request for unadvertised object".

Signed-off-by: Matt McCutchen <matt@mattmccutchen.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofetch_refs_via_pack: call report_unmatched_refs
Matt McCutchen [Wed, 22 Feb 2017 16:02:15 +0000 (11:02 -0500)]
fetch_refs_via_pack: call report_unmatched_refs

"git fetch" currently doesn't bother to check that it got all refs it
sought, because the common case of requesting a nonexistent ref triggers
a die() in get_fetch_map.  However, there's at least one case that
slipped through: "git fetch REMOTE SHA1" if the server doesn't allow
requests for unadvertised objects.  Make fetch_refs_via_pack (which is
on the "git fetch" code path) call report_unmatched_refs so that we at
least get an error message in that case.

Signed-off-by: Matt McCutchen <matt@mattmccutchen.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofetch-pack: move code to report unmatched refs to a function
Matt McCutchen [Wed, 22 Feb 2017 16:01:22 +0000 (11:01 -0500)]
fetch-pack: move code to report unmatched refs to a function

Prepare to reuse this code in transport.c for "git fetch".

While we're here, internationalize the existing error message.

Signed-off-by: Matt McCutchen <matt@mattmccutchen.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocheckout: restrict @-expansions when finding branch
Jeff King [Thu, 2 Mar 2017 08:23:18 +0000 (03:23 -0500)]
checkout: restrict @-expansions when finding branch

When we parse "git checkout $NAME", we try to interpret
$NAME as a local branch-name. If it is, then we point HEAD
to that branch. Otherwise, we detach the HEAD at whatever
commit $NAME points to.

We do the interpretation by calling strbuf_branchname(), and
then blindly sticking "refs/heads/" on the front. This leads
to nonsense results when expansions like "@{upstream}" or
"@" point to something besides a local branch. We end up
with a local branch name like "refs/heads/origin/master" or
"refs/heads/HEAD".

Normally this has no user-visible effect because those
branches don't exist, and so we fallback to feeding the
result to get_sha1(), which resolves them correctly.

But as the new test in t3204 shows, there are corner cases
where the effect is observable, and we check out the wrong
local branch rather than detaching to the correct one.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agostrbuf_check_ref_format(): expand only local branches
Jeff King [Thu, 2 Mar 2017 08:23:14 +0000 (03:23 -0500)]
strbuf_check_ref_format(): expand only local branches

This function asks strbuf_branchname() to expand any @-marks
in the branchname, and then we blindly stick refs/heads/ in
front of the result. This is obviously nonsense if the
expansion is "HEAD" or a ref in refs/remotes/.

The most obvious end-user effect is that creating or
renaming a branch with an expansion may have confusing
results (e.g., creating refs/heads/origin/master from
"@{upstream}" when the operation should be disallowed).

We can fix this by telling strbuf_branchname() that we are
only interested in local expansions. Any unexpanded bits are
then fed to check_ref_format(), which either disallows them
(in the case of "@{upstream}") or lets them through
("refs/heads/@" is technically valid, if a bit silly).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agobranch: restrict @-expansions when deleting
Jeff King [Thu, 2 Mar 2017 08:23:10 +0000 (03:23 -0500)]
branch: restrict @-expansions when deleting

We use strbuf_branchname() to expand the branch name from
the command line, so you can delete the branch given by
@{-1}, for example.  However, we allow other nonsense like
"@", and we do not respect our "-r" flag (so we may end up
deleting an oddly-named local ref instead of a remote one).

We can fix this by passing the appropriate "allowed" flag to
strbuf_branchname().

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot3204: test git-branch @-expansion corner cases
Jeff King [Thu, 2 Mar 2017 08:23:06 +0000 (03:23 -0500)]
t3204: test git-branch @-expansion corner cases

git-branch feeds the branch names from the command line to
strbuf_branchname(), but we do not yet tell that function
which kinds of expansions should be allowed. Let's create a
set of tests that cover both the allowed and disallowed
cases.

That shows off some breakages where we currently create or
delete the wrong ref (and will make sure that we do not
break any cases that _should_ be working when we do add more
restrictions).

Note that we check branch creation and deletion, but do not
bother with renames. Those follow the same code path as
creation.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agointerpret_branch_name: allow callers to restrict expansions
Jeff King [Thu, 2 Mar 2017 08:23:01 +0000 (03:23 -0500)]
interpret_branch_name: allow callers to restrict expansions

The interpret_branch_name() function converts names like
@{-1} and @{upstream} into branch names. The expanded ref
names are not fully qualified, and may be outside of the
refs/heads/ namespace (e.g., "@" expands to "HEAD", and
"@{upstream}" is likely to be in "refs/remotes/").

This is OK for callers like dwim_ref() which are primarily
interested in resolving the resulting name, no matter where
it is. But callers like "git branch" treat the result as a
branch name in refs/heads/.  When we expand to a ref outside
that namespace, the results are very confusing (e.g., "git
branch @" tries to create refs/heads/HEAD, which is
nonsense).

Callers can't know from the returned string how the
expansion happened (e.g., did the user really ask for a
branch named "HEAD", or did we do a bogus expansion?). One
fix would be to return some out-parameters describing the
types of expansion that occurred. This has the benefit that
the caller can generate precise error messages ("I
understood @{upstream} to mean origin/master, but that is a
remote tracking branch, so you cannot create it as a local
name").

However, out-parameters make the function interface somewhat
cumbersome. Instead, let's do the opposite: let the caller
tell us which elements to expand. That's easier to pass in,
and none of the callers give more precise error messages
than "@{upstream} isn't a valid branch name" anyway (which
should be sufficient).

The strbuf_branchname() function needs a similar parameter,
as most of the callers access interpret_branch_name()
through it.

We can break the callers down into two groups:

  1. Callers that are happy with any kind of ref in the
     result. We pass "0" here, so they continue to work
     without restrictions. This includes merge_name(),
     the reflog handling in add_pending_object_with_path(),
     and substitute_branch_name(). This last is what powers
     dwim_ref().

  2. Callers that have funny corner cases (mostly in
     git-branch and git-checkout). These need to make use of
     the new parameter, but I've left them as "0" in this
     patch, and will address them individually in follow-on
     patches.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agostrbuf_branchname: add docstring
Jeff King [Thu, 2 Mar 2017 08:21:30 +0000 (03:21 -0500)]
strbuf_branchname: add docstring

This function and its companion, strbuf_check_branch_ref(),
did not have their purpose or semantics explained. Let's do
so.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agostrbuf_branchname: drop return value
Jeff King [Thu, 2 Mar 2017 08:21:27 +0000 (03:21 -0500)]
strbuf_branchname: drop return value

The return value from strbuf_branchname() is confusing and
useless: it's 0 if the whole name was consumed by an @-mark,
but otherwise is the length of the original name we fed.

No callers actually look at the return value, so let's just
get rid of it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agointerpret_branch_name: move docstring to header file
Jeff King [Thu, 2 Mar 2017 08:21:23 +0000 (03:21 -0500)]
interpret_branch_name: move docstring to header file

We generally put docstrings with function declarations,
because it's the callers who need to know how the function
works. Let's do so for interpret_branch_name().

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agointerpret_branch_name(): handle auto-namelen for @{-1}
Jeff King [Mon, 27 Feb 2017 09:25:40 +0000 (04:25 -0500)]
interpret_branch_name(): handle auto-namelen for @{-1}

The interpret_branch_name() function takes a ptr/len pair
for the name, but you can pass "0" for "namelen", which will
cause it to check the length with strlen().

However, before we do that auto-namelen magic, we call
interpret_nth_prior_checkout(), which gets fed the bogus
"0". This was broken by 8cd4249c4 (interpret_branch_name:
always respect "namelen" parameter, 2014-01-15).  Though to
be fair to that commit, it was broken in the _opposite_
direction before, where we would always treat "name" as a
string even if a length was passed.

You can see the bug with "git log -g @{-1}". That code path
always passes "0", and without this patch it cannot figure
out which branch's reflog to show.

We can fix it by a small reordering of the code.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodiff: do not short-cut CHECK_SIZE_ONLY check in diff_populate_filespec()
Junio C Hamano [Wed, 1 Mar 2017 17:04:44 +0000 (18:04 +0100)]
diff: do not short-cut CHECK_SIZE_ONLY check in diff_populate_filespec()

Callers of diff_populate_filespec() can choose to ask only for the
size of the blob without grabbing the blob data, and the function,
after running lstat() when the filespec points at a working tree
file, returns by copying the value in size field of the stat
structure into the size field of the filespec when this is the case.

However, this short-cut cannot be taken if the contents from the
path needs to go through convert_to_git(), whose resulting real blob
data may be different from what is in the working tree file.

As "git diff --quiet" compares the .size fields of filespec
structures to skip content comparison, this bug manifests as a
false "there are differences" for a file that needs eol conversion,
for example.

Reported-by: Mike Crowe <mac@mcrowe.com>
Helped-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoadd--interactive: fix missing file prompt for patch mode with "-i"
Jeff King [Thu, 2 Mar 2017 09:48:22 +0000 (04:48 -0500)]
add--interactive: fix missing file prompt for patch mode with "-i"

When invoked as "git add -i", each menu interactive menu
option prompts the user to select a list of files. This
includes the "patch" option, which gets the list before
starting the hunk-selection loop.

As "git add -p", it behaves differently, and jumps straight
to the hunk selection loop.

Since 0539d5e6d (i18n: add--interactive: mark patch prompt
for translation, 2016-12-14), the "add -i" case mistakenly
jumps to straight to the hunk-selection loop. Prior to that
commit the distinction between the two cases was managed by
the $patch_mode variable. That commit used $patch_mode for
something else, and moved the old meaning to the "$cmd"
variable.  But it forgot to update the $patch_mode check
inside patch_update_cmd() which controls the file-list
behavior.

The simplest fix would be to change that line to check $cmd.
But while we're here, let's use a less obscure name for this
flag: $patch_mode_only, a boolean which tells whether we are
in full-interactive mode or only in patch-mode.

Reported-by: Henrik Grubbström <grubba@grubba.org>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopretty: use fmt_output_email_subject()
René Scharfe [Wed, 1 Mar 2017 11:37:07 +0000 (12:37 +0100)]
pretty: use fmt_output_email_subject()

Add the email-style subject prefix (e.g. "Subject: [PATCH] ") directly
when it's needed instead of letting log_write_email_headers() prepare
it in a static buffer in advance.  This simplifies storage ownership and
code flow.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoREADME: create HTTP/HTTPS links from URLs in Markdown
Eric Wong [Wed, 1 Mar 2017 22:22:04 +0000 (22:22 +0000)]
README: create HTTP/HTTPS links from URLs in Markdown

Markdown supports automatic links by surrounding URLs with
angle brackets, as documented in
<https://daringfireball.net/projects/markdown/syntax#autolink>

While we're at it, update URLs to avoid redirecting clients for
git-scm.com (by using HTTPS) and public-inbox.org (by adding a
trailing slash).

Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogitweb tests: skip tests when we don't have Time::HiRes
Ævar Arnfjörð Bjarmason [Wed, 1 Mar 2017 21:15:40 +0000 (21:15 +0000)]
gitweb tests: skip tests when we don't have Time::HiRes

Change the gitweb tests to skip when we can't load the Time::HiRes
module.

Gitweb needs this module to work. It has been in perl core since v5.8,
which is the oldest version we support. However CentOS (and perhaps
some other distributions) carve it into its own non-core-perl package
that's not installed along with /usr/bin/perl by default. Without this
we'll hard fail the gitweb tests when trying to load the module.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogitweb tests: change confusing "skip_all" phrasing
Ævar Arnfjörð Bjarmason [Wed, 1 Mar 2017 21:15:39 +0000 (21:15 +0000)]
gitweb tests: change confusing "skip_all" phrasing

Change the phrasing so that instead of saying that the CGI module is
unusable, we say that it's not available.

This came up on the git mailing list in
<4b34e3a0-3da7-d821-2a7f-9a420ac1d3f6@gmail.com> from Jakub Narębski.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agolog-tree: factor out fmt_output_email_subject()
René Scharfe [Wed, 1 Mar 2017 11:36:38 +0000 (12:36 +0100)]
log-tree: factor out fmt_output_email_subject()

Use a strbuf to store the subject prefix string and move its
construction into its own function.  This gets rid of two arbitrary
length limits and allows the string to be added by callers directly.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agostash: allow pathspecs in the no verb form
Thomas Gummerer [Tue, 28 Feb 2017 20:33:40 +0000 (20:33 +0000)]
stash: allow pathspecs in the no verb form

Now that stash_push is used in the no verb form of stash, allow
specifying the command line for this form as well.  Always use -- to
disambiguate pathspecs from other non-option arguments.

Also make git stash -p an alias for git stash push -p.  This allows
users to use git stash -p <pathspec>.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agostash: use stash_push for no verb form
Thomas Gummerer [Tue, 28 Feb 2017 20:33:39 +0000 (20:33 +0000)]
stash: use stash_push for no verb form

Now that we have stash_push, which accepts pathspec arguments, use
it instead of stash_save in git stash without any additional verbs.

Previously we allowed git stash -- -message, which is no longer allowed
after this patch.  Messages starting with a hyphen was allowed since
3c2eb80f, ("stash: simplify defaulting to "save" and reject unknown
options").  However it was never the intent to allow that, but rather it
was allowed accidentally.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agostash: teach 'push' (and 'create_stash') to honor pathspec
Thomas Gummerer [Tue, 28 Feb 2017 20:33:38 +0000 (20:33 +0000)]
stash: teach 'push' (and 'create_stash') to honor pathspec

While working on a repository, it's often helpful to stash the changes
of a single or multiple files, and leave others alone.  Unfortunately
git currently offers no such option.  git stash -p can be used to work
around this, but it's often impractical when there are a lot of changes
over multiple files.

Allow 'git stash push' to take pathspec to specify which paths to stash.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosubmodule init: warn about falling back to a local path
Stefan Beller [Sat, 25 Feb 2017 01:31:47 +0000 (17:31 -0800)]
submodule init: warn about falling back to a local path

When a submodule is initialized, the config variable 'submodule.<name>.url'
is set depending on the value of the same variable in the .gitmodules
file. When the URL indicates to be relative, then the url is computed
relative to its default remote. The default remote cannot be determined
accurately in all cases, such that it falls back to 'origin'.

The 'origin' remote may not exist, though. In that case we give up looking
for a suitable remote and we'll just assume it to be a local relative path.

This can be confusing to users as there is a lot of guessing involved,
which is not obvious to the user.

So in the corner case of assuming a local autoritative truth, warn the
user to lessen the confusion.

This behavior was introduced in 4d6893200 (submodule add: allow relative
repository path even when no url is set, 2011-06-06), which shared the
code with submodule-init and then ported to C in 3604242f080a (submodule:
port init from shell to C, 2016-04-15).

In case of submodule-add, this behavior makes sense in some use cases[1],
however for submodule-init there does not seem to be an immediate obvious
use case to fall back to a local submodule. However there might be, so
warn instead of die here.

While adding the warning, also clarify the behavior of relative URLs in
the documentation.

[1] e.g. http://stackoverflow.com/questions/8721984/git-ignore-files-for-public-repository-but-not-for-private
"store a secret locally in a submodule, with no intention to publish it"

Reported-by: Shawn Pearce <spearce@spearce.org>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agowrapper.c: remove unused gitmkstemps() function
Ramsay Jones [Tue, 28 Feb 2017 01:26:06 +0000 (01:26 +0000)]
wrapper.c: remove unused gitmkstemps() function

The last call to the mkstemps() function was removed in commit 659488326
("wrapper.c: delete dead function git_mkstemps()", 22-04-2016). In order
to support platforms without mkstemps(), this functionality was provided,
along with a Makefile build variable (NO_MKSTEMPS), by the gitmkstemps()
function. Remove the dead code, along with the defunct build machinery.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agowrapper.c: remove unused git_mkstemp() function
Ramsay Jones [Tue, 28 Feb 2017 01:24:10 +0000 (01:24 +0000)]
wrapper.c: remove unused git_mkstemp() function

The last caller of git_mkstemp() was removed in commit 6fec0a89
("verify_signed_buffer: use tempfile object", 16-06-2016). Since
the introduction of the 'tempfile' APIs, along with git_mkstemp_mode,
it is unlikely that new callers will materialize. Remove the dead
code.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agohttp: attempt updating base URL only if no error
Jonathan Tan [Tue, 28 Feb 2017 02:53:11 +0000 (18:53 -0800)]
http: attempt updating base URL only if no error

http.c supports HTTP redirects of the form

  http://foo/info/refs?service=git-upload-pack
  -> http://anything
  -> http://bar/info/refs?service=git-upload-pack

(that is to say, as long as the Git part of the path and the query
string is preserved in the final redirect destination, the intermediate
steps can have any URL). However, if one of the intermediate steps
results in an HTTP exception, a confusing "unable to update url base
from redirection" message is printed instead of a Curl error message
with the HTTP exception code.

This was introduced by 2 commits. Commit c93c92f ("http: update base
URLs when we see redirects", 2013-09-28) introduced a best-effort
optimization that required checking if only the "base" part of the URL
differed between the initial request and the final redirect destination,
but it performed the check before any HTTP status checking was done. If
something went wrong, the normal code path was still followed, so this
did not cause any confusing error messages until commit 6628eb4 ("http:
always update the base URL for redirects", 2016-12-06), which taught
http to die if the non-"base" part of the URL differed.

Therefore, teach http to check the HTTP status before attempting to
check if only the "base" part of the URL differed. This commit teaches
http_request_reauth to return early without updating options->base_url
upon an error; the only invoker of this function that passes a non-NULL
"options" is remote-curl.c (through "http_get_strbuf"), which only uses
options->base_url for an informational message in the situations that
this commit cares about (that is, when the return value is not HTTP_OK).

The included test checks that the redirect scheme at the beginning of
this commit message works, and that returning a 502 in the middle of the
redirect scheme produces the correct result. Note that this is different
from the test in commit 6628eb4 ("http: always update the base URL for
redirects", 2016-12-06) in that this commit tests that a Git-shaped URL
(http://.../info/refs?service=git-upload-pack) works, whereas commit
6628eb4 tests that a non-Git-shaped URL
(http://.../info/refs/foo?service=git-upload-pack) does not work (even
though Git is processing that URL) and is an error that is fatal, not
silently swallowed.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodocs/diffcore: unquote "Complete Rewrites" in headers
Patrick Steinhardt [Tue, 28 Feb 2017 08:59:05 +0000 (09:59 +0100)]
docs/diffcore: unquote "Complete Rewrites" in headers

The gitdiffcore documentation quotes the term "Complete Rewrites" in
headers for no real gain. This would make sense if the term could be
easily confused if not properly grouped together. But actually, the term
is quite obvious and thus does not really need any quoting, especially
regarding that it is not used anywhere else.

But more importanly, this brings up a bug when rendering man pages: when
trying to render quotes inside of a section header, we end up with
quotes which have been misaligned to the end of line. E.g.

    diffcore-break: For Splitting Up Complete Rewrites
    --------------------------------------------------

renders as

    DIFFCORE-BREAK: FOR SPLITTING UP  COMPLETE REWRITES""

, which is obviously wrong. While this is fixable for the man pages by
using double-quotes (e.g. ""COMPLETE REWRITES""), this again breaks it
for our generated HTML pages.

So fix the issue by simply dropping quotes inside of section headers,
which is currently only done for the term "Complete Rewrites".

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodocs/diffcore: fix grammar in diffcore-rename header
Patrick Steinhardt [Tue, 28 Feb 2017 08:59:04 +0000 (09:59 +0100)]
docs/diffcore: fix grammar in diffcore-rename header

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoFirst batch after 2.12
Junio C Hamano [Mon, 27 Feb 2017 22:04:24 +0000 (14:04 -0800)]
First batch after 2.12

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'rl/remote-allow-missing-branch-name-merge'
Junio C Hamano [Mon, 27 Feb 2017 21:57:18 +0000 (13:57 -0800)]
Merge branch 'rl/remote-allow-missing-branch-name-merge'

"git remote rm X", when a branch has remote X configured as the
value of its branch.*.remote, tried to remove branch.*.remote and
branch.*.merge and failed if either is unset.

* rl/remote-allow-missing-branch-name-merge:
  remote: ignore failure to remove missing branch.<name>.merge

7 years agoMerge branch 'km/delete-ref-reflog-message'
Junio C Hamano [Mon, 27 Feb 2017 21:57:18 +0000 (13:57 -0800)]
Merge branch 'km/delete-ref-reflog-message'

"git update-ref -d" and other operations to delete references did
not leave any entry in HEAD's reflog when the reference being
deleted was the current branch.  This is not a problem in practice
because you do not want to delete the branch you are currently on,
but caused renaming of the current branch to something else not to
be logged in a useful way.

* km/delete-ref-reflog-message:
  branch: record creation of renamed branch in HEAD's log
  rename_ref: replace empty message in HEAD's log
  update-ref: pass reflog message to delete_ref()
  delete_ref: accept a reflog message argument

7 years agoMerge branch 'jk/tempfile-ferror-fclose-confusion'
Junio C Hamano [Mon, 27 Feb 2017 21:57:18 +0000 (13:57 -0800)]
Merge branch 'jk/tempfile-ferror-fclose-confusion'

A caller of tempfile API that uses stdio interface to write to
files may ignore errors while writing, which is detected when
tempfile is closed (with a call to ferror()).  By that time, the
original errno that may have told us what went wrong is likely to
be long gone and was overwritten by an irrelevant value.
close_tempfile() now resets errno to EIO to make errno at least
predictable.

* jk/tempfile-ferror-fclose-confusion:
  tempfile: set errno to a known value before calling ferror()

7 years agoMerge branch 'vn/xdiff-func-context'
Junio C Hamano [Mon, 27 Feb 2017 21:57:17 +0000 (13:57 -0800)]
Merge branch 'vn/xdiff-func-context'

"git diff -W" has been taught to handle the case where a new
function is added at the end of the file better.

* vn/xdiff-func-context:
  xdiff -W: relax end-of-file function detection

7 years agoMerge branch 'js/git-path-in-subdir'
Junio C Hamano [Mon, 27 Feb 2017 21:57:17 +0000 (13:57 -0800)]
Merge branch 'js/git-path-in-subdir'

The "--git-path", "--git-common-dir", and "--shared-index-path"
options of "git rev-parse" did not produce usable output.  They are
now updated to show the path to the correct file, relative to where
the caller is.

* js/git-path-in-subdir:
  rev-parse: fix several options when running in a subdirectory
  rev-parse tests: add tests executed from a subdirectory

7 years agoMerge branch 'mm/two-more-xstrfmt'
Junio C Hamano [Mon, 27 Feb 2017 21:57:17 +0000 (13:57 -0800)]
Merge branch 'mm/two-more-xstrfmt'

Code clean-up and a string truncation fix.

* mm/two-more-xstrfmt:
  bisect_next_all: convert xsnprintf to xstrfmt
  stop_progress_msg: convert xsnprintf to xstrfmt

7 years agoMerge branch 'nd/clean-preserve-errno-in-warning'
Junio C Hamano [Mon, 27 Feb 2017 21:57:16 +0000 (13:57 -0800)]
Merge branch 'nd/clean-preserve-errno-in-warning'

Some warning() messages from "git clean" were updated to show the
errno from failed system calls.

* nd/clean-preserve-errno-in-warning:
  clean: use warning_errno() when appropriate

7 years agoMerge branch 'jk/show-branch-lift-name-len-limit'
Junio C Hamano [Mon, 27 Feb 2017 21:57:16 +0000 (13:57 -0800)]
Merge branch 'jk/show-branch-lift-name-len-limit'

"git show-branch" expected there were only very short branch names
in the repository and used a fixed-length buffer to hold them
without checking for overflow.

* jk/show-branch-lift-name-len-limit:
  show-branch: use skip_prefix to drop magic numbers
  show-branch: store resolved head in heap buffer
  show-branch: drop head_len variable

7 years agoMerge branch 'jn/remote-helpers-with-git-dir'
Junio C Hamano [Mon, 27 Feb 2017 21:57:16 +0000 (13:57 -0800)]
Merge branch 'jn/remote-helpers-with-git-dir'

"git ls-remote" and "git archive --remote" are designed to work
without being in a directory under Git's control.  However, recent
updates revealed that we randomly look into a directory called
.git/ without actually doing necessary set-up when working in a
repository.  Stop doing so.

* jn/remote-helpers-with-git-dir:
  remote helpers: avoid blind fall-back to ".git" when setting GIT_DIR
  remote: avoid reading $GIT_DIR config in non-repo

7 years agoMerge branch 'jk/grep-no-index-fix'
Junio C Hamano [Mon, 27 Feb 2017 21:57:15 +0000 (13:57 -0800)]
Merge branch 'jk/grep-no-index-fix'

The code to parse the command line "git grep <patterns>... <rev>
[[--] <pathspec>...]" has been cleaned up, and a handful of bugs
have been fixed (e.g. we used to check "--" if it is a rev).

* jk/grep-no-index-fix:
  grep: treat revs the same for --untracked as for --no-index
  grep: do not diagnose misspelt revs with --no-index
  grep: avoid resolving revision names in --no-index case
  grep: fix "--" rev/pathspec disambiguation
  grep: re-order rev-parsing loop
  grep: do not unnecessarily query repo for "--"
  grep: move thread initialization a little lower

7 years agoMerge branch 'dt/gc-ignore-old-gc-logs'
Junio C Hamano [Mon, 27 Feb 2017 21:57:15 +0000 (13:57 -0800)]
Merge branch 'dt/gc-ignore-old-gc-logs'

A "gc.log" file left by a backgrounded "gc --auto" disables further
automatic gc; it has been taught to run at least once a day (by
default) by ignoring a stale "gc.log" file that is too old.

* dt/gc-ignore-old-gc-logs:
  gc: ignore old gc.log files

7 years agoMerge branch 'jh/preload-index-skip-skip'
Junio C Hamano [Mon, 27 Feb 2017 21:57:15 +0000 (13:57 -0800)]
Merge branch 'jh/preload-index-skip-skip'

The preload-index code has been taught not to bother with the index
entries that are paths that are not checked out by "sparse checkout".

* jh/preload-index-skip-skip:
  preload-index: avoid lstat for skip-worktree items

7 years agoMerge branch 'mh/submodule-hash'
Junio C Hamano [Mon, 27 Feb 2017 21:57:15 +0000 (13:57 -0800)]
Merge branch 'mh/submodule-hash'

Code and design clean-up for the refs API.

* mh/submodule-hash:
  read_loose_refs(): read refs using resolve_ref_recursively()
  files_ref_store::submodule: use NULL for the main repository
  base_ref_store_init(): remove submodule argument
  refs: push the submodule attribute down
  refs: store submodule ref stores in a hashmap
  register_ref_store(): new function
  refs: remove some unnecessary handling of submodule == ""
  refs: make some ref_store lookup functions private
  refs: reorder some function definitions

7 years agoMerge branch 'sf/putty-w-args'
Junio C Hamano [Mon, 27 Feb 2017 21:57:14 +0000 (13:57 -0800)]
Merge branch 'sf/putty-w-args'

The command line options for ssh invocation needs to be tweaked for
some implementations of SSH (e.g. PuTTY plink wants "-P <port>"
while OpenSSH wants "-p <port>" to specify port to connect to), and
the variant was guessed when GIT_SSH environment variable is used
to specify it.  The logic to guess now applies to the command
specified by the newer GIT_SSH_COMMAND and also core.sshcommand
configuration variable, and comes with an escape hatch for users to
deal with misdetected cases.

* sf/putty-w-args:
  connect.c: stop conflating ssh command names and overrides
  connect: Add the envvar GIT_SSH_VARIANT and ssh.variant config
  git_connect(): factor out SSH variant handling
  connect: rename tortoiseplink and putty variables
  connect: handle putty/plink also in GIT_SSH_COMMAND

7 years agoMerge branch 'js/rebase-helper'
Junio C Hamano [Mon, 27 Feb 2017 21:57:14 +0000 (13:57 -0800)]
Merge branch 'js/rebase-helper'

"git rebase -i" starts using the recently updated "sequencer" code.

* js/rebase-helper:
  rebase -i: use the rebase--helper builtin
  rebase--helper: add a builtin helper for interactive rebases

7 years agoMerge branch 'bw/attr'
Junio C Hamano [Mon, 27 Feb 2017 21:57:14 +0000 (13:57 -0800)]
Merge branch 'bw/attr'

The gitattributes machinery is being taught to work better in a
multi-threaded environment.

* bw/attr: (27 commits)
  attr: reformat git_attr_set_direction() function
  attr: push the bare repo check into read_attr()
  attr: store attribute stack in attr_check structure
  attr: tighten const correctness with git_attr and match_attr
  attr: remove maybe-real, maybe-macro from git_attr
  attr: eliminate global check_all_attr array
  attr: use hashmap for attribute dictionary
  attr: change validity check for attribute names to use positive logic
  attr: pass struct attr_check to collect_some_attrs
  attr: retire git_check_attrs() API
  attr: convert git_check_attrs() callers to use the new API
  attr: convert git_all_attrs() to use "struct attr_check"
  attr: (re)introduce git_check_attr() and struct attr_check
  attr: rename function and struct related to checking attributes
  attr.c: outline the future plans by heavily commenting
  Documentation: fix a typo
  attr.c: add push_stack() helper
  attr: support quoting pathname patterns in C style
  attr.c: plug small leak in parse_attr_line()
  attr.c: tighten constness around "git_attr" structure
  ...

7 years agoMerge branch 'sg/completion'
Junio C Hamano [Mon, 27 Feb 2017 21:57:14 +0000 (13:57 -0800)]
Merge branch 'sg/completion'

Clean-up and updates to command line completion (in contrib/).

* sg/completion: (22 commits)
  completion: restore removed line continuating backslash
  completion: cache the path to the repository
  completion: extract repository discovery from __gitdir()
  completion: don't guard git executions with __gitdir()
  completion: consolidate silencing errors from git commands
  completion: don't use __gitdir() for git commands
  completion: respect 'git -C <path>'
  rev-parse: add '--absolute-git-dir' option
  completion: fix completion after 'git -C <path>'
  completion: don't offer commands when 'git --opt' needs an argument
  completion: list short refs from a remote given as a URL
  completion: don't list 'HEAD' when trying refs completion outside of a repo
  completion: list refs from remote when remote's name matches a directory
  completion: respect 'git --git-dir=<path>' when listing remote refs
  completion: fix most spots not respecting 'git --git-dir=<path>'
  completion: ensure that the repository path given on the command line exists
  completion tests: add tests for the __git_refs() helper function
  completion tests: check __gitdir()'s output in the error cases
  completion tests: consolidate getting path of current working directory
  completion tests: make the $cur variable local to the test helper functions
  ...