Where can I get informatin about how git stashing works internally? I'm interested in detailed explanation similiar to the one about git objects in the 9.2 Git Internals - Git Objects of git-scm book.
EDIT:
I'm updating my question based on the information that I received from that link.
Is my logic described below correct?
HEAD is on the branch br1. The last commit 'br1-c0' on that branch had the following tree:
somefile.txt (text inside - 'some text') anotherfile.txt
I've modified somefile.txt to have 'updated text' as text inside. I'm stashing changes:
1) one commit is created, which has the following tree: somefile.txt (text inside - 'updated text') anotherfile.txt AND has link to commit 'br1-c0' and state of file index.
2) the working tree is reverted to 'br1-c0' commit.
Git is open source so source code ;) (or google)
In any case the stashes are list of commits. You can see how they are constructed by creating a stash:
# git stash --keep-index
# git stash list
stash@{0}: WIP on master: dafe337 sss
# git log 'stash@{0}' | cat
commit 7f86a90fb4e57590d6fe5026b7408306a757132a
Merge: dafe337 2881ede
Author: Maciej Piechotka <[email protected]>
Date: Fri Aug 30 09:27:10 2013 +0200
WIP on master: dafe337 sss
commit 2881ede55d619570a82bb7312257c4e43bd3b334
Author: Maciej Piechotka <[email protected]>
Date: Fri Aug 30 09:27:10 2013 +0200
index on master: dafe337 sss
commit dafe33716c2e5aee994612c88d8142f1163c624e
Author: Maciej Piechotka <[email protected]>
Date: Fri Aug 30 09:25:40 2013 +0200
sss
Sss is first commit (HEAD) while the rest two commits is the save of current index (staged changes) and the merge contains unstaged changes:
% git show 2881ede55d619570a82bb7312257c4e43bd3b334
commit 2881ede55d619570a82bb7312257c4e43bd3b334
Author: Maciej Piechotka <[email protected]>
Date: Fri Aug 30 09:27:10 2013 +0200
index on master: dafe337 sss
diff --git a/test.c b/test.c
index b9a1dd0..7beafd5 100644
--- a/test.c
+++ b/test.c
@@ -1 +1,2 @@
dddd
+fff
% git show 7f86a90fb4e57590d6fe5026b7408306a757132a
commit 7f86a90fb4e57590d6fe5026b7408306a757132a
Merge: dafe337 2881ede
Author: Maciej Piechotka <[email protected]>
Date: Fri Aug 30 09:27:10 2013 +0200
WIP on master: dafe337 sss
diff --cc test.c
index b9a1dd0,7beafd5..551a609
--- a/test.c
+++ b/test.c
@@@ -1,1 -1,2 +1,3 @@@
dddd
+ fff
++ggg
Now the list of stashes is an existing structure - reflog (n.b. useful structure on its own) and the name is... stash. So stashes are implemented de-facto as a branch with moving head and what we are interested in is reflog. To make it more interesting I created a second stash which created commit 0dee308c461955e13a864c9a904a69d611e82730
.
% git reflog stash | cat
7f86a90 stash@{0}: WIP on master: dafe337 sss
% cat .git/refs/stash
0dee308c461955e13a864c9a904a69d611e82730
% cat .git/logs/refs/stash
0000000000000000000000000000000000000000 7f86a90fb4e57590d6fe5026b7408306a757132a Maciej Piechotka <[email protected]> 1377847630 +0200 WIP on master: dafe337 sss
7f86a90fb4e57590d6fe5026b7408306a757132a 0dee308c461955e13a864c9a904a69d611e82730 Maciej Piechotka <[email protected]> 1377847983 +0200 WIP on master: dafe337 sss
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With