Re: [PATCH] checkout doc: clarify command line args for "checkout paths" mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux