Re: [RFC PATCH 1/2] add a --delete option to git push

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jeff King
Date: Thursday, August 13, 2009 - 11:55 pm

On Thu, Aug 13, 2009 at 11:40:44PM -0700, Sverre Rabbelier wrote:


Hmm. Actually, looking at the code, we _already_ have a funny
two-element syntax:

  git push origin tag v1.6.1

which, AFAICT, is totally useless, as you can just push v1.6.1 directly.
I assume it's historical. I still think it's probably not a good idea to
introduce a similar "delete foo".


Really? I was thinking something as simple as:

diff --git a/builtin-push.c b/builtin-push.c
index 67f6d96..aa3784c 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -44,6 +44,12 @@ static void set_refspecs(const char **refs, int nr)
 			strcat(tag, refs[i]);
 			ref = tag;
 		}
+		if (!prefixcmp("--delete=", ref)) {
+			struct strbuf deleted = STRBUF_INIT;
+			strbuf_addstr(&deleted, ":");
+			strbuf_addstr(&deleted, skip_prefix(ref, "--delete="));
+			ref = strbuf_detach(&deleted, NULL);
+		}
 		add_refspec(ref);
 	}
 }

which is even shorter than your patch, not needing a separate option
parser.

That being said, currently parseopt will complain about that, even after
the "remote" field; we would need to pass it
PARSE_OPT_STOP_AT_NON_OPTION.


I think you mean "deduce", but yes, I think we have seen people complain
about the syntax in the past. I'm not against fixing it; I just want to
make sure what we introduce doesn't make any new confusion.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC PATCH 0/2] add a --delete option to git push, Sverre Rabbelier, (Thu Aug 13, 10:05 pm)
[RFC PATCH 1/2] add a --delete option to git push, Sverre Rabbelier, (Thu Aug 13, 10:05 pm)
[RFC PATCH 2/2] test that git push --delete deletes the re ..., Sverre Rabbelier, (Thu Aug 13, 10:05 pm)
Re: [RFC PATCH 1/2] add a --delete option to git push, Sverre Rabbelier, (Thu Aug 13, 11:24 pm)
Re: [RFC PATCH 1/2] add a --delete option to git push, Sverre Rabbelier, (Thu Aug 13, 11:40 pm)
Re: [RFC PATCH 1/2] add a --delete option to git push, Junio C Hamano, (Thu Aug 13, 11:53 pm)
Re: [RFC PATCH 1/2] add a --delete option to git push, Jeff King, (Thu Aug 13, 11:55 pm)
Re: [RFC PATCH 1/2] add a --delete option to git push, Sverre Rabbelier, (Fri Aug 14, 12:05 am)
Re: [RFC PATCH 1/2] add a --delete option to git push, Junio C Hamano, (Fri Aug 14, 12:51 am)
Re: [RFC PATCH 0/2] add a --delete option to git push, Jakub Narebski, (Fri Aug 14, 1:50 am)
Re: [RFC PATCH 0/2] add a --delete option to git push, Jakub Narebski, (Fri Aug 14, 1:25 pm)
Re: [RFC PATCH 1/2] add a --delete option to git push, Junio C Hamano, (Fri Aug 14, 7:01 pm)
Re: [RFC PATCH 1/2] add a --delete option to git push, Sverre Rabbelier, (Sat Aug 15, 7:30 pm)
Re: [RFC PATCH 1/2] add a --delete option to git push, Jakub Narebski, (Sun Aug 16, 2:19 am)