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

Re: Usability issue: "Your branch is up to date"

From
Manuel Quiñones <manuel.por.aca@gmail.com>
Date
Feb 4, 2025, 12:38 UTC
Message-ID
<CAPpV+Oaq3d3oNE-V3pnpQRNrGCoZr52uY91QtWYxcu1tgG_QXg@mail.gmail.com>
In-Reply-To
<xmqq34guzi0f.fsf@gitster.g>

El lun, 3 feb 2025 a la(s) 9:10 p.m., Junio C Hamano (gitster@pobox.com) escribió:

Show 68 quoted lines
>
> Junio C Hamano <gitster@pobox.com> writes:
>
> > Manuel Quiñones <manuel.por.aca@gmail.com> writes:
> >
> >> that can be fetched from the remote. My proposal: Add the timestamp of
> >> the last fetch to the message. For example:
> >>
> >> ```
> >> $ git switch main
> >> Switched to branch 'main'
> >> Your branch is up to date with 'origin/main'. Last check was 2 hours ago.
> >> ```
> >>
> >> It looks like the timestamp of file `.git/FETCH_HEAD` would be enough
> >> to implement it.
> >
> > Not generally.  Your last fetch may not have been about origin/main
> > (e.g., "git fetch origin next"), or it may even have been about a
> > totally different remote (e.g., "git fetch elsewhere").
> >
> > The timestamp of the last entry of the reflog of origin/main may be
> > a lot better place to look for the information, if available.
>
> Unfortunately, this is not quite enough.
>
> I do not think a "git fetch" that noticed that the remote-tracking
> branch is up-to-date updates the reflog of the remote-tracking
> branch, so if you observed that their 'main' is at certain value 10
> hours ago, and if your more recent fetch done two hours ago found
> that they haven't made any progress, the reflog says "You observed
> that their 'main' is at this commit as of 10 hours ago" and not the
> number you want.
>
> However, as I said, the fetch that touched the FETCH_HEAD file may
> not have been about the ref in question, so while a two-hour old
> FETCH_HEAD can guarantee that update of any ref by fetching
> (including a fetch done as part of "git pull") did not happen in the
> last two hours, it does not really mean what you have in your
> remote-tracking branch is not stale from reality by more than two
> hours.
>
> You could inspect the contents of FETCH_HEAD to see if the source of
> the remote-tracking branch is listed there, and when it appears in
> the file, can use the timestamp of the file.  If you did this:
>
>     $ git fetch origin main
>
> and it left something like
>
>         f93ff170b... branch 'main' of https://www.kernel.org/...
>
> in the file, you can reverse map the URL and the branch using the
> remote.*.URL and the remote.*.fetch configuration variables to
> figure out that it must have been stored at our 'origin/main'.
> At that point, you know that the timestamp of FETCH_HEAD would be
> when we observed that value in the 'origin/main'.
>
> But even then, because the FETCH_HEAD file is not versioned, if you
> did
>
>     $ git fetch elsewhere main
>
> then the file gets overwritten, and you would no longer know when
> was the last time you observed the value of 'origin/main'.
>
> In short, there is not enough information kept anywhere to compute
> the number you want to show reliably.

Thanks for the insightful explanation Junio! Looking forward, do you think that it could be possible to record the timestamp that the remote-tracking branch has been updated with the remote branch? In order to make such information available to the end user.

-- 
.. manuq ..
Previous: Bram van OosterhoutNext: Junio C Hamano
Message 8 of 14 in “Usability issue: "Your branch is up to date"”
  1. Manuel QuiñonesFeb 3, 2025
  2. Junio C HamanoFeb 3, 2025
  3. Junio C HamanoFeb 4, 2025
  4. Bram van OosterhoutFeb 4, 2025
  5. D. Ben KnobleFeb 4, 2025
  6. Manuel QuiñonesFeb 4, 2025
  7. Bram van OosterhoutFeb 5, 2025
  8. Manuel QuiñonesFeb 4, 2025
  9. Junio C HamanoFeb 4, 2025
  10. Patrick SteinhardtFeb 5, 2025
  11. Junio C HamanoFeb 5, 2025
  12. Patrick SteinhardtFeb 6, 2025
  13. Karthik NayakFeb 7, 2025
  14. Fwd: Usability issue: "Your branch is up to date"Bram van Oosterhout, Feb 4, 2025

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.