Commit graph

15 commits

Author SHA1 Message Date
Junio C Hamano 257f3020f6 Update callers of check_ref_format()
This updates send-pack and fast-import to use symbolic constants
for checking the return values from check_ref_format(), and also
futureproof the logic in lock_any_ref_for_update() to explicitly
name the case that is usually considered an error but is Ok for
this particular use.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-02 11:20:09 -08:00
Jeff King 07f507155d send-pack: cluster ref status reporting
Instead of intermingling success and failure, we now print:

  1. all uptodate refs (if args.verbose is enabled)
  2. successfully pushed refs
  3. failed refs

with the assumption that the user is most likely to see the
ones at the end, and therefore we order them from "least
interesting" to "most interesting."

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-20 23:25:31 -08:00
Jeff King 73fa0b44ac send-pack: fix "everything up-to-date" message
This has always been slightly inaccurate, since it used the
new_refs counter, which really meant "did we send any
objects," so deletions were not counted.

It has gotten even worse with recent patches, since we no
longer look at the 'ret' value, meaning we would say "up to
date" if non-ff pushes were rejected.

Instead, we now claim up to date iff every ref is either
unmatched or up to date. Any other case should already have
generated a status line.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-18 02:35:39 -08:00
Jeff King 2a0fe89a97 send-pack: tighten remote error reporting
Previously, we set all ref pushes to 'OK', and then marked
them as errors if the remote reported so. This has the
problem that if the remote dies or fails to report a ref, we
just assume it was OK.

Instead, we use a new non-OK state to indicate that we are
expecting status (if the remote doesn't support the
report-status feature, we fall back on the old behavior).
Thus we can flag refs for which we expected a status, but
got none (conversely, we now also print a warning for refs
for which we get a status, but weren't expecting one).

This also allows us to simplify the receive_status exit
code, since each ref is individually marked with failure
until we get a success response. We can just print the usual
status table, so the user still gets a sense of what we were
trying to do when the failure happened.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-18 02:34:52 -08:00
Jeff King ca74c458a3 send-pack: assign remote errors to each ref
This lets us show remote errors (e.g., a denied hook) along
with the usual push output.

There is a slightly clever optimization in receive_status
that bears explanation. We need to correlate the returned
status and our ref objects, which naively could be an O(m*n)
operation. However, since the current implementation of
receive-pack returns the errors to us in the same order that
we sent them, we optimistically look for the next ref to be
looked up to come after the last one we have found. So it
should be an O(m+n) merge if the receive-pack behavior
holds, but we fall back to a correct but slower behavior if
it should change.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-17 12:10:50 -08:00
Jeff King 1f0e2a1a65 send-pack: check ref->status before updating tracking refs
Previously, we manually checked the 'NONE' and 'UPTODATE'
conditions. Now that we have ref->status, we can easily
say "only update if we pushed successfully".

This adds a test for and fixes a regression introduced in
ed31df31 where deleted refs did not have their tracking
branches removed. This was due to a bogus per-ref error test
that is superseded by the more accurate ref->status flag.

Signed-off-by: Jeff King <peff@peff.net>
Completely-Acked-By: Alex "Sleepy" Riesen <raa.lkml@gmail.com>
Acked-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-17 12:10:50 -08:00
Jeff King 8736a84890 send-pack: track errors for each ref
Instead of keeping the 'ret' variable, we instead have a
status flag for each ref that tracks what happened to it.
We then print the ref status after all of the refs have
been examined.

This paves the way for three improvements:
  - updating tracking refs only for non-error refs
  - incorporating remote rejection into the printed status
  - printing errors in a different order than we processed
    (e.g., consolidating non-ff errors near the end with
    a special message)

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Alex Riesen <raa.lkml@gmail.com>
Acked-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-17 12:10:50 -08:00
Junio C Hamano bcd2e266a6 Merge branch 'aw/mirror-push' into jk/send-pack
* aw/mirror-push:
  git-push: add documentation for the newly added --mirror mode
  Add tests for git push'es mirror mode
  git-push: plumb in --mirror mode
  Teach send-pack a mirror mode
  send-pack: segfault fix on forced push
  send-pack: require --verbose to show update of tracking refs
  receive-pack: don't mention successful updates
  more terse push output

Conflicts:

	transport.c
	transport.h
2007-11-14 03:13:30 -08:00
Junio C Hamano 2d4eb71c6c Merge branch 'ar/send-pack-remote-track' into jk/send-pack
* ar/send-pack-remote-track:
  Update the tracking references only if they were succesfully updated on remote
  Add a test checking if send-pack updated local tracking branches correctly
2007-11-14 03:11:37 -08:00
Junio C Hamano a108e53861 Merge branch 'db/remote-builtin' into jk/send-pack
* db/remote-builtin:
  Reteach builtin-ls-remote to understand remotes
  Build in ls-remote
  Use built-in send-pack.
  Build-in send-pack, with an API for other programs to call.
  Build-in peek-remote, using transport infrastructure.
  Miscellaneous const changes and utilities

Conflicts:

	transport.c
2007-11-14 03:09:52 -08:00
Andy Whitcroft 28b9d6e548 Teach send-pack a mirror mode
Existing "git push --all" is almost perfect for backing up to
another repository, except that "--all" only means "all
branches" in modern git, and it does not delete old branches and
tags that exist at the back-up repository that you have removed
from your local repository.

This teaches "git-send-pack" a new "--mirror" option.  The
difference from the "--all" option are that (1) it sends all
refs, not just branches, and (2) it deletes old refs you no
longer have on the local side from the remote side.

Original patch by Junio C Hamano.

Signed-off-by: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-09 21:14:10 -08:00
Junio C Hamano 6738c81942 send-pack: segfault fix on forced push
When pushing to overwrite a ref that points at a commit we do
not even have, the recent "terse push" patch tried to get a
unique abbreviation for the non-existent (from our point of
view) object, which resulted in strcpy(buf, NULL) and
segfaulted.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-08 01:43:34 -08:00
Jeff King b50fa2bd06 send-pack: require --verbose to show update of tracking refs
This is really an uninteresting detail, and it just takes
attention away from the actual push updates and posssible
errors.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-05 13:24:18 -08:00
Jeff King f76734902b 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>
2007-11-05 13:24:18 -08:00
Daniel Barkalow 96249c04c0 Build-in send-pack, with an API for other programs to call.
Also marks some more things as const, as needed.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-02 22:40:44 -07:00
Renamed from send-pack.c (Browse further)