Message ID | pull.423.git.1572289087.gitgitgadget@gmail.com (mailing list archive) |
---|---|
Headers | show |
Series | Allow the 'revert' option in Git Gui to operate on untracked files, deleting them | expand |
On 2019-10-28 at 18:58:06, Jonathan Gilbert via GitGitGadget wrote: > My development environment sometimes makes automatic changes that I don't > want to keep. In some cases, this involves new files being added that I > don't want to commit or keep. I have typically had to explicitly delete > those files externally to Git Gui, and I want to be able to just select > those newly-created untracked files and "revert" them into oblivion. Is there a reason these new files can't be ignored, with one of the .gitignore file, .git/info/exclude, or core.excludesFile? If so, it would be helpful to explain that in the commit message so we can more fully understand the rationale here.
> Is there a reason these new files can't be ignored, with one of the.gitignore file, .git/info/exclude, or core.excludesFile? I guess it's implied in the way I worded the message, but I have fallen into the habit of using Git-Gui to manage the state of the working copy (at least in detail). I am primarily doing .NET development, for which projects can have a file App.config that stores various settings that apply to the project at runtime. The NuGet package manager sometimes edits App.config on your behalf as part of installing a package, and if a project doesn't already have an App.config file, it adds one. It has also updated a packages.config file and the main project file. If I decide that I actually don't want the change after all, Git-Gui permits me to revert the packages.config change and revert the project file change. If an existing App.config file was edited, I can revert that too, but if it was newly-generated, then I want to delete that file, but I don't want to ignore App.config files going forward, because there's a good chance a future change may introduce a different need for an App.config file. With the current Git-Gui version, I need to exit the Git-Gui UI/flow, navigate to the project in a console window (which probably isn't already in the correct folder) and manually delete the unwanted file. This deletion requires me to identify the file explicitly as well. With the proposed change, the untracked file, which Git-Gui already lists, can be selected, and then activating the "revert" function performs a UI flow for deleting the file. Without these changes, Git-Gui simply does nothing at all when you tell it to revert an untracked file. Another example is when I go to review changes and discover a VIM crash dump or a spurious temporary file from a code analyzer, files that aren't _expected_ to normally come into existence at all. While we could try to anticipate every type of spurious file and .gitignore them all, I prefer to simply delete the files, and for similar reasons as before, navigating a separate tool to the correct folder to perform the deletion is a manual, time-consuming and context-switching process. This is what led me to want this feature directly from the Git-Gui tool, which is what identifies the rogue file to me in the first place. If you can think of a concise way to say that, I'll be happy to add it to the commit message. My intuition is that that's too wordy as-written, but if that intuition is wrong, I can copy/paste this text too. :-) Thanks, Jonathan Gilbert On Mon, Oct 28, 2019 at 7:12 PM brian m. carlson sandals-at-crustytoothpaste.net |GitHub Public/Example Allow| <92ue75mvem3o2ht@sneakemail.com> wrote: > > On 2019-10-28 at 18:58:06, Jonathan Gilbert via GitGitGadget wrote: > > My development environment sometimes makes automatic changes that I don't > > want to keep. In some cases, this involves new files being added that I > > don't want to commit or keep. I have typically had to explicitly delete > > those files externally to Git Gui, and I want to be able to just select > > those newly-created untracked files and "revert" them into oblivion. > > Is there a reason these new files can't be ignored, with one of the > .gitignore file, .git/info/exclude, or core.excludesFile? > > If so, it would be helpful to explain that in the commit message so we > can more fully understand the rationale here. > -- > brian m. carlson: Houston, Texas, US > OpenPGP: https://keybase.io/bk2204
On Mon, Oct 28, 2019 at 7:58 PM Jonathan Gilbert via GitGitGadget <gitgitgadget@gmail.com> wrote: > > My development environment sometimes makes automatic changes that I don't > want to keep. In some cases, this involves new files being added that I > don't want to commit or keep. I have typically had to explicitly delete > those files externally to Git Gui, and I want to be able to just select > those newly-created untracked files and "revert" them into oblivion. > I have an entry in the 'Tools" menu for this called 'Delete': [guitool "Delete"] cmd = rm -f \"$FILENAME\" noconsole = yes needsfile = yes confirm = yes Best, Bert > This change updates the revert_helper function to check for untracked files > as well as changes, and then any changes to be reverted and untracked files > are handled by independent blocks of code. The user is prompted > independently for untracked files, since the underlying action is > fundamentally different (rm -f). If after deleting untracked files, the > directory containing them becomes empty, then the directory is removed as > well. > > This introduces new strings in index.tcl. I have been told that there is a > separate process whereby the translations get updated. > > Jonathan Gilbert (1): > git-gui: Revert untracked files by deleting them > > git-gui/lib/index.tcl | 139 +++++++++++++++++++++++++++++++----------- > 1 file changed, 104 insertions(+), 35 deletions(-) > >
That's kind of neat, I wasn't aware of that facet of Git Gui :-) But, it isn't quite the same feature: * It has to be manually set up on each installation. * It invokes an external process, I don't know if it's safe to assume that "rm" will work on all platforms (though I just tested it on my Windows installation and it worked). * It doesn't remove directories that it makes empty. * I don't see a way to bind it to a keyboard shortcut. That could just be me not knowing enough about custom tools, though. :-) * It only processes the first file selected. * If I select a tracked file, it will still delete it, and the feature I'm looking for is more of a "return repository to clean state" type function, like "revert" already is but extended to handle files that you can't actually "git revert". Thanks, Jonathan Gilbert On Tue, Oct 29, 2019 at 9:32 AM Bert Wesarg bert.wesarg-at-googlemail.com |GitHub Public/Example Allow| <xlwsizdz58ciy7t@sneakemail.com> wrote: > > On Mon, Oct 28, 2019 at 7:58 PM Jonathan Gilbert via GitGitGadget > <gitgitgadget@gmail.com> wrote: > > > > My development environment sometimes makes automatic changes that I don't > > want to keep. In some cases, this involves new files being added that I > > don't want to commit or keep. I have typically had to explicitly delete > > those files externally to Git Gui, and I want to be able to just select > > those newly-created untracked files and "revert" them into oblivion. > > > > I have an entry in the 'Tools" menu for this called 'Delete': > > [guitool "Delete"] > cmd = rm -f \"$FILENAME\" > noconsole = yes > needsfile = yes > confirm = yes > > Best, > Bert > > > This change updates the revert_helper function to check for untracked files > > as well as changes, and then any changes to be reverted and untracked files > > are handled by independent blocks of code. The user is prompted > > independently for untracked files, since the underlying action is > > fundamentally different (rm -f). If after deleting untracked files, the > > directory containing them becomes empty, then the directory is removed as > > well. > > > > This introduces new strings in index.tcl. I have been told that there is a > > separate process whereby the translations get updated. > > > > Jonathan Gilbert (1): > > git-gui: Revert untracked files by deleting them > > > > git-gui/lib/index.tcl | 139 +++++++++++++++++++++++++++++++----------- > > 1 file changed, 104 insertions(+), 35 deletions(-) > > > >
(should have had:) > > I have an entry in the "Tools" menu for this called 'Delete': > That's kind of neat, I wasn't aware of that facet of Git Gui :-) But, > it isn't quite the same feature: Oops, double gaffe. I accidentally forgot to "Reply All", so this was a re-send of the message. And when I re-sent it, I didn't notice that the e-mail client hid the quoted line from me and accidentally sent it without quoting Bert's line. I wasn't sure whether to write this follow-up but the longer I stared at it, the more sure I was that somebody would call me out on it so I decided to be pre-emptive. My apologies if it would have been better to just let it slide. Jonathan Gilbert On Tue, Oct 29, 2019 at 3:25 PM Jonathan Gilbert <logic@deltaq.org> wrote: > > That's kind of neat, I wasn't aware of that facet of Git Gui :-) But, > it isn't quite the same feature: > > * It has to be manually set up on each installation. > * It invokes an external process, I don't know if it's safe to assume > that "rm" will work on all platforms (though I just tested it on my > Windows installation and it worked). > * It doesn't remove directories that it makes empty. > * I don't see a way to bind it to a keyboard shortcut. That could just > be me not knowing enough about custom tools, though. :-) > * It only processes the first file selected. > * If I select a tracked file, it will still delete it, and the feature > I'm looking for is more of a "return repository to clean state" type > function, like "revert" already is but extended to handle files that > you can't actually "git revert". > > Thanks, > > Jonathan Gilbert > > On Tue, Oct 29, 2019 at 9:32 AM Bert Wesarg > bert.wesarg-at-googlemail.com |GitHub Public/Example Allow| > <xlwsizdz58ciy7t@sneakemail.com> wrote: > > > > On Mon, Oct 28, 2019 at 7:58 PM Jonathan Gilbert via GitGitGadget > > <gitgitgadget@gmail.com> wrote: > > > > > > My development environment sometimes makes automatic changes that I don't > > > want to keep. In some cases, this involves new files being added that I > > > don't want to commit or keep. I have typically had to explicitly delete > > > those files externally to Git Gui, and I want to be able to just select > > > those newly-created untracked files and "revert" them into oblivion. > > > > > > > I have an entry in the 'Tools" menu for this called 'Delete': > > > > [guitool "Delete"] > > cmd = rm -f \"$FILENAME\" > > noconsole = yes > > needsfile = yes > > confirm = yes > > > > Best, > > Bert > > > > > This change updates the revert_helper function to check for untracked files > > > as well as changes, and then any changes to be reverted and untracked files > > > are handled by independent blocks of code. The user is prompted > > > independently for untracked files, since the underlying action is > > > fundamentally different (rm -f). If after deleting untracked files, the > > > directory containing them becomes empty, then the directory is removed as > > > well. > > > > > > This introduces new strings in index.tcl. I have been told that there is a > > > separate process whereby the translations get updated. > > > > > > Jonathan Gilbert (1): > > > git-gui: Revert untracked files by deleting them > > > > > > git-gui/lib/index.tcl | 139 +++++++++++++++++++++++++++++++----------- > > > 1 file changed, 104 insertions(+), 35 deletions(-) > > > > > >
On 29/10/19 03:25PM, Jonathan Gilbert wrote: > That's kind of neat, I wasn't aware of that facet of Git Gui :-) But, > it isn't quite the same feature: > > * It has to be manually set up on each installation. > * It invokes an external process, I don't know if it's safe to assume > that "rm" will work on all platforms (though I just tested it on my > Windows installation and it worked). > * It doesn't remove directories that it makes empty. > * I don't see a way to bind it to a keyboard shortcut. That could just > be me not knowing enough about custom tools, though. :-) You can't as of now. Harish was in the process of implementing this [0], but I left some comments and he hasn't re-rolled the patch since. So unless I find some time to tie it up, this will remain un-implemented. Of course, if you'd like to see that feature in git-gui, feel free to pick it up and brush up the changes :). The latest version can be found at [1]. But it does not have a proper commit message (apart from the other changes I suggested) since Harish did not format the patch correctly when sending. > * It only processes the first file selected. > * If I select a tracked file, it will still delete it, and the feature > I'm looking for is more of a "return repository to clean state" type > function, like "revert" already is but extended to handle files that > you can't actually "git revert". [0] https://public-inbox.org/git/CACV9s2MQCP04QASgt0xhi3cSNPSKjwXTufxmZQXAUNvnWD9DSw@mail.gmail.com/ [1] https://github.com/prati0100/git-gui/tree/hk/custom-keyboard-shortcuts