git.git
7 years agoprotocol-v2 doc: put HTTP headers after request
Josh Steadmon [Fri, 22 Jun 2018 19:01:12 +0000 (12:01 -0700)]
protocol-v2 doc: put HTTP headers after request

HTTP servers return 400 if you send headers before the GET request.

Signed-off-by: Josh Steadmon <redacted>
Reviewed-by: Jonathan Nieder <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agocontrib/git-jump/git-jump: jump to exact location
Taylor Blau [Fri, 22 Jun 2018 15:49:54 +0000 (10:49 -0500)]
contrib/git-jump/git-jump: jump to exact location

Take advantage of 'git-grep(1)''s new option, '--column' in order to
teach Peff's 'git-jump' script how to jump to the correct column for any
given match.

'git-grep(1)''s output is in the correct format for Vim's jump list, so
no additional cleanup is necessary.

Signed-off-by: Taylor Blau <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogrep.c: add configuration variables to show matched option
Taylor Blau [Fri, 22 Jun 2018 15:49:49 +0000 (10:49 -0500)]
grep.c: add configuration variables to show matched option

To support git-grep(1)'s new option, '--column', document and teach
grep.c how to interpret relevant configuration options, similar to those
associated with '--line-number'.

Signed-off-by: Taylor Blau <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agobuiltin/grep.c: add '--column' option to 'git-grep(1)'
Taylor Blau [Fri, 22 Jun 2018 15:49:45 +0000 (10:49 -0500)]
builtin/grep.c: add '--column' option to 'git-grep(1)'

Teach 'git-grep(1)' a new option, '--column', to show the column
number of the first match on a non-context line. This makes it possible
to teach 'contrib/git-jump/git-jump' how to seek to the first matching
position of a grep match in your editor, and allows similar additional
scripting capabilities.

For example:

  $ git grep -n --column foo | head -n3
  .clang-format:51:14:# myFunction(foo, bar, baz);
  .clang-format:64:7:# int foo();
  .clang-format:75:8:# void foo()

Signed-off-by: Taylor Blau <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogrep.c: display column number of first match
Taylor Blau [Fri, 22 Jun 2018 15:49:42 +0000 (10:49 -0500)]
grep.c: display column number of first match

To prepare for 'git grep' learning '--column', teach grep.c's
show_line() how to show the column of the first match on non-context
lines.

Signed-off-by: Taylor Blau <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogrep.[ch]: extend grep_opt to allow showing matched column
Taylor Blau [Fri, 22 Jun 2018 15:49:39 +0000 (10:49 -0500)]
grep.[ch]: extend grep_opt to allow showing matched column

To support showing the matched column when calling 'git-grep(1)', teach
'grep_opt' the normal set of options to configure the default behavior
and colorization of this feature.

Now that we have opt->columnnum, use it to disable short-circuiting over
ORs and ANDs so that col and icol are always filled with the earliest
matches on each line. In addition, don't return the first match from
match_line(), for the same reason.

Signed-off-by: Taylor Blau <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogrep.c: expose {,inverted} match column in match_line()
Taylor Blau [Fri, 22 Jun 2018 15:49:35 +0000 (10:49 -0500)]
grep.c: expose {,inverted} match column in match_line()

When calling match_line(), callers presently cannot determine the
relative offset of the match because match_line() discards the
'regmatch_t' that contains this information.

Instead, teach match_line() to take in two 'ssize_t's. Fill the first
with the offset of the match produced by the given expression. If
extended, fill the later with the offset of the match produced as if
--invert were given.

For instance, matching "--not -e x" on this line produces a columnar
offset of 0, (i.e., the whole line does not contain an x), but "--invert
--not -e -x" will fill the later ssize_t of the column containing an
"x", because this expression is semantically equivalent to "-e x".

To determine the column for the inverted and non-inverted case, do the
following:

  - If matching an atom, the non-inverted column is as given from
    match_one_pattern(), and the inverted column is unset.

  - If matching a --not, the inverted column and non-inverted column
    swap.

  - If matching an --and, or --or, the non-inverted column is the
    minimum of the two children.

Presently, the existing short-circuiting logic for AND and OR applies as
before. This will change in the following commit when we add options to
configure the --column flag. Taken together, this and the forthcoming
change will always yield the earlier column on a given line.

This patch will become useful when we later pick between the two new
results in order to display the column number of the first match on a
line with --column.

Co-authored-by: Jeff King <redacted>
Signed-off-by: Taylor Blau <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agodocs: link to gitsubmodules
Brandon Williams [Wed, 20 Jun 2018 21:50:30 +0000 (14:50 -0700)]
docs: link to gitsubmodules

Add a link to gitsubmodules(7) under the `submodule.active` entry in
git-config(1).

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agotest-pkt-line: add unpack-sideband subcommand
Brandon Williams [Wed, 20 Jun 2018 21:32:28 +0000 (14:32 -0700)]
test-pkt-line: add unpack-sideband subcommand

Add an 'unpack-sideband' subcommand to the test-pkt-line helper to
enable unpacking packet line data sent multiplexed using a sideband.

Signed-off-by: Brandon Williams <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoDocumentation/config.txt: camel-case lineNumber for consistency
Taylor Blau [Wed, 20 Jun 2018 20:05:34 +0000 (15:05 -0500)]
Documentation/config.txt: camel-case lineNumber for consistency

lineNumber has casing that is inconsistent with surrounding options,
like color.grep.matchContext, and color.grep.matchSelected. Re-case this
documentation in order to be consistent with the text around it, and to
ensure that new entries are consistent, too.

Signed-off-by: Taylor Blau <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agopack-bitmap: add free function
Jonathan Tan [Thu, 7 Jun 2018 19:04:14 +0000 (12:04 -0700)]
pack-bitmap: add free function

Add a function to free struct bitmap_index instances, and use it where
needed (except when rebuild_existing_bitmaps() is used, since it creates
references to the bitmaps within the struct bitmap_index passed to it).

Note that the hashes field in struct bitmap_index is not freed because
it points to another field within the same struct. The documentation for
that field has been updated to clarify that.

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agopack-bitmap: remove bitmap_git global variable
Jonathan Tan [Thu, 7 Jun 2018 19:04:13 +0000 (12:04 -0700)]
pack-bitmap: remove bitmap_git global variable

Remove the bitmap_git global variable. Instead, generate on demand an
instance of struct bitmap_index for code that needs to access it.

This allows us significant control over the lifetime of instances of
struct bitmap_index. In particular, packs can now be closed without
worrying if an unnecessarily long-lived "pack" field in struct
bitmap_index still points to it.

The bitmap API is also clearer in that we need to first obtain a struct
bitmap_index, then we use it.

This patch raises two potential issues: (1) memory for the struct
bitmap_index is allocated without being freed, and (2)
prepare_bitmap_git() and prepare_bitmap_walk() can reuse a previously
loaded bitmap. For (1), this will be dealt with in a subsequent patch in
this patch set that also deals with freeing the contents of the struct
bitmap_index (which were not freed previously, because they have global
scope). For (2), current bitmap users only load the bitmap once at most
(note that pack-objects can use bitmaps or write bitmaps, but not both
at the same time), so support for reuse has no effect - and future users
can pass around the struct bitmap_index * obtained if they need to do 2
or more things with the same bitmap.

Helped-by: Stefan Beller <redacted>
Signed-off-by: Jonathan Tan <redacted>
Helped-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoGit 2.18
Junio C Hamano [Thu, 21 Jun 2018 17:00:06 +0000 (10:00 -0700)]
Git 2.18

Signed-off-by: Junio C Hamano <redacted>
7 years agoewah: delete unused 'rlwit_discharge_empty()'
Junio C Hamano [Tue, 19 Jun 2018 21:51:20 +0000 (22:51 +0100)]
ewah: delete unused 'rlwit_discharge_empty()'

Complete the removal of unused 'ewah bitmap' code by removing the now
unused 'rlwit_discharge_empty()' function. Also, the 'ewah_clear()'
function can now be made a file-scope static symbol.

Signed-off-by: Ramsay Jones <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoformat-patch: clear UNINTERESTING flag before prepare_bases
Xiaolong Ye [Mon, 4 Jun 2018 15:05:43 +0000 (23:05 +0800)]
format-patch: clear UNINTERESTING flag before prepare_bases

When users specify the commit range with 'Z..C' pattern for format-patch, all
the parents of Z (including Z) would be marked as UNINTERESTING which would
prevent revision walk in prepare_bases from getting the prerequisite commits,
thus `git format-patch --base <base_commit_sha> Z..C` won't be able to generate
the list of prerequisite patch ids. Clear UNINTERESTING flag with
clear_object_flags solves this issue.

Reported-by: Eduardo Habkost <redacted>
Signed-off-by: Xiaolong Ye <redacted>
Reviewed-by: Stefan Beller <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoMerge branch 'en/rename-directory-detection-reboot'
Junio C Hamano [Tue, 19 Jun 2018 18:11:03 +0000 (11:11 -0700)]
Merge branch 'en/rename-directory-detection-reboot'

* en/rename-directory-detection-reboot:
  merge-recursive: use xstrdup() instead of fixed buffer

7 years agosequencer: do not squash 'reword' commits when we hit conflicts
Phillip Wood [Tue, 19 Jun 2018 12:46:51 +0000 (13:46 +0100)]
sequencer: do not squash 'reword' commits when we hit conflicts

Ever since commit 18633e1a22 ("rebase -i: use the rebase--helper builtin",
2017-02-09), when a commit marked as 'reword' in an interactive rebase
has conflicts and fails to apply, when the rebase is resumed that commit
will be squashed into its parent with its commit message taken.

The issue can be understood better by looking at commit 56dc3ab04b
("sequencer (rebase -i): implement the 'edit' command", 2017-01-02), which
introduced error_with_patch() for the edit command.  For the edit command,
it needs to stop the rebase whether or not the patch applies cleanly.  If
the patch does apply cleanly, then when it resumes it knows it needs to
amend all changes into the previous commit.  If it does not apply cleanly,
then the changes should not be amended.  Thus, it passes !res (success of
applying the 'edit' commit) to error_with_patch() for the to_amend flag.

The problematic line of code actually came from commit 04efc8b57c
("sequencer (rebase -i): implement the 'reword' command", 2017-01-02).
Note that to get to this point in the code:
  * !!res (i.e. patch application failed)
  * item->command < TODO_SQUASH
  * item->command != TODO_EDIT
  * !is_fixup(item->command) [i.e. not squash or fixup]
So that means this can only be a failed patch application that is either a
pick, revert, or reword.  We only need to amend HEAD when rewording the
root commit or a commit that has been fast-forwarded, for any of the other
cases we want a new commit, so we should not set the to_amend flag.

Helped-by: Johannes Schindelin <redacted>
Original-patch-by: Elijah Newren <redacted>
Signed-off-by: Phillip Wood <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogit-p4: python3: fix octal constants
Luke Diamand [Tue, 19 Jun 2018 08:04:11 +0000 (09:04 +0100)]
git-p4: python3: fix octal constants

See PEP3127. Works fine with python2 as well.

Signed-off-by: Luke Diamand <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogit-p4: python3: use print() function
Luke Diamand [Tue, 19 Jun 2018 08:04:10 +0000 (09:04 +0100)]
git-p4: python3: use print() function

Replace calls to print ... with the function form, print(...), to
allow use with python3 as well as python2.x.

Converted using 2to3 (and some hand-editing).

Signed-off-by: Luke Diamand <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogit-p4: python3: basestring workaround
Luke Diamand [Tue, 19 Jun 2018 08:04:09 +0000 (09:04 +0100)]
git-p4: python3: basestring workaround

In Python3, basestring no longer exists, so use this workaround.

Signed-off-by: Luke Diamand <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogit-p4: python3: remove backticks
Luke Diamand [Tue, 19 Jun 2018 08:04:08 +0000 (09:04 +0100)]
git-p4: python3: remove backticks

Backticks around a variable are a deprecated alias for repr().
This has been removed in python3, so just use the string
representation instead, which is equivalent.

Signed-off-by: Luke Diamand <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogit-p4: python3: replace dict.has_key(k) with "k in dict"
Luke Diamand [Tue, 19 Jun 2018 08:04:07 +0000 (09:04 +0100)]
git-p4: python3: replace dict.has_key(k) with "k in dict"

Python3 does not have the dict.has_key() function, so replace all
such calls with "k in dict". This will still work with python2.6
and python2.7.

Converted using 2to3 (plus some hand-editing)

Signed-off-by: Luke Diamand <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogit-p4: python3: replace <> with !=
Luke Diamand [Tue, 19 Jun 2018 08:04:06 +0000 (09:04 +0100)]
git-p4: python3: replace <> with !=

The <> string inequality operator (which doesn't seem to be even
documented) no longer exists in python3. Replace with !=.

This still works with python2.

Signed-off-by: Luke Diamand <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoMerge tag 'l10n-2.18.0-rnd3.1' of git://github.com/git-l10n/git-po
Junio C Hamano [Tue, 19 Jun 2018 16:29:23 +0000 (09:29 -0700)]
Merge tag 'l10n-2.18.0-rnd3.1' of git://github.com/git-l10n/git-po

Merge Korean translation for l10n of Git 2.18.0 round 3

* tag 'l10n-2.18.0-rnd3.1' of git://github.com/git-l10n/git-po:
  l10n: ko.po: Update Korean translation

7 years agosubmodule deinit: unset core.worktree
Stefan Beller [Tue, 19 Jun 2018 00:06:08 +0000 (17:06 -0700)]
submodule deinit: unset core.worktree

When a submodule is deinit'd, the working tree is gone, so the setting of
core.worktree is bogus. Unset it.

Signed-off-by: Stefan Beller <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agosubmodule: ensure core.worktree is set after update
Stefan Beller [Tue, 19 Jun 2018 00:06:07 +0000 (17:06 -0700)]
submodule: ensure core.worktree is set after update

Signed-off-by: Stefan Beller <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoMerge branch 'cf/submodule-progress-dissociate'
Junio C Hamano [Tue, 19 Jun 2018 16:26:59 +0000 (09:26 -0700)]
Merge branch 'cf/submodule-progress-dissociate'

* cf/submodule-progress-dissociate:
  t7400: encapsulate setup code in test_expect_success

7 years agoMerge branch 'js/rebase-i-root-fix'
Junio C Hamano [Tue, 19 Jun 2018 16:26:28 +0000 (09:26 -0700)]
Merge branch 'js/rebase-i-root-fix'

* js/rebase-i-root-fix:
  t3404: check root commit in 'rebase -i --root reword root commit'

7 years agot7400: encapsulate setup code in test_expect_success
Stefan Beller [Mon, 18 Jun 2018 23:41:48 +0000 (16:41 -0700)]
t7400: encapsulate setup code in test_expect_success

When running t7400 in a shell you observe more output than expected:

    ...
    ok 8 - setup - hide init subdirectory
    ok 9 - setup - repository to add submodules to
    ok 10 - submodule add
    [master (root-commit) d79ce16] one
     Author: A U Thor <redacted>
     1 file changed, 1 insertion(+)
     create mode 100644 one.t
    ok 11 - redirected submodule add does not show progress
    ok 12 - redirected submodule add --progress does show progress
    ok 13 - submodule add to .gitignored path fails
    ...

Fix the output by encapsulating the setup code in test_expect_success

Signed-off-by: Stefan Beller <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agot3404: check root commit in 'rebase -i --root reword root commit'
Todd Zullinger [Mon, 18 Jun 2018 22:19:42 +0000 (18:19 -0400)]
t3404: check root commit in 'rebase -i --root reword root commit'

When testing a reworded root commit, ensure that the squash-onto commit
which is created and amended is still the root commit.

Suggested-by: Phillip Wood <redacted>
Helped-by: Johannes Schindelin <redacted>
Signed-off-by: Todd Zullinger <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agodoc: fix typos in documentation and release notes
Karthikeyan Singaravelan [Sun, 17 Jun 2018 04:35:54 +0000 (04:35 +0000)]
doc: fix typos in documentation and release notes

Signed-off-by: Karthikeyan Singaravelan <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogit-credential-netrc: make "all" default target of Makefile
Todd Zullinger [Wed, 13 Jun 2018 03:10:36 +0000 (23:10 -0400)]
git-credential-netrc: make "all" default target of Makefile

Running "make" in contrib/credential/netrc should run the "all" target
rather than the "test" target.  Add an empty "all::" target like most of
our other Makefiles.

Signed-off-by: Todd Zullinger <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoAlmost 2.18 final
Junio C Hamano [Mon, 18 Jun 2018 18:24:21 +0000 (11:24 -0700)]
Almost 2.18 final

Signed-off-by: Junio C Hamano <redacted>
7 years agoMerge branch 'es/make-no-iconv'
Junio C Hamano [Mon, 18 Jun 2018 18:23:24 +0000 (11:23 -0700)]
Merge branch 'es/make-no-iconv'

"make NO_ICONV=NoThanks" did not override NEEDS_LIBICONV
(i.e. linkage of -lintl, -liconv, etc. that are platform-specific
tweaks), which has been corrected.

* es/make-no-iconv:
  Makefile: make NO_ICONV really mean "no iconv"

7 years agoMerge branch 'sg/t7406-chain-fix'
Junio C Hamano [Mon, 18 Jun 2018 18:23:23 +0000 (11:23 -0700)]
Merge branch 'sg/t7406-chain-fix'

Test fix.

* sg/t7406-chain-fix:
  t7406-submodule-update: fix broken &&-chains

7 years agoMerge branch 'ks/branch-set-upstream'
Junio C Hamano [Mon, 18 Jun 2018 18:23:23 +0000 (11:23 -0700)]
Merge branch 'ks/branch-set-upstream'

A test title has been reworded to clarify it.

* ks/branch-set-upstream:
  t3200: clarify description of --set-upstream test

7 years agoMerge branch 'js/rebase-i-root-fix'
Junio C Hamano [Mon, 18 Jun 2018 18:23:22 +0000 (11:23 -0700)]
Merge branch 'js/rebase-i-root-fix'

A regression to "rebase -i --root" introduced during this cycle has
been fixed.

* js/rebase-i-root-fix:
  rebase --root: fix amending root commit messages
  rebase --root: demonstrate a bug while amending root commit messages

7 years agoMerge branch 'jk/ewah-bounds-check'
Junio C Hamano [Mon, 18 Jun 2018 18:23:22 +0000 (11:23 -0700)]
Merge branch 'jk/ewah-bounds-check'

The code to read compressed bitmap was not careful to avoid reading
past the end of the file, which has been corrected.

* jk/ewah-bounds-check:
  ewah: adjust callers of ewah_read_mmap()
  ewah_read_mmap: bounds-check mmap reads

7 years agoMerge tag 'l10n-2.18.0-rnd3' of git://github.com/git-l10n/git-po
Junio C Hamano [Mon, 18 Jun 2018 17:21:24 +0000 (10:21 -0700)]
Merge tag 'l10n-2.18.0-rnd3' of git://github.com/git-l10n/git-po

l10n for Git 2.18.0 round 3

* tag 'l10n-2.18.0-rnd3' of git://github.com/git-l10n/git-po:
  l10n: zh_CN: for git v2.18.0 l10n round 1 to 3
  l10n: bg.po: Updated Bulgarian translation (3608t)
  l10n: vi.po(3608t): Update Vietnamese translation for v2.18.0 round 3
  l10n: fr.po v2.18.0 round 3
  l10n: es.po: Spanish update for v2.18.0 round 3
  l10n: git.pot: v2.18.0 round 3 (1 new, 1 removed)
  l10n: vi.po(3608t): Update Vietnamese translation for v2.18.0 round2
  l10n: bg.po: Updated Bulgarian translation (3608t)
  l10n: es.po: Spanish update for v2.18.0 round 2
  l10n: sv.po: Update Swedish translation (3608t0f0u)
  l10n: sv.po: Update Swedish translation (3470t0f0u)
  l10n: git.pot: v2.18.0 round 2 (144 new, 6 removed)
  l10n: fr.po v2.18 round 1
  l10n: vi(3470t): Updated Vietnamese translation for v2.18.0
  l10n: es.po: Spanish update for v2.18.0 round 1
  l10n: git.pot: v2.18.0 round 1 (108 new, 14 removed)
  l10n: TEAMS: remove inactive de team members
  l10n: de.po: fix typos
  l10n: Update Catalan translation

7 years agoA bunch of micro-fixes before going 2.18 final
Junio C Hamano [Mon, 18 Jun 2018 17:20:42 +0000 (10:20 -0700)]
A bunch of micro-fixes before going 2.18 final

Signed-off-by: Junio C Hamano <redacted>
7 years agol10n: ko.po: Update Korean translation
Changwoo Ryu [Mon, 18 Jun 2018 17:07:46 +0000 (02:07 +0900)]
l10n: ko.po: Update Korean translation

Update the Korean translation and change the team leader to Gwan-gyeong
Mun.

Signed-off-by: Gwan-gyeong Mun <redacted>
Signed-off-by: Changwoo Ryu <redacted>
Reviewed-by: Gwan-gyeong Mun <redacted>
7 years agoMerge branch 'sb/blame-color'
Junio C Hamano [Mon, 18 Jun 2018 17:18:45 +0000 (10:18 -0700)]
Merge branch 'sb/blame-color'

Leakfix.

* sb/blame-color:
  blame: release string_list after use in parse_color_fields()

7 years agoMerge branch 'mw/doc-merge-enumfix'
Junio C Hamano [Mon, 18 Jun 2018 17:18:45 +0000 (10:18 -0700)]
Merge branch 'mw/doc-merge-enumfix'

Fix old merge glitch in Documentation during v2.13-rc0 era.

* mw/doc-merge-enumfix:
  doc: update the order of the syntax `git merge --continue`

7 years agoMerge branch 'en/rename-directory-detection'
Junio C Hamano [Mon, 18 Jun 2018 17:18:44 +0000 (10:18 -0700)]
Merge branch 'en/rename-directory-detection'

Newly added codepath in merge-recursive had potential buffer
overrun, which has been fixed.

* en/rename-directory-detection:
  merge-recursive: use xstrdup() instead of fixed buffer

7 years agoMerge branch 'rd/doc-remote-tracking-with-hyphen'
Junio C Hamano [Mon, 18 Jun 2018 17:18:43 +0000 (10:18 -0700)]
Merge branch 'rd/doc-remote-tracking-with-hyphen'

Doc update.

* rd/doc-remote-tracking-with-hyphen:
  Use hyphenated "remote-tracking branch" (docs and comments)

7 years agoMerge branch 'jl/zlib-restore-nul-termination'
Junio C Hamano [Mon, 18 Jun 2018 17:18:43 +0000 (10:18 -0700)]
Merge branch 'jl/zlib-restore-nul-termination'

Make zlib inflate codepath more robust against versions of zlib
that clobber unused portion of outbuf.

* jl/zlib-restore-nul-termination:
  packfile: correct zlib buffer handling

7 years agoMerge branch 'ab/cred-netrc-no-autodie'
Junio C Hamano [Mon, 18 Jun 2018 17:18:42 +0000 (10:18 -0700)]
Merge branch 'ab/cred-netrc-no-autodie'

Hotfix for contrib/ stuff broken by this cycle.

* ab/cred-netrc-no-autodie:
  git-credential-netrc: remove use of "autodie"

7 years agoMerge branch 'km/doc-workflows-typofix'
Junio C Hamano [Mon, 18 Jun 2018 17:18:42 +0000 (10:18 -0700)]
Merge branch 'km/doc-workflows-typofix'

Typofix.

* km/doc-workflows-typofix:
  gitworkflows: fix grammar in 'Merge upwards' rule

7 years agoMerge branch 'ld/git-p4-updates'
Junio C Hamano [Mon, 18 Jun 2018 17:18:41 +0000 (10:18 -0700)]
Merge branch 'ld/git-p4-updates'

"git p4" updates.

* ld/git-p4-updates:
  git-p4: auto-size the block
  git-p4: narrow the scope of exceptions caught when parsing an int
  git-p4: raise exceptions from p4CmdList based on error from p4 server
  git-p4: better error reporting when p4 fails
  git-p4: add option to disable syncing of p4/master with p4
  git-p4: disable-rebase: allow setting this via configuration
  git-p4: add options --commit and --disable-rebase

7 years agoMerge branch 'rd/diff-options-typofix'
Junio C Hamano [Mon, 18 Jun 2018 17:18:41 +0000 (10:18 -0700)]
Merge branch 'rd/diff-options-typofix'

Typofix.

* rd/diff-options-typofix:
  diff-options.txt: fix minor typos, font inconsistencies, in docs

7 years agoMerge branch 'rd/comment-typofix-in-sha1-file'
Junio C Hamano [Mon, 18 Jun 2018 17:18:40 +0000 (10:18 -0700)]
Merge branch 'rd/comment-typofix-in-sha1-file'

In code comment typofix

* rd/comment-typofix-in-sha1-file:
  sha1-file.c: correct $GITDIR to $GIT_DIR in a comment

7 years agoewah: drop ewah_serialize_native function
Jeff King [Fri, 15 Jun 2018 03:32:28 +0000 (23:32 -0400)]
ewah: drop ewah_serialize_native function

We don't call this function, and never have. The on-disk
bitmap format uses network-byte-order integers, meaning that
we cannot use the native-byte-order format written here.

Let's drop it in the name of simplicity.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoewah: drop ewah_deserialize function
Jeff King [Fri, 15 Jun 2018 03:31:58 +0000 (23:31 -0400)]
ewah: drop ewah_deserialize function

We don't call this function, and in fact never have since it
was added (at least not in iterations of the ewah patches
that got merged). Instead we use ewah_read_mmap().

Let's drop the unused code.

Note to anybody who later wants to resurrect this: it does
not check for integer overflow in the ewah data size,
meaning it may be possible to convince the code to allocate
a too-small buffer and read() into it.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoewah_io: delete unused 'ewah_serialize()'
Derrick Stolee [Fri, 15 Jun 2018 18:27:52 +0000 (18:27 +0000)]
ewah_io: delete unused 'ewah_serialize()'

Reported-by: Ramsay Jones <redacted>
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoewah_bitmap: delete unused 'ewah_or()'
Derrick Stolee [Fri, 15 Jun 2018 18:27:50 +0000 (18:27 +0000)]
ewah_bitmap: delete unused 'ewah_or()'

Reported-by: Ramsay Jones <redacted>
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoewah_bitmap: delete unused 'ewah_not()'
Derrick Stolee [Fri, 15 Jun 2018 18:27:48 +0000 (18:27 +0000)]
ewah_bitmap: delete unused 'ewah_not()'

Reported-by: Ramsay Jones <redacted>
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoewah_bitmap: delete unused 'ewah_and_not()'
Derrick Stolee [Fri, 15 Jun 2018 18:27:46 +0000 (18:27 +0000)]
ewah_bitmap: delete unused 'ewah_and_not()'

Reported-by: Ramsay Jones <redacted>
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoewah_bitmap: delete unused 'ewah_and()'
Derrick Stolee [Fri, 15 Jun 2018 18:27:44 +0000 (18:27 +0000)]
ewah_bitmap: delete unused 'ewah_and()'

Reported-by: Ramsay Jones <redacted>
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoewah/bitmap.c: delete unused 'bitmap_each_bit()'
Derrick Stolee [Fri, 15 Jun 2018 18:27:41 +0000 (18:27 +0000)]
ewah/bitmap.c: delete unused 'bitmap_each_bit()'

Reported-by: Ramsay Jones <redacted>
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoewah/bitmap.c: delete unused 'bitmap_clear()'
Derrick Stolee [Fri, 15 Jun 2018 18:27:38 +0000 (18:27 +0000)]
ewah/bitmap.c: delete unused 'bitmap_clear()'

Reported-by: Ramsay Jones <redacted>
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agomerge-recursive: use xstrdup() instead of fixed buffer
René Scharfe [Sun, 10 Jun 2018 10:56:31 +0000 (12:56 +0200)]
merge-recursive: use xstrdup() instead of fixed buffer

Paths can be longer than PATH_MAX.  Avoid a buffer overrun in
check_dir_renamed() by using xstrdup() to make a private copy safely.

Signed-off-by: Rene Scharfe <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoRelNotes 2.18: minor fix to entry about dynamically loading completions
SZEDER Gábor [Mon, 18 Jun 2018 10:46:09 +0000 (12:46 +0200)]
RelNotes 2.18: minor fix to entry about dynamically loading completions

It was not "newer versions of bash" but newer versions of
bash-completion that made commit 085e2ee0e6 (completion: load
completion file for external subcommand, 2018-04-29) both necessary
and possible.

Update the corresponding RelNotes entry accordingly.

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agot7406-submodule-update: fix broken &&-chains
SZEDER Gábor [Sat, 16 Jun 2018 20:33:19 +0000 (22:33 +0200)]
t7406-submodule-update: fix broken &&-chains

Three tests in 't7406-submodule-update' contain broken &&-chains, but
since they are all in subshells, chain-lint couldn't notice them.

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agorebase --root: fix amending root commit messages
Johannes Schindelin [Sat, 16 Jun 2018 19:00:38 +0000 (21:00 +0200)]
rebase --root: fix amending root commit messages

The code path that triggered that "BUG" really does not want to run
without an explicit commit message. In the case where we want to amend a
commit message, we have an *implicit* commit message, though: the one of
the commit to amend. Therefore, this code path should not even be
entered.

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agorebase --root: demonstrate a bug while amending root commit messages
Todd Zullinger [Fri, 15 Jun 2018 04:31:11 +0000 (00:31 -0400)]
rebase --root: demonstrate a bug while amending root commit messages

When splitting a repository, running `git rebase -i --root` to reword
the initial commit, Git dies with

BUG: sequencer.c:795: root commit without message.

Signed-off-by: Todd Zullinger <redacted>
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoewah: adjust callers of ewah_read_mmap()
Jeff King [Fri, 15 Jun 2018 03:44:43 +0000 (23:44 -0400)]
ewah: adjust callers of ewah_read_mmap()

The return value of ewah_read_mmap() is now an ssize_t,
since we could (in theory) process up to 32GB of data. This
would never happen in practice, but a corrupt or malicious
.bitmap or index file could convince us to do so.

Let's make sure that we don't stuff the value into an int,
which would cause us to incorrectly move our pointer
forward.  We'd always move too little, since negative values
are used for reporting errors. So the worst case is just
that we end up reporting a corrupt file, not an
out-of-bounds read.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoewah_read_mmap: bounds-check mmap reads
Jeff King [Fri, 15 Jun 2018 03:31:13 +0000 (23:31 -0400)]
ewah_read_mmap: bounds-check mmap reads

The on-disk ewah format tells us how big the ewah data is,
and we blindly read that much from the buffer without
considering whether the mmap'd data is long enough, which
can lead to out-of-bound reads.

Let's make sure we have data available before reading it,
both for the ewah header/footer as well as for the bit data
itself. In particular:

  - keep our ptr/len pair in sync as we move through the
    buffer, and check it before each read

  - check the size for integer overflow (this should be
    impossible on 64-bit, as the size is given as a 32-bit
    count of 8-byte words, but is possible on a 32-bit
    system)

  - return the number of bytes read as an ssize_t instead of
    an int, again to prevent integer overflow

  - compute the return value using a pointer difference;
    this should yield the same result as the existing code,
    but makes it more obvious that we got our computations
    right

The included test is far from comprehensive, as it just
picks a static point at which to truncate the generated
bitmap. But in practice this will hit in the middle of an
ewah and make sure we're at least exercising this code.

Reported-by: Luat Nguyen <redacted>
Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agot3200: clarify description of --set-upstream test
Kaartic Sivaraam [Sun, 17 Jun 2018 11:56:27 +0000 (17:26 +0530)]
t3200: clarify description of --set-upstream test

Support for the --set-upstream option was removed in 52668846ea
(builtin/branch: stop supporting the "--set-upstream" option,
2017-08-17). The change did not completely remove the command
due to an issue noted in the commit's log message.

So, a test was added to ensure that a command which uses the
'--set-upstream' option fails instead of silently acting as an alias
for the '--set-upstream-to' option due to option parsing features.

To avoid confusion, clarify that the option is disabled intentionally
in the corresponding test description.

The test is expected to be around as long as we intentionally fail
on seeing the '--set-upstream' option which in turn we expect to
do for a period of time after which we can be sure that existing
users of '--set-upstream' are aware that the option is no
longer supported.

Signed-off-by: Kaartic Sivaraam <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogit-credential-netrc: fix exit status when tests fail
Luis Marsano [Wed, 13 Jun 2018 03:10:39 +0000 (23:10 -0400)]
git-credential-netrc: fix exit status when tests fail

Signed-off-by: Luis Marsano <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogit-credential-netrc: use in-tree Git.pm for tests
Luis Marsano [Wed, 13 Jun 2018 03:10:38 +0000 (23:10 -0400)]
git-credential-netrc: use in-tree Git.pm for tests

The netrc test.pl script calls git-credential-netrc which imports the
Git module.  Pass GITPERLLIB to git-credential-netrc via PERL5LIB to
ensure the in-tree Git module is used for testing.

Signed-off-by: Luis Marsano <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agogit-credential-netrc: minor whitespace cleanup in test script
Todd Zullinger [Wed, 13 Jun 2018 03:10:37 +0000 (23:10 -0400)]
git-credential-netrc: minor whitespace cleanup in test script

Signed-off-by: Todd Zullinger <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agol10n: zh_CN: for git v2.18.0 l10n round 1 to 3
Jiang Xin [Mon, 28 May 2018 01:11:57 +0000 (09:11 +0800)]
l10n: zh_CN: for git v2.18.0 l10n round 1 to 3

Translate 251 new messages (3608t0f0u) for git 2.18.0.

Signed-off-by: Jiang Xin <redacted>
7 years agoMerge branch 'master' of git://github.com/nafmo/git-l10n-sv
Jiang Xin [Sun, 17 Jun 2018 14:44:08 +0000 (22:44 +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 (3608t0f0u)
  l10n: sv.po: Update Swedish translation (3470t0f0u)

7 years agoMerge branch 'master' of https://github.com/vnwildman/git
Jiang Xin [Sun, 17 Jun 2018 14:41:43 +0000 (22:41 +0800)]
Merge branch 'master' of https://github.com/vnwildman/git

* 'master' of https://github.com/vnwildman/git:
  l10n: vi.po(3608t): Update Vietnamese translation for v2.18.0 round 3

7 years agoMerge branch 'master' of git://github.com/alshopov/git-po
Jiang Xin [Sun, 17 Jun 2018 14:37:53 +0000 (22:37 +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 (3608t)

7 years agoMerge branch 'fr_2.18_rnd3' of git://github.com/jnavila/git
Jiang Xin [Sun, 17 Jun 2018 14:36:41 +0000 (22:36 +0800)]
Merge branch 'fr_2.18_rnd3' of git://github.com/jnavila/git

* 'fr_2.18_rnd3' of git://github.com/jnavila/git:
  l10n: fr.po v2.18.0 round 3

7 years agol10n: bg.po: Updated Bulgarian translation (3608t)
Alexander Shopov [Sun, 17 Jun 2018 11:16:40 +0000 (13:16 +0200)]
l10n: bg.po: Updated Bulgarian translation (3608t)

Signed-off-by: Alexander Shopov <redacted>
7 years agol10n: vi.po(3608t): Update Vietnamese translation for v2.18.0 round 3
Tran Ngoc Quan [Sun, 17 Jun 2018 00:06:44 +0000 (07:06 +0700)]
l10n: vi.po(3608t): Update Vietnamese translation for v2.18.0 round 3

Signed-off-by: Tran Ngoc Quan <redacted>
7 years agol10n: fr.po v2.18.0 round 3
Jean-Noël Avila [Sat, 16 Jun 2018 18:35:01 +0000 (20:35 +0200)]
l10n: fr.po v2.18.0 round 3

Signed-off-by: Jean-Noël Avila <redacted>
7 years agol10n: es.po: Spanish update for v2.18.0 round 3
Christopher Diaz Riveros [Sat, 16 Jun 2018 14:58:53 +0000 (09:58 -0500)]
l10n: es.po: Spanish update for v2.18.0 round 3

Signed-off-by: Christopher Diaz Riveros <redacted>
7 years agol10n: git.pot: v2.18.0 round 3 (1 new, 1 removed)
Jiang Xin [Sat, 16 Jun 2018 14:06:45 +0000 (22:06 +0800)]
l10n: git.pot: v2.18.0 round 3 (1 new, 1 removed)

Generate po/git.pot from v2.18.0-rc2 for git v2.18.0 l10n round 3.

Signed-off-by: Jiang Xin <redacted>
7 years agoMerge branch 'master' of git://github.com/git-l10n/git-po
Jiang Xin [Sat, 16 Jun 2018 14:05:21 +0000 (22:05 +0800)]
Merge branch 'master' of git://github.com/git-l10n/git-po

* 'master' of git://github.com/git-l10n/git-po:
  l10n: vi.po(3608t): Update Vietnamese translation for v2.18.0 round2
  l10n: bg.po: Updated Bulgarian translation (3608t)
  l10n: es.po: Spanish update for v2.18.0 round 2
  l10n: git.pot: v2.18.0 round 2 (144 new, 6 removed)
  l10n: fr.po v2.18 round 1
  l10n: vi(3470t): Updated Vietnamese translation for v2.18.0
  l10n: es.po: Spanish update for v2.18.0 round 1
  l10n: git.pot: v2.18.0 round 1 (108 new, 14 removed)
  l10n: TEAMS: remove inactive de team members
  l10n: de.po: fix typos
  l10n: Update Catalan translation

7 years agoMakefile: make NO_ICONV really mean "no iconv"
Eric Sunshine [Fri, 15 Jun 2018 02:25:03 +0000 (22:25 -0400)]
Makefile: make NO_ICONV really mean "no iconv"

The Makefile tweak NO_ICONV is meant to allow Git to be built without
iconv in case iconv is not installed or is otherwise dysfunctional.
However, NO_ICONV's disabling of iconv is incomplete and can incorrectly
allow "-liconv" to slip into the linker flags when NEEDS_LIBICONV is
defined, which breaks the build when iconv is not installed.

On some platforms, iconv lives directly in libc, whereas, on others it
resides in libiconv. For the latter case, NEEDS_LIBICONV instructs the
Makefile to add "-liconv" to the linker flags. config.mak.uname
automatically defines NEEDS_LIBICONV for platforms which require it.
The adding of "-liconv" is done unconditionally, despite NO_ICONV.

Work around this problem by making NO_ICONV take precedence over
NEEDS_LIBICONV.

Reported by: Mahmoud Al-Qudsi <redacted>
Signed-off-by: Eric Sunshine <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agotests: clean after SANITY tests
Junio C Hamano [Fri, 15 Jun 2018 18:13:39 +0000 (11:13 -0700)]
tests: clean after SANITY tests

Some of our tests try to make sure Git behaves sensibly in a
read-only directory, by dropping 'w' permission bit before doing a
test and then restoring it after it is done.  The latter is needed
for the test framework to clean after itself without leaving a
leftover directory that cannot be removed.

Ancient parts of tests however arrange the above with

chmod a-w . &&
... do the test ...
status=$?
chmod 775 .
(exit $status)

which obviously would not work if the test somehow dies before it
has the chance to do "chmod 775".  Rewrite them by following a more
robust pattern recently written tests use, which is

test_when_finished "chmod 775 ." &&
chmod a-w . &&
... do the test ...

Signed-off-by: Junio C Hamano <redacted>
7 years agolog: prevent error if line range ends past end of file
Isabella Stephens [Fri, 15 Jun 2018 06:29:28 +0000 (16:29 +1000)]
log: prevent error if line range ends past end of file

If the -L option is used to specify a line range in git log, and the end
of the range is past the end of the file, git will fail with a fatal
error. This commit prevents such behaviour - instead we perform the log
for existing lines within the specified range.

This commit also fixes a corner case where -L ,-n:file would be treated
as a log over the whole file. Now we treat this as -L 1,-n:file and
blame the first line of the file instead.

Signed-off-by: Isabella Stephens <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoblame: prevent error if range ends past end of file
Isabella Stephens [Fri, 15 Jun 2018 06:29:27 +0000 (16:29 +1000)]
blame: prevent error if range ends past end of file

If the -L option is used to specify a line range in git blame, and the
end of the range is past the end of the file, git will fail with a fatal
error. This commit prevents such behavior - instead we display the blame
for existing lines within the specified range. Tests are amended
accordingly.

This commit also fixes two corner cases. Blaming -L n,-(n+1) now blames
the first n lines of a file rather than from n to the end of the file.
Blaming -L ,-n will be treated as -L 1,-n and blame the first line of
the file, rather than blaming the whole file.

Signed-off-by: Isabella Stephens <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agofetch-pack: introduce negotiator API
Jonathan Tan [Thu, 14 Jun 2018 22:54:28 +0000 (15:54 -0700)]
fetch-pack: introduce negotiator API

Introduce the new files fetch-negotiator.{h,c}, which contains an API
behind which the details of negotiation are abstracted. Currently, only
one algorithm is available: the existing one.

This patch is written to be easily reviewed: static functions are
moved verbatim from fetch-pack.c to negotiator/default.c, and it can be
seen that the lines replaced by negotiator->X() calls are present in the
X() functions respectively.

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agofetch-pack: move common check and marking together
Jonathan Tan [Thu, 14 Jun 2018 22:54:27 +0000 (15:54 -0700)]
fetch-pack: move common check and marking together

When receiving 'ACK <object-id> continue' for a common commit, check if
the commit was already known to be common and mark it as such if not up
front. This should make future refactoring of how the information about
common commits is stored more straightforward.

No visible change intended.

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agofetch-pack: make negotiation-related vars local
Jonathan Tan [Thu, 14 Jun 2018 22:54:26 +0000 (15:54 -0700)]
fetch-pack: make negotiation-related vars local

Reduce the number of global variables by making the priority queue and
the count of non-common commits in it local, passing them as a struct to
various functions where necessary.

This also helps in the case that fetch_pack() is invoked twice in the
same process (when tag following is required when using a transport that
does not support tag following), in that different priority queues will
now be used in each invocation, instead of reusing the possibly
non-empty one.

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agofetch-pack: use ref adv. to prune "have" sent
Jonathan Tan [Thu, 14 Jun 2018 22:54:25 +0000 (15:54 -0700)]
fetch-pack: use ref adv. to prune "have" sent

In negotiation using protocol v2, fetch-pack sometimes does not make
full use of the information obtained in the ref advertisement:
specifically, that if the server advertises a commit that the client
also has, the client never needs to inform the server that it has the
commit's parents, since it can just tell the server that it has the
advertised commit and it knows that the server can and will infer the
rest.

This is because, in do_fetch_pack_v2(), rev_list_insert_ref_oid() is
invoked before mark_complete_and_common_ref(). This means that if we
have a commit that is both our ref and their ref, it would be enqueued
by rev_list_insert_ref_oid() as SEEN, and since it is thus already SEEN,
mark_complete_and_common_ref() would not enqueue it.

If mark_complete_and_common_ref() were invoked first, as it is in
do_fetch_pack() for protocol v0, then mark_complete_and_common_ref()
would enqueue it with COMMON_REF | SEEN. The addition of COMMON_REF
ensures that its parents are not sent as "have" lines.

Change the order in do_fetch_pack_v2() to be consistent with
do_fetch_pack(), and to avoid sending unnecessary "have" lines.

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agofetch-pack: directly end negotiation if ACK ready
Jonathan Tan [Thu, 14 Jun 2018 22:54:24 +0000 (15:54 -0700)]
fetch-pack: directly end negotiation if ACK ready

When "ACK %s ready" is received, find_common() clears rev_list in an
attempt to stop further "have" lines from being sent [1]. It is much
more readable to explicitly break from the loop instead.

So explicitly break from the loop, and make the clearing of the rev_list
happen unconditionally.

[1] The rationale is further described in the originating commit
f2cba9299b ("fetch-pack: Finish negotation if remote replies "ACK %s
ready"", 2011-03-14).

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoMerge branch 'master' of https://github.com/vnwildman/git
Jiang Xin [Fri, 15 Jun 2018 02:04:25 +0000 (10:04 +0800)]
Merge branch 'master' of https://github.com/vnwildman/git

* 'master' of https://github.com/vnwildman/git:
  l10n: vi.po(3608t): Update Vietnamese translation for v2.18.0 round2

7 years agosubmodule: unset core.worktree if no working tree is present
Stefan Beller [Tue, 12 Jun 2018 23:58:23 +0000 (16:58 -0700)]
submodule: unset core.worktree if no working tree is present

When a submodules work tree is removed, we should unset its core.worktree
setting as the worktree is no longer present. This is not just in line
with the conceptual view of submodules, but it fixes an inconvenience
for looking at submodules that are not checked out:

    git clone --recurse-submodules git://github.com/git/git && cd git &&
    git checkout --recurse-submodules v2.13.0
    git -C .git/modules/sha1collisiondetection log
    fatal: cannot chdir to '../../../sha1collisiondetection': \
        No such file or directory

With this patch applied, the final call to git log works instead of dying
in its setup, as the checkout will unset the core.worktree setting such
that following log will be run in a bare repository.

This patch covers all commands that are in the unpack machinery, i.e.
checkout, read-tree, reset. A follow up patch will address
"git submodule deinit", which will also make use of the new function
submodule_unset_core_worktree(), which is why we expose it in this patch.

Signed-off-by: Stefan Beller <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agot5526: test recursive submodules when fetching moved submodules
Stefan Beller [Thu, 14 Jun 2018 17:37:30 +0000 (10:37 -0700)]
t5526: test recursive submodules when fetching moved submodules

The topic merged in 0c7ecb7c311 (Merge branch 'sb/submodule-move-nested',
2018-05-08) provided support for moving nested submodules.

Remove the NEEDSWORK comment and implement the nested submodules test as
the comment hinted at.

Signed-off-by: Stefan Beller <redacted>
Acked-by: Heiko Voigt <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agosubmodule: fix NULL correctness in renamed broken submodules
Stefan Beller [Thu, 14 Jun 2018 17:31:07 +0000 (10:31 -0700)]
submodule: fix NULL correctness in renamed broken submodules

When fetching with recursing into submodules, the fetch logic inspects
the superproject which submodules actually need to be fetched. This is
tricky for submodules that were renamed in the fetched range of commits.
This was implemented in c68f8375760 (implement fetching of moved
submodules, 2017-10-16), and this patch fixes a mistake in the logic
there.

When the warning is printed, the `name` might be NULL as
default_name_or_path can return NULL, so fix the warning to use the path
as obtained from the diff machinery, as that is not NULL.

While at it, make sure we only attempt to load the submodule if a git
directory of the submodule is found as default_name_or_path will return
NULL in case the git directory cannot be found. Note that passing NULL
to submodule_from_name is just a semantic error, as submodule_from_name
accepts NULL as a value, but then the return value is not the submodule
that was asked for, but some arbitrary other submodule. (Cf. 'config_from'
in submodule-config.c: "If any parameter except the cache is a NULL
pointer just return the first submodule. Can be used to check whether
there are any submodules parsed.")

Reported-by: Duy Nguyen <redacted>
Helped-by: Duy Nguyen <redacted>
Helped-by: Heiko Voigt <redacted>
Signed-off-by: Stefan Beller <redacted>
Acked-by: Heiko Voigt <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agofetch-pack: clear marks before re-marking
Jonathan Tan [Wed, 6 Jun 2018 20:47:08 +0000 (13:47 -0700)]
fetch-pack: clear marks before re-marking

If tag following is required when using a transport that does not
support tag following, fetch_pack() will be invoked twice in the same
process, necessitating a clearing of the object flags used by
fetch_pack() sometime during the second invocation. This is currently
done in find_common(), which means that the invocation of
mark_complete_and_common_ref() in do_fetch_pack() is useless.

(This cannot be reproduced with Git alone, because all transports that
come with Git support tag following.)

Therefore, move this clearing from find_common() to its
parent function do_fetch_pack(), right before it calls
mark_complete_and_common_ref().

This has been occurring since the commit that introduced the clearing of
marks, 420e9af498 ("Fix tag following", 2008-03-19).

The corresponding code for protocol v2 in do_fetch_pack_v2() does not
have this problem, as the clearing of flags is done before any marking
(whether by rev_list_insert_ref_oid() or
mark_complete_and_common_ref()).

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agofetch-pack: split up everything_local()
Jonathan Tan [Wed, 6 Jun 2018 20:47:07 +0000 (13:47 -0700)]
fetch-pack: split up everything_local()

The function everything_local(), despite its name, also (1) marks
commits as COMPLETE and COMMON_REF and (2) invokes filter_refs() as
important side effects. Extract (1) into its own function
(mark_complete_and_common_ref()) and remove
(2).

The restoring of save_commit_buffer, which was introduced in a1c6d7c1a7
("fetch-pack: restore save_commit_buffer after use", 2017-12-08), is a
concern of the parse_object() call in mark_complete_and_common_ref(), so
it has been moved from the end of everything_local() to the end of
mark_complete_and_common_ref().

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agodoc: update the order of the syntax `git merge --continue`
Meng-Sung Wu [Thu, 14 Jun 2018 01:33:34 +0000 (09:33 +0800)]
doc: update the order of the syntax `git merge --continue`

The syntax "git merge <message> HEAD <commit>" has been removed. The
order of the syntax should also be updated.

Signed-off-by: Meng-Sung Wu <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agoblame: release string_list after use in parse_color_fields()
René Scharfe [Sat, 9 Jun 2018 11:26:53 +0000 (13:26 +0200)]
blame: release string_list after use in parse_color_fields()

Signed-off-by: Rene Scharfe <redacted>
Signed-off-by: Junio C Hamano <redacted>
7 years agomerge-recursive: use xstrdup() instead of fixed buffer
René Scharfe [Sun, 10 Jun 2018 10:56:31 +0000 (12:56 +0200)]
merge-recursive: use xstrdup() instead of fixed buffer

Paths can be longer than PATH_MAX.  Avoid a buffer overrun in
check_dir_renamed() by using xstrdup() to make a private copy safely.

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