{"thread":{"id":"58922","subject":"rebase update-refs can delete ref branch","startedAt":"2022-12-08T23:00:38Z","lastAt":"2022-12-09T10:40:21Z","messageCount":4,"participants":["Eric Musser","Victoria Dye","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"468803","messageId":"CAGW=zr_BD=7d5dZi+yO4cpufFi=jEjH=wQoTndDLfTi14UresQ@mail.gmail.com","threadId":"58922","inReplyTo":null,"subject":"rebase update-refs can delete ref branch","fromName":"Eric Musser","fromEmail":"eric.musser@snowflake.com","sentAt":"2022-12-08T23:00:18Z","receivedAt":"2022-12-08T23:00:38Z","isPatch":false,"sender":{"key":"eric.musser@snowflake.com","avatar":null},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n$ git init\nInitialized empty Git repository in /home/emusser/git/test/.git/\n$ git checkout -b working-branch\nSwitched to a new branch 'working-branch'\n$ git commit -m \"commit 1\" --allow-empty\n[working-branch (root-commit) 1238cf8] commit 1\n$ git commit -m \"commit 2\" --allow-empty\n[working-branch 2dd4408] commit 2\n$ git branch other-branch\n$ git commit -m \"commit 3\" --allow-empty\n[working-branch 39f626e] commit 3\n$ git rebase -i --update-refs HEAD~2\n[I am presented]:\npick 2dd4408 commit 2 # empty\nupdate-ref other-branch\n\npick 39f626e commit 3 # empty\n\n[I deleted first two lines and submitted]:\npick 39f626e commit 3 # empty\n\nSuccessfully rebased and updated refs/heads/working-branch.\nUpdated the following refs with --update-refs:\nrefs/heads/other-branch\n$ git rev-parse other-branch\nother-branch\nfatal: ambiguous argument 'other-branch': unknown revision or path not\nin the working tree.\nUse '--' to separate paths from revisions, like this:\n'git <command> [<revision>...] -- [<file>...]'\n\nWhat did you expect to happen? (Expected behavior)\nThe branch I interactively removed from the rebase to not actually be\ndeleted. It is common\nto remove unrelated changes (and refs) from your working branch before pushing.\nI'd hope in this case I would not have to use `git rebase\n--no-update-refs' (if I'm set\nin my config UpdateRefs=true) to avoid branches from being deleted.\n\nWhat happened instead? (Actual behavior)\nThe branch was deleted.\n\nWhat's different between what you expected and what actually happened?\nThe branch was deleted when I would expect branches that are no longer listed\nto not be updated or deleted.\n\nAnything else you want to add:\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.38.0\ncpu: aarch64\nbuilt from commit: 3dcec76d9df911ed8321007b1d197c1a206dc164\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.16.13-generic #2 SMP Fri Mar 11 12:48:38 UTC 2022 aarch64\ncompiler info: gnuc: 10.2\nlibc info: glibc: 2.17\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\npre-commit\n"},{"id":"468821","messageId":"8edcef4f-4438-e07a-a6fb-698b6179fcc4@github.com","threadId":"58922","inReplyTo":"CAGW=zr_BD=7d5dZi+yO4cpufFi=jEjH=wQoTndDLfTi14UresQ@mail.gmail.com","subject":"Re: rebase update-refs can delete ref branch","fromName":"Victoria Dye","fromEmail":"vdye@github.com","sentAt":"2022-12-09T07:50:36Z","receivedAt":"2022-12-09T07:50:44Z","isPatch":false,"sender":{"key":"vdye@github.com","avatar":"https://avatars.githubusercontent.com/u/3619353?v=4"},"body":"Hi Eric!\n\n> [I am presented]:\n> pick 2dd4408 commit 2 # empty\n> update-ref other-branch\n> \n> pick 39f626e commit 3 # empty\n> \n> [I deleted first two lines and submitted]:\n> pick 39f626e commit 3 # empty\n> \n> Successfully rebased and updated refs/heads/working-branch.\n> Updated the following refs with --update-refs:\n> refs/heads/other-branch\n> $ git rev-parse other-branch\n> other-branch\n> fatal: ambiguous argument 'other-branch': unknown revision or path not\n> in the working tree.\n> Use '--' to separate paths from revisions, like this:\n> 'git <command> [<revision>...] -- [<file>...]'\n\nI believe this is the same bug as one reported back in October [1], where\ndeleting all 'update-ref' lines from the 'rebase-todo' inadvertently causes\nthe rebase to delete those refs. The bug was fixed in 44da9e0841 (rebase\n--update-refs: avoid unintended ref deletion, 2022-11-07), so you shouldn't\nsee the issue anymore in Git that's built from newer revisions (e.g., the\nlatest pre-release v2.39.0-rc2 or the upcoming final v2.39.0).\n\nI hope that helps!\n- Victoria\n\n[1] https://lore.kernel.org/git/CAFzd1+5F4zqQ1CNeY2xaaf0r__JmE4ECiBt5h5OdiJHbaE78VA@mail.gmail.com/\n\n> [System Info]\n> git version:\n> git version 2.38.0\n> cpu: aarch64\n> built from commit: 3dcec76d9df911ed8321007b1d197c1a206dc164\n> sizeof-long: 8\n> sizeof-size_t: 8\n> shell-path: /bin/sh\n> uname: Linux 5.16.13-generic #2 SMP Fri Mar 11 12:48:38 UTC 2022 aarch64\n> compiler info: gnuc: 10.2\n> libc info: glibc: 2.17\n> $SHELL (typically, interactive shell): /bin/bash\n> \n> \n> [Enabled Hooks]\n> pre-commit\n\n"},{"id":"468823","messageId":"xmqq1qp90zvi.fsf@gitster.g","threadId":"58922","inReplyTo":"8edcef4f-4438-e07a-a6fb-698b6179fcc4@github.com","subject":"Re: rebase update-refs can delete ref branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-12-09T08:01:37Z","receivedAt":"2022-12-09T08:01:43Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Victoria Dye <vdye@github.com> writes:\n\n> I believe this is the same bug as one reported back in October [1], where\n> deleting all 'update-ref' lines from the 'rebase-todo' inadvertently causes\n> the rebase to delete those refs. The bug was fixed in 44da9e0841 (rebase\n> --update-refs: avoid unintended ref deletion, 2022-11-07), so you shouldn't\n> see the issue anymore in Git that's built from newer revisions (e.g., the\n> latest pre-release v2.39.0-rc2 or the upcoming final v2.39.0).\n\nThanks for digging the history.  It is unfortunate that, even though\nthe fix exactly identifies b3b1a21d (sequencer: rewrite update-refs\nas user edits todo list, 2022-07-19) as the culprit and it is trivial\nto see that was shipped as part of Git 2.38, the fix was not queued\nto allow merging 44da9e0841 into 2.38.x maintenance track, so it is\nunlikely to appear in any 2.38.x maintenance releases we might issue\nin the future.\n\nBut if the users can afford to update to 2.38.x or 2.39.0, picking\nthe latter is always better, as the newer feature release has longer\nshelf life ;-)\n\n"},{"id":"468825","messageId":"xmqqa63wzwq8.fsf@gitster.g","threadId":"58922","inReplyTo":"xmqq1qp90zvi.fsf@gitster.g","subject":"Re: rebase update-refs can delete ref branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-12-09T10:40:15Z","receivedAt":"2022-12-09T10:40:21Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Thanks for digging the history.  It is unfortunate that, even though\n> the fix exactly identifies b3b1a21d (sequencer: rewrite update-refs\n> as user edits todo list, 2022-07-19) as the culprit and it is trivial\n> to see that was shipped as part of Git 2.38, the fix was not queued\n> to allow merging 44da9e0841 into 2.38.x maintenance track, so it is\n> unlikely to appear in any 2.38.x maintenance releases we might issue\n> in the future.\n\nWell, I changed my mind.  Let's bite the bullet and cherry-pick the\nsingle patch, just for this once (as a general principle, I hate\ncherry-picking and try to avoid unless the fix is absolutely needed).\n\nThis is primarily because we have enough material to prepare for\nGit 2.38.2 already accumulated on the 'maint' front, all from the\nbugfixes merged to 'master' for the upcoming Git 2.39.\n\nI'd plan to tag 2.38.2 and 2.39 at the same time on coming Monday,\nbut note that I am operating in Asia/Tokyo timezone, so it may be\nSunday for many folks in the western hemisphere.\n\n\n\n\n"}]}