#### To review with Git
-on a detached HEAD...
+To review an updated patchset
- git fetch ${repositoryUrl} ${ticketRef} && git checkout FETCH_HEAD
+ git fetch && git checkout ${reviewBranch} && git pull --ff-only
-on a new branch...
+To review a rewritten patchset
- git fetch ${repositoryUrl} ${ticketRef} && git checkout -B ${reviewBranch} FETCH_HEAD
+ git fetch && git checkout ${reviewBranch} && git reset --hard origin/${reviewBranch}
}\r
\r
protected void addGitReviewInstructions(UserModel user, RepositoryModel repository, MarkupContainer panel) {\r
- String repoUrl = getRepositoryUrl(user, repository);\r
-\r
panel.add(new Label("gitStep1", MessageFormat.format(getString("gb.stepN"), 1)));\r
panel.add(new Label("gitStep2", MessageFormat.format(getString("gb.stepN"), 2)));\r
\r
String ticketBranch = Repository.shortenRefName(PatchsetCommand.getTicketBranch(ticket.number));\r
- String reviewBranch = PatchsetCommand.getReviewBranch(ticket.number);\r
\r
- String step1 = MessageFormat.format("git fetch {0} {1}", repoUrl, ticketBranch);\r
- String step2 = MessageFormat.format("git checkout -B {0} FETCH_HEAD", reviewBranch);\r
+ String step1 = "git fetch";\r
+ String step2 = MessageFormat.format("git checkout {0} && git pull -ff-only\nOR\ngit checkout {0} && git reset --hard origin/{0}", ticketBranch);\r
\r
panel.add(new Label("gitPreStep1", step1));\r
panel.add(new Label("gitPreStep2", step2));\r
protected Component getMergeInstructions(UserModel user, RepositoryModel repository, String markupId, String infoKey) {\r
Fragment cmd = new Fragment(markupId, "commandlineMergeFragment", this);\r
cmd.add(new Label("instructions", MessageFormat.format(getString(infoKey), ticket.mergeTo)));\r
- String repoUrl = getRepositoryUrl(user, repository);\r
\r
// git instructions\r
cmd.add(new Label("mergeStep1", MessageFormat.format(getString("gb.stepN"), 1)));\r
String ticketBranch = Repository.shortenRefName(PatchsetCommand.getTicketBranch(ticket.number));\r
String reviewBranch = PatchsetCommand.getReviewBranch(ticket.number);\r
\r
- String step1 = MessageFormat.format("git checkout -B {0} {1}", reviewBranch, ticket.mergeTo);\r
- String step2 = MessageFormat.format("git pull {0} {1}", repoUrl, ticketBranch);\r
- String step3 = MessageFormat.format("git checkout {0}\ngit merge {1}\ngit push origin {0}", ticket.mergeTo, reviewBranch);\r
+ String step1 = MessageFormat.format("git checkout -b {0} {1}", reviewBranch, ticket.mergeTo);\r
+ String step2 = MessageFormat.format("git pull origin {0}", ticketBranch);\r
+ String step3 = MessageFormat.format("git checkout {0}\ngit merge {1}\ngit push origin {0}\ngit branch -d {1}", ticket.mergeTo, reviewBranch);\r
\r
cmd.add(new Label("mergePreStep1", step1));\r
cmd.add(new Label("mergePreStep2", step2));\r
cd ${repo}
git checkout -b ${reviewBranch} ${integrationBranch}
...
- git push --up-stream origin ${reviewBranch}
+ git push --set-upstream origin ${reviewBranch}
## Standard Features (GO/WAR)\r
- JGit http/https SmartHTTP servlet\r
- JGit git protocol daemon\r
-- Menu driven native platform clone links for all popular Git clients\r
-- Browser and git client authentication\r
+- Optional feature to allow users to create personal repositories\r
+- Optional feature to fork a repository to a personal repository\r
+- Optional feature to create a repository on push\r
+- Optional feature to automatically fetch ref updates for repository mirrors\r
+- Optional Issue Tracker and Pull-Request-like mechanism\r
- Four *per-repository* access restriction configurations with a Read-Only control flag\r
- ![anonymous](blank.png) *Anonymous View, Clone & Push*\r
- ![push](lock_go_16x16.png) *Authenticated Push*\r
- **RWC** (clone and push with ref creation)\r
- **RWD** (clone and push with ref creation, deletion)\r
- **RW+** (clone and push with ref creation, deletion, rewind)\r
-- Optional feature to allow users to create personal repositories\r
-- Optional feature to fork a repository to a personal repository\r
-- Optional feature to create a repository on push\r
-- Optional feature to automatically fetch ref updates for repository mirrors\r
-- Optional Issue Tracker and Pull-Request-like mechanism\r
+- Menu driven native platform clone links for all popular Git clients\r
- *Experimental* built-in Garbage Collection\r
- Ability to federate with one or more other Gitblit instances\r
- RSS/JSON RPC interface\r
- Java/Swing Gitblit Manager tool\r
-- Gitweb inspired web UI\r
- Responsive web UI that subtracts elements to be usable on phones, tablets, and desktop browsers\r
- Groovy pre- and post- push hook scripts, per-repository or globally for all repositories\r
-- Email push notifications *(via sendmail.groovy push script)*\r
+- Rich Push email notifications *(via sendmail.groovy push script)*\r
+- Rich Ticket email notifications\r
- Lucene indexing of specified repository branches\r
- Administrators may create, edit, rename, or delete repositories through the web UI or RPC interface\r
- Administrators may create, edit, rename, or delete users through the web UI or RPC interface\r
- Display of Author and Committer email addresses can be disabled\r
- Case-insensitive searching of commit messages, authors, or committers\r
- Dynamic zip downloads feature\r
+- Docs page which enumerates all Markdown files within a repository\r
- Markdown, Confluence, Textile, Twiki, Tracwiki, & Mediawiki markup rendering support\r
- Syntax highlighting for popular source code types\r
- Customizable regular expression substitution for commit messages (i.e. bug or code review link integration)\r
- Single text file for users configuration\r
-- Optional Docs page which enumerates all Markdown files within a repository\r
-2009-01-27)*\r
- Translations\r
- English\r
- Japanese\r
- Korean\r
- Brazilian Portuguese\r
- Dutch\r
- - Chinese (zh_CN)\r
+ - Simplified Chinese (zh_CN)\r
\r
## Gitblit GO Features\r
- Out-of-the-box integrated stack requiring minimal configuration\r
- Built-in AJP connector for Apache httpd\r
\r
## Limitations\r
-- HTTP/HTTPS/GIT are the only supported Git protocols (SSH is in progress)\r
-- Built-in access controls are not path-based, they are repository-based.\r
+- HTTP/HTTPS/GIT are the only supported Git protocols (SSH is in progress, ticket-6)\r
+- Built-in access controls are not branch-based, they are repository-based.\r
\r
[jgit]: http://eclipse.org/jgit "Eclipse JGit Site"\r
Any authenticated user who can clone your repository.
+ git clone https://server/r/repo.git
+ cd repo
git checkout -b mytopic
...add a single commit...
git push origin HEAD:refs/for/new
- git branch --set-upstream-to={remote}/ticket/{id}
+ # read ticket id from server output
+ git branch --set-upstream-to=origin/ticket/{id}
### Creating the first Patchset for an Existing Ticket
-If you have an existing ticket that does **not** yet have a proposed patchset you can push using the magic ref.
+If you have an existing ticket that does **not** yet have a proposed patchset you can push using the ticket branch ref.
*Who can create the first patchset for an existing ticket?*
Any authenticated user who can clone your repository.
- git checkout -b mytopic
+ git clone https://server/r/repo.git
+ cd repo
+ git checkout -b ticket/{id}
...add one or more commits...
- git push origin HEAD:refs/for/{id}
- git branch --set-upstream-to={remote}/ticket/{id}
+ git push --set-upstream origin ticket/{id}
### Safely adding commits to a Patchset for an Existing Ticket
4. Any user with write (RW) permissions to the repository
- git checkout ticket/{id}
+ git fetch && git checkout ticket/{id}
+ git pull --ff-only
...add one or more commits...
git push
See the above rules for who can add commits to a patchset. You do **not** need rewind (RW+) to the repository to push a non-fast-forward patchset. Gitblit will detect the non-fast-forward update and create a new patchset ref. This preserves the previous patchset.
- git checkout ticket/{id}
+ git fetch && git checkout ticket/{id}
+ git pull --ff-only
...amend, rebase, squash...
git push origin HEAD:refs/for/{id}
+OR if you have RW+ permissions, then you can push using *-f* flag.
+
+ git push -f
+
+### Updating your copy of a rewritten Patchset
+
+If a patchset has been rewritten you can no longer simply *pull* to update. Let's assume your checkout *does not* have any unshared commits - i.e. it represents the previous patchset. The simplest way to update your branch to the current patchset is to reset it.
+
+ git fetch && git checkout ticket/{id}
+ git reset --hard origin/ticket/{id}
+
+If you *do* have unshared commits then you'll could make a new temporary branch and then cherry-pick your changes onto the rewritten patchset.
+
+ git branch oldticket ticket/{id}
+ git fetch && git checkout ticket/{id}
+ git reset --hard origin/ticket/{id}
+ git cherry-pick <commitid1> <commitid2>
+ git branch -D oldticket
+
+Since Git is a powerful and flexible tool, there are no doubt several other strategies you could use to resolve this situation.
+
+
### Ticket RefSpecs
Gitblit supports two primary push ref specs: the magic ref and the patchset ref.
git checkout master
git merge ticket-{id}
git push origin master
+ git branch -d ticket-{id}
### Closing Tickets on Push with a Completely New Patchset