git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing list <git@vger.kernel.org>, Kevin Daudt <me@ikke.info>, "Robert P. J. Day" <rpjday@crashcourse.ca>
Subject: Re: [PATCH] checkout doc: clarify command line args for "checkout paths" mode
Date: Tue, 10 Oct 2017 20:22:40 -0700
Message-ID: <20171011032240.GZ19555@aiede.mtv.corp.google.com> (raw)
In-Reply-To: <xmqqefqao1av.fsf_-_@gitster.mtv.corp.google.com>

Hi,

Junio C Hamano wrote:

[...]
> The source of the confusion is that -p(atch) is described as if it
> is just another "optional" part and its description is lumped
> together with the non patch mode, even though the actual end user
> experience is vastly different.

Makes sense.  This should have been done as part of b831deda
(2010-06-01), but better late than never.

Let's see how the patch goes...

[...]
>  Documentation/git-checkout.txt | 32 +++++++++++++++++---------------
>  1 file changed, 17 insertions(+), 15 deletions(-)
> 
> diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
> index d6399c0af8..8e77a9de49 100644
> --- a/Documentation/git-checkout.txt
> +++ b/Documentation/git-checkout.txt
> @@ -13,7 +13,8 @@ SYNOPSIS
>  'git checkout' [-q] [-f] [-m] [--detach] <commit>
>  'git checkout' [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>]
>  'git checkout' [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>...
> +'git checkout' [<tree-ish>] [--] <pathspec>...
> -'git checkout' [-p|--patch] [<tree-ish>] [--] [<paths>...]
> +'git checkout' (-p|--patch) [<tree-ish>] [--] [<paths>...]

This file is inconsistent about <commit> versus <commit-ish>, <paths>
versus <pathspec>, etc.

On the subject of <commit> versus <commit-ish>, nowadays <commit> is
almost always preferable.  Git commands consistently accept a tag
pointing to a commit where a commit is expected, so emphasizing that
feature by calling it a commit-ish only adds distraction.  That's not
what this patch is about, though.

Even for this particular form, the current file is inconsistent about
whether to call the arguments '<paths>...' or '<pathspec>...'.
"<paths>..." is even more strange when I think about it for a moment,
since it is the plural of the plural of path --- i.e., it implies that
each argument names multiple paths.  Why does this patch use
<pathspec> for the --no-patch case and <paths> for the --patch case?


>  DESCRIPTION
>  -----------
> @@ -78,20 +79,13 @@ be used to detach HEAD at the tip of the branch (`git checkout
>  +
>  Omitting <branch> detaches HEAD at the tip of the current branch.
>  
> +'git checkout' [<tree-ish>] [--] <pathspec>...::
> +	Restore modified or deleted paths in the working tree by
> +	replacing with their original contents from the index, or
> +	the contents from a named <tree-ish> (most often a

This sentence is hard to read:

- "Restore ... in" reads oddly, as though this is an art conservation
  project that takes place in the working tree.  Is the intent that
  the command will bring the content of those paths back to the
  working tree, or something else?

- "replacing with" reads a little briskly and informally.  In this
  context, "replacing them with" will work better.

- "their original contents from" also reads oddly.  "Their original
  content from" would be fine, meaning their original content as
  obtained from.  I was tempted to read this as "The original contents
  of", but that was a misreading.

- Similarly, "the contents from" perhaps should be "the content of".

Stepping back, what problem is this solving in the original text?
It said

	When <paths> or --patch are given, git checkout does *not*
	switch branches. It updates the named paths in the working
	tree from the index file or from a named <tree-ish> (most
	often a commit). In this case, the -b and --track options are
	meaningless and giving either of them results in an error. The
	<tree-ish> argument can be used to specify a specific tree-ish
	(i.e. commit, tag or tree) to update the index for the given
	paths before updating the working tree.

The "or --patch" would have to go, of course.  Is the problem that
the description focuses too much on what this form does not do?
To fix that, it could say

	Replace matching paths in the working tree with content
	from the index or the named tree (most often a commit).  The
	<tree-ish> argument can be used to specify a specific tree,
	commit, or tag that will be used to update the entries for
	matching paths in the index before updating the working tree.

One thing that doesn't tell is what happens to files that are present
in the worktree but deleted in the index or the named tree.  Does "git
checkout" delete them?  I remember wishing that it would but don't
remember whether it does, so it's probably worth mentioning the
manpage giving an answer.

... aha, now I see the next paragraph where this text came from.  I
still think I like my example text based on the first paragraph
better. :)

[...]
> @@ -101,6 +95,14 @@ specific side of the merge can be checked out of the index by
>  using `--ours` or `--theirs`.  With `-m`, changes made to the working tree
>  file can be discarded to re-create the original conflicted merge result.
>  
> +'git checkout' (-p|--patch) [<tree-ish>] [--] [<pathspec>...]::
> +	This is similar to the "check out paths to the working tree
> +	from either the index or from a tree-ish" mode described
> +	above, but lets you use the interactive interface to show
> +	the "diff" output and choose which hunks to use in the
> +	result.

s/use/apply/, perhaps.

The options section explains --patch again.  Maybe that should point
back to here to avoid some duplication.

Thanks,
Jonathan

  reply index

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-30  9:27 "man git-checkout", man page is inconsistent between SYNOPSIS and details Robert P. J. Day
2017-09-30 14:32 ` Kevin Daudt
2017-09-30 15:01   ` Robert P. J. Day
2017-09-30 22:04   ` Robert P. J. Day
2017-10-01  3:49     ` Junio C Hamano
2017-10-01 10:05       ` Robert P. J. Day
2017-10-02  0:29         ` Junio C Hamano
2017-10-11  2:39           ` [PATCH] checkout doc: clarify command line args for "checkout paths" mode Junio C Hamano
2017-10-11  3:22             ` Jonathan Nieder [this message]
2017-10-11  5:02               ` Junio C Hamano
2017-10-11  5:16                 ` Jonathan Nieder

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171011032240.GZ19555@aiede.mtv.corp.google.com \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ikke.info \
    --cc=rpjday@crashcourse.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

git@vger.kernel.org mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox