lib git: Run commit with --all and deduplicate code somewhat

This commit is contained in:
Hylke Bons 2012-07-01 13:30:33 +02:00
parent ef196d00b8
commit aa9af2c094

View file

@ -439,7 +439,7 @@ namespace SparkleLib.Git {
} }
git = new SparkleGit (LocalPath, git = new SparkleGit (LocalPath,
"commit -m \"" + message + "\" " + "commit --all --message=\"" + message + "\" " +
"--author=\"" + SparkleConfig.DefaultConfig.User.Name + "--author=\"" + SparkleConfig.DefaultConfig.User.Name +
" <" + SparkleConfig.DefaultConfig.User.Email + ">\""); " <" + SparkleConfig.DefaultConfig.User.Email + ">\"");
@ -483,12 +483,12 @@ namespace SparkleLib.Git {
// meaning, and how SparkleShare should handle them. // meaning, and how SparkleShare should handle them.
// //
// DD unmerged, both deleted -> Do nothing // DD unmerged, both deleted -> Do nothing
// AU unmerged, added by us -> Use theirs, save ours as a timestamped copy // AU unmerged, added by us -> Use server's, save ours as a timestamped copy
// UD unmerged, deleted by them -> Use ours // UD unmerged, deleted by them -> Use ours
// UA unmerged, added by them -> Use theirs, save ours as a timestamped copy // UA unmerged, added by them -> Use server's, save ours as a timestamped copy
// DU unmerged, deleted by us -> Use theirs // DU unmerged, deleted by us -> Use server's
// AA unmerged, both added -> Use theirs, save ours as a timestamped copy // AA unmerged, both added -> Use server's, save ours as a timestamped copy
// UU unmerged, both modified -> Use theirs, save ours as a timestamped copy // UU unmerged, both modified -> Use server's, save ours as a timestamped copy
// ?? unmerged, new files -> Stage the new files // ?? unmerged, new files -> Stage the new files
// //
// Note that a rebase merge works by replaying each commit from the working branch on // Note that a rebase merge works by replaying each commit from the working branch on
@ -496,7 +496,7 @@ namespace SparkleLib.Git {
// side reported as 'ours' is the so-far rebased series, starting with upstream, // side reported as 'ours' is the so-far rebased series, starting with upstream,
// and 'theirs' is the working branch. In other words, the sides are swapped. // and 'theirs' is the working branch. In other words, the sides are swapped.
// //
// So: 'ours' means the 'server's version' and 'theirs' means the 'local version' // So: 'ours' means the 'server's version' and 'theirs' means the 'local version' after this comment
SparkleGit git_status = new SparkleGit (LocalPath, "status --porcelain"); SparkleGit git_status = new SparkleGit (LocalPath, "status --porcelain");
git_status.Start (); git_status.Start ();
@ -527,9 +527,8 @@ namespace SparkleLib.Git {
File.SetAttributes (Path.Combine (LocalPath, conflicting_path), FileAttributes.Hidden); File.SetAttributes (Path.Combine (LocalPath, conflicting_path), FileAttributes.Hidden);
SparkleGit git_rebase_continue = new SparkleGit (LocalPath, "rebase --continue"); Add ();
git_rebase_continue.Start (); RebaseContinue ();
git_rebase_continue.WaitForExit ();
continue; continue;
} }
@ -566,10 +565,7 @@ namespace SparkleLib.Git {
git_ours.WaitForExit (); git_ours.WaitForExit ();
Add (); Add ();
RebaseContinue ();
SparkleGit git_rebase_continue = new SparkleGit (LocalPath, "rebase --continue");
git_rebase_continue.Start ();
git_rebase_continue.WaitForExit ();
// The local version has been modified, but the server version was removed // The local version has been modified, but the server version was removed
} else if (line.StartsWith ("DU")) { } else if (line.StartsWith ("DU")) {
@ -585,9 +581,7 @@ namespace SparkleLib.Git {
git_add.Start (); git_add.Start ();
git_add.WaitForExit (); git_add.WaitForExit ();
SparkleGit git_rebase_continue = new SparkleGit (LocalPath, "rebase --continue"); RebaseContinue ();
git_rebase_continue.Start ();
git_rebase_continue.WaitForExit ();
// The server version has been modified, but the local version was removed // The server version has been modified, but the local version was removed
} else if (line.StartsWith ("UD")) { } else if (line.StartsWith ("UD")) {
@ -601,12 +595,17 @@ namespace SparkleLib.Git {
// New local files // New local files
} else { } else {
Add (); Add ();
RebaseContinue ();
}
}
}
SparkleGit git_rebase_continue = new SparkleGit (LocalPath, "rebase --continue");
git_rebase_continue.Start (); private void RebaseContinue ()
git_rebase_continue.WaitForExit (); {
} SparkleGit git = new SparkleGit (LocalPath, "rebase --continue");
} git.Start ();
git.WaitForExit ();
} }