Bug 1129 - Allow committing parts of a file
Summary: Allow committing parts of a file
Status: NEW
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Version Control ()
Version: Trunk
Hardware: PC Mac OS
: Normal enhancement
Target Milestone: Future Cycle (TBD)
Assignee: Marius Ungureanu
URL:
Depends on:
Blocks:
 
Reported: 2011-09-29 05:58 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2016-12-14 18:55 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 1129 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Rolf Bjarne Kvinge [MSFT] 2011-09-29 05:58:18 UTC
I'd like to be able to commit parts of a file (line and hunk based staging, like git gui can do). This obviously makes it necessary for MD to use the git index properly.

Another advantage is that it's a way to store the selected files when reviewing changes - closing and reopening the "Review Changes" dialog will re-select all deselected files.
Comment 1 Mikayla Hutchinson [MSFT] 2011-09-29 06:21:05 UTC
The way gitx allows staging lines and hunks is awesome. I usually use it reviewing and for committing.

See also bug 372 - git addin uses index inconsistently
Comment 2 Lluis Sanchez 2011-10-14 03:33:45 UTC
I'll consider using the git index for everything, although this requires some important changes and right now there are other priorities. Here are some changes that need to be done in the Review Changes view:

* It can't support reviewing changes in a specific directory. The index is global, so all operations will have be done at solution (or repository root) level.
* We need api to support adding/removing files to the index, and link that to the commit checkbox we currently have in the changes list.
* Added/removed files will require special handling, since you can't arbitrarily select them in the index, they will always be included in the next commit.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2011-10-14 05:23:45 UTC
(In reply to comment #2)
> * Added/removed files will require special handling, since you can't
> arbitrarily select them in the index, they will always be included in the next
> commit.

What do you mean here? It is possible to commit parts of a new file too with git (or not commit them at all).
Comment 4 Lluis Sanchez 2011-10-14 05:34:13 UTC
Let's say you add two new files to the index:

git add file1.cs
git add file2.cs

Is it possible to make a commit which includes the addition of file1.cs but not file2.cs?
Comment 5 Rolf Bjarne Kvinge [MSFT] 2011-10-14 05:55:51 UTC
Yes.

git rm --cached file2.cs

will remove it from the index (but not from the file system).
Comment 6 Lluis Sanchez 2011-10-14 06:23:11 UTC
That's not what I'm talking about. The current Review Changes view allows selecting what you want to commit. You may have for example a file modification and a file addition. You'll see both in the changes view. You can select the modification and only commit that. You can later select the addition and commit the addition. This can currently be done because the index is not being used, those are direct commits.

Now, if all commit operations are done through the index, whatever is in the index will be committed. For modified files that's not a problem, because you can stage/unstage modified files and that will not change the status of "file modified". But for file additions/removals that's different. For a file to be marked as added or removed, the file has to be in the index. If you unstage a file addition, you are effectively reverting the file addition. So on an index-based Review Changes view, you should not be able to unselect file additions/removals. You can of course Revert them but that's a different operation.

I'm not saying that's good or bad. I'm just exposing changes that will have to be done.
Comment 7 Rolf Bjarne Kvinge [MSFT] 2011-10-14 07:07:17 UTC
What does Revert mean for new files: remove from index or delete file completely?
Comment 8 Lluis Sanchez 2011-10-14 07:37:28 UTC
Remove from the index. The file is not deleted.
Comment 9 Mikayla Hutchinson [MSFT] 2011-10-18 04:29:27 UTC
The problem is that the addin's abusing the operation of "adding to the index" to make new files show up in the commit dialog. The correct way to do this is to list all unknown files, then the user can choose to stage them or not. That's what .gitignore's for.