git.git
7 years agoMerge branch 'nd/shared-index-fix' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:16 +0000 (14:24 -0700)]
Merge branch 'nd/shared-index-fix' into maint

Code clean-up.

* nd/shared-index-fix:
  read-cache: don't write index twice if we can't write shared index
  read-cache.c: move tempfile creation/cleanup out of write_shared_index
  read-cache.c: change type of "temp" in write_shared_index()

7 years agoMerge branch 'jc/mailinfo-cleanup-fix' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:16 +0000 (14:24 -0700)]
Merge branch 'jc/mailinfo-cleanup-fix' into maint

Corner case bugfix.

* jc/mailinfo-cleanup-fix:
  mailinfo: avoid segfault when can't open files

7 years agoMerge branch 'rb/hashmap-h-compilation-fix' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:15 +0000 (14:24 -0700)]
Merge branch 'rb/hashmap-h-compilation-fix' into maint

Code clean-up.

* rb/hashmap-h-compilation-fix:
  hashmap.h: remove unused variable

7 years agoMerge branch 'rs/describe-unique-abbrev' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:14 +0000 (14:24 -0700)]
Merge branch 'rs/describe-unique-abbrev' into maint

Code clean-up.

* rs/describe-unique-abbrev:
  describe: use strbuf_add_unique_abbrev() for adding short hashes

7 years agoMerge branch 'ks/submodule-doc-updates' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:13 +0000 (14:24 -0700)]
Merge branch 'ks/submodule-doc-updates' into maint

Doc updates.

* ks/submodule-doc-updates:
  Doc/git-submodule: improve readability and grammar of a sentence
  Doc/gitsubmodules: make some changes to improve readability and syntax

7 years agoMerge branch 'cl/t9001-cleanup' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:13 +0000 (14:24 -0700)]
Merge branch 'cl/t9001-cleanup' into maint

Test clean-up.

* cl/t9001-cleanup:
  t9001: use existing helper in send-email test

7 years agoMerge branch 'bw/oidmap-autoinit' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:12 +0000 (14:24 -0700)]
Merge branch 'bw/oidmap-autoinit' into maint

Code clean-up.

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

7 years agoMerge branch 'sg/test-i18ngrep' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:12 +0000 (14:24 -0700)]
Merge branch 'sg/test-i18ngrep' into maint

Test fixes.

* sg/test-i18ngrep:
  t: make 'test_i18ngrep' more informative on failure
  t: validate 'test_i18ngrep's parameters
  t: move 'test_i18ncmp' and 'test_i18ngrep' to 'test-lib-functions.sh'
  t5536: let 'test_i18ngrep' read the file without redirection
  t5510: consolidate 'grep' and 'test_i18ngrep' patterns
  t4001: don't run 'git status' upstream of a pipe
  t6022: don't run 'git merge' upstream of a pipe
  t5812: add 'test_i18ngrep's missing filename parameter
  t5541: add 'test_i18ngrep's missing filename parameter

7 years agoMerge branch 'jt/fsck-code-cleanup' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:12 +0000 (14:24 -0700)]
Merge branch 'jt/fsck-code-cleanup' into maint

Plug recently introduced leaks in fsck.

* jt/fsck-code-cleanup:
  fsck: fix leak when traversing trees

7 years agoMerge branch 'ew/svn-branch-segfault-fix' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:11 +0000 (14:24 -0700)]
Merge branch 'ew/svn-branch-segfault-fix' into maint

Workaround for segfault with more recent versions of SVN.

* ew/svn-branch-segfault-fix:
  git-svn: control destruction order to avoid segfault

7 years agoMerge branch 'nd/list-merge-strategy' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:11 +0000 (14:24 -0700)]
Merge branch 'nd/list-merge-strategy' into maint

Completion of "git merge -s<strategy>" (in contrib/) did not work
well in non-C locale.

* nd/list-merge-strategy:
  completion: fix completing merge strategies on non-C locales

7 years agoMerge branch 'jk/daemon-fixes' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:10 +0000 (14:24 -0700)]
Merge branch 'jk/daemon-fixes' into maint

Assorted fixes to "git daemon".

* jk/daemon-fixes:
  daemon: fix length computation in newline stripping
  t/lib-git-daemon: add network-protocol helpers
  daemon: handle NULs in extended attribute string
  daemon: fix off-by-one in logging extended attributes
  t/lib-git-daemon: record daemon log
  t5570: use ls-remote instead of clone for interp tests

7 years agoMerge branch 'tg/split-index-fixes' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:10 +0000 (14:24 -0700)]
Merge branch 'tg/split-index-fixes' into maint

The split-index mode had a few corner case bugs fixed.

* tg/split-index-fixes:
  travis: run tests with GIT_TEST_SPLIT_INDEX
  split-index: don't write cache tree with null oid entries
  read-cache: fix reading the shared index for other repos

7 years agoMerge branch 'mr/packed-ref-store-fix' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:10 +0000 (14:24 -0700)]
Merge branch 'mr/packed-ref-store-fix' into maint

Crash fix for a corner case where an error codepath tried to unlock
what it did not acquire lock on.

* mr/packed-ref-store-fix:
  files_initial_transaction_commit(): only unlock if locked

7 years agoMerge branch 'jt/http-redact-cookies' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:09 +0000 (14:24 -0700)]
Merge branch 'jt/http-redact-cookies' into maint

The http tracing code, often used to debug connection issues,
learned to redact potentially sensitive information from its output
so that it can be more safely sharable.

* jt/http-redact-cookies:
  http: support omitting data from traces
  http: support cookie redaction when tracing

7 years agoMerge branch 'nd/diff-flush-before-warning' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:09 +0000 (14:24 -0700)]
Merge branch 'nd/diff-flush-before-warning' into maint

Avoid showing a warning message in the middle of a line of "git
diff" output.

* nd/diff-flush-before-warning:
  diff.c: flush stdout before printing rename warnings

7 years agoMerge branch 'sg/travis-build-during-script-phase' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:08 +0000 (14:24 -0700)]
Merge branch 'sg/travis-build-during-script-phase' into maint

Build the executable in 'script' phase in Travis CI integration, to
follow the established practice, rather than during 'before_script'
phase.  This allows the CI categorize the failures better ('failed'
is project's fault, 'errored' is build environment's).

* sg/travis-build-during-script-phase:
  travis-ci: build Git during the 'script' phase

7 years agoparse-options: do not show usage upon invalid option value
Paul-Sebastian Ungureanu [Thu, 22 Mar 2018 18:43:51 +0000 (20:43 +0200)]
parse-options: do not show usage upon invalid option value

Usually, the usage should be shown only if the user does not know what
options are available. If the user specifies an invalid value, the user
is already aware of the available options. In this case, there is no
point in displaying the usage anymore.

This patch applies to "git tag --contains", "git branch --contains",
"git branch --points-at", "git for-each-ref --contains" and many more.

Signed-off-by: Paul-Sebastian Ungureanu <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agosha1_name: use bsearch_pack() for abbreviations
Derrick Stolee [Thu, 22 Mar 2018 17:40:10 +0000 (13:40 -0400)]
sha1_name: use bsearch_pack() for abbreviations

When computing abbreviation lengths for an object ID against a single
packfile, the method find_abbrev_len_for_pack() currently implements
binary search. This is one of several implementations. One issue with
this implementation is that it ignores the fanout table in the pack-
index.

Translate this binary search to use the existing bsearch_pack() method
that correctly uses a fanout table.

Due to the use of the fanout table, the abbreviation computation is
slightly faster than before. For a fully-repacked copy of the Linux
repo, the following 'git log' commands improved:

* git log --oneline --parents --raw
  Before: 59.2s
  After:  56.9s
  Rel %:  -3.8%

* git log --oneline --parents
  Before: 6.48s
  After:  5.91s
  Rel %: -8.9%

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agopackfile: define and use bsearch_pack()
Derrick Stolee [Thu, 22 Mar 2018 17:40:09 +0000 (13:40 -0400)]
packfile: define and use bsearch_pack()

The method bsearch_hash() generalizes binary searches using a
fanout table. The only consumer is currently find_pack_entry_one().
It requires a bit of pointer arithmetic to align the fanout table
and the lookup table depending on the pack-index version.

Extract the pack-index pointer arithmetic to a new method,
bsearch_pack(), so this can be re-used in other code paths.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agosha1_name: convert struct min_abbrev_data to object_id
brian m. carlson [Thu, 22 Mar 2018 17:40:08 +0000 (13:40 -0400)]
sha1_name: convert struct min_abbrev_data to object_id

This structure is only written to in one place, where we already have a
struct object_id.  Convert the struct to use a struct object_id instead.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agocompletion: clear cached --options when sourcing the completion script
SZEDER Gábor [Thu, 22 Mar 2018 14:16:04 +0000 (15:16 +0100)]
completion: clear cached --options when sourcing the completion script

The established way to update the completion script in an already
running shell is to simply source it again: this brings in any new
--options and features, and clears caching variables.  E.g. it clears
the variables caching the list of (all|porcelain) git commands, so
when they are later lazy-initialized again, then they will list and
cache any newly installed commmands as well.

Unfortunately, since d401f3debc (git-completion.bash: introduce
__gitcomp_builtin, 2018-02-09) and subsequent patches this doesn't
work for a lot of git commands' options.  To eliminate a lot of
hard-to-maintain hard-coded lists of options, those commits changed
the completion script to use a bunch of programmatically created and
lazy-initialized variables to cache the options of those builtin
porcelain commands that use parse-options.  These variables are not
cleared upon sourcing the completion script, therefore they continue
caching the old lists of options, even when some commands recently
learned new options or when deprecated options were removed.

Always 'unset' these variables caching the options of builtin commands
when sourcing the completion script.

Redirect 'unset's stderr to /dev/null, because ZSH's 'unset' complains
if it's invoked without any arguments, i.e. no variables caching
builtin's options are set.  This can happen, if someone were to source
the completion script twice without completing any --options in
between.  Bash stays silent in this case.

Add tests to ensure that these variables are indeed cleared when the
completion script is sourced; not just the variables caching options,
but all other caching variables, i.e. the variables caching commands,
porcelain commands and merge strategies as well.

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agostash: drop superfluos pathspec parameter
Thomas Gummerer [Wed, 21 Mar 2018 21:53:10 +0000 (21:53 +0000)]
stash: drop superfluos pathspec parameter

Since 833622a945 ("stash push: avoid printing errors", 2018-03-19) we
don't use the 'git clean' call for the pathspec case anymore.  The
commit however forgot to remove the pathspec argument to the call.
Remove the superfluos argument to make the code a little more obvious.

Signed-off-by: Thomas Gummerer <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoGit 2.17-rc1
Junio C Hamano [Wed, 21 Mar 2018 19:02:04 +0000 (12:02 -0700)]
Git 2.17-rc1

Signed-off-by: Junio C Hamano <redacted>
7 years agoMerge branch 'jk/attributes-path-doc'
Junio C Hamano [Wed, 21 Mar 2018 18:30:15 +0000 (11:30 -0700)]
Merge branch 'jk/attributes-path-doc'

Doc update.

* jk/attributes-path-doc:
  doc/gitattributes: mention non-recursive behavior

7 years agoMerge branch 'rj/warning-uninitialized-fix'
Junio C Hamano [Wed, 21 Mar 2018 18:30:15 +0000 (11:30 -0700)]
Merge branch 'rj/warning-uninitialized-fix'

Compilation fix.

* rj/warning-uninitialized-fix:
  read-cache: fix an -Wmaybe-uninitialized warning
  -Wuninitialized: remove some 'init-self' workarounds

7 years agoMerge branch 'tz/complete-tag-delete-tagname'
Junio C Hamano [Wed, 21 Mar 2018 18:30:15 +0000 (11:30 -0700)]
Merge branch 'tz/complete-tag-delete-tagname'

* tz/complete-tag-delete-tagname:
  completion: complete tags with git tag --delete/--verify

7 years agoMerge branch 'ml/filter-branch-portability-fix'
Junio C Hamano [Wed, 21 Mar 2018 18:30:14 +0000 (11:30 -0700)]
Merge branch 'ml/filter-branch-portability-fix'

Shell script portability fix.

* ml/filter-branch-portability-fix:
  filter-branch: use printf instead of echo -e

7 years agoMerge branch 'js/ming-strftime'
Junio C Hamano [Wed, 21 Mar 2018 18:30:14 +0000 (11:30 -0700)]
Merge branch 'js/ming-strftime'

* js/ming-strftime:
  mingw: abort on invalid strftime formats

7 years agoMerge branch 'dp/merge-strategy-doc-fix'
Junio C Hamano [Wed, 21 Mar 2018 18:30:13 +0000 (11:30 -0700)]
Merge branch 'dp/merge-strategy-doc-fix'

Doc fix.

* dp/merge-strategy-doc-fix:
  Documentation/merge-strategies: typofix

7 years agoMerge branch 'tz/relnotes-1.7-on-perl'
Junio C Hamano [Wed, 21 Mar 2018 18:30:12 +0000 (11:30 -0700)]
Merge branch 'tz/relnotes-1.7-on-perl'

* tz/relnotes-1.7-on-perl:
  RelNotes: add details on Perl module changes

7 years agoMerge branch 'rj/http-code-cleanup'
Junio C Hamano [Wed, 21 Mar 2018 18:30:12 +0000 (11:30 -0700)]
Merge branch 'rj/http-code-cleanup'

There was an unused file-scope static variable left in http.c when
building for versions of libCURL that is older than 7.19.4, which
has been fixed.

* rj/http-code-cleanup:
  http: fix an unused variable warning for 'curl_no_proxy'

7 years agoMerge branch 'ks/t3200-typofix'
Junio C Hamano [Wed, 21 Mar 2018 18:30:12 +0000 (11:30 -0700)]
Merge branch 'ks/t3200-typofix'

Test typofix.

* ks/t3200-typofix:
  t/t3200: fix a typo in a test description

7 years agoMerge branch 'jt/transfer-fsck-with-promissor'
Junio C Hamano [Wed, 21 Mar 2018 18:30:11 +0000 (11:30 -0700)]
Merge branch 'jt/transfer-fsck-with-promissor'

The transfer.fsckobjects configuration tells "git fetch" to
validate the data and connected-ness of objects in the received
pack; the code to perform this check has been taught about the
narrow clone's convention that missing objects that are reachable
from objects in a pack that came from a promissor remote is OK.

* jt/transfer-fsck-with-promissor:
  fetch-pack: do not check links for partial fetch
  index-pack: support checking objects but not links

7 years agoMerge branch 'bp/refresh-cache-ent-rehash-fix'
Junio C Hamano [Wed, 21 Mar 2018 18:30:11 +0000 (11:30 -0700)]
Merge branch 'bp/refresh-cache-ent-rehash-fix'

The codepath to replace an existing entry in the index had a bug in
updating the name hash structure, which has been fixed.

* bp/refresh-cache-ent-rehash-fix:
  Fix bugs preventing adding updated cache entries to the name hash

7 years agoMerge branch 'jh/fsck-promisors'
Junio C Hamano [Wed, 21 Mar 2018 18:30:10 +0000 (11:30 -0700)]
Merge branch 'jh/fsck-promisors'

A hotfix to a topic that graduated recently.

* jh/fsck-promisors:
  sha1_file: restore OBJECT_INFO_QUICK functionality

7 years agoMerge branch 'ma/skip-writing-unchanged-index'
Junio C Hamano [Wed, 21 Mar 2018 18:30:10 +0000 (11:30 -0700)]
Merge branch 'ma/skip-writing-unchanged-index'

Internal API clean-up to allow write_locked_index() optionally skip
writing the in-core index when it is not modified.

* ma/skip-writing-unchanged-index:
  write_locked_index(): add flag to avoid writing unchanged index

7 years agoMerge branch 'ma/config-page-only-in-list-mode'
Junio C Hamano [Wed, 21 Mar 2018 18:30:09 +0000 (11:30 -0700)]
Merge branch 'ma/config-page-only-in-list-mode'

In a way similar to how "git tag" learned to honor the pager
setting only in the list mode, "git config" learned to ignore the
pager setting when it is used for setting values (i.e. when the
purpose of the operation is not to "show").

* ma/config-page-only-in-list-mode:
  config: change default of `pager.config` to "on"
  config: respect `pager.config` in list/get-mode only
  t7006: add tests for how git config paginates

7 years agodiff-highlight: detect --graph by indent
Jeff King [Wed, 21 Mar 2018 05:59:01 +0000 (01:59 -0400)]
diff-highlight: detect --graph by indent

This patch fixes a corner case where diff-highlight may
scramble some diffs when combined with --graph.

Commit 7e4ffb4c17 (diff-highlight: add support for --graph
output, 2016-08-29) taught diff-highlight to skip past the
graph characters at the start of each line with this regex:

  ($COLOR?\|$COLOR?\s+)*

I.e., any series of pipes separated by and followed by
arbitrary whitespace.  We need to match more than just a
single space because the commit in question may be indented
to accommodate other parts of the graph drawing. E.g.:

 * commit 1234abcd
 | ...
 | diff --git ...

has only a single space, but for the last commit before a
fork:

 | | |
 | * | commit 1234abcd
 | |/  ...
 | |   diff --git

the diff lines have more spaces between the pipes and the
start of the diff.

However, when we soak up all of those spaces with the
$GRAPH regex, we may accidentally include the leading space
for a context line. That means we may consider the actual
contents of a context line as part of the diff syntax. In
other words, something like this:

   normal context line
  -old line
  +new line
   -this is a context line with a leading dash

would cause us to see that final context line as a removal
line, and we'd end up showing the hunk in the wrong order:

  normal context line
  -old line
   -this is a context line with a leading dash
  +new line

Instead, let's a be a little more clever about parsing the
graph. We'll look for the actual "*" line that marks the
start of a commit, and record the indentation we see there.
Then we can skip past that indentation when checking whether
the line is a hunk header, removal, addition, etc.

There is one tricky thing: the indentation in bytes may be
different for various lines of the graph due to coloring.
E.g., the "*" on a commit line is generally shown without
color, but on the actual diff lines, it will be replaced
with a colorized "|" character, adding several bytes. We
work around this here by counting "visible" bytes. This is
unfortunately a bit more expensive, making us about twice as
slow to handle --graph output. But since this is meant to be
used interactively anyway, it's tolerably fast (and the
non-graph case is unaffected).

One alternative would be to search for hunk header lines and
use their indentation (since they'd have the same colors as
the diff lines which follow). But that just opens up
different corner cases. If we see:

  | |    @@ 1,2 1,3 @@

we cannot know if this is a real diff that has been
indented due to the graph, or if it's a context line that
happens to look like a diff header. We can only be sure of
the indent on the "*" lines, since we know those don't
contain arbitrary data (technically the user could include a
bunch of extra indentation via --format, but that's rare
enough to disregard).

Reported-by: Phillip Wood <redacted>
Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agodiff-highlight: use flush() helper consistently
Jeff King [Wed, 21 Mar 2018 05:56:37 +0000 (01:56 -0400)]
diff-highlight: use flush() helper consistently

The current flush() helper only shows the queued diff but
does not clear the queue. This is conceptually a bug, but it
works because we only call it once at the end of the
program.

Let's teach it to clear the queue, which will let us use it
in more places (one for now, but more in future patches).

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agodiff-highlight: test graphs with --color
Jeff King [Wed, 21 Mar 2018 05:49:57 +0000 (01:49 -0400)]
diff-highlight: test graphs with --color

Our tests send git's output directly to files or pipes, so
there will never be any color. Let's do at least one --color
test to make sure that we can handle this case (which we
currently can, but will be an easy thing to mess up when we
touch the graph code in a future patch).

We'll just cover the --graph case, since this is much more
complex than the earlier cases (i.e., if it manages to
highlight, then the non-graph case definitely would).

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agodiff-highlight: test interleaved parallel lines of history
Jeff King [Wed, 21 Mar 2018 05:49:26 +0000 (01:49 -0400)]
diff-highlight: test interleaved parallel lines of history

The graph test in t9400 covers the case of two simultaneous
branches, but all of the commits during this time are on the
right-hand branch. So we test a graph structure like:

  | |
  | * commit ...
  | |

but we never see the reverse, a commit on the left-hand
branch:

  | |
  * | commit ...
  | |

Since this is an easy thing to get wrong when touching the
graph-matching code, let's cover it by adding one more
commit with its timestamp interleaved with the other branch.

Note that we need to pass --date-order to convince Git to
show it this way (since --topo-order tries to keep lines of
history separate).

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agodiff-highlight: prefer "echo" to "cat" in tests
Jeff King [Wed, 21 Mar 2018 05:48:53 +0000 (01:48 -0400)]
diff-highlight: prefer "echo" to "cat" in tests

We generate a bunch of one-line files whose contents match
their names, and then generate our commits by cat-ing those
files. Let's just echo the contents directly, which saves
some processes.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agodiff-highlight: use test_tick in graph test
Jeff King [Wed, 21 Mar 2018 05:48:40 +0000 (01:48 -0400)]
diff-highlight: use test_tick in graph test

The exact ordering output by Git may depend on the commit
timestamps, so let's make sure they're actually
monotonically increasing, and not all the same (or worse,
subject to how long the test script takes to run).

Let's use test_tick to make sure this is stable. Note that
we actually have to rearrange the order of the branches to
match the expected graph structure (which means that
previously we might racily have been testing a slightly
different output, though the test is written in such a way
that we'd still pass).

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agodiff-highlight: correct test graph diagram
Jeff King [Wed, 21 Mar 2018 05:47:45 +0000 (01:47 -0400)]
diff-highlight: correct test graph diagram

We actually branch "A" off of "D". The sample "--graph"
output is right, but the left-to-right diagram is
misleading. Let's fix it.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoMerge branch 'master' of git://github.com/nafmo/git-l10n-sv
Jiang Xin [Wed, 21 Mar 2018 14:13:51 +0000 (22:13 +0800)]
Merge branch 'master' of git://github.com/nafmo/git-l10n-sv

* 'master' of git://github.com/nafmo/git-l10n-sv:
  l10n: sv.po: Update Swedish translation (3376t0f0u)

7 years agoMerge branch 'master' of https://github.com/Softcatala/git-po
Jiang Xin [Wed, 21 Mar 2018 14:07:53 +0000 (22:07 +0800)]
Merge branch 'master' of https://github.com/Softcatala/git-po

* 'master' of https://github.com/Softcatala/git-po:
  l10n: Update Catalan translation

7 years agorebase --root: stop assuming squash_onto is unset
Phillip Wood [Tue, 20 Mar 2018 10:03:13 +0000 (10:03 +0000)]
rebase --root: stop assuming squash_onto is unset

If the user set the environment variable 'squash_onto', the 'rebase'
command would erroneously assume that the user passed the option
'--root'.

Signed-off-by: Phillip Wood <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agodoc/gitattributes: mention non-recursive behavior
Jeff King [Tue, 20 Mar 2018 04:14:54 +0000 (00:14 -0400)]
doc/gitattributes: mention non-recursive behavior

The gitattributes documentation claims that the pattern
rules are largely the same as for gitignore. However, the
rules for recursion are different.

In an ideal world, we would make them the same (if for
nothing else than consistency and simplicity), but that
would create backwards compatibility issues. For some
discussion, see this thread:

  https://public-inbox.org/git/slrnkldd3g.1l4.jan@majutsushi.net/

But let's at least document the differences instead of
actively misleading the user by claiming that they're the
same.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoread-cache: fix an -Wmaybe-uninitialized warning
Ramsay Jones [Mon, 19 Mar 2018 17:56:11 +0000 (17:56 +0000)]
read-cache: fix an -Wmaybe-uninitialized warning

The function ce_write_entry() uses a 'self-initialised' variable
construct, for the symbol 'saved_namelen', to suppress a gcc
'-Wmaybe-uninitialized' warning, given that the warning is a false
positive.

For the purposes of this discussion, the ce_write_entry() function has
three code blocks of interest, that look like so:

        /* block #1 */
        if (ce->ce_flags & CE_STRIP_NAME) {
                saved_namelen = ce_namelen(ce);
                ce->ce_namelen = 0;
        }

        /* block #2 */
        /*
 * several code blocks that contain, among others, calls
         * to copy_cache_entry_to_ondisk(ondisk, ce);
         */

        /* block #3 */
        if (ce->ce_flags & CE_STRIP_NAME) {
                ce->ce_namelen = saved_namelen;
                ce->ce_flags &= ~CE_STRIP_NAME;
        }

The warning implies that gcc thinks it is possible that the first
block is not entered, the calls to copy_cache_entry_to_ondisk()
could toggle the CE_STRIP_NAME flag on, thereby entering block #3
with saved_namelen unset. However, the copy_cache_entry_to_ondisk()
function does not write to ce->ce_flags (it only reads). gcc could
easily determine this, since that function is local to this file,
but it obviously doesn't.

In order to suppress this warning, we make it clear to the reader
(human and compiler), that block #3 will only be entered when the
first block has been entered, by introducing a new 'stripped_name'
boolean variable. We also take the opportunity to change the type
of 'saved_namelen' to 'unsigned int' to match ce->ce_namelen.

Signed-off-by: Ramsay Jones <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years ago-Wuninitialized: remove some 'init-self' workarounds
Ramsay Jones [Mon, 19 Mar 2018 17:54:35 +0000 (17:54 +0000)]
-Wuninitialized: remove some 'init-self' workarounds

The 'self-initialised' variables construct (ie <type> var = var;) has
been used to silence gcc '-W[maybe-]uninitialized' warnings. This has,
unfortunately, caused MSVC to issue 'uninitialized variable' warnings.
Also, using clang static analysis causes complaints about an 'Assigned
value is garbage or undefined'.

There are six such constructs in the current codebase. Only one of the
six causes gcc to issue a '-Wmaybe-uninitialized' warning (which will
be addressed elsewhere). The remaining five 'init-self' gcc workarounds
are noted below, along with the commit which introduced them:

  1. builtin/rev-list.c: 'reaches' and 'all', see commit 457f08a030
     ("git-rev-list: add --bisect-vars option.", 2007-03-21).

  2. merge-recursive.c:2064 'mrtree', see commit f120ae2a8e ("merge-
     recursive.c: mrtree in merge() is not used before set", 2007-10-29).

  3. fast-import.c:3023 'oe', see commit 85c62395b1 ("fast-import: let
     importers retrieve blobs", 2010-11-28).

  4. fast-import.c:3006 'oe', see commit 28c7b1f7b7 ("fast-import: add a
     get-mark command", 2015-07-01).

Remove the 'self-initialised' variable constructs noted above.

Signed-off-by: Ramsay Jones <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agostash push -u: don't create empty stash
Thomas Gummerer [Mon, 19 Mar 2018 23:21:56 +0000 (23:21 +0000)]
stash push -u: don't create empty stash

When introducing the stash push feature, and thus allowing users to pass
in a pathspec to limit the files that would get stashed in
df6bba0937 ("stash: teach 'push' (and 'create_stash') to honor
pathspec", 2017-02-28), this developer missed one place where the
pathspec should be passed in.

Namely in the call to the 'untracked_files()' function in the
'no_changes()' function.  This resulted in 'git stash push -u --
<non-existant>' creating an empty stash when there are untracked files
in the repository other that don't match the pathspec.

As 'git stash' never creates empty stashes, this behaviour is wrong and
confusing for users.  Instead it should just show a message "No local
changes to save", and not create a stash.

Luckily the 'untracked_files()' function already correctly respects
pathspecs that are passed to it, so the fix is simply to pass the
pathspec along to the function.

Reported-by: Marc Strapetz <redacted>
Signed-off-by: Thomas Gummerer <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agostash push: avoid printing errors
Thomas Gummerer [Mon, 19 Mar 2018 23:21:55 +0000 (23:21 +0000)]
stash push: avoid printing errors

'git stash push -u -- <pathspec>' prints the following errors if
<pathspec> only matches untracked files:

    fatal: pathspec 'untracked' did not match any files
    error: unrecognized input

This is because we first clean up the untracked files using 'git clean
<pathspec>', and then use a command chain involving 'git add -u
<pathspec>' and 'git apply' to clear the changes to files that are in
the index and were stashed.

As the <pathspec> only includes untracked files that were already
removed by 'git clean', the 'git add' call will barf, and so will 'git
apply', as there are no changes that need to be applied.

Fix this by avoiding the 'git clean' if a pathspec is given, and use the
pipeline that's used for pathspec mode to get rid of the untracked files
as well.

Reported-by: Marc Strapetz <redacted>
Signed-off-by: Thomas Gummerer <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agostash: fix nonsense pipeline
Junio C Hamano [Mon, 19 Mar 2018 23:21:54 +0000 (23:21 +0000)]
stash: fix nonsense pipeline

An earlier change bba067d2 ("stash: don't delete untracked files
that match pathspec", 2018-01-06) was made by taking a suggestion in
a list discussion [1] but did not copy the suggested snippet
correctly.  And the bug was unnoticed during the review and slipped
through.

This fixes it.

[1] https://public-inbox.org/git/xmqqpo7byjwb.fsf@gitster.mtv.corp.google.com/

Signed-off-by: Junio C Hamano <redacted>
7 years agofilter-branch: use printf instead of echo -e
Michele Locati [Mon, 19 Mar 2018 15:52:59 +0000 (16:52 +0100)]
filter-branch: use printf instead of echo -e

In order to echo a tab character, it's better to use printf instead of
"echo -e", because it's more portable (for instance, "echo -e" doesn't work
as expected on a Mac).

This solves the "fatal: Not a valid object name" error in git-filter-branch
when using the --state-branch option.

Furthermore, let's switch from "/bin/echo" to just "echo", so that the
built-in echo command is used where available.

Signed-off-by: Michele Locati <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agomingw: abort on invalid strftime formats
Johannes Schindelin [Mon, 19 Mar 2018 16:49:22 +0000 (17:49 +0100)]
mingw: abort on invalid strftime formats

On Windows, strftime() does not silently ignore invalid formats, but
warns about them and then returns 0 and sets errno to EINVAL.

Unfortunately, Git does not expect such a behavior, as it disagrees
with strftime()'s semantics on Linux. As a consequence, Git
misinterprets the return value 0 as "I need more space" and grows the
buffer. As the larger buffer does not fix the format, the buffer grows
and grows and grows until we are out of memory and abort.

Ideally, we would switch off the parameter validation just for
strftime(), but we cannot even override the invalid parameter handler
via _set_thread_local_invalid_parameter_handler() using MINGW because
that function is not declared. Even _set_invalid_parameter_handler(),
which *is* declared, does not help, as it simply does... nothing.

So let's just bite the bullet and override strftime() for MINGW and
abort on an invalid format string. While this does not provide the
best user experience, it is the best we can do.

See https://msdn.microsoft.com/en-us/library/fe06s4ak.aspx for more
details.

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

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agocompletion: complete tags with git tag --delete/--verify
Todd Zullinger [Sun, 18 Mar 2018 04:01:35 +0000 (00:01 -0400)]
completion: complete tags with git tag --delete/--verify

Completion of tag names has worked for the short -d/-v options since
88e21dc746 ("Teach bash about completing arguments for git-tag",
2007-08-31).  The long options were not added to "git tag" until many
years later, in c97eff5a95 ("git-tag: introduce long forms for the
options", 2011-08-28).

Extend tag name completion to --delete/--verify.

Signed-off-by: Todd Zullinger <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoDocumentation/merge-strategies: typofix
David Pursehouse [Sat, 17 Mar 2018 03:31:42 +0000 (12:31 +0900)]
Documentation/merge-strategies: typofix

It's strategy, not stragegy.

Signed-off-by: David Pursehouse <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agol10n: sv.po: Update Swedish translation (3376t0f0u)
Peter Krefting [Sun, 18 Mar 2018 19:57:00 +0000 (20:57 +0100)]
l10n: sv.po: Update Swedish translation (3376t0f0u)

Signed-off-by: Peter Krefting <redacted>
7 years agol10n: Update Catalan translation
Jordi Mas [Sun, 18 Mar 2018 15:03:18 +0000 (16:03 +0100)]
l10n: Update Catalan translation

Signed-off-by: Jordi Mas <redacted>
7 years agoMerge branch 'fr_v2.17.0' of git://github.com/jnavila/git
Jiang Xin [Sun, 18 Mar 2018 11:46:38 +0000 (19:46 +0800)]
Merge branch 'fr_v2.17.0' of git://github.com/jnavila/git

* 'fr_v2.17.0' of git://github.com/jnavila/git:
  l10n: fr.po v2.17.0 round 1

7 years agol10n: fr.po v2.17.0 round 1
Jean-Noël Avila [Fri, 16 Mar 2018 22:39:49 +0000 (23:39 +0100)]
l10n: fr.po v2.17.0 round 1

Signed-off-by: Jean-Noël Avila <redacted>
7 years agoMerge branch 'master' of https://github.com/vnwildman/git
Jiang Xin [Sat, 17 Mar 2018 03:27:05 +0000 (11:27 +0800)]
Merge branch 'master' of https://github.com/vnwildman/git

* 'master' of https://github.com/vnwildman/git:
  l10n: vi.po(3376t): Updated Vietnamese translation for v2.17

7 years agoMerge branch 'master' of git://github.com/alshopov/git-po
Jiang Xin [Sat, 17 Mar 2018 03:24:53 +0000 (11:24 +0800)]
Merge branch 'master' of git://github.com/alshopov/git-po

* 'master' of git://github.com/alshopov/git-po:
  l10n: bg.po: Updated Bulgarian translation (3376t)

7 years agol10n: vi.po(3376t): Updated Vietnamese translation for v2.17
Tran Ngoc Quan [Sat, 17 Mar 2018 00:53:33 +0000 (07:53 +0700)]
l10n: vi.po(3376t): Updated Vietnamese translation for v2.17

Signed-off-by: Tran Ngoc Quan <redacted>
7 years agoRelNotes: add details on Perl module changes
Todd Zullinger [Fri, 16 Mar 2018 22:07:48 +0000 (18:07 -0400)]
RelNotes: add details on Perl module changes

Document changes to core and non-core Perl module handling in 2.17.

Signed-off-by: Todd Zullinger <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agol10n: bg.po: Updated Bulgarian translation (3376t)
Alexander Shopov [Fri, 16 Mar 2018 08:55:13 +0000 (09:55 +0100)]
l10n: bg.po: Updated Bulgarian translation (3376t)

Signed-off-by: Alexander Shopov <redacted>
7 years agol10n: es.po: Update Spanish translation 2.17.0
Christopher Diaz Riveros [Fri, 16 Mar 2018 02:55:20 +0000 (21:55 -0500)]
l10n: es.po: Update Spanish translation 2.17.0

Signed-off-by: Christopher Diaz Riveros <redacted>
7 years agoMerge remote-tracking branch 'git-po/maint'
Jiang Xin [Thu, 15 Mar 2018 23:36:32 +0000 (07:36 +0800)]
Merge remote-tracking branch 'git-po/maint'

* git-po/maint:
  l10n: es.po: fixes to Spanish translation

7 years agol10n: git.pot: v2.17.0 round 1 (132 new, 44 removed)
Jiang Xin [Thu, 15 Mar 2018 23:34:52 +0000 (07:34 +0800)]
l10n: git.pot: v2.17.0 round 1 (132 new, 44 removed)

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

Signed-off-by: Jiang Xin <redacted>
7 years agoGit 2.17-rc0
Junio C Hamano [Thu, 15 Mar 2018 22:01:05 +0000 (15:01 -0700)]
Git 2.17-rc0

Signed-off-by: Junio C Hamano <redacted>
7 years agoMerge branch 'tl/userdiff-csharp-async'
Junio C Hamano [Thu, 15 Mar 2018 22:00:47 +0000 (15:00 -0700)]
Merge branch 'tl/userdiff-csharp-async'

Update funcname pattern used for C# to recognize "async" keyword.

* tl/userdiff-csharp-async:
  userdiff.c: add C# async keyword in diff pattern

7 years agoMerge branch 'sg/cvs-tests-with-x'
Junio C Hamano [Thu, 15 Mar 2018 22:00:46 +0000 (15:00 -0700)]
Merge branch 'sg/cvs-tests-with-x'

Allow running a couple of tests with "sh -x".

* sg/cvs-tests-with-x:
  t9402-git-cvsserver-refs: don't check the stderr of a subshell
  t9400-git-cvsserver-server: don't rely on the output of 'test_cmp'

7 years agoMerge branch 'ab/man-sec-list'
Junio C Hamano [Thu, 15 Mar 2018 22:00:46 +0000 (15:00 -0700)]
Merge branch 'ab/man-sec-list'

Doc update.

* ab/man-sec-list:
  git manpage: note git-security@googlegroups.com

7 years agoMerge branch 'ab/perl-fixes'
Junio C Hamano [Thu, 15 Mar 2018 22:00:46 +0000 (15:00 -0700)]
Merge branch 'ab/perl-fixes'

Clean-up to various pieces of Perl code we have.

* ab/perl-fixes:
  perl Git::LoadCPAN: emit better errors under NO_PERL_CPAN_FALLBACKS
  Makefile: add NO_PERL_CPAN_FALLBACKS knob
  perl: move the perl/Git/FromCPAN tree to perl/FromCPAN
  perl: generalize the Git::LoadCPAN facility
  perl: move CPAN loader wrappers to another namespace
  perl: update our copy of Mail::Address
  perl: update our ancient copy of Error.pm
  git-send-email: unconditionally use Net::{SMTP,Domain}
  Git.pm: hard-depend on the File::{Temp,Spec} modules
  gitweb: hard-depend on the Digest::MD5 5.8 module
  Git.pm: add the "use warnings" pragma
  Git.pm: remove redundant "use strict" from sub-package
  perl: *.pm files should not have the executable bit

7 years agoMerge branch 'cl/send-email-reply-to'
Junio C Hamano [Thu, 15 Mar 2018 22:00:45 +0000 (15:00 -0700)]
Merge branch 'cl/send-email-reply-to'

"git send-email" learned "--reply-to=<address>" option.

* cl/send-email-reply-to:
  send-email: support separate Reply-To address
  send-email: rename variable for clarity

7 years agoMerge branch 'np/send-email-header-parsing'
Junio C Hamano [Thu, 15 Mar 2018 22:00:45 +0000 (15:00 -0700)]
Merge branch 'np/send-email-header-parsing'

Code refactoring.

* np/send-email-header-parsing:
  send-email: extract email-parsing code into a subroutine

7 years agot/t3200: fix a typo in a test description
Kaartic Sivaraam [Sat, 10 Mar 2018 15:54:16 +0000 (21:24 +0530)]
t/t3200: fix a typo in a test description

Signed-off-by: Kaartic Sivaraam <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agohttp: fix an unused variable warning for 'curl_no_proxy'
Ramsay Jones [Wed, 14 Mar 2018 21:56:06 +0000 (21:56 +0000)]
http: fix an unused variable warning for 'curl_no_proxy'

Signed-off-by: Ramsay Jones <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoMakefile: optionally symlink libexec/git-core binaries to bin/git
Ævar Arnfjörð Bjarmason [Tue, 13 Mar 2018 20:39:35 +0000 (20:39 +0000)]
Makefile: optionally symlink libexec/git-core binaries to bin/git

Add a INSTALL_SYMLINKS option which if enabled, changes the default
hardlink installation method to one where the relevant binaries in
libexec/git-core are symlinked back to ../../bin, instead of being
hardlinked.

This new option also overrides the behavior of the existing
NO_*_HARDLINKS variables which in some cases would produce symlinks
within to libexec/, e.g. "git-add" symlinked to "git" which would be
copy of the "git" found in bin/, now "git-add" in libexec/ is always
going to be symlinked to the "git" found in the bin/ directory.

This option is being added because:

 1) I think it makes what we're doing a lot more obvious. E.g. I'd
    never noticed that the libexec binaries were really just hardlinks
    since e.g. ls(1) won't show that in any obvious way. You need to
    start stat(1)-ing things and look at the inodes to see what's
    going on.

 2) Some tools have very crappy support for hardlinks, e.g. the Git
    shipped with GitLab is much bigger than it should be because
    they're using a chef module that doesn't know about hardlinks, see
    https://github.com/chef/omnibus/issues/827

    I've also ran into other related issues that I think are explained
    by this, e.g. compiling git with debugging and rpm refusing to
    install a ~200MB git package with 2GB left on the FS, I think that
    was because it doesn't consider hardlinks, just the sum of the
    byte size of everything in the package.

As for the implementation, the "../../bin" noted above will vary given
some given some values of "../.." and "bin" depending on the depth of
the gitexecdir relative to the destdir, and the "bindir" target,
e.g. setting "bindir=/tmp/git/binaries gitexecdir=foo/bar/baz" will do
the right thing and produce this result:

    $ file /tmp/git/foo/bar/baz/git-add
    /tmp/git/foo/bar/baz/git-add: symbolic link to ../../../binaries/git

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoMakefile: add a gitexecdir_relative variable
Ævar Arnfjörð Bjarmason [Tue, 13 Mar 2018 20:39:34 +0000 (20:39 +0000)]
Makefile: add a gitexecdir_relative variable

This variable will be e.g. "libexec/git-core" if
gitexecdir=/tmp/git/libexec/git-core is given. It'll be used by a
subsequent change.

This is stolen from the yet-to-be integrated (needs resubmission)
"Makefile: add Perl runtime prefix support" patch on the mailing
list. See
<redacted> (https://public-inbox.org/git/20180108030239.92036-3-dnj@google.com/).

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoMakefile: fix broken bindir_relative variable
Ævar Arnfjörð Bjarmason [Tue, 13 Mar 2018 20:39:33 +0000 (20:39 +0000)]
Makefile: fix broken bindir_relative variable

Change the bindir_relative variable to work like the other *_relative
variables, which are computed as a function of the absolute
path. Before this change, supplying e.g. bindir=/tmp/git/binaries to
the Makefile would yield a bindir_relative of just "bin", as opposed
to "binaries".

This logic was originally added back in 026fa0d5ad ("Move computation
of absolute paths from Makefile to runtime (in preparation for
RUNTIME_PREFIX)", 2009-01-18), then later in 971f85388f ("Makefile:
make mandir, htmldir and infodir absolute", 2013-02-24) when
more *_relative variables were added those new variables didn't have
this bug, but bindir_relative was never fixed.

There is a small change in behavior here, which is that setting
bindir_relative as an argument to the Makefile won't work anymore, I
think that's fine, since this was always intended as an internal
variable (e.g. INSTALL documents bindir=*, not bindir_relative=*).

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoworktree prune: improve prune logic when worktree is moved
Nguyễn Thái Ngọc Duy [Thu, 15 Mar 2018 16:44:12 +0000 (17:44 +0100)]
worktree prune: improve prune logic when worktree is moved

Automatic detection of worktree relocation by a user (via 'mv', for
instance) was removed by 618244e160 (worktree: stop supporting moving
worktrees manually - 2016-01-22). Prior to that,
.git/worktrees/<tag>/gitdir was updated whenever the worktree was
accessed in order to let the pruning logic know that the worktree was
"active" even if it disappeared for a while (due to being located on
removable media, for instance).

"git worktree move" has come so we don't really need this, but since
it's easy to do, perhaps we could keep supporting manual worktree move
a bit longer. Notice that when a worktree is active, the "index" file
should be updated pretty often in common case. The logic is updated to
check for index mtime to see if the worktree is alive.

The old logic of checking gitdir's mtime is dropped because nobody
updates it anyway. The new corner case is, if the index file does not
exist, we immediately remove the stale worktree. But if the "index"
file does not exist, you may have a bigger problem.

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoworktree: delete dead code
Nguyễn Thái Ngọc Duy [Thu, 15 Mar 2018 16:44:11 +0000 (17:44 +0100)]
worktree: delete dead code

This "link" was a feature in early iterations of multiple worktree
functionality for some reason it was dropped [1]. Since nobody creates
this "link", there's no need to check it.

This is mostly used to let the user moves a worktree manually [2]. If
you move a worktree within the same file system, this hard link count
lets us know the worktree is still there even if we don't know where it
is.

We support 'worktree move' now and don't need this anymore.

[1] last appearance in v4 message-id:
    1393675983-3232-25-git-send-email-pclouds@gmail.com
    and the reason in v5 was "revisit later", message-id:
    1394246900-31535-1-git-send-email-pclouds@gmail.com
[2] 23af91d102 (prune: strategies for linked checkouts - 2014-11-30)

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogc.txt: more details about what gc does
Nguyễn Thái Ngọc Duy [Thu, 15 Mar 2018 16:44:10 +0000 (17:44 +0100)]
gc.txt: more details about what gc does

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoremote-curl: don't request v2 when pushing
Brandon Williams [Thu, 15 Mar 2018 17:31:42 +0000 (10:31 -0700)]
remote-curl: don't request v2 when pushing

In order to be able to ship protocol v2 with only supporting fetch, we
need clients to not issue a request to use protocol v2 when pushing
(since the client currently doesn't know how to push using protocol v2).
This allows a client to have protocol v2 configured in
`protocol.version` and take advantage of using v2 for fetch and falling
back to using v0 when pushing while v2 for push is being designed.

We could run into issues if we didn't fall back to protocol v2 when
pushing right now.  This is because currently a server will ignore a request to
use v2 when contacting the 'receive-pack' endpoint and fall back to
using v0, but when push v2 is rolled out to servers, the 'receive-pack'
endpoint will start responding using v2.  So we don't want to get into a
state where a client is requesting to push with v2 before they actually
know how to push using v2.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoremote-curl: implement stateless-connect command
Brandon Williams [Thu, 15 Mar 2018 17:31:41 +0000 (10:31 -0700)]
remote-curl: implement stateless-connect command

Teach remote-curl the 'stateless-connect' command which is used to
establish a stateless connection with servers which support protocol
version 2.  This allows remote-curl to act as a proxy, allowing the git
client to communicate natively with a remote end, simply using
remote-curl as a pass through to convert requests to http.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agohttp: eliminate "# service" line when using protocol v2
Brandon Williams [Thu, 15 Mar 2018 17:31:40 +0000 (10:31 -0700)]
http: eliminate "# service" line when using protocol v2

When an http info/refs request is made, requesting that protocol v2 be
used, don't send a "# service" line since this line is not part of the
v2 spec.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agohttp: don't always add Git-Protocol header
Brandon Williams [Thu, 15 Mar 2018 17:31:39 +0000 (10:31 -0700)]
http: don't always add Git-Protocol header

Instead of always sending the Git-Protocol header with the configured
version with every http request, explicitly send it when discovering
refs and then only send it on subsequent http requests if the server
understood the version requested.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agohttp: allow providing extra headers for http requests
Brandon Williams [Thu, 15 Mar 2018 17:31:38 +0000 (10:31 -0700)]
http: allow providing extra headers for http requests

Add a way for callers to request that extra headers be included when
making http requests.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoremote-curl: store the protocol version the server responded with
Brandon Williams [Thu, 15 Mar 2018 17:31:37 +0000 (10:31 -0700)]
remote-curl: store the protocol version the server responded with

Store the protocol version the server responded with when performing
discovery.  This will be used in a future patch to either change the
'Git-Protocol' header sent in subsequent requests or to determine if a
client needs to fallback to using a different protocol version.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoremote-curl: create copy of the service name
Brandon Williams [Thu, 15 Mar 2018 17:31:36 +0000 (10:31 -0700)]
remote-curl: create copy of the service name

Make a copy of the service name being requested instead of relying on
the buffer pointed to by the passed in 'const char *' to remain
unchanged.

Currently, all service names are string constants, but a subsequent
patch will introduce service names from external sources.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agopkt-line: add packet_buf_write_len function
Brandon Williams [Thu, 15 Mar 2018 17:31:35 +0000 (10:31 -0700)]
pkt-line: add packet_buf_write_len function

Add the 'packet_buf_write_len()' function which allows for writing an
arbitrary length buffer into a 'struct strbuf' and formatting it in
packet-line format.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agotransport-helper: introduce stateless-connect
Brandon Williams [Thu, 15 Mar 2018 17:31:34 +0000 (10:31 -0700)]
transport-helper: introduce stateless-connect

Introduce the transport-helper capability 'stateless-connect'.  This
capability indicates that the transport-helper can be requested to run
the 'stateless-connect' command which should attempt to make a
stateless connection with a remote end.  Once established, the
connection can be used by the git client to communicate with
the remote end natively in a stateless-rpc manner as supported by
protocol v2.  This means that the client must send everything the server
needs in a single request as the client must not assume any
state-storing on the part of the server or transport.

If a stateless connection cannot be established then the remote-helper
will respond in the same manner as the 'connect' command indicating that
the client should fallback to using the dumb remote-helper commands.

A future patch will implement the 'stateless-connect' capability in our
http remote-helper (remote-curl) so that protocol v2 can be used using
the http transport.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agotransport-helper: refactor process_connect_service
Brandon Williams [Thu, 15 Mar 2018 17:31:33 +0000 (10:31 -0700)]
transport-helper: refactor process_connect_service

A future patch will need to take advantage of the logic which runs and
processes the response of the connect command on a remote helper so
factor out this logic from 'process_connect_service()' and place it into
a helper function 'run_connect()'.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agotransport-helper: remove name parameter
Brandon Williams [Thu, 15 Mar 2018 17:31:32 +0000 (10:31 -0700)]
transport-helper: remove name parameter

Commit 266f1fdfa (transport-helper: be quiet on read errors from
helpers, 2013-06-21) removed a call to 'die()' which printed the name of
the remote helper passed in to the 'recvline_fh()' function using the
'name' parameter.  Once the call to 'die()' was removed the parameter
was no longer necessary but wasn't removed.  Clean up 'recvline_fh()'
parameter list by removing the 'name' parameter.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoconnect: don't request v2 when pushing
Brandon Williams [Thu, 15 Mar 2018 17:31:31 +0000 (10:31 -0700)]
connect: don't request v2 when pushing

In order to be able to ship protocol v2 with only supporting fetch, we
need clients to not issue a request to use protocol v2 when pushing
(since the client currently doesn't know how to push using protocol v2).
This allows a client to have protocol v2 configured in
`protocol.version` and take advantage of using v2 for fetch and falling
back to using v0 when pushing while v2 for push is being designed.

We could run into issues if we didn't fall back to protocol v2 when
pushing right now.  This is because currently a server will ignore a request to
use v2 when contacting the 'receive-pack' endpoint and fall back to
using v0, but when push v2 is rolled out to servers, the 'receive-pack'
endpoint will start responding using v2.  So we don't want to get into a
state where a client is requesting to push with v2 before they actually
know how to push using v2.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoconnect: refactor git_connect to only get the protocol version once
Brandon Williams [Thu, 15 Mar 2018 17:31:30 +0000 (10:31 -0700)]
connect: refactor git_connect to only get the protocol version once

Instead of having each builtin transport asking for which protocol
version the user has configured in 'protocol.version' by calling
`get_protocol_version_config()` multiple times, factor this logic out
so there is just a single call at the beginning of `git_connect()`.

This will be helpful in the next patch where we can have centralized
logic which determines if we need to request a different protocol
version than what the user has configured.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agofetch-pack: support shallow requests
Brandon Williams [Thu, 15 Mar 2018 17:31:29 +0000 (10:31 -0700)]
fetch-pack: support shallow requests

Enable shallow clones and deepen requests using protocol version 2 if
the server 'fetch' command supports the 'shallow' feature.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agofetch-pack: perform a fetch using v2
Brandon Williams [Thu, 15 Mar 2018 17:31:28 +0000 (10:31 -0700)]
fetch-pack: perform a fetch using v2

When communicating with a v2 server, perform a fetch by requesting the
'fetch' command.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
git clone https://git.99rst.org/PROJECT