Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
GitAddin: Fixed removing files with status 'Added'
  • Loading branch information
dgrunwald committed Aug 29, 2010
1 parent 0c2e680 commit 5746f2f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/AddIns/VersionControl/GitAddIn/Src/Git.cs
Expand Up @@ -61,6 +61,17 @@ public static void Add(string fileName, Action<int> callback)
RunGit(wcRoot, "add " + AdaptFileName(wcRoot, fileName), callback);
}

public static void Remove(string fileName, bool indexOnly, Action<int> callback)
{
string wcRoot = FindWorkingCopyRoot(fileName);
if (wcRoot == null)
return;
if (indexOnly)
RunGit(wcRoot, "rm --cached " + AdaptFileName(wcRoot, fileName), callback);
else
RunGit(wcRoot, "rm " + AdaptFileName(wcRoot, fileName), callback);
}

public static string AdaptFileName(string wcRoot, string fileName)
{
return '"' + AdaptFileNameNoQuotes(wcRoot, fileName) + '"';
Expand Down
10 changes: 8 additions & 2 deletions src/AddIns/VersionControl/GitAddIn/Src/RegisterEventsCommand.cs
Expand Up @@ -30,10 +30,16 @@ public class RegisterEventsCommand : AbstractCommand
public override void Run()
{
FileService.FileCreated += (sender, args) => {
Git.Add(args.FileName,
Git.Add(args.FileName,
exitcode => WorkbenchSingleton.SafeThreadAsyncCall(ClearStatusCacheAndEnqueueFile, args.FileName)
);
};
FileService.FileRemoved += (sender, args) => {
if (GitStatusCache.GetFileStatus(args.FileName) == GitStatus.Added) {
Git.Remove(args.FileName, true,
exitcode => WorkbenchSingleton.SafeThreadAsyncCall(ClearStatusCacheAndEnqueueFile, args.FileName));
}
};
FileUtility.FileSaved += (sender, e) => {
ClearStatusCacheAndEnqueueFile(e.FileName);
};
Expand Down Expand Up @@ -67,7 +73,7 @@ void ClearStatusCacheAndEnqueueFile(string fileName)
if (pad == null) return;
FileNode node = pad.ProjectBrowserControl.FindFileNode(fileName);
if (node == null) return;
OverlayIconManager.EnqueueParents(node);
OverlayIconManager.EnqueueParents(node);
}
}
}

0 comments on commit 5746f2f

Please sign in to comment.