git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git-reflog.txt: add an EXAMPLES section
@ 2022-10-03  8:46 Elia Pinto
  2022-10-03  9:20 ` Ævar Arnfjörð Bjarmason
  2022-10-03 13:07 ` Bagas Sanjaya
  0 siblings, 2 replies; 7+ messages in thread
From: Elia Pinto @ 2022-10-03  8:46 UTC (permalink / raw)
  To: git; +Cc: Elia Pinto

This commit adds an "EXAMPLES" section to the git reflog man page.
This new section currently provides examples of using git reflog
with branches, for which doubts often exist. In this commit we also
add a "SEE ALSO" section which refers to further information
on git commands or documentation referenced in the git reflog man page.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 Documentation/git-reflog.txt | 42 ++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/Documentation/git-reflog.txt b/Documentation/git-reflog.txt
index 70791b9fd8..5bbd5958fe 100644
--- a/Documentation/git-reflog.txt
+++ b/Documentation/git-reflog.txt
@@ -96,6 +96,48 @@ them.
 --verbose::
 	Print extra information on screen.
 
+EXAMPLES
+--------
+
+`git reflog`::
+	Lists entries of reflog of HEAD, starting at `HEAD@{0}`.
+
+`git reflog HEAD`::
+	The same.
+
+`git reflog show HEAD`::
+	The same.
+
+`git reflog HEAD@{4}`::
+	The same, starting at the 4th prior value of HEAD.
+
+`git reflog master`::
+	Lists entries of reflog of `master`.
+
+`git reflog master@{0}`::
+	The same.
+
+`git reflog master@{now}`::
+	The same, show with timestamp.
+
+`git reflog master@{4.minutes}`::
+	The same, starting at master, 4 minutes ago.
+
+For the branch that is currently checked out, you can omit the name
+when you use any of the @{..} notation, so
+
+`git reflog @{0}`
+
+`git reflog @{now}`
+
+are often the easiest ways to view what you did on the current
+branch
+
+SEE ALSO
+--------
+linkgit:gitrevisions[7],
+linkgit:git-log[1]
+
 GIT
 ---
 Part of the linkgit:git[1] suite
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] git-reflog.txt: add an EXAMPLES section
  2022-10-03  8:46 [PATCH] git-reflog.txt: add an EXAMPLES section Elia Pinto
@ 2022-10-03  9:20 ` Ævar Arnfjörð Bjarmason
  2022-10-03 13:53   ` Elia Pinto
  2022-10-03 16:31   ` Junio C Hamano
  2022-10-03 13:07 ` Bagas Sanjaya
  1 sibling, 2 replies; 7+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-10-03  9:20 UTC (permalink / raw)
  To: Elia Pinto; +Cc: git


On Mon, Oct 03 2022, Elia Pinto wrote:

> This commit adds an "EXAMPLES" section to the git reflog man page.
> This new section currently provides examples of using git reflog
> with branches, for which doubts often exist. In this commit we also
> add a "SEE ALSO" section which refers to further information
> on git commands or documentation referenced in the git reflog man page.

I think it can be valuable to have an EXAMPLES section, but:

> +EXAMPLES
> +--------
> +
> +`git reflog`::
> +	Lists entries of reflog of HEAD, starting at `HEAD@{0}`.
> +
> +`git reflog HEAD`::
> +	The same.
> +
> +`git reflog show HEAD`::
> +	The same.
> +
> +`git reflog HEAD@{4}`::
> +	The same, starting at the 4th prior value of HEAD.
> +
> +`git reflog master`::
> +	Lists entries of reflog of `master`.
> +
> +`git reflog master@{0}`::
> +	The same.
> +
> +`git reflog master@{now}`::
> +	The same, show with timestamp.
> +
> +`git reflog master@{4.minutes}`::
> +	The same, starting at master, 4 minutes ago.
> +
> +For the branch that is currently checked out, you can omit the name
> +when you use any of the @{..} notation, so
> +
> +`git reflog @{0}`
> +
> +`git reflog @{now}`
> +
> +are often the easiest ways to view what you did on the current
> +branch

Most of this really just seems to be duplicating "SPECIFYING REVISIONS",
and some of it such as "show with timestamp" is ambiguous/misleading. If
I didn't know how it worked I'd think that it might affect the output
itself (maybe showing times "relative to now"), but it's just
gitrevisions syntax.

> +SEE ALSO
> +--------
> +linkgit:gitrevisions[7],
> +linkgit:git-log[1]

Likewise "SEE ALSO" sections can be really valuable, but they're really
for "now that you've read the above, maybe this is also useful". It's
not a "SEE STUFF YOU SAW BEFORE" :)

In this case we link to these in the first and third paragraphs of the
DESCRIPTION section (respectively), since explaining the revision syntax
etc. is really core to understanding how this command works.

The "SEE ALSO" section is really more for stuff like (in this case)
'git-fsck', 'git-filter-branch', 'git-rev-list' or 'git-stash'. All of
those commansd have some direct interaction with the 'reflog', but are
not mentioned in the main prose.






^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] git-reflog.txt: add an EXAMPLES section
  2022-10-03  8:46 [PATCH] git-reflog.txt: add an EXAMPLES section Elia Pinto
  2022-10-03  9:20 ` Ævar Arnfjörð Bjarmason
@ 2022-10-03 13:07 ` Bagas Sanjaya
  2022-10-03 16:36   ` Junio C Hamano
  1 sibling, 1 reply; 7+ messages in thread
From: Bagas Sanjaya @ 2022-10-03 13:07 UTC (permalink / raw)
  To: Elia Pinto, git

On 10/3/22 15:46, Elia Pinto wrote:
> This commit adds an "EXAMPLES" section to the git reflog man page.
> This new section currently provides examples of using git reflog
> with branches, for which doubts often exist. In this commit we also
> add a "SEE ALSO" section which refers to further information
> on git commands or documentation referenced in the git reflog man page.
> 

Better say "Add git-reflog usage examples to the man page."
Also, shouldn't "SEE ALSO" additions be split from this patch?

-- 
An old man doll... just what I always wanted! - Clara

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] git-reflog.txt: add an EXAMPLES section
  2022-10-03  9:20 ` Ævar Arnfjörð Bjarmason
@ 2022-10-03 13:53   ` Elia Pinto
  2022-10-03 16:40     ` Junio C Hamano
  2022-10-03 16:31   ` Junio C Hamano
  1 sibling, 1 reply; 7+ messages in thread
From: Elia Pinto @ 2022-10-03 13:53 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git

Il giorno lun 3 ott 2022 alle ore 11:27 Ævar Arnfjörð Bjarmason
<avarab@gmail.com> ha scritto:
>
>
> On Mon, Oct 03 2022, Elia Pinto wrote:
>
> > This commit adds an "EXAMPLES" section to the git reflog man page.
> > This new section currently provides examples of using git reflog
> > with branches, for which doubts often exist. In this commit we also
> > add a "SEE ALSO" section which refers to further information
> > on git commands or documentation referenced in the git reflog man page.
>
> I think it can be valuable to have an EXAMPLES section, but:
>
> > +EXAMPLES
> > +--------
> > +
> > +`git reflog`::
> > +     Lists entries of reflog of HEAD, starting at `HEAD@{0}`.
> > +
> > +`git reflog HEAD`::
> > +     The same.
> > +
> > +`git reflog show HEAD`::
> > +     The same.
> > +
> > +`git reflog HEAD@{4}`::
> > +     The same, starting at the 4th prior value of HEAD.
> > +
> > +`git reflog master`::
> > +     Lists entries of reflog of `master`.
> > +
> > +`git reflog master@{0}`::
> > +     The same.
> > +
> > +`git reflog master@{now}`::
> > +     The same, show with timestamp.
> > +
> > +`git reflog master@{4.minutes}`::
> > +     The same, starting at master, 4 minutes ago.
> > +
> > +For the branch that is currently checked out, you can omit the name
> > +when you use any of the @{..} notation, so
> > +
> > +`git reflog @{0}`
> > +
> > +`git reflog @{now}`
> > +
> > +are often the easiest ways to view what you did on the current
> > +branch
>
> Most of this really just seems to be duplicating "SPECIFYING REVISIONS",
> and some of it such as "show with timestamp" is ambiguous/misleading. If
> I didn't know how it worked I'd think that it might affect the output
> itself (maybe showing times "relative to now"), but it's just
> gitrevisions syntax.

Thanks a lot, in the meantime.

The examples included are based on an email exchange done here between
a user and a git developer, maybe Junio, I don't remember. The user
found the explanation useful, as he had a hard time understanding how
git-reflog worked with branches. I agree that better could be done,
for example by entering how to recover lost commits, but that was not
the goal at the moment. Later this is something that it is  always
possible to do. It is also true that the examples in practice show
what should already be known with gitrevisions however obviously many
users cannot find the link between the two, I must imagine
>
> > +SEE ALSO
> > +--------
> > +linkgit:gitrevisions[7],
> > +linkgit:git-log[1]
>
> Likewise "SEE ALSO" sections can be really valuable, but they're really
> for "now that you've read the above, maybe this is also useful". It's
> not a "SEE STUFF YOU SAW BEFORE" :)
>
> In this case we link to these in the first and third paragraphs of the
> DESCRIPTION section (respectively), since explaining the revision syntax
> etc. is really core to understanding how this command works.
>
> The "SEE ALSO" section is really more for stuff like (in this case)
> 'git-fsck', 'git-filter-branch', 'git-rev-list' or 'git-stash'. All of
> those commansd have some direct interaction with the 'reflog', but are
> not mentioned in the main prose.
>

Better not to put a "SEE ALSO" then? I personally don't know

>
>
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] git-reflog.txt: add an EXAMPLES section
  2022-10-03  9:20 ` Ævar Arnfjörð Bjarmason
  2022-10-03 13:53   ` Elia Pinto
@ 2022-10-03 16:31   ` Junio C Hamano
  1 sibling, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2022-10-03 16:31 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: Elia Pinto, git

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> On Mon, Oct 03 2022, Elia Pinto wrote:
>
>> This commit adds an "EXAMPLES" section to the git reflog man page.
>> This new section currently provides examples of using git reflog
>> with branches, for which doubts often exist. In this commit we also
>> add a "SEE ALSO" section which refers to further information
>> on git commands or documentation referenced in the git reflog man page.
>
> I think it can be valuable to have an EXAMPLES section, but:
> ...
> Most of this really just seems to be duplicating "SPECIFYING REVISIONS",
> and some of it such as "show with timestamp" is ambiguous/misleading.

It would become immediately clear what these phrases want to say,
when the reader runs "git reflog @{0}" and "git reflog @{now}" while
reading the document.  I am not sure if the description is ambiguous
or misleading to those who haven't seen any reflog output, especially
the timestamped ones.  Perhaps some sample output in the documentation
would help, do you think?

    $ git reflog -2 HEAD@{now}
    ce17cbfa2b HEAD@{Mon Oct 3 09:07:30 2022 -0700}: checkout: moving...
    ce17cbfa2b HEAD@{Mon Oct 3 09:07:14 2022 -0700}: am: ssh signing...
    $ git reflog -2 HEAD@{0}
    ce17cbfa2b HEAD@{0}: checkout: moving...
    ce17cbfa2b HEAD@{1}: am: ssh signing...

I would freely admit that this is one of my least favourite part of
Git UI that allows what comes inside @{} as parameter to "git
reflog" affect both the starting point (e.g. @{2.days} omits the
activities of the past 48 hours) and the format of the output.  The
taste of the design is bad, but it is what we ended up with.

>> +SEE ALSO
>> +--------
>> +linkgit:gitrevisions[7],
>> +linkgit:git-log[1]
>
> Likewise "SEE ALSO" sections can be really valuable, but they're really
> for "now that you've read the above, maybe this is also useful". It's
> not a "SEE STUFF YOU SAW BEFORE" :)
>
> In this case we link to these in the first and third paragraphs of the
> DESCRIPTION section (respectively), since explaining the revision syntax
> etc. is really core to understanding how this command works.

I do not know about that.

Only the part of the revision syntax that refers to the tip of a ref
works as input for "git reflog".  IOW, "git reflog seen^2~4" does
not work.  I do not think the knowledge of revision syntax helps
understanding how to operate the command that much because of the
above.  I agree with you that it is dubious if it is a good idea to
list gitrevisions[7] here, but for an entirely different reason.

On the other hand, git-log[1] might not be a bad thing to refer to,
in order to learn that you can say something like

    git reflog --pretty=short --stat @{now}

Thanks for a review.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] git-reflog.txt: add an EXAMPLES section
  2022-10-03 13:07 ` Bagas Sanjaya
@ 2022-10-03 16:36   ` Junio C Hamano
  0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2022-10-03 16:36 UTC (permalink / raw)
  To: Bagas Sanjaya; +Cc: Elia Pinto, git

Bagas Sanjaya <bagasdotme@gmail.com> writes:

> On 10/3/22 15:46, Elia Pinto wrote:
>> This commit adds an "EXAMPLES" section to the git reflog man page.
>> This new section currently provides examples of using git reflog
>> with branches, for which doubts often exist. In this commit we also
>> add a "SEE ALSO" section which refers to further information
>> on git commands or documentation referenced in the git reflog man page.
>> 
>
> Better say "Add git-reflog usage examples to the man page."

Thanks, indeed.

> Also, shouldn't "SEE ALSO" additions be split from this patch?

I think they are better together.  The overall theme is to help
readers of that one documentation page, and 80% of the effort of
this step is spent on adding an EXAMPLES section, while the rest
goes to SEE ALSO.

Thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] git-reflog.txt: add an EXAMPLES section
  2022-10-03 13:53   ` Elia Pinto
@ 2022-10-03 16:40     ` Junio C Hamano
  0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2022-10-03 16:40 UTC (permalink / raw)
  To: Elia Pinto; +Cc: Ævar Arnfjörð Bjarmason, git

Elia Pinto <gitter.spiros@gmail.com> writes:

> The examples included are based on an email exchange done here between
> a user and a git developer, maybe Junio, I don't remember. The user
> found the explanation useful, as he had a hard time understanding how
> git-reflog worked with branches. I agree that better could be done,
> for example by entering how to recover lost commits, but that was not
> the goal at the moment. Later this is something that it is  always
> possible to do. It is also true that the examples in practice show
> what should already be known with gitrevisions however obviously many
> users cannot find the link between the two, I must imagine

Geez.  I did find the examples, especially the use of "4" as a
random number pulled out of thin air, vaguely familiar.  You seem
to mean https://lore.kernel.org/git/xmqqo7xuif46.fsf@gitster.g/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-03 16:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-03  8:46 [PATCH] git-reflog.txt: add an EXAMPLES section Elia Pinto
2022-10-03  9:20 ` Ævar Arnfjörð Bjarmason
2022-10-03 13:53   ` Elia Pinto
2022-10-03 16:40     ` Junio C Hamano
2022-10-03 16:31   ` Junio C Hamano
2022-10-03 13:07 ` Bagas Sanjaya
2022-10-03 16:36   ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).