gitweb.git
checkout: add simple check for 'git checkout -b'Derrick Stolee Thu, 29 Aug 2019 17:01:32 +0000 (10:01 -0700)

checkout: add simple check for 'git checkout -b'

The 'git switch' command was created to separate half of the
behavior of 'git checkout'. It specifically has the mode to
do nothing with the index and working directory if the user
only specifies to create a new branch and change HEAD to that
branch. This is also the behavior most users expect from
'git checkout -b', but for historical reasons it also performs
an index update by scanning the working directory. This can be
slow for even moderately-sized repos.

A performance fix for 'git checkout -b' was introduced by
fa655d8411 (checkout: optimize "git checkout -b <new_branch>"
2018-08-16). That change includes details about the config
setting checkout.optimizeNewBranch when the sparse-checkout
feature is required. The way this change detected if this
behavior change is safe was through the skip_merge_working_tree()
method. This method was complex and needed to be updated
as new options were introduced.

This behavior was essentially reverted by 65f099b ("switch:
no worktree status unless real branch switch happens"
2019-03-29). Instead, two members of the checkout_opts struct
were used to distinguish between 'git checkout' and 'git switch':

* switch_branch_doing_nothing_is_ok
* only_merge_on_switching_branches

These settings have opposite values depending on if we start
in cmd_checkout or cmd_switch.

The message for 64f099b includes "Users of big repos are
encouraged to move to switch." Making this change while
'git switch' is still experimental is too aggressive.

Create a happy medium between these two options by making
'git checkout -b <branch>' behave just like 'git switch',
but only if we read exactly those arguments. This must
be done in cmd_checkout to avoid the arguments being
consumed by the option parsing logic.

This differs from the previous change by fa644d8 in that
the config option checkout.optimizeNewBranch remains
deleted. This means that 'git checkout -b' will ignore
the index merge even if we have a sparse-checkout file.
While this is a behavior change for 'git checkout -b',
it matches the behavior of 'git switch -c'.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Acked-by: Elijah Newren <newren@gmail.com>
Acked-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

restore: fix typo in docsWilliam Chargin Sat, 3 Aug 2019 22:04:58 +0000 (15:04 -0700)

restore: fix typo in docs

Signed-off-by: William Chargin <wchargin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

completion: disable dwim on "git switch -d"Nguyễn Thái Ngọc Duy Thu, 20 Jun 2019 09:55:22 +0000 (16:55 +0700)

completion: disable dwim on "git switch -d"

Even though dwim is enabled by default, it will never be done when
--detached is specified. If you force "-d --guess" you will get an error
because --guess then implies -c which cannot be used with -d. So we can
disable dwim in "switch -d". It makes the completion list in this case a
bit shorter.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

switch: allow to switch in the middle of bisectNguyễn Thái Ngọc Duy Thu, 20 Jun 2019 09:55:21 +0000 (16:55 +0700)

switch: allow to switch in the middle of bisect

In c45f0f525d (switch: reject if some operation is in progress,
2019-03-29), a check is added to prevent switching when some operation
is in progress. The reason is it's often not safe to do so.

This is true for merge, am, rebase, cherry-pick and revert, but not so
much for bisect because bisecting is basically jumping/switching between
a bunch of commits to pin point the first bad one. git-bisect suggests
the next commit to test, but it's not wrong for the user to test a
different commit because git-bisect cannot have the knowledge to know
better.

For this reason, allow to switch when bisecting (*). I considered if we
should still prevent switching by default and allow it with
--ignore-in-progress. But I don't think the prevention really adds
anything much.

If the user switches away by mistake, since we print the previous HEAD
value, even if they don't know about the "-" shortcut, switching back is
still possible.

The warning will be printed on every switch while bisect is still
ongoing, not the first time you switch away from bisect's suggested
commit, so it could become a bit annoying.

(*) of course when it's safe to do so, i.e. no loss of local changes and
stuff.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t2027: use test_must_be_emptyNguyễn Thái Ngọc Duy Thu, 20 Jun 2019 09:55:20 +0000 (16:55 +0700)

t2027: use test_must_be_empty

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Declare both git-switch and git-restore experimentalNguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:46:00 +0000 (16:46 +0700)

Declare both git-switch and git-restore experimental

These two commands are basically redesigned git-checkout. We will not
have that many opportunities to redo (because we run out of verbs, and
that would also increase maintenance cost).

To play it safe, let's declare the two commands experimental in one or
two releases. If there is a serious flaw in the UI, we could still fix
it. If everything goes well and nobody complains loudly, we can remove
the experimental status by reverting this patch.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

help: move git-diff and git-reset to different groupsNguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:45:59 +0000 (16:45 +0700)

help: move git-diff and git-reset to different groups

The third column in command-list.txt determines what group a common
command is printed in 'git help'.

"git reset" is currently in the "work on the current change (see also:
git help everyday)" group. While it's true that "git reset" can
manipulate the index and can be in this group, its unique
functionality is resetting HEAD, which should be the "grow, mark,
tweak history" group.

Moving it there will also avoid the confusion because both 'restore'
and 'reset' are in the same group, next to each other.

While looking at the 'group, mark, tweak history', I realize "git
diff" should not be there. All the commands in this group is about
_changing_ the commit history while "git diff" is a read-only
operation. It fits better in the "examine the history and state" group
(especially when "git status", its close friend, is already there).

This is what we have after the reorganization:

work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
restore Restore working tree files
rm Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
diff Show changes between commits, commit and working tree, etc
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status

grow, mark and tweak your common history
branch List, create, or delete branches
commit Record changes to the repository
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
reset Reset current HEAD to the specified state
switch Switch branches
tag Create, list, delete or verify a tag object signed with GPG

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

doc: promote "git restore"Nguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:45:58 +0000 (16:45 +0700)

doc: promote "git restore"

The new command "git restore" (together with "git switch") are added
to avoid the confusion of one-command-do-all "git checkout" for new
users. They are also helpful to avoid ambiguous context.

For these reasons, promote it everywhere possible. This includes
documentation, suggestions/advice from other commands.

One nice thing about git-restore is the ability to restore
"everything", so it can be used in "git status" advice instead of both
"git checkout" and "git reset". The three commands suggested by "git
status" are add, rm and restore.

"git checkout" is also removed from "git help" (i.e. it's no longer
considered a commonly used command)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

user-manual.txt: prefer 'merge --abort' over 'reset... Nguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:45:57 +0000 (16:45 +0700)

user-manual.txt: prefer 'merge --abort' over 'reset --hard'

Since the operation in progress is merge, stick to the 'git merge'
variant of aborting. 'git reset --hard' does not really tell you about
aborting the merge by just looking, longer to type, and even though I
know by heart what --hard do, I still dislike it when I need to consider
whether --hard, --mixed or --soft.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

completion: support restoreNguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:45:56 +0000 (16:45 +0700)

completion: support restore

Completion for restore is straightforward. We could still do better
though by giving the list of just tracked files instead of all present
ones. But let's leave it for later.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t: add tests for restoreNguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:45:55 +0000 (16:45 +0700)

t: add tests for restore

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

restore: support --patchNguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:45:54 +0000 (16:45 +0700)

restore: support --patch

git-restore is different from git-checkout that it only restores the
worktree by default, not both worktree and index. add--interactive
needs some update to support this mode.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

restore: replace --force with --ignore-unmergedNguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:45:53 +0000 (16:45 +0700)

restore: replace --force with --ignore-unmerged

Use a more specific option name to express its purpose. --force may come
back as an alias of --ignore-unmerged and possibly more. But since this
is a destructive operation, I don't see why we need to "force" anything
more. We already don't hold back.

When 'checkout --force' or 'restore --ignore-unmerged' is used, we may
also print warnings about unmerged entries being ignore. Since this is
not exactly warning (people tell us to do so), more informational, let
it be suppressed if --quiet is given. This is a behavior change for
git-checkout.

PS. The diff looks a bit iffy since --force is moved to
add_common_switch_branch_options() (i.e. for switching). But
git-checkout is also doing switching and inherits this --force.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

restore: default to --source=HEAD when only --staged... Nguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:45:52 +0000 (16:45 +0700)

restore: default to --source=HEAD when only --staged is specified

"git restore --staged" without --source does not make much sense since
by default we restore from the index. Instead of copying the index to
itself, set the default source to HEAD in this case, yielding behavior
that matches "git reset -- <paths>".

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

restore: reject invalid combinations with --stagedNguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:45:51 +0000 (16:45 +0700)

restore: reject invalid combinations with --staged

git-checkout rejects plenty of invalid option combinations. Since
git-checkout is equivalent of either

git restore --source --staged --worktree

or

git restore --worktree

that still leaves the new mode 'git restore --index' unprotected. Reject
some more invalid option combinations.

The other new mode 'restore --source --worktree' does not need anything
else.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

restore: add --worktree and --stagedNguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:45:50 +0000 (16:45 +0700)

restore: add --worktree and --staged

'git checkout <tree-ish> <pathspec>' updates both index and
worktree. But updating the index when you want to restore worktree
files is non-intuitive. The index contains the data ready for the next
commit, and there's no indication that the user will want to commit
the restored versions.

'git restore' therefore by default only touches worktree. The user has
the option to update either the index with

git restore --staged --source=<tree> <path> (1)

or update both with

git restore --staged --worktree --source=<tree> <path> (2)

PS. Orignally I wanted to make worktree update default and form (1)
would add index update while also updating the worktree, and the user
would need to do "--staged --no-worktree" to update index only. But it
looks really confusing that "--staged" option alone updates both. So
now form (2) is used for both, which reads much more obvious.

PPS. Yes form (1) overlaps with "git reset <rev> <path>". I don't know
if we can ever turn "git reset" back to "_always_ reset HEAD and
optionally do something else".

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

checkout: factor out worktree checkout codeNguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:45:49 +0000 (16:45 +0700)

checkout: factor out worktree checkout code

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

restore: disable overlay mode by defaultNguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:45:48 +0000 (16:45 +0700)

restore: disable overlay mode by default

Overlay mode is considered confusing when the command is about
restoring files on worktree. Disable it by default. The user can still
turn it on, or use 'git checkout' which still has overlay mode on by
default.

While at it, make the check in checkout_branch() stricter. Neither
--overlay or --no-overlay should be accepted in branch switching mode.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

restore: make pathspec mandatoryNguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:45:47 +0000 (16:45 +0700)

restore: make pathspec mandatory

"git restore" without arguments does not make much sense when
it's about restoring files (what files now?). We could default to
either

git restore .

or

git restore :/

Neither is intuitive. Make the user always give pathspec, force the
user to think the scope of restore they want because this is a
destructive operation.

"git restore -p" without pathspec is an exception to this
because it really is a separate mode. It will be treated as running
patch mode on the whole worktree.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

restore: take tree-ish from --source option insteadNguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:45:46 +0000 (16:45 +0700)

restore: take tree-ish from --source option instead

This is another departure from 'git checkout' syntax, which uses -- to
separate ref and pathspec. The observation is restore (or "git
checkout -- <pathspec>") is most often used to restore some files from
the index. If this is correct, we can simplify it by taking away the
ref, so that we can write

git restore some-file

without worrying about some-file being a ref and whether we need to do

git restore -- some-file

for safety. If the source of the restore comes from a tree, it will be
in the form of an option with value, e.g.

git restore --source=this-tree some-file

This is of course longer to type than using "--". But hopefully it
will not be used as often, and it is clearly easier to understand.

dwim_new_local_branch is no longer set (or unset) in cmd_restore_files()
because it's irrelevant because we don't really care about dwim-ing.
With accept_ref being unset, dwim can't happen.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

checkout: split part of it to new command 'restore'Nguyễn Thái Ngọc Duy Thu, 25 Apr 2019 09:45:45 +0000 (16:45 +0700)

checkout: split part of it to new command 'restore'

Previously the switching branch business of 'git checkout' becomes a
new command 'switch'. This adds the restore command for the checking
out paths path.

Similar to git-switch, a new man page is added to describe what the
command will become. The implementation will be updated shortly to
match the man page.

A couple main differences from 'git checkout <paths>':

- 'restore' by default will only update worktree. This matters more
when --source is specified ('checkout <tree> <paths>' updates both
worktree and index).

- 'restore --staged' can be used to restore the index. This command
overlaps with 'git reset <paths>'.

- both worktree and index could also be restored at the same time
(from a tree) when both --staged and --worktree are specified. This
overlaps with 'git checkout <tree> <paths>'

- default source for restoring worktree and index is the index and
HEAD respectively. A different (tree) source could be specified as
with --source (*).

- when both index and worktree are restored, --source must be
specified since the default source for these two individual targets
are different (**)

- --no-overlay is enabled by default, if an entry is missing in the
source, restoring means deleting the entry

(*) I originally went with --from instead of --source. I still think
--from is a better name. The short option -f however is already
taken by force. And I do think short option is good to have, e.g. to
write -s@ or -s@^ instead of --source=HEAD.

(**) If you sit down and think about it, moving worktree's source from
the index to HEAD makes sense, but nobody is really thinking it
through when they type the commands.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

doc: promote "git switch"Nguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:19 +0000 (17:39 +0700)

doc: promote "git switch"

The new command "git switch" is added to avoid the confusion of
one-command-do-all "git checkout" for new users. They are also helpful
to avoid ambiguation context.

For these reasons, promote it everywhere possible. This includes
documentation, suggestions/advice from other commands...

The "Checking out files" progress line in unpack-trees.c is also updated
to "Updating files" to be neutral to both git-checkout and git-switch.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

completion: support switchNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:18 +0000 (17:39 +0700)

completion: support switch

Completion support for --guess could be made better. If no --detach is
given, we should only provide a list of refs/heads/* and dwim ones,
not the entire ref space. But I still can't penetrate that
__git_refs() function yet.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t: add tests for switchNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:17 +0000 (17:39 +0700)

t: add tests for switch

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

switch: make --orphan switch to an empty treeNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:16 +0000 (17:39 +0700)

switch: make --orphan switch to an empty tree

Switching and creating branches always involves knowing the
<start-point> to begin the new branch from. Sometimes, people want to
create a new branch that does not have any commits yet; --orphan is a
flag to allow that.

--orphan overrides the default of HEAD for <start-point> instead causing
us to start from an empty history with all tracked files removed from
the index and working tree. The use of --orphan is incompatible with
specifying a <start-point>.

A note on the implementation. An alternative is just create a dummy
commit in-core with empty tree and switch to it. But there's a chance
the commit's SHA-1 may end up somewhere permanent like reflog. It's best
to make sure "commit" pointer is NULL to avoid it.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

switch: reject if some operation is in progressNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:15 +0000 (17:39 +0700)

switch: reject if some operation is in progress

Unless you know what you're doing, switching to another branch to do
something then switching back could be confusing. Worse, you may even
forget that you're in the middle of something. By the time you realize,
you may have done a ton of work and it gets harder to go back.

A new option --ignore-in-progress was considered but dropped because it
was not exactly clear what should happen. Sometimes you can switch away
and get back safely and resume the operation. Sometimes not. And the
git-checkout behavior is automatically clear merge/revert/cherry-pick,
which makes it a bit even more confusing [1].

We may revisit and add this option in the future. But for now play it
safe and not allow it (you can't even skip this check with --force). The
user is suggested to cancel the operation by themselves (and hopefully
they do consider the consequences, not blindly type the command), or to
create a separate worktree instead of switching. The third option is
the good old "git checkout", but it's not mentioned.

[1] CACsJy8Axa5WsLSjiscjnxVK6jQHkfs-gH959=YtUvQkWriAk5w@mail.gmail.com

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

switch: no worktree status unless real branch switch... Nguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:14 +0000 (17:39 +0700)

switch: no worktree status unless real branch switch happens

When we switch from one branch to another, it makes sense to show a
summary of local changes since there could be conflicts, or some files
left modified.... When switch is used solely for creating a new
branch (and "switch" to the same commit) or detaching, we don't really
need to show anything.

"git checkout" does it anyway for historical reasons. But we can start
with a clean slate with switch and don't have to.

This essentially reverts fa655d8411 (checkout: optimize "git checkout
-b <new_branch>" - 2018-08-16) and make it default for switch,
but also for -B and --detach. Users of big repos are encouraged to
move to switch.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

switch: implicit dwim, use --no-guess to disable itNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:13 +0000 (17:39 +0700)

switch: implicit dwim, use --no-guess to disable it

This is already the default in git-checkout. The real change in here is
just minor cleanup. The main excuse is to explain why dwim is kept default.

Contrary to detach mode that is easy to get into and confusing to get
back out. Automatically creating a tracking branch often does not kick
in as often (you would need a branch of the same name on a remote). And
since the branch creation is reported clearly, the user should be able
to undo/delete it if it's unwanted.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

switch: add short option for --detachNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:12 +0000 (17:39 +0700)

switch: add short option for --detach

"git checkout" automatically detaches branches and --detach is not
that useful (--no-detach is more likely). But for "switch", you
may want to use it more often once you're used to detached HEAD. This
of course adds -d to git-checkout but it does not harm (yet?) to do it.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

switch: only allow explicit detached HEADNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:11 +0000 (17:39 +0700)

switch: only allow explicit detached HEAD

"git checkout <commit>" will checkout the commit in question and
detach HEAD from the current branch. It is naturally a right thing to
do once you get git references. But detached HEAD is a scary concept
to new users because we show a lot of warnings and stuff, and it could
be hard to get out of (until you know better).

To keep switch a bit more friendly to new users, we only allow
entering detached HEAD mode when --detach is given. "git
switch" must take a branch (unless you create a new branch,
then of course switch can take any commit-ish)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

switch: reject "do nothing" caseNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:10 +0000 (17:39 +0700)

switch: reject "do nothing" case

"git checkout" can be executed without any arguments. What it does is
not exactly great: it switches from HEAD to HEAD and shows worktree
modification as a side effect.

Make switch reject this case. Just use "git status" if you want
that side effect. For switch, you have to either

- really switch a branch
- (explicitly) detach from the current branch
- create a new branch

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

switch: stop accepting pathspecNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:09 +0000 (17:39 +0700)

switch: stop accepting pathspec

This command is about switching branch (or creating a new one) and
should not accept pathspec. This helps simplify ambiguation
handling. The other two ("git checkout" and "git restore") of
course do accept pathspec as before.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

switch: remove -lNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:08 +0000 (17:39 +0700)

switch: remove -l

This option is ancient. Nowadays reflog is enabled by default and
automatically created for new branches. Keep it in git-checkout only.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

switch: add --discard-changesNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:07 +0000 (17:39 +0700)

switch: add --discard-changes

--discard-changes is a better name than --force for this option since
it's what really happens. --force is turned to an alias for
--discard-changes. But it's meant to be an alias for potentially more
force options in the future.

Side note. It's not obvious from the patch but --discard-changes also
affects submodules if --recurse-submodules is used. The knob to force
updating submodules is hidden behind unpack-trees.c

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

switch: better names for -b and -BNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:06 +0000 (17:39 +0700)

switch: better names for -b and -B

The shortcut of these options do not make much sense when used with
switch. And their descriptions are also tied to checkout. Move -b/-B
to cmd_checkout() and new -c/-C with the same functionality in
cmd_switch_branch()

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

checkout: split part of it to new command 'switch'Nguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:05 +0000 (17:39 +0700)

checkout: split part of it to new command 'switch'

"git checkout" doing too many things is a source of confusion for many
users (and it even bites old timers sometimes). To remedy that, the
command will be split into two new ones: switch and restore. The good
old "git checkout" command is still here and will be until all (or most
of users) are sick of it.

See the new man page for the final design of switch. The actual
implementation though is still pretty much the same as "git checkout"
and not completely aligned with the man page. Following patches will
adjust their behavior to match the man page.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

checkout: split options[] array in three piecesNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:04 +0000 (17:39 +0700)

checkout: split options[] array in three pieces

This is a preparation step for introducing new commands that do parts
of what checkout does. There will be two new commands, one is about
switching branches, detaching HEAD... one about checking out
paths. These share the a subset of command line options. The rest of
command line options are separate.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

checkout: move 'confict_style' and 'dwim_..' to checkou... Nguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:03 +0000 (17:39 +0700)

checkout: move 'confict_style' and 'dwim_..' to checkout_opts

These local variables are referenced by struct option[]. This struct
will soon be broken down, moved away and we can't rely on local
variables anymore. Move these two to struct checkout_opts in
preparation for that.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

checkout: make "opts" in cmd_checkout() a pointerNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:02 +0000 (17:39 +0700)

checkout: make "opts" in cmd_checkout() a pointer

"opts" will soon be moved out of cmd_checkout(). To keep changes in
that patch smaller, convert "opts" to a pointer and keep the real
thing behind "real_opts".

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

checkout: factor out some code in parse_branchname_arg()Nguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:01 +0000 (17:39 +0700)

checkout: factor out some code in parse_branchname_arg()

This is in preparation for the new command restore, which also
needs to parse opts->source_tree but does not need all the
disambiguation logic.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

checkout: keep most #include sortedNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:39:00 +0000 (17:39 +0700)

checkout: keep most #include sorted

The include list becomes very long and frankly a bit unorganized. With
the exception of builtin.h, cache.h or git-compat-util.h which have to
come first, keep the rest sorted.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

checkout: inform the user when removing branch stateNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:38:59 +0000 (17:38 +0700)

checkout: inform the user when removing branch state

After a successful switch, if a merge, cherry-pick or revert is ongoing,
it is canceled. This behavior has been with us from the very early
beginning, soon after git-merge was created but never actually
documented [1]. It may be a good idea to be transparent and tell the
user if some operation is canceled.

I consider this a better way of telling the user than just adding a
sentence or two in git-checkout.txt, which will be mostly ignored
anyway.

PS. Originally I wanted to print more details like

warning: cancelling an in-progress merge from <SHA-1>

which may allow some level of undo if the user wants to. But that seems
a lot more work. Perhaps it can be improved later if people still want
that.

[1] ... and I will try not to argue whether it is a sensible behavior.
There is some more discussion here if people are interested:
CACsJy8Axa5WsLSjiscjnxVK6jQHkfs-gH959=YtUvQkWriAk5w@mail.gmail.com

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

checkout: advice how to get out of detached HEAD modeNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:38:58 +0000 (17:38 +0700)

checkout: advice how to get out of detached HEAD mode

Detached HEAD mode is considered dangerous and confusing for newcomers
and we print a big block of warning how to move forward. But we should
also suggest the user the way to get out of it if they get into detached
HEAD by mistake.

While at there, I also suggest how to turn the advice off. This is
another thing I find annoying with advices and should be dealt with in a
more generic way. But that may require some refactoring in advice.c
first.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t: rename t2014-switch.sh to t2014-checkout-switch.shNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:38:57 +0000 (17:38 +0700)

t: rename t2014-switch.sh to t2014-checkout-switch.sh

The old name does not really say that this is about 'checkout -b'. See
49d833dc07 (Revert "checkout branch: prime cache-tree fully" -
2009-05-12) for more information

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-checkout.txt: fix monospace typesetNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:38:56 +0000 (17:38 +0700)

git-checkout.txt: fix monospace typeset

Add backticks where we have none, replace single quotes with backticks
and replace double-quotes. Drop double-quotes from nested constructions
such as `"@{-1}"`.

Helped-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

doc: document --overwrite-ignoreNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:38:55 +0000 (17:38 +0700)

doc: document --overwrite-ignore

I added this option in git-checkout and git-merge in c1d7036b6b
(checkout,merge: disallow overwriting ignored files with
--no-overwrite-ignore - 2011-11-27) but did not remember to update
documentation. This completes that commit.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-checkout.txt: fix one syntax lineNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:38:54 +0000 (17:38 +0700)

git-checkout.txt: fix one syntax line

<branch> can be omitted in this syntax, and it's actually documented a
few paragraphs down:

You could omit <branch>, in which case the command degenerates to
"check out the current branch", which is a glorified no-op with
rather expensive side-effects to show only the tracking information,
if exists, for the current branch.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-checkout.txt: spell out --no-optionNguyễn Thái Ngọc Duy Fri, 29 Mar 2019 10:38:53 +0000 (17:38 +0700)

git-checkout.txt: spell out --no-option

It's easier to search for and also less cryptic.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

The second batchJunio C Hamano Mon, 11 Mar 2019 07:18:22 +0000 (16:18 +0900)

The second batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Sync with maintJunio C Hamano Mon, 11 Mar 2019 07:16:34 +0000 (16:16 +0900)

Sync with maint

* maint:
mingw: allow building with an MSYS2 runtime v3.x

Merge branch 'js/rebase-recreate-merge'Junio C Hamano Mon, 11 Mar 2019 07:16:26 +0000 (16:16 +0900)

Merge branch 'js/rebase-recreate-merge'

Docfix.

* js/rebase-recreate-merge:
rebase docs: fix "gitlink" typo

Merge branch 'js/untravis-windows'Junio C Hamano Mon, 11 Mar 2019 07:16:26 +0000 (16:16 +0900)

Merge branch 'js/untravis-windows'

Dev support.

* js/untravis-windows:
travis: remove the hack to build the Windows job on Azure Pipelines

Merge branch 'rd/gc-prune-doc-fix'Junio C Hamano Mon, 11 Mar 2019 07:16:26 +0000 (16:16 +0900)

Merge branch 'rd/gc-prune-doc-fix'

Doxfix.

* rd/gc-prune-doc-fix:
docs/git-gc: fix typo "--prune=all" to "--prune=now"

Merge branch 'js/find-lib-h-with-ls-files-when-possible'Junio C Hamano Mon, 11 Mar 2019 07:16:25 +0000 (16:16 +0900)

Merge branch 'js/find-lib-h-with-ls-files-when-possible'

The Makefile uses 'find' utility to enumerate all the *.h header
files, which is expensive on platforms with slow filesystems; it
now optionally uses "ls-files" if working within a repository,
which is a trick similar to how all sources are enumerated to run
ETAGS on.

* js/find-lib-h-with-ls-files-when-possible:
Makefile: use `git ls-files` to list header files, if possible

Merge branch 'rj/hdr-check-gcrypt-fix'Junio C Hamano Mon, 11 Mar 2019 07:16:25 +0000 (16:16 +0900)

Merge branch 'rj/hdr-check-gcrypt-fix'

The set of header files used by "make hdr-check" unconditionally
included sha256/gcrypt.h, even when it is not used, causing the
make target to fail. We now skip it when GCRYPT_SHA256 is not in
use.

* rj/hdr-check-gcrypt-fix:
Makefile: fix 'hdr-check' when GCRYPT not installed

Merge branch 'jk/guard-bswap-header'Junio C Hamano Mon, 11 Mar 2019 07:16:25 +0000 (16:16 +0900)

Merge branch 'jk/guard-bswap-header'

The include file compat/bswap.h has been updated so that it is safe
to (accidentally) include it more than once.

* jk/guard-bswap-header:
compat/bswap: add include header guards

Merge branch 'rd/attr.c-comment-typofix'Junio C Hamano Mon, 11 Mar 2019 07:16:24 +0000 (16:16 +0900)

Merge branch 'rd/attr.c-comment-typofix'

In-code comment typofix.

* rd/attr.c-comment-typofix:
attr.c: ".gitattribute" -> ".gitattributes" (comments)

Merge branch 'yb/utf-16le-bom-spellfix'Junio C Hamano Mon, 11 Mar 2019 07:16:24 +0000 (16:16 +0900)

Merge branch 'yb/utf-16le-bom-spellfix'

Doc update.

* yb/utf-16le-bom-spellfix:
gitattributes.txt: fix typo

mingw: allow building with an MSYS2 runtime v3.xJohannes Schindelin Fri, 8 Mar 2019 15:51:19 +0000 (07:51 -0800)

mingw: allow building with an MSYS2 runtime v3.x

Recently the Git for Windows project started the upgrade process to
a MSYS2 runtime version based on Cygwin v3.x.

This has the very notable consequence that `$(uname -r)` no longer
reports a version starting with "2", but a version with "3".

That breaks our build, as df5218b4c30b (config.mak.uname: support MSys2,
2016-01-13) simply did not expect the version reported by `uname -r` to
depend on the underlying Cygwin version: it expected the reported
version to match the "2" in "MSYS2".

So let's invert that test case to test for *anything else* than a
version starting with "1" (for MSys). That should safeguard us for the
future, even if Cygwin ends up releasing versionsl like 314.272.65536.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

mingw: drop MakeMaker referenceJohannes Schindelin Mon, 25 Feb 2019 19:27:11 +0000 (11:27 -0800)

mingw: drop MakeMaker reference

In 20d2a30f8ffe (Makefile: replace perl/Makefile.PL with simple make
rules, 2017-12-10), Git stopped using MakeMaker. Therefore, that
definition in the MINGW-specific section became useless.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Start 2.22 cycleJunio C Hamano Thu, 7 Mar 2019 02:59:54 +0000 (11:59 +0900)

Start 2.22 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'jt/http-auth-proto-v2-fix'Junio C Hamano Thu, 7 Mar 2019 00:59:59 +0000 (09:59 +0900)

Merge branch 'jt/http-auth-proto-v2-fix'

Unify RPC code for smart http in protocol v0/v1 and v2, which fixes
a bug in the latter (lack of authentication retry) and generally
improves the code base.

* jt/http-auth-proto-v2-fix:
remote-curl: use post_rpc() for protocol v2 also
remote-curl: refactor reading into rpc_state's buf
remote-curl: reduce scope of rpc_state.result
remote-curl: reduce scope of rpc_state.stdin_preamble
remote-curl: reduce scope of rpc_state.argv

Merge branch 'jk/diff-no-index-initialize'Junio C Hamano Thu, 7 Mar 2019 00:59:59 +0000 (09:59 +0900)

Merge branch 'jk/diff-no-index-initialize'

"git diff --no-index" may still want to access Git goodies like
--ext-diff and --textconv, but so far these have been ignored,
which has been corrected.

* jk/diff-no-index-initialize:
diff: reuse diff setup for --no-index case

Merge branch 'nd/no-more-check-racy'Junio C Hamano Thu, 7 Mar 2019 00:59:59 +0000 (09:59 +0900)

Merge branch 'nd/no-more-check-racy'

Unused code removal.

* nd/no-more-check-racy:
Delete check-racy.c

Merge branch 'rd/doc-hook-used-in-sample'Junio C Hamano Thu, 7 Mar 2019 00:59:59 +0000 (09:59 +0900)

Merge branch 'rd/doc-hook-used-in-sample'

Doc update.

* rd/doc-hook-used-in-sample:
mention use of "hooks.allownonascii" in "man githooks"

Merge branch 'nd/diff-parseopt-2'Junio C Hamano Thu, 7 Mar 2019 00:59:58 +0000 (09:59 +0900)

Merge branch 'nd/diff-parseopt-2'

Second batch to teach the diff machinery to use the parse-options
API.

* nd/diff-parseopt-2: (21 commits)
diff-parseopt: convert --ignore-some-changes
diff-parseopt: convert --[no-]minimal
diff-parseopt: convert --relative
diff-parseopt: convert --no-renames|--[no--rename-empty
diff-parseopt: convert --find-copies-harder
diff-parseopt: convert -C|--find-copies
diff-parseopt: convert -D|--irreversible-delete
diff-parseopt: convert -M|--find-renames
diff-parseopt: convert -B|--break-rewrites
diff-parseopt: convert --output-*
diff-parseopt: convert --[no-]compact-summary
diff-parseopt: convert --stat*
diff-parseopt: convert -s|--no-patch
diff-parseopt: convert --name-status
diff-parseopt: convert --name-only
diff-parseopt: convert --patch-with-stat
diff-parseopt: convert --summary
diff-parseopt: convert --check
diff-parseopt: convert --dirstat and friends
diff-parseopt: convert --numstat and --shortstat
...

Merge branch 'en/merge-options-doc'Junio C Hamano Thu, 7 Mar 2019 00:59:58 +0000 (09:59 +0900)

Merge branch 'en/merge-options-doc'

Doc update.

* en/merge-options-doc:
merge-options.txt: correct wording of --no-commit option

Merge branch 'nd/completion-more-parameters'Junio C Hamano Thu, 7 Mar 2019 00:59:57 +0000 (09:59 +0900)

Merge branch 'nd/completion-more-parameters'

The command line completion (in contrib/) has been taught to
complete more subcommand parameters.

* nd/completion-more-parameters:
completion: add more parameter value completion

Merge branch 'ab/receive-pack-use-after-free-fix'Junio C Hamano Thu, 7 Mar 2019 00:59:57 +0000 (09:59 +0900)

Merge branch 'ab/receive-pack-use-after-free-fix'

Memfix.

* ab/receive-pack-use-after-free-fix:
receive-pack: fix use-after-free bug

Merge branch 'dl/doc-submodule-wo-subcommand'Junio C Hamano Thu, 7 Mar 2019 00:59:57 +0000 (09:59 +0900)

Merge branch 'dl/doc-submodule-wo-subcommand'

Doc update.

* dl/doc-submodule-wo-subcommand:
submodule: document default behavior

Merge branch 'jk/unused-params'Junio C Hamano Thu, 7 Mar 2019 00:59:56 +0000 (09:59 +0900)

Merge branch 'jk/unused-params'

Code clean-up.

* jk/unused-params:
ref-filter: drop unused "sz" parameters
ref-filter: drop unused "obj" parameters
ref-filter: drop unused buf/sz pairs
files-backend: drop refs parameter from split_symref_update()
pack-objects: drop unused parameter from oe_map_new_pack()
merge-recursive: drop several unused parameters
diff: drop complete_rewrite parameter from run_external_diff()
diff: drop unused emit data parameter from sane_truncate_line()
diff: drop unused color reset parameters
diff: drop options parameter from diffcore_fix_diff_index()

Merge branch 'jk/prune-optim'Junio C Hamano Thu, 7 Mar 2019 00:59:56 +0000 (09:59 +0900)

Merge branch 'jk/prune-optim'

"git prune" has been taught to take advantage of reachability
bitmap when able.

* jk/prune-optim:
t5304: rename "sha1" variables to "oid"
prune: check SEEN flag for reachability
prune: use bitmaps for reachability traversal
prune: lazily perform reachability traversal

Merge branch 'jh/trace2'Junio C Hamano Thu, 7 Mar 2019 00:59:56 +0000 (09:59 +0900)

Merge branch 'jh/trace2'

A more structured way to obtain execution trace has been added.

* jh/trace2:
trace2: add for_each macros to clang-format
trace2: t/helper/test-trace2, t0210.sh, t0211.sh, t0212.sh
trace2:data: add subverb for rebase
trace2:data: add subverb to reset command
trace2:data: add subverb to checkout command
trace2:data: pack-objects: add trace2 regions
trace2:data: add trace2 instrumentation to index read/write
trace2:data: add trace2 hook classification
trace2:data: add trace2 transport child classification
trace2:data: add trace2 sub-process classification
trace2:data: add editor/pager child classification
trace2:data: add trace2 regions to wt-status
trace2: collect Windows-specific process information
trace2: create new combined trace facility
trace2: Documentation/technical/api-trace2.txt

Merge branch 'js/doc-symref-in-proto-v1'Junio C Hamano Thu, 7 Mar 2019 00:59:56 +0000 (09:59 +0900)

Merge branch 'js/doc-symref-in-proto-v1'

Doc update.

* js/doc-symref-in-proto-v1:
protocol-capabilities.txt: document symref

Merge branch 'nd/split-index-null-base-fix'Junio C Hamano Thu, 7 Mar 2019 00:59:56 +0000 (09:59 +0900)

Merge branch 'nd/split-index-null-base-fix'

Split-index fix.

* nd/split-index-null-base-fix:
read-cache.c: fix writing "link" index ext with null base oid

Merge branch 'rj/prune-packed-excess-args'Junio C Hamano Thu, 7 Mar 2019 00:59:55 +0000 (09:59 +0900)

Merge branch 'rj/prune-packed-excess-args'

"git prune-packed" did not notice and complain against excess
arguments given from the command line, which now it does.

* rj/prune-packed-excess-args:
prune-packed: check for too many arguments

Merge branch 'jc/test-yes-doc'Junio C Hamano Thu, 7 Mar 2019 00:59:54 +0000 (09:59 +0900)

Merge branch 'jc/test-yes-doc'

Test doc update.

* jc/test-yes-doc:
test: caution on our version of 'yes'

Merge branch 'en/combined-all-paths'Junio C Hamano Thu, 7 Mar 2019 00:59:54 +0000 (09:59 +0900)

Merge branch 'en/combined-all-paths'

Output from "diff --cc" did not show the original paths when the
merge involved renames. A new option adds the paths in the
original trees to the output.

* en/combined-all-paths:
log,diff-tree: add --combined-all-paths option

Merge branch 'sc/pack-redundant'Junio C Hamano Thu, 7 Mar 2019 00:59:54 +0000 (09:59 +0900)

Merge branch 'sc/pack-redundant'

Update the implementation of pack-redundant for performance in a
repository with many packfiles.

* sc/pack-redundant:
pack-redundant: consistent sort method
pack-redundant: rename pack_list.all_objects
pack-redundant: new algorithm to find min packs
pack-redundant: delete redundant code
pack-redundant: delay creation of unique_objects
t5323: test cases for git-pack-redundant

Merge branch 'du/branch-show-current'Junio C Hamano Thu, 7 Mar 2019 00:59:53 +0000 (09:59 +0900)

Merge branch 'du/branch-show-current'

"git branch" learned a new subcommand "--show-current".

* du/branch-show-current:
branch: introduce --show-current display option

Merge branch 'dl/complete-submodule-absorbgitdirs'Junio C Hamano Thu, 7 Mar 2019 00:59:53 +0000 (09:59 +0900)

Merge branch 'dl/complete-submodule-absorbgitdirs'

Command-line completion (in contrib/) learned to tab-complete the
"git submodule absorbgitdirs" subcommand.

* dl/complete-submodule-absorbgitdirs:
completion: complete git submodule absorbgitdirs

Merge branch 'wh/author-committer-ident-config'Junio C Hamano Thu, 7 Mar 2019 00:59:53 +0000 (09:59 +0900)

Merge branch 'wh/author-committer-ident-config'

Four new configuration variables {author,committer}.{name,email}
have been introduced to override user.{name,email} in more specific
cases.

* wh/author-committer-ident-config:
config: allow giving separate author and committer idents

Merge branch 'aw/pretty-trailers'Junio C Hamano Thu, 7 Mar 2019 00:59:52 +0000 (09:59 +0900)

Merge branch 'aw/pretty-trailers'

The %(trailers) formatter in "git log --format=..." now allows to
optionally pick trailers selectively by keyword, show only values,
etc.

* aw/pretty-trailers:
pretty: add support for separator option in %(trailers)
strbuf: separate callback for strbuf_expand:ing literals
pretty: add support for "valueonly" option in %(trailers)
pretty: allow showing specific trailers
pretty: single return path in %(trailers) handling
pretty: allow %(trailers) options with explicit value
doc: group pretty-format.txt placeholders descriptions

Merge branch 'nd/diff-parseopt'Junio C Hamano Thu, 7 Mar 2019 00:59:52 +0000 (09:59 +0900)

Merge branch 'nd/diff-parseopt'

The diff machinery, one of the oldest parts of the system, which
long predates the parse-options API, uses fairly long and complex
handcrafted option parser. This is being rewritten to use the
parse-options API.

* nd/diff-parseopt:
diff.c: convert --raw
diff.c: convert -W|--[no-]function-context
diff.c: convert -U|--unified
diff.c: convert -u|-p|--patch
diff.c: prepare to use parse_options() for parsing
diff.h: avoid bit fields in struct diff_flags
diff.h: keep forward struct declarations sorted
parse-options: allow ll_callback with OPTION_CALLBACK
parse-options: avoid magic return codes
parse-options: stop abusing 'callback' for lowlevel callbacks
parse-options: add OPT_BITOP()
parse-options: disable option abbreviation with PARSE_OPT_KEEP_UNKNOWN
parse-options: add one-shot mode
parse-options.h: remove extern on function prototypes

Merge branch 'tg/checkout-no-overlay'Junio C Hamano Thu, 7 Mar 2019 00:59:51 +0000 (09:59 +0900)

Merge branch 'tg/checkout-no-overlay'

"git checkout --no-overlay" can be used to trigger a new mode of
checking out paths out of the tree-ish, that allows paths that
match the pathspec that are in the current index and working tree
and are not in the tree-ish.

* tg/checkout-no-overlay:
revert "checkout: introduce checkout.overlayMode config"
checkout: introduce checkout.overlayMode config
checkout: introduce --{,no-}overlay option
checkout: factor out mark_cache_entry_for_checkout function
checkout: clarify comment
read-cache: add invalidate parameter to remove_marked_cache_entries
entry: support CE_WT_REMOVE flag in checkout_entry
entry: factor out unlink_entry function
move worktree tests to t24*

attr.c: ".gitattribute" -> ".gitattributes" (comments)Robert P. J. Day Wed, 6 Mar 2019 09:14:44 +0000 (04:14 -0500)

attr.c: ".gitattribute" -> ".gitattributes" (comments)

Correct misspelled ".gitattribute" in comments only, so no functional
change.

Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitattributes.txt: fix typoYash Bhatambare Wed, 6 Mar 2019 05:23:10 +0000 (05:23 +0000)

gitattributes.txt: fix typo

`UTF-16-LE-BOM` to `UTF-16LE-BOM`.

this closes https://github.com/git-for-windows/git/issues/2095

Signed-off-by: Yash Bhatambare <ybhatambare@gmail.com>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

compat/bswap: add include header guardsJeff King Wed, 6 Mar 2019 19:05:10 +0000 (14:05 -0500)

compat/bswap: add include header guards

Our compat/bswap.h lacks the usual preprocessor guards against multiple
inclusion. This usually isn't an issue since it only gets included from
git-compat-util.h, which has its own guards. But it would produce
redeclaration errors if any file included it separately.

Our hdr-check target would complain about this, except that it currently
skips items in compat/ entirely.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Makefile: fix 'hdr-check' when GCRYPT not installedRamsay Jones Wed, 6 Mar 2019 00:11:13 +0000 (00:11 +0000)

Makefile: fix 'hdr-check' when GCRYPT not installed

If the GCRYPT_SHA256 build variable is not set, then the 'hdr-check'
target complains about the missing <gcrypt.h> header file. Add the
'sha256/gcrypt.h' header file to the exception list, if the build
variable is not defined. While here, replace the 'xdiff%' filter
pattern with 'xdiff/%' (and similarly for the compat pattern) since
the original pattern inadvertently excluded the 'xdiff-interface.h'
header.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Makefile: use `git ls-files` to list header files,... Johannes Schindelin Mon, 4 Mar 2019 13:47:06 +0000 (05:47 -0800)

Makefile: use `git ls-files` to list header files, if possible

In d85b0dff72 (Makefile: use `find` to determine static header
dependencies, 2014-08-25), we switched from a static list of header
files to a dynamically-generated one, asking `find` to enumerate them.

Back in those days, we did not use `$(LIB_H)` by default, and many a
`make` implementation seems smart enough not to run that `find` command
in that case, so it was deemed okay to run `find` for special targets
requiring this macro.

However, as of ebb7baf02f (Makefile: add a hdr-check target,
2018-09-19), $(LIB_H) is part of a global rule and therefore must be
expanded. Meaning: this `find` command has to be run upon every
`make` invocation. In the presence of many a worktree, this can tax the
developers' patience quite a bit.

Even in the absence of worktrees or other untracked files and
directories, the cost of I/O to generate that list of header files is
simply a lot larger than a simple `git ls-files` call.

Therefore, just like in 335339758c (Makefile: ask "ls-files" to list
source files if available, 2011-10-18), we now prefer to use `git
ls-files` to enumerate the header files to enumerating them via `find`,
falling back to the latter if the former failed (which would be the case
e.g. in a worktree that was extracted from a source .tar file rather
than from a clone of Git's sources).

This has one notable consequence: we no longer include `command-list.h`
in `LIB_H`, as it is a generated file, not a tracked one, but that is
easily worked around. Of the three sites that use `LIB_H`, two
(`LOCALIZED_C` and `CHK_HDRS`) already handle generated headers
separately. In the third, the computed-dependency fallback, we can just
add in a reference to $(GENERATED_H).

Likewise, we no longer include not-yet-tracked header files in `LIB_H`.

Given the speed improvements, these consequences seem a comparably small
price to pay.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Acked-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge tag 'l10n-2.21.0-rnd2.1' of git://github.com... Junio C Hamano Tue, 5 Mar 2019 12:53:10 +0000 (21:53 +0900)

Merge tag 'l10n-2.21.0-rnd2.1' of git://github.com/git-l10n/git-po

L10n for Git 2.21.0 round 2.1

* tag 'l10n-2.21.0-rnd2.1' of git://github.com/git-l10n/git-po:
l10n: Fixes to Catalan translation
l10n: Updated Vietnamese translation for v2.21 rd2
l10n: fr.po remove obsolete entries

remote-curl: use post_rpc() for protocol v2 alsoJonathan Tan Thu, 21 Feb 2019 20:24:41 +0000 (12:24 -0800)

remote-curl: use post_rpc() for protocol v2 also

When transmitting and receiving POSTs for protocol v0 and v1,
remote-curl uses post_rpc() (and associated functions), but when doing
the same for protocol v2, it uses a separate set of functions
(proxy_rpc() and others). Besides duplication of code, this has caused
at least one bug: the auth retry mechanism that was implemented in v0/v1
was not implemented in v2.

To fix this issue and avoid it in the future, make remote-curl also use
post_rpc() when handling protocol v2. Because line lengths are written
to the HTTP request in protocol v2 (unlike in protocol v0/v1), this
necessitates changes in post_rpc() and some of the functions it uses;
perform these changes too.

A test has been included to ensure that the code for both the unchunked
and chunked variants of the HTTP request is exercised.

Note: stateless_connect() has been updated to use the lower-level packet
reading functions instead of struct packet_reader. The low-level control
is necessary here because we cannot change the destination buffer of
struct packet_reader while it is being used; struct packet_buffer has a
peeking mechanism which relies on the destination buffer being present
in between a peek and a read.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

docs/git-gc: fix typo "--prune=all" to "--prune=now"Robert P. J. Day Sat, 2 Mar 2019 08:51:52 +0000 (03:51 -0500)

docs/git-gc: fix typo "--prune=all" to "--prune=now"

Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

l10n: Fixes to Catalan translationJordi Mas Sat, 2 Mar 2019 18:12:58 +0000 (19:12 +0100)

l10n: Fixes to Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>

l10n: Updated Vietnamese translation for v2.21 rd2Tran Ngoc Quan Tue, 26 Feb 2019 07:50:59 +0000 (14:50 +0700)

l10n: Updated Vietnamese translation for v2.21 rd2

Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>

travis: remove the hack to build the Windows job on... Johannes Schindelin Thu, 28 Feb 2019 19:33:52 +0000 (11:33 -0800)

travis: remove the hack to build the Windows job on Azure Pipelines

Since Travis did not support Windows (and now only supports very limited
Windows jobs, too limited for our use, the test suite would time out
*all* the time), we added a hack where a Travis job would trigger an
Azure Pipeline (which back then was still called VSTS Build), wait for
it to finish (or time out), and download the log (if available).

Needless to say that it was a horrible hack, necessitated by a bad
situation.

Nowadays, however, we have Azure Pipelines support, and do not need that
hack anymore. So let's retire it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rebase docs: fix "gitlink" typoKyle Meyer Thu, 28 Feb 2019 02:43:15 +0000 (21:43 -0500)

rebase docs: fix "gitlink" typo

Change it to "linkgit" so that the reference is properly rendered.

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

l10n: fr.po remove obsolete entriesJean-Noël Avila Mon, 25 Feb 2019 21:11:15 +0000 (22:11 +0100)

l10n: fr.po remove obsolete entries

On NetBSD, the version of msgfmt is still 0.14.4. There's no hope for
an upgrade due to some GPLv3 allergy of NetBSD's. This version chokes
on heavily decorated commented entries in po files. It's safer to get
rid of all these obsolete entries.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>

Git 2.21 v2.21.0Junio C Hamano Sun, 24 Feb 2019 15:55:19 +0000 (07:55 -0800)

Git 2.21

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'yn/checkout-doc-fix'Junio C Hamano Sun, 24 Feb 2019 15:18:00 +0000 (07:18 -0800)

Merge branch 'yn/checkout-doc-fix'

Doc fix.

* yn/checkout-doc-fix:
checkout doc: fix an unmatched double-quote pair