From: Robin Rosenberg <robin.rosenberg.lists@dewire.com>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: git@vger.kernel.org
Subject: Re: [JGIT PATCH] Create a debugging tool "jgit rebuild-commitgraph"
Date: Mon, 16 Mar 2009 21:09:46 +0100 [thread overview]
Message-ID: <200903162109.46653.robin.rosenberg.lists@dewire.com> (raw)
In-Reply-To: <20090316144450.GN22920@spearce.org>
måndag 16 mars 2009 15:44:50 skrev "Shawn O. Pearce" <spearce@spearce.org>:
> Robin Rosenberg <robin.rosenberg@dewire.com> wrote:
> >
> > I'd hate to put such a dangerous thing in the list of normal tools. If the user
> > want to shoot him/her-self in the foot they should get a license first.
>
> How about squashing this in?
Does it have to be a utility accessible through the pgm interface? Why not
just run ut as java org.spearce.jgit.pgm.debug.RebuildCommitGraph ?
>
> diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/RebuildCommitGraph.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/RebuildCommitGraph.java
> index ccee997..cc23438 100644
> --- a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/RebuildCommitGraph.java
> +++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/RebuildCommitGraph.java
> @@ -50,6 +50,7 @@
> import java.util.Map;
>
> import org.kohsuke.args4j.Argument;
> +import org.kohsuke.args4j.Option;
> import org.spearce.jgit.errors.MissingObjectException;
> import org.spearce.jgit.errors.ObjectWritingException;
> import org.spearce.jgit.lib.Commit;
> @@ -85,6 +86,11 @@
> * <p>
> */
> class RebuildCommitGraph extends TextBuiltin {
> + private final String REALLY = "--destroy-this-repository";
> +
> + @Option(name = REALLY, usage = "approve destruction of repository")
> + boolean really;
> +
> @Argument(index = 0, required = true, metaVar = "REFS", usage = "for-each-ref output")
> File refList;
>
> @@ -97,6 +103,30 @@
>
> @Override
> protected void run() throws Exception {
> + if (!really && !db.getAllRefs().isEmpty()) {
> + final StringBuilder m = new StringBuilder();
> + m.append("fatal: ");
> + m.append("This program will destroy the repository:");
> + m.append("\n");
> + m.append("fatal:\n");
> + m.append("fatal: ");
> + m.append(db.getDirectory().getAbsolutePath());
> + m.append("\n");
> + m.append("fatal:\n");
> + m.append("fatal: ");
> + m.append("To continue, add ");
> + m.append(REALLY);
> + m.append(" to the command line");
> + m.append("\n");
> + m.append("fatal:");
> + System.err.println(m);
> + throw die("Need approval to destroy current repository");
What's wrong with old fashioned '+' ? (which just translated to exactly this series
of StringBuilder calls anyway?
> + }
> + if (!refList.isFile())
> + throw die("no such file: " + refList.getPath());
> + if (!graph.isFile())
> + throw die("no such file: " + graph.getPath());
> +
> recreateCommitGraph();
> detachHead();
> deleteAllRefs();
-- robin
next prev parent reply other threads:[~2009-03-16 20:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-13 14:35 [JGIT PATCH] Create a debugging tool "jgit rebuild-commitgraph" Shawn O. Pearce
2009-03-13 14:49 ` Johannes Schindelin
2009-03-13 14:52 ` Shawn O. Pearce
2009-03-15 11:34 ` Robin Rosenberg
2009-03-16 14:44 ` Shawn O. Pearce
2009-03-16 20:09 ` Robin Rosenberg [this message]
2009-03-16 20:13 ` Shawn O. Pearce
2009-03-16 23:58 ` [JGIT PATCH v3] Create a debugging tool "jgit debug-rebuild-commitgraph" Shawn O. Pearce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200903162109.46653.robin.rosenberg.lists@dewire.com \
--to=robin.rosenberg.lists@dewire.com \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).