Re: [PATCH 2/2] git-gc: skip stashes when expiring reflogs

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

 



Wincent Colaiuta <win@xxxxxxxxxxx> writes:

> (2) The people largely responsible for the implementation of "git
> stash" never envisaged its use for long term storage (either
> intentional abuse of "stash", or inadvertent misuse) and architected
> it in such a way that it can "forget" stashes after a period of time

I apologize for my lack of perfect foresight as the original
author of the command.  As I already said, I think expiration
period of reflogs that is configurable for each ref as suggested
earlier by Junio makes sense.

But changing the default expiration "never" for stash has its
own problem and I think we need to modify the way a stash entry
is created to solve it.

You will find in the DISCUSSION section of git-stash manual page
that a stash entry is represented as a commit that is a merge
between the commit the stash was made on (H), and a fake commit
whose tree records the contents of the index (I).  The merge
commit itself records the state of the files in the working
directory as its tree (W):

           .----W
          /    /
    -----H----I

If you do not expire stash forever, you will keep the history
behind the commit H.  This is unnecessary and is problematic
particularly if you rebase your branches frequently.

In order to apply a stash, all you need is the tree of the three
commits contained in this structure.  You do not need the
history behind commit H.

The following is a trial patch to change how a stash is recorded.
With this patch I do not think we will keep unnecessary commits
behind H in the repository even when a stash is kept forever.

diff --git a/git-stash.sh b/git-stash.sh
index 4938ade..f4c4236 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -54,6 +54,9 @@ create_stash () {
 	fi
 	msg=$(printf '%s: %s' "$branch" "$head")
 
+	# create the base commit that is parentless
+	b_commit=$(printf 'base of %s\n' "$msg" | git commit-tree "HEAD:")
+
 	# state of the index
 	i_tree=$(git write-tree) &&
 	i_commit=$(printf 'index on %s\n' "$msg" |


-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/

----------------------------------------------------------------------
Get a free email address with REAL anti-spam protection.
http://www.bluebottle.com/tag/1

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

  Powered by Linux