Re: "man git-checkout", man page is inconsistent between SYNOPSIS and details

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

 



"Robert P. J. Day" <rpjday@xxxxxxxxxxxxxx> writes:

>   it's simply a matter of the forms not matching between the SYNOPSIS
> and the DESCRIPTION sections. am i making sense?

I think the whole thing is wrong and the root cause is because the
(relatively newer) description of the "--patch" mode lazily tried to
piggy-back the description of existing "check out from the index or
tree-ish" mode, ending up in a confusing description.

"git checkout [<tree-ish>] -- <pathspec>..." is a way to overwrite
the working tree files with what is in the object store.  When you
give <tree-ish>, the paths that match the <pathspec> are grabbed
from the tree-ish, added to the index, and overwrites the working
tree files.  In this mode, you need to have at least one pathspec
element on the command line, so <pathspec> is mandatory.  With no
pathspec, if <tree-ish> happens to be a commit-ish, then the
operation is "check out the commit, so that we can prepare to make
a new commit as its child".

"git checkout -p/--patch [<tree-ish>]" is quite different.  It can
be used without any <pathspec> to pick and choose from all changes
treewide, but you can use <pathspec> to limit the changes you need
to choose from.

Something like the following may be a good starting point.  As I
didn't spend many brain-cycles to come up with a description for the
"--patch" mode, that paragraph needs a total rewrite on top, but I
think the structure to separate the normal "per-path" checkout mode
and "patch" mode and describe it separately should make it a lot
clearer to see what is being described.

Short of such a fundamental correction,

	git checkout [-p|--patch] [<tree-ish>] -- [<pathspec>...]

would allow you to give none of -p/--patch/<pathspec>, which is
totally a different operation from what is being described in the
text.

 Documentation/git-checkout.txt | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index d6399c0af8..3d88f703e9 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' [-p|--patch] [<tree-ish>] [--] [<paths>...]
+'git checkout' [<tree-ish>] [--] <pathspec>...
+'git checkout' (-p|--patch) [<tree-ish>] [--] [<paths>...]
 
 DESCRIPTION
 -----------
@@ -78,10 +79,9 @@ 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' [-p|--patch] [<tree-ish>] [--] <pathspec>...::
+'git checkout' [<tree-ish>] [--] <pathspec>...::
 
-	When <paths> or `--patch` are given, 'git checkout' does *not*
-	switch branches.  It updates the named paths in the working tree
+	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
@@ -89,7 +89,7 @@ Omitting <branch> detaches HEAD at the tip of the current branch.
 	(i.e.  commit, tag or tree) to update the index for the given
 	paths before updating the working tree.
 +
-'git checkout' with <paths> or `--patch` is used to restore modified or
+'git checkout' with <paths> is used to restore modified or
 deleted paths to their original contents from the index or replace paths
 with the contents from a named <tree-ish> (most often a commit-ish).
 +
@@ -101,6 +101,13 @@ 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"
+	mode described above, but lets you use the interactive
+	interface show the "diff" output and choose which hunks to
+	use in the result.
+
+
 OPTIONS
 -------
 -q::



[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