threads / patch / 2744

patchWarn when send-pack does nothing

Subject: [PATCH] Warn when send-pack does nothing

## tl;dr

One message between Dec 4, 2005 and Dec 4, 2005. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Daniel Barkalow· Dec 4, 2005, 16:59 UTC · lore

If you try to push into an empty repository with no ref arguments to git push, it doesn't do anything and doesn't say anything. This adds a warning when send-pack isn't going to push anything, so you don't assume that it silently did what you wanted.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
---
 send-pack.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

applies-to: fe523a4df93cce3e5c5b0266b9d3f1cbea009afa 5519af6444d6da0ac55343fe48fe7f68fdb593d9

Show changes to send-pack.c +6 −0
diff --git a/send-pack.c b/send-pack.c
index 3eeb18f..589e1f9 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -190,6 +190,12 @@ static int send_pack(int in, int out, in
 	if (match_refs(local_refs, remote_refs, &remote_tail,
 		       nr_refspec, refspec, send_all))
 		return -1;
+
+	if (!remote_refs) {
+		fprintf(stderr, "No refs in common and none specified; doing nothing.\n");
+		return 0;
+	}
+
 	/*
 	 * Finally, tell the other end!
 	 */
---
0.99.9.GIT

← back to recent threads