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

Re: [PATCH] add a reflog_exists and delete_reflog abstraction

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
May 6, 2014, 15:23 UTC
Message-ID
<5368FE5E.7020009@alum.mit.edu>
In-Reply-To
<1399330677-17930-1-git-send-email-sahlberg@google.com>
On 05/06/2014 12:57 AM, Ronnie Sahlberg wrote:
Show 15 quoted lines
> This is a single patch that adds two new functions to try to hide the reflog
> implementation details from the callers in checkout.c and reflog.c.
> It adds new functions to test if a reflog exists and to delete it, thus
> allowing checkout.c to perform this if-test-then-delete operation without
> having to know the internal implementation of reflogs (i.e. that they are files
> that live unde r.git/logs)
> 
> It also changes checkout.c to use ref_exists when checking for whether a ref
> exists or not instead of checking if the loose ref file exists or not.
> Using ref_exists instead both hides the reflog implementation details from
> checkout.c as well as making the code more robust against future changes.
> It currently has a hard assumption that the loose ref file must exist at this
> stage or else it would end up deleting the reflog which is true today, as far
> as I can tell, but would break if git would change such that we could have
> a branch checked out without having a loose ref file for that branch.

For single patches, people usually don't send a separate cover letter. Any comments that you want to make that are not suitable for the commit message can go between the "---" line and the diffstat of the patch email.

Regarding this change, I think before too long we will also need an API to turn reflogs on for a reference. We might want to add a flag to ref transaction entries that cause the reflog to be created if it doesn't already exist. Reflogs can currently be created for a reference via the config setting "core.logAllRefUpdates" or (for branches) by "git branch --create-reflog" (maybe there are others).

Several tests in the test suite currently create reflog files by hand. Thus we might also need a way to create reflogs at the command line by the time we implement pluggable reference backends.

Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
Previous: Ronnie SahlbergNext: Ronnie Sahlberg
Message 5 of 8 in “add a reflog_exists and delete_reflog abstraction”
  1. add a reflog_exists and delete_reflog abstractionRonnie Sahlberg, May 5, 2014
  2. refs.c: add new functions reflog_exists and delete_reflogRonnie Sahlberg, May 5, 2014
  3. Michael HaggertyMay 6, 2014
  4. Ronnie SahlbergMay 6, 2014
  5. Michael HaggertyMay 6, 2014
  6. Ronnie SahlbergMay 7, 2014
  7. Junio C HamanoMay 6, 2014
  8. Ronnie SahlbergMay 6, 2014

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.