{"thread":{"id":"60869","subject":"git gc destroys autostash","startedAt":"2024-02-07T20:52:13Z","lastAt":"2024-02-07T21:48:01Z","messageCount":3,"participants":["Orgad Shaneh","Junio C Hamano","Kristoffer Haugsbakk"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"488173","messageId":"CAGHpTBKpYp370QTw93wK_RP+X2S+44jd-8kjodiUj4k0BoAEqA@mail.gmail.com","threadId":"60869","inReplyTo":null,"subject":"git gc destroys autostash","fromName":"Orgad Shaneh","fromEmail":"orgads@gmail.com","sentAt":"2024-02-07T20:52:00Z","receivedAt":"2024-02-07T20:52:13Z","isPatch":false,"sender":{"key":"orgads@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1246544?v=4"},"body":"Running git gc --prune=now during rebase with autostash deletes the\nautostash object, and it cannot be recovered when the rebase ends.\n\nExample:\n\n#!/bin/sh\n\ngit init\necho 1 > foo; git add foo; git commit -m 'Initial commit'\necho 2 > foo; git add foo; git commit -m 'Second commit'\necho 3 > foo; git rebase -i --autostash HEAD^\n# Choose edit\ngit gc --prune=now\ngit rebase --continue\n# fatal: '3b88163a1bff3859a005554c168d94e5357ee45b' is not a stash-like commit\n# error: cannot store 3b88163a1bff3859a005554c168d94e5357ee45b\n# Successfully rebased and updated refs/heads/master.\n\nThanks,\n- Orgad\n"},{"id":"488179","messageId":"xmqq7cjg6l3r.fsf@gitster.g","threadId":"60869","inReplyTo":"CAGHpTBKpYp370QTw93wK_RP+X2S+44jd-8kjodiUj4k0BoAEqA@mail.gmail.com","subject":"Re: git gc destroys autostash","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-02-07T21:05:44Z","receivedAt":"2024-02-07T21:05:50Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Orgad Shaneh <orgads@gmail.com> writes:\n\n> Running git gc --prune=now during rebase with autostash deletes the\n> autostash object, and it cannot be recovered when the rebase ends.\n>\n> Example:\n>\n> #!/bin/sh\n>\n> git init\n> echo 1 > foo; git add foo; git commit -m 'Initial commit'\n> echo 2 > foo; git add foo; git commit -m 'Second commit'\n> echo 3 > foo; git rebase -i --autostash HEAD^\n> # Choose edit\n> git gc --prune=now\n\nThis is totally expected, unfortunately, as the autostash does not\nuse the ref API to use the refs/stash (presumably in order to avoid\nshifting the shash@{$N} numbers). Because of that, the stash entry\nis not protected from the garbage collection.  This currently falls\ninto \"it hurts when I twist my arm this way. --do not do it then\"\ncategory.\n\nIt may be a simple fix to teach sequencer.c:apply_save_autostash()\nnot to use a random on-disk file to store the returned value from\n\"git stash create\", but use a dedicated ref that is not refs/stash\nfor its own use via proper use of the ref API.\n\n> git rebase --continue\n> # fatal: '3b88163a1bff3859a005554c168d94e5357ee45b' is not a stash-like commit\n> # error: cannot store 3b88163a1bff3859a005554c168d94e5357ee45b\n> # Successfully rebased and updated refs/heads/master.\n>\n> Thanks,\n> - Orgad\n"},{"id":"488187","messageId":"a18532ba-b168-4928-bced-d1604a483f24@app.fastmail.com","threadId":"60869","inReplyTo":"CAGHpTBKpYp370QTw93wK_RP+X2S+44jd-8kjodiUj4k0BoAEqA@mail.gmail.com","subject":"Re: git gc destroys autostash","fromName":"Kristoffer Haugsbakk","fromEmail":"code@khaugsbakk.name","sentAt":"2024-02-07T21:47:40Z","receivedAt":"2024-02-07T21:48:01Z","isPatch":false,"sender":{"key":"code@khaugsbakk.name","avatar":"https://avatars.githubusercontent.com/u/2229597?v=4"},"body":"On Wed, Feb 7, 2024, at 21:52, Orgad Shaneh wrote:\n> Running git gc --prune=now during rebase with autostash deletes the\n> autostash object, and it cannot be recovered when the rebase ends.\n\nThings like this is why I don’t use the stash.[1][2] I just commit\neverything of value and non-value.\n\n† 1: With very rare exceptions where the stash is popped before the\n    whole operation leaves my own working memory\n† 2: Also how you have to find unreachable objects using git-fsck(1) if\n    you pop the last stash\n\n-- \nKristoffer Haugsbakk\n"}]}