@matheusbsbs / matheus-bagliano / commits / f76734902b
Fork 0

more terse push output

This changes the output of send-pack to match the new, more terse fetch output. It looks like this: To git://host.tld/path/to/repo + f3325dc...3b91d1c hasforce -> mirror/hasforce (forced update) f3325dc..bb022dc master -> mirror/master ! [rejected] needsforce -> mirror/needsforce (non-fast forward) * [new branch] newbranch -> mirror/newbranch * [new tag] v1.0 -> v1.0 instead of: updating 'refs/heads/mirror/hasforce' using 'refs/heads/hasforce' from f3325dca9c4a34d74012c0e159254f454930cec7 to 3b91d1c310ca9d7b547b85466dd876e143498304 updating 'refs/heads/mirror/master' using 'refs/heads/master' from f3325dca9c4a34d74012c0e159254f454930cec7 to bb022dc363d5c2aa9aa3026beb9706d44fbe1328 error: remote 'refs/heads/mirror/needsforce' is not an ancestor of local 'refs/heads/needsforce'. Maybe you are not up-to-date and need to pull first? updating 'refs/heads/mirror/newbranch' using 'refs/heads/newbranch' from 0000000000000000000000000000000000000000 to 3b91d1c310ca9d7b547b85466dd876e143498304 updating 'refs/tags/v1.0' from 0000000000000000000000000000000000000000 to bb022dc363d5c2aa9aa3026beb9706d44fbe1328 Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Nov 5, 2007 at 00:11 UTC f76734902bba47afff622068524a0c38f642d769
1 file changed +64 -17
builtin-send-pack.c
+64 -17
@@ -206,7 +206,18 @@ static void update_tracking_ref(struct remote *remote, struct ref *ref)
206 }
207 }
208
209 -static int do_send_pack(int in, int out, struct remote *remote, int nr_refspec, const char **refspec)
209 +static const char *prettify_ref(const char *name)
210 +{
211 + return name + (
212 + !prefixcmp(name, "refs/heads/") ? 11 :
213 + !prefixcmp(name, "refs/tags/") ? 10 :
214 + !prefixcmp(name, "refs/remotes/") ? 13 :
215 + 0);
216 +}
217 +
218 +#define SUMMARY_WIDTH (2 * DEFAULT_ABBREV + 3)
219 +
220 +static int do_send_pack(int in, int out, struct remote *remote, const char *dest, int nr_refspec, const char **refspec)
221 {
222 struct ref *ref;
223 int new_refs;
@@ -214,6 +225,7 @@ static int do_send_pack(int in, int out, struct remote *remote, int nr_refspec,
225 int ask_for_status_report = 0;
226 int allow_deleting_refs = 0;
227 int expect_status_report = 0;
228 + int shown_dest = 0;
229
230 /* No funny business with the matcher */
231 remote_tail = get_remote_heads(in, &remote_refs, 0, NULL, REF_NORMAL);
@@ -245,21 +257,33 @@ static int do_send_pack(int in, int out, struct remote *remote, int nr_refspec,
257 for (ref = remote_refs; ref; ref = ref->next) {
258 char old_hex[60], *new_hex;
259 int will_delete_ref;
260 + const char *pretty_ref;
261 + const char *pretty_peer;
262
263 if (!ref->peer_ref)
264 continue;
265
266 + if (!shown_dest) {
267 + fprintf(stderr, "To %s\n", dest);
268 + shown_dest = 1;
269 + }
270 +
271 + pretty_ref = prettify_ref(ref->name);
272 + pretty_peer = prettify_ref(ref->peer_ref->name);
273
274 will_delete_ref = is_null_sha1(ref->peer_ref->new_sha1);
275 if (will_delete_ref && !allow_deleting_refs) {
255 - error("remote does not support deleting refs");
276 + fprintf(stderr, " ! %-*s %s (remote does not support deleting refs)\n",
277 + SUMMARY_WIDTH, "[rejected]", pretty_ref);
278 ret = -2;
279 continue;
280 }
281 if (!will_delete_ref &&
282 !hashcmp(ref->old_sha1, ref->peer_ref->new_sha1)) {
283 if (args.verbose)
262 - fprintf(stderr, "'%s': up-to-date\n", ref->name);
284 + fprintf(stderr, " = %-*s %s -> %s\n",
285 + SUMMARY_WIDTH, "[up to date]",
286 + pretty_peer, pretty_ref);
287 continue;
288 }
289
@@ -296,12 +320,9 @@ static int do_send_pack(int in, int out, struct remote *remote, int nr_refspec,
320 * commits at the remote end and likely
321 * we were not up to date to begin with.
322 */
299 - error("remote '%s' is not a strict "
300 - "subset of local ref '%s'. "
301 - "maybe you are not up-to-date and "
302 - "need to pull first?",
303 - ref->name,
304 - ref->peer_ref->name);
323 + fprintf(stderr, " ! %-*s %s -> %s (non-fast forward)\n",
324 + SUMMARY_WIDTH, "[rejected]",
325 + pretty_peer, pretty_ref);
326 ret = -2;
327 continue;
328 }
@@ -325,14 +346,40 @@ static int do_send_pack(int in, int out, struct remote *remote, int nr_refspec,
346 old_hex, new_hex, ref->name);
347 }
348 if (will_delete_ref)
328 - fprintf(stderr, "deleting '%s'\n", ref->name);
349 + fprintf(stderr, " - %-*s %s\n",
350 + SUMMARY_WIDTH, "[deleting]",
351 + pretty_ref);
352 + else if (is_null_sha1(ref->old_sha1)) {
353 + const char *msg;
354 +
355 + if (!prefixcmp(ref->name, "refs/tags/"))
356 + msg = "[new tag]";
357 + else
358 + msg = "[new branch]";
359 + fprintf(stderr, " * %-*s %s -> %s\n",
360 + SUMMARY_WIDTH, msg,
361 + pretty_peer, pretty_ref);
362 + }
363 else {
330 - fprintf(stderr, "updating '%s'", ref->name);
331 - if (strcmp(ref->name, ref->peer_ref->name))
332 - fprintf(stderr, " using '%s'",
333 - ref->peer_ref->name);
334 - fprintf(stderr, "\n from %s\n to %s\n",
335 - old_hex, new_hex);
364 + char quickref[83];
365 + char type = ' ';
366 + const char *msg = "";
367 +
368 + strcpy(quickref, find_unique_abbrev(ref->old_sha1, DEFAULT_ABBREV));
369 + if (ref_newer(ref->peer_ref->new_sha1, ref->old_sha1))
370 + strcat(quickref, "..");
371 + else {
372 + strcat(quickref, "...");
373 + type = '+';
374 + msg = " (forced update)";
375 + }
376 + strcat(quickref, find_unique_abbrev(ref->new_sha1, DEFAULT_ABBREV));
377 +
378 + fprintf(stderr, " %c %-*s %s -> %s%s\n",
379 + type,
380 + SUMMARY_WIDTH, quickref,
381 + pretty_peer, pretty_ref,
382 + msg);
383 }
384 }
385
@@ -460,7 +507,7 @@ int send_pack(struct send_pack_args *my_args,
507 verify_remote_names(nr_heads, heads);
508
509 conn = git_connect(fd, dest, args.receivepack, args.verbose ? CONNECT_VERBOSE : 0);
463 - ret = do_send_pack(fd[0], fd[1], remote, nr_heads, heads);
510 + ret = do_send_pack(fd[0], fd[1], remote, dest, nr_heads, heads);
511 close(fd[0]);
512 close(fd[1]);
513 ret |= finish_connect(conn);