Skip to content

Stash drop (and pop) leave the entry in place when more than one stash exists #10

Closed

Description

@dnnsjsk

Stash::drop() does not remove an entry when the stash holds more than one. It computes the remaining entries but never writes the reflog back; it only moves refs/stash to the last remaining entry (

// Remove entry from reflog (rebuild without the dropped entry)
$newEntries = $entries;
array_splice($newEntries, count($newEntries) - 1 - $index, 1);
// Update refs/stash to point to the new top
$top = end($newEntries);
if ($top !== false) {
$this->refs->update('refs/stash', ObjectId::fromHex($top['new']));
}
). Because pop() drops after applying, stash pop applies the top entry and leaves it on the list.

Repro

pitmaster init && git config user.name T && git config user.email t@x
echo a > a.txt && pitmaster add a.txt && pitmaster commit -m first
for m in one two three; do echo $m >> a.txt; pitmaster stash push $m; done
pitmaster stash drop      # "Dropped stash"
pitmaster stash list      # still three entries: three, two, one
git stash list            # same three entries

After the drop, refs/stash and stash@{0} in logs/refs/stash no longer agree.

Expected

The dropped entry disappears from logs/refs/stash and refs/stash points to the new top entry, as with git stash drop. Dropping the only entry already works (the ref and the log are deleted).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions