Re: [PATCH] Remove branch by putting a null sha1 into the ref file.

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

 



Christian Couder <chriscool@xxxxxxxxxxxxx> writes:

> You are right, so what about moving ".git/refs/heads/frotz" 
> to ".git/deleted-refs/heads/frotz.ref" 
> or ".git/deleted-refs/heads/frotz~ref" (because "~" is forbidden in ref 
> names).

But wouldn't it bring up the issue of locking among deleters,
updaters/creators, and traversers?

If we choose to use packed-refs.lock as the "set of all refs"
lock, the whole sequence would become something like this.  Note
that this tries to make readers lockless but I am sure there are
nasty race condition issues.  I am not sure what we would want
to do about them.

= Looking up a ref $frotz.

 - check if .git/$frotz exists, and use it if it does.

 - check if .git/deleted-refs/$frotz~ref exists, and return "no
   such ref" if it does.

 - find $frotz in .git/packed-refs.

= Looping over refs.

 - grab all .git/refs/ and subtract all .git/deleted-refs/

 - walk .git/packed-refs and the result from the above in
   parallel as in the current code.

= Storing a new value in ref $frotz.

 - acquire .git/packed-refs.lock

 - lock .git/$frotz.lock.

 - write into .git/$frotz.lock.

 - create or update .git/logs/$frotz as needed.

 - if .git/deleted-refs/$frotz~ref exists, unlink it.

 - rename .git/$frotz.lock to .git/$frotz to unlock it.

 - unlink .git/packed-refs.lock

= Deleting a ref $frotz.

 - acquire .git/packed-refs.lock

 - look up $frotz; if it does not exist either barf or return
   silent (haven't thought it through yet).

 - create .git/deleted-refs/$frotz~ref.

 - remove .git/logs/$frotz

 - unlink .git/packed-refs.lock

= Packing refs, with optional pruning.

 - lock .git/packed-refs.lock

 - loop over refs:
   - write it out to .git/packed-refs.lock unless a symref.
   - if it is a loose one (not a symref), remember it for pruning.

 - if pruning:
   - remove the entire .git/deleted-refs/ hierarchy
   - remove the remembered ones

 - rename .git/packed-refs.lock to .git/packed-refs

-
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]