Re: [JGIT PATCH] Create a debugging tool "jgit rebuild-commitgraph"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



måndag 16 mars 2009 15:44:50 skrev "Shawn O. Pearce" <spearce@xxxxxxxxxxx>:
> Robin Rosenberg <robin.rosenberg@xxxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux