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

Re: [PATCH] add a reflog_exists and delete_reflog abstraction

From
Ronnie Sahlberg <sahlberg@google.com>
Date
May 7, 2014, 20:47 UTC
Message-ID
<CAL=YDW=dhNR3qy9mym9naS9QrHhghSZmoQ=2L1nA47CtmY90=g@mail.gmail.com>
In-Reply-To
<5368FE5E.7020009@alum.mit.edu>
On Tue, May 6, 2014 at 8:23 AM, Michael Haggerty <mhagger@alum.mit.edu> wrote:
Show 27 quoted lines
> On 05/06/2014 12:57 AM, Ronnie Sahlberg wrote:
>> 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).
Yes. I agree.

I think we need a flag to ref_transaction_create and ref_transaction_update to create a new reflog.

Then I also think we need to add a new transaction command, ref_transaction_reflog() that can be used to either append or overwrite the reflog. Builtin/reflog.c will need an API to create/overwrite the reflog with new text.

And finally we also need an api to create symrefs. ref_transaction_symref() or something.

But this will wait until my current patch series is merged.
>
> 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.
I can add this once we have an api.
Show 7 quoted lines
>
> Michael
>
> --
> Michael Haggerty
> mhagger@alum.mit.edu
> http://softwareswirl.blogspot.com/
Previous: Michael HaggertyNext: Junio C Hamano
Message 6 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.