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 6, 2014, 19:29 UTC
Message-ID
<CAL=YDWnyKHSj8ZtD0t84Pg=uoHumGv2zgtOC0NAzP+Y+CanJ_w@mail.gmail.com>
In-Reply-To
<xmqq1tw6g1mp.fsf@gitster.dls.corp.google.com>
On Tue, May 6, 2014 at 12:15 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 8 quoted lines
> Ronnie Sahlberg <sahlberg@google.com> writes:
>
>> 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.
>
> Hmmmm.  Do you mean this sequence will break?

As Michael suggested, this is already broken :-( This sequence will delete the reflog from master :

    $ git init-db
    $ git config core.logallrefupdates true
    $ git commit -m Initial --allow-empty
        [master (root-commit) bb11abe] Initial
    $ git reflog master
        [8561dcb master@{0}: commit (initial): Initial]
    $ find .git/{refs,logs} -type f | grep master
        [.git/refs/heads/master]
        [.git/logs/refs/heads/master]
    $ git branch foo
    $ git pack-refs --all
    $ find .git/{refs,logs} -type f | grep master
        [.git/logs/refs/heads/master]
    $ git checkout foo
    $ find .git/{refs,logs} -type f | grep master
        ... reflog file is missing ...
    $ git reflog master
        ... nothing ...
I am adding a test for this in the next set of patches :
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
index 236b13a..8cab06f 100755
--- a/t/t1410-reflog.sh
+++ b/t/t1410-reflog.sh
@@ -245,4 +245,12 @@ test_expect_success 'gc.reflogexpire=false' '

 '

+test_expect_success 'checkout should not delete log for packed ref' '
+       test $(git reflog master | wc -l) = 4 &&
+       git branch foo &&
+       git pack-refs --all &&
+       git checkout foo &&
+       test $(git reflog master | wc -l) = 4
+'
+
 test_done





>
>         : gitster x; git init lo
>         Initialized empty Git repository in /var/tmp/x/lo/.git/
>         : gitster x; cd lo
>         : gitster lo/master; git commit --allow-empty -m initial
>         [master (root-commit) db2b430] initial
>         : gitster lo/master; git branch next
>
> Now we have two branches, master and next, and we are on master.
>
>         : gitster lo/master; git pack-refs --all
>         : gitster lo/master; ls .git/refs/heads
>         ./  ../
>         : gitster lo/master; cat .git/packed-refs
>         # pack-refs with: peeled fully-peeled
>         db2b43072749258d1e3c119c9570349d77c26b3a refs/heads/master
>         db2b43072749258d1e3c119c9570349d77c26b3a refs/heads/next
>
> And loose refs are fully packed.
>
>         : gitster lo/master; git checkout next
>         Switched to branch 'next'
>         : gitster lo/next; ls .git/refs/heads
>         ./  ../
>
Previous: Junio C Hamano
Message 8 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.