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

12 messages from 2009-02-14 to 2009-02-16. Participants: Eric Kidd, Johannes Schindelin, Junio C Hamano, Sitaram Chamarty.
Thread: https://gitlist.dev/t/17784

## Eric Kidd, 2009-02-14 02:45

Subject: filter-branch: Remove original/* (was Re: [RFC] What's the best UI for 'git submodule split'?)
Message-ID: <431341160902131845g58d99635ie0735b433802d6be@mail.gmail.com>
URL: https://gitlist.dev/e/431341160902131845g58d99635ie0735b433802d6be%40mail.gmail.com

```
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.

Cheers,
Eric

```

## Johannes Schindelin, 2009-02-14 21:25

Subject: Re: filter-branch: Remove original/* (was Re: [RFC] What's the best UI for 'git submodule split'?)
Message-ID: <alpine.DEB.1.00.0902142219010.10279@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0902142219010.10279%40pacific.mpi-cbg.de
In-Reply-To: <431341160902131845g58d99635ie0735b433802d6be@mail.gmail.com>

```
Hi,

On Fri, 13 Feb 2009, Eric Kidd wrote:

> 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, 2009-02-15 19:33

Subject: Re: filter-branch: Remove original/*
Message-ID: <7vvdrblcl0.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vvdrblcl0.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <alpine.DEB.1.00.0902142219010.10279@pacific.mpi-cbg.de>

```
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, 2009-02-15 19:47

Subject: Re: filter-branch: Remove original/*
Message-ID: <alpine.DEB.1.00.0902152046090.10279@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0902152046090.10279%40pacific.mpi-cbg.de
In-Reply-To: <7vvdrblcl0.fsf@gitster.siamese.dyndns.org>

```
Hi,

On Sun, 15 Feb 2009, Junio C Hamano wrote:

> 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, 2009-02-15 21:26

Subject: Re: filter-branch: Remove original/*
Message-ID: <7vvdrbie7k.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vvdrbie7k.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <alpine.DEB.1.00.0902152046090.10279@pacific.mpi-cbg.de>

```
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, 2009-02-15 21:33

Subject: Re: filter-branch: Remove original/*
Message-ID: <alpine.DEB.1.00.0902152230330.10279@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0902152230330.10279%40pacific.mpi-cbg.de
In-Reply-To: <7vvdrbie7k.fsf@gitster.siamese.dyndns.org>

```
Hi,

On Sun, 15 Feb 2009, Junio C Hamano wrote:

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

> > 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, 2009-02-15 21:51

Subject: Re: filter-branch: Remove original/*
Message-ID: <7vbpt3id1w.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vbpt3id1w.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <alpine.DEB.1.00.0902152230330.10279@pacific.mpi-cbg.de>

```
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.

```

## Junio C Hamano, 2009-02-15 21:58

Subject: Re: filter-branch: Remove original/*
Message-ID: <7v7i3ricr4.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v7i3ricr4.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <7vbpt3id1w.fsf@gitster.siamese.dyndns.org>

```
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.

```

## Sitaram Chamarty, 2009-02-16 01:19

Subject: Re: filter-branch: Remove original/*
Message-ID: <slrngphfok.hul.sitaramc@sitaramc.homelinux.net>
URL: https://gitlist.dev/e/slrngphfok.hul.sitaramc%40sitaramc.homelinux.net
In-Reply-To: <7vvdrbie7k.fsf@gitster.siamese.dyndns.org>

```
On 2009-02-15, Junio C Hamano <gitster@pobox.com> wrote:
> 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.

```

## Johannes Schindelin, 2009-02-16 11:19

Subject: Re: filter-branch: Remove original/*
Message-ID: <alpine.DEB.1.00.0902161218250.10279@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0902161218250.10279%40pacific.mpi-cbg.de
In-Reply-To: <7v7i3ricr4.fsf@gitster.siamese.dyndns.org>

```
Hi,

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).

Eric?

Ciao,
Dscho

```

## Johannes Schindelin, 2009-02-16 11:25

Subject: Re: filter-branch: Remove original/*
Message-ID: <alpine.DEB.1.00.0902161224140.10279@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0902161224140.10279%40pacific.mpi-cbg.de
In-Reply-To: <alpine.DEB.1.00.0902161218250.10279@pacific.mpi-cbg.de>

```
Hi,

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.

So please strike my suggestion from your memory.

Ciao,
Dscho

```

## Johannes Schindelin, 2009-02-16 11:38

Subject: Re: filter-branch: Remove original/*
Message-ID: <alpine.DEB.1.00.0902161234120.10279@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0902161234120.10279%40pacific.mpi-cbg.de
In-Reply-To: <alpine.DEB.1.00.0902161224140.10279@pacific.mpi-cbg.de>

```
Hi,

On Mon, 16 Feb 2009, Johannes Schindelin wrote:

> 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

```
