threads / discuss / 17784

filter-branch: Remove original/* (was Re: [RFC] What's the best UI for 'git submodule split'?)

Subject: filter-branch: Remove original/* (was Re: [RFC] What's the best UI for 'git submodule split'?)

## tl;dr

12 messages between Feb 14, 2009 and Feb 16, 2009.

replies: 11people: 4as markdown or json

Eric Kidd· Feb 14, 2009, 02:45 UTC · lore

On Thu, Feb 12, 2009 at 4:59 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 9 quoted lines
>
> On Thu, 12 Feb 2009, Eric Kidd wrote:
>
> >   rm .git/refs/original # or just use --force below
>
> BTW I wanted to get rid of this for a long time now, but I cannot seem to
> find the time to work on it.  The 'original' refs should not be needed, as
> that's a job for the reflogs (yeah, people tried to convince me back then,
> but I finally got it, okay?)

Removing the original/* directory would certainly make my life easier. But the reflog only stores backups for branch heads, not tags, right? If there's a good way to handle this, I'd be happy to send a patch.

Cheers, Eric

Johannes Schindelin· Feb 14, 2009, 21:25 UTC · re: Eric Kidd · lore

Re: filter-branch: Remove original/* (was Re: [RFC] What's the best UI for 'git submodule split'?)

Hi,
On Fri, 13 Feb 2009, Eric Kidd wrote:
Show 15 quoted lines
> On Thu, Feb 12, 2009 at 4:59 PM, Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
> >
> > On Thu, 12 Feb 2009, Eric Kidd wrote:
> >
> > >   rm .git/refs/original # or just use --force below
> >
> > BTW I wanted to get rid of this for a long time now, but I cannot seem 
> > to find the time to work on it.  The 'original' refs should not be 
> > needed, as that's a job for the reflogs (yeah, people tried to 
> > convince me back then, but I finally got it, okay?)
> 
> Removing the original/* directory would certainly make my life easier. 
> But the reflog only stores backups for branch heads, not tags, right? If 
> there's a good way to handle this, I'd be happy to send a patch.

Hmm. Indeed, we ignore reflogs in log_ref_write() when the ref starts with refs/tags/ (implicitly, not explicitely).

Maybe it is time to change that.

Ciao, Dscho

Junio C Hamano· Feb 15, 2009, 19:33 UTC · re: Johannes Schindelin · lore

Re: filter-branch: Remove original/*

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> Hmm.  Indeed, we ignore reflogs in log_ref_write() when the ref starts 
> with refs/tags/ (implicitly, not explicitely).
>
> Maybe it is time to change that.

Why? Most tags will be created once and will stay there. That is how tags are supposed to behave, isn't it?

Johannes Schindelin· Feb 15, 2009, 19:47 UTC · re: Junio C Hamano · lore

Re: filter-branch: Remove original/*

Hi,
On Sun, 15 Feb 2009, Junio C Hamano wrote:
Show 9 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > Hmm.  Indeed, we ignore reflogs in log_ref_write() when the ref starts 
> > with refs/tags/ (implicitly, not explicitely).
> >
> > Maybe it is time to change that.
> 
> Why?  Most tags will be created once and will stay there.  That is how 
> tags are supposed to behave, isn't it?
Exactly my point.  In the common case, it does not change a thing.

However in the case that we _do_ change tags, would you not agree that the reflog is _the_ place to record the change?

Ciao, Dscho

Junio C Hamano· Feb 15, 2009, 21:26 UTC · re: Johannes Schindelin · lore

Re: filter-branch: Remove original/*

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> Why?  Most tags will be created once and will stay there.  That is how 
>> tags are supposed to behave, isn't it?
>
> Exactly my point.  In the common case, it does not change a thing.
Wrong.

In the common case, you will create tons of useless files that waste a disk block to store 180-byte or so perr each tag.

> However in the case that we _do_ change tags, would you not agree that the 
> reflog is _the_ place to record the change?

That merely means whoever changes the tag and wants the record of such an update, which is uncommon, need to make sure reflog is created for that tag (and that tag only).

Johannes Schindelin· Feb 15, 2009, 21:33 UTC · re: Junio C Hamano · lore

Re: filter-branch: Remove original/*

Hi,
On Sun, 15 Feb 2009, Junio C Hamano wrote:
Show 11 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> >> Why?  Most tags will be created once and will stay there.  That is how 
> >> tags are supposed to behave, isn't it?
> >
> > Exactly my point.  In the common case, it does not change a thing.
> 
> Wrong.
> 
> In the common case, you will create tons of useless files that waste a
> disk block to store 180-byte or so perr each tag.

Hmm. My reasoning was that the reflogs will be purged by git gc anyway, and that it might be interesting to be able to know how a tag entered the current repository (if it was not too long ago), but you're probably right on that.

Show 6 quoted lines
> > However in the case that we _do_ change tags, would you not agree that 
> > the reflog is _the_ place to record the change?
> 
> That merely means whoever changes the tag and wants the record of such an
> update, which is uncommon, need to make sure reflog is created for that
> tag (and that tag only).
The thing is: we cannot.  At least not at the moment.

I agree that "git tag" should not add a reflog. But one should be able to force "git update-ref" to create a reflog entry, no?

Ciao, Dscho

Junio C Hamano· Feb 15, 2009, 21:51 UTC · re: Johannes Schindelin · lore

Re: filter-branch: Remove original/*

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 5 quoted lines
>> That merely means whoever changes the tag and wants the record of such an
>> update, which is uncommon, need to make sure reflog is created for that
>> tag (and that tag only).
>
> The thing is: we cannot.  At least not at the moment.
$ mkdir -p .git/logs/refs/tags
$ >.git/logs/refs/tags/junker
$ git tag junker
$ wc .git/logs/refs/tags/junker
  1   8 134 .git/logs/refs/tags/junker
Ok, it's not 180 byte as I said, but only 134 bytes.
Junio C Hamano· Feb 15, 2009, 21:58 UTC · re: Junio C Hamano · lore

Re: filter-branch: Remove original/*

Junio C Hamano <gitster@pobox.com> writes:
Show 15 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
>>> That merely means whoever changes the tag and wants the record of such an
>>> update, which is uncommon, need to make sure reflog is created for that
>>> tag (and that tag only).
>>
>> The thing is: we cannot.  At least not at the moment.
>
> $ mkdir -p .git/logs/refs/tags
> $ >.git/logs/refs/tags/junker
> $ git tag junker
> $ wc .git/logs/refs/tags/junker
>   1   8 134 .git/logs/refs/tags/junker
>
> Ok, it's not 180 byte as I said, but only 134 bytes.

Having proven my superiour intelligence ;-) I think I can agree if your next proposal is to toggle reflog on for the tag when "git tag -f" is used to update an existing tag and core.logAllRefUpdates does not say "never" (this new value needs to be treated the same as "false" for most other purposes), and the tag does not already have a reflog.

Johannes Schindelin· Feb 16, 2009, 11:19 UTC · re: Junio C Hamano · lore

Re: filter-branch: Remove original/*

Hi,
On Sun, 15 Feb 2009, Junio C Hamano wrote:
Show 23 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> 
> > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> >
> >>> That merely means whoever changes the tag and wants the record of such an
> >>> update, which is uncommon, need to make sure reflog is created for that
> >>> tag (and that tag only).
> >>
> >> The thing is: we cannot.  At least not at the moment.
> >
> > $ mkdir -p .git/logs/refs/tags
> > $ >.git/logs/refs/tags/junker
> > $ git tag junker
> > $ wc .git/logs/refs/tags/junker
> >   1   8 134 .git/logs/refs/tags/junker
> >
> > Ok, it's not 180 byte as I said, but only 134 bytes.
> 
> Having proven my superiour intelligence ;-) I think I can agree if your
> next proposal is to toggle reflog on for the tag when "git tag -f" is used
> to update an existing tag and core.logAllRefUpdates does not say "never"
> (this new value needs to be treated the same as "false" for most other
> purposes), and the tag does not already have a reflog.

Actually, to prove my inferior intelligence, I suggest going for the easy solution: replace the update-ref in filter-branch by a call to git tag -f, after making sure that the reflog exists (with >>.git/logs/$tagname).

Eric?

Ciao, Dscho

Johannes Schindelin· Feb 16, 2009, 11:25 UTC · re: Johannes Schindelin · lore

Re: filter-branch: Remove original/*

Hi,
On Mon, 16 Feb 2009, Johannes Schindelin wrote:
Show 29 quoted lines
> On Sun, 15 Feb 2009, Junio C Hamano wrote:
> 
> > Junio C Hamano <gitster@pobox.com> writes:
> > 
> > > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> > >
> > >>> That merely means whoever changes the tag and wants the record of such an
> > >>> update, which is uncommon, need to make sure reflog is created for that
> > >>> tag (and that tag only).
> > >>
> > >> The thing is: we cannot.  At least not at the moment.
> > >
> > > $ mkdir -p .git/logs/refs/tags
> > > $ >.git/logs/refs/tags/junker
> > > $ git tag junker
> > > $ wc .git/logs/refs/tags/junker
> > >   1   8 134 .git/logs/refs/tags/junker
> > >
> > > Ok, it's not 180 byte as I said, but only 134 bytes.
> > 
> > Having proven my superiour intelligence ;-) I think I can agree if your
> > next proposal is to toggle reflog on for the tag when "git tag -f" is used
> > to update an existing tag and core.logAllRefUpdates does not say "never"
> > (this new value needs to be treated the same as "false" for most other
> > purposes), and the tag does not already have a reflog.
> 
> Actually, to prove my inferior intelligence, I suggest going for the easy 
> solution: replace the update-ref in filter-branch by a call to git tag -f, 
> after making sure that the reflog exists (with >>.git/logs/$tagname).

Indeed, this proves my inferior intelligence: the update-ref method at least kept as much information as possible in the tag, including the tagger.

So please strike my suggestion from your memory.

Ciao, Dscho

Johannes Schindelin· Feb 16, 2009, 11:38 UTC · re: Johannes Schindelin · lore

Re: filter-branch: Remove original/*

Hi,
On Mon, 16 Feb 2009, Johannes Schindelin wrote:
Show 37 quoted lines
> On Mon, 16 Feb 2009, Johannes Schindelin wrote:
> 
> > On Sun, 15 Feb 2009, Junio C Hamano wrote:
> > 
> > > Junio C Hamano <gitster@pobox.com> writes:
> > > 
> > > > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> > > >
> > > >>> That merely means whoever changes the tag and wants the record 
> > > >>> of such an update, which is uncommon, need to make sure reflog 
> > > >>> is created for that tag (and that tag only).
> > > >>
> > > >> The thing is: we cannot.  At least not at the moment.
> > > >
> > > > $ mkdir -p .git/logs/refs/tags
> > > > $ >.git/logs/refs/tags/junker
> > > > $ git tag junker
> > > > $ wc .git/logs/refs/tags/junker
> > > >   1   8 134 .git/logs/refs/tags/junker
> > > >
> > > > Ok, it's not 180 byte as I said, but only 134 bytes.
> > > 
> > > Having proven my superiour intelligence ;-) I think I can agree if 
> > > your next proposal is to toggle reflog on for the tag when "git tag 
> > > -f" is used to update an existing tag and core.logAllRefUpdates does 
> > > not say "never" (this new value needs to be treated the same as 
> > > "false" for most other purposes), and the tag does not already have 
> > > a reflog.
> > 
> > Actually, to prove my inferior intelligence, I suggest going for the 
> > easy solution: replace the update-ref in filter-branch by a call to 
> > git tag -f, after making sure that the reflog exists (with 
> > >>.git/logs/$tagname).
> 
> Indeed, this proves my inferior intelligence: the update-ref method at 
> least kept as much information as possible in the tag, including the 
> tagger.

Maybe I can salvage a little bit of the "sapiens" part in the name of the species I think I am part of:

-- snip --
 git-filter-branch.sh |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 27b57b8..d828a91 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -459,6 +459,10 @@ if [ "$filter_tag_name" ]; then
 			then
 				warn "gpg signature stripped from tag object $sha1t"
 			fi
+			# make sure the reflogs are written
+			mkdir -p "$(dirname "$GIT_DIR/logs/$new_ref")" &&
+			>> "$GIT_DIR/logs/$new_ref" ||
+			die "Could not initialize reflogs for $new_ref"
 		fi
 
 		git update-ref "refs/tags/$new_ref" "$new_sha1" ||
-- snap --

Eric, this is not even compile tested ;-)  But maybe you can start from 
there?

Ciao,
Dscho
Sitaram Chamarty· Feb 16, 2009, 01:19 UTC · re: Junio C Hamano · lore

Re: filter-branch: Remove original/*

On 2009-02-15, Junio C Hamano <gitster@pobox.com> wrote:
Show 11 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
>>> Why?  Most tags will be created once and will stay there.  That is how 
>>> tags are supposed to behave, isn't it?
>>
>> Exactly my point.  In the common case, it does not change a thing.
>
> Wrong.
>
> In the common case, you will create tons of useless files that waste a
> disk block to store 180-byte or so perr each tag.

Instead of a separate file for each tag, why not something like logs/TAGS, which just records tag creations.

The downside is it wouldn't represent a *continuous state* of anything in particular, because you can create tags for any commit while on any (other) branch. I'm not smart enough to figure out the implications of that across the entire system.

← back to recent threads