git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Documentation/git-checkout: make doc. of checkout <tree-ish> clearer

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 24, 2017, 01:55 UTC
Message-ID
<xmqqo9vm36xg.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1492881136.7368.3.camel@gmail.com>
Christoph Michelbach <michelbach94@gmail.com> writes:
>> Care to send in a patch to update the documentation?

Thanks. The attached patch text appears linewrapped, but I think I'll be able to salvage, so forgetting about the formatting, here are some comments.

Show 10 quoted lines
> From: Christoph Michelbach <michelbach94@gmail.com>
> Date: Sat, 22 Apr 2017 18:49:57 +0200
> Subject: [PATCH] Doc./git-checkout: correct doc. of checkout
> <pathspec>...
>
> The previous documentation states that the named paths are
> updated both in the index and the working tree. This is not
> correct as those paths can point to folders which are not
> updated to what they are in the given tree-ish. Rather,
> the files pointed to by the pathspecs are copied from the
s/pointed to by/that match/
> tree-ish to the index and working tree One difference being
Missing full-stop after "tree".
> that one can name paths which are not present in the working
> tree ...

That one is not a difference, I would think. If your current index and working tree lack F, you give pathspec that match F, and the tree-ish has that path F, that named path _is_ updated both in the index and in the working tree.

> ... and another being that only files which are already
> present in the given tree-ish are affected.
This one indeed was missing piece of information.
Show 17 quoted lines
> Signed-off-by: Christoph Michelbach <michelbach94@gmail.com>
> ---
>  Documentation/git-checkout.txt | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/Documentation/git-checkout.txt b/Documentation/git-
> checkout.txt
> index 8e2c066..f74f237 100644
> --- a/Documentation/git-checkout.txt
> +++ b/Documentation/git-checkout.txt
> @@ -81,13 +81,15 @@ Omitting <branch> detaches HEAD at the tip of the
> current branch.
>  'git checkout' [-p|--patch] [<tree-ish>] [--] <pathspec>...::
>  
>  	When <paths> or `--patch` are given, 'git checkout' does *not*
> +	switch branches.  It copies the files matching the pathspecs in
> +	<tree-is> (i.e. a commit, tag, or tree) to the index and

<tree-ish> is misspelled here. Drop (i.e. ...) as (1) it is not correct (a tag may not point at a tree-ish) and (2) "checkout" is not a place to learn what a tree-ish is (glossary is).

> +	subsequently to the working directory, overwriting changes

Do we need to say "subsequently" when we are aiming to be more intelligible by not describing the order of execution? The end result is that the blobs named by the pathspecs from the tree-ish are checked out to the index and to the working tree at the same time.

> +...	Note that because the index is updated, the
> +	changes introduced by this command are automatically staged.

This is redundant and unnecessary, I would say. If you absolutely need to say this, at least drop "automatically". There is nothing automatic about it. The user is asking to checkout the named blobs out of the tree-ish to the index and to the working tree, and Git is merely doing as it was told.

In addition the description is fuzzy; what are "changes introduced by this command" relative to? If you did "checkout HEAD path" after editing path in the working tree, is "reverting my edit" the "changes introduced by this command"? If you did "checkout HEAD path" after editing path, "git add path" and then editing path further, what are the "changes introduced by this command"?

Previous: Christoph MichelbachNext: Christoph Michelbach
Message 17 of 23 in “Documentation/git-checkout: make doc. of checkout <tree-ish> clearer”
  1. Documentation/git-checkout: make doc. of checkout <tree-ish> clearerChristoph Michelbach, Apr 15, 2017
  2. Philip OakleyApr 15, 2017
  3. Christoph MichelbachApr 16, 2017
  4. Philip OakleyApr 16, 2017
  5. Christoph MichelbachApr 16, 2017
  6. Philip OakleyApr 16, 2017
  7. Christoph MichelbachApr 16, 2017
  8. Philip OakleyApr 17, 2017
  9. Junio C HamanoApr 18, 2017
  10. Christoph MichelbachApr 18, 2017
  11. Philip OakleyApr 19, 2017
  12. Philip OakleyApr 17, 2017
  13. Junio C HamanoApr 18, 2017
  14. Christoph MichelbachApr 18, 2017
  15. Junio C HamanoApr 19, 2017
  16. Christoph MichelbachApr 22, 2017
  17. Junio C HamanoApr 24, 2017
  18. Christoph MichelbachApr 24, 2017
  19. Christoph MichelbachApr 24, 2017
  20. Junio C HamanoApr 25, 2017
  21. Christoph MichelbachApr 25, 2017
  22. Philip OakleyApr 19, 2017
  23. Christoph MichelbachApr 18, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.