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

[PATCH] add a reflog_exists and delete_reflog abstraction

From
Ronnie Sahlberg <sahlberg@google.com>
Date
May 5, 2014, 22:57 UTC
Message-ID
<1399330677-17930-1-git-send-email-sahlberg@google.com>

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.

Ronnie Sahlberg (1):
  refs.c: add new functions reflog_exists and delete_reflog
 builtin/checkout.c |  8 ++------
 builtin/reflog.c   |  2 +-
 refs.c             | 20 ++++++++++++++------
 refs.h             |  6 ++++++
 4 files changed, 23 insertions(+), 13 deletions(-)
-- 
2.0.0.rc1.351.gd2b7e18.dirty
Next: Ronnie Sahlberg
Message 1 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.