Re: [PATCH] add a reflog_exists and delete_reflog abstraction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 6, 2014 at 12:15 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Ronnie Sahlberg <sahlberg@xxxxxxxxxx> 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
>         ./  ../
>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]