]> Pileus Git - ~andy/git/commitdiff
Merge branch 'jc/upload-pack-send-symref'
authorJunio C Hamano <gitster@pobox.com>
Wed, 30 Oct 2013 19:10:00 +0000 (12:10 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 Oct 2013 19:10:06 +0000 (12:10 -0700)
One long-standing flaw in the pack transfer protocol used by "git
clone" was that there was no way to tell the other end which branch
"HEAD" points at, and the receiving end needed to guess.  A new
capability has been defined in the pack protocol to convey this
information so that cloning from a repository with more than one
branches pointing at the same commit where the HEAD is at now
reliably sets the initial branch in the resulting repository.

* jc/upload-pack-send-symref:
  t5570: Update for clone-progress-to-stderr branch
  t5570: Update for symref capability
  clone: test the new HEAD detection logic
  connect: annotate refs with their symref information in get_remote_head()
  connect.c: make parse_feature_value() static
  upload-pack: send non-HEAD symbolic refs
  upload-pack: send symbolic ref information as capability
  upload-pack.c: do not pass confusing cb_data to mark_our_ref()
  t5505: fix "set-head --auto with ambiguous HEAD" test

1  2 
connect.c
connect.h
t/t5601-clone.sh
upload-pack.c

diff --cc connect.c
index 40868610ab1c02d10cc7cdc927fdf97a5e010414,553a80c734dc2a4420ee8c0db4491edead53b947..06e88b0705f7fbd138e504920c20c70218121696
+++ b/connect.c
@@@ -5,10 -5,11 +5,12 @@@
  #include "refs.h"
  #include "run-command.h"
  #include "remote.h"
 +#include "connect.h"
  #include "url.h"
+ #include "string-list.h"
  
  static char *server_capabilities;
+ static const char *parse_feature_value(const char *, const char *, int *);
  
  static int check_ref(const char *name, int len, unsigned int flags)
  {
diff --cc connect.h
index 9dff25cad4de82e84343b50490b1b1601103ffac,0000000000000000000000000000000000000000..64fb7dbbee8714c034c5e018b3b1b4f8c29f0ea7
mode 100644,000000..100644
--- /dev/null
+++ b/connect.h
@@@ -1,13 -1,0 +1,12 @@@
- extern const char *parse_feature_value(const char *feature_list, const char *feature, int *len_ret);
 +#ifndef CONNECT_H
 +#define CONNECT_H
 +
 +#define CONNECT_VERBOSE       (1u << 0)
 +extern struct child_process *git_connect(int fd[2], const char *url, const char *prog, int flags);
 +extern int finish_connect(struct child_process *conn);
 +extern int git_connection_is_socket(struct child_process *conn);
 +extern int server_supports(const char *feature);
 +extern int parse_feature_request(const char *features, const char *feature);
 +extern const char *server_feature_value(const char *feature, int *len_ret);
 +
 +#endif
index 8f3cd44d514f3996b62da28f6f83be7b1d786f01,f8e5a9a4ae1051216e4ef55c8a46c99686e45b5c..1d1c8755ead4e432744a82f0d7b8ed7dfc8a6510
@@@ -280,53 -280,20 +280,64 @@@ test_expect_success 'clone checking ou
        test_cmp fetch.expected fetch.actual
  '
  
 +test_expect_success 'setup ssh wrapper' '
 +      write_script "$TRASH_DIRECTORY/ssh-wrapper" <<-\EOF &&
 +      echo >>"$TRASH_DIRECTORY/ssh-output" "ssh: $*" &&
 +      # throw away all but the last argument, which should be the
 +      # command
 +      while test $# -gt 1; do shift; done
 +      eval "$1"
 +      EOF
 +
 +      GIT_SSH="$TRASH_DIRECTORY/ssh-wrapper" &&
 +      export GIT_SSH &&
 +      export TRASH_DIRECTORY
 +'
 +
 +clear_ssh () {
 +      >"$TRASH_DIRECTORY/ssh-output"
 +}
 +
 +expect_ssh () {
 +      {
 +              case "$1" in
 +              none)
 +                      ;;
 +              *)
 +                      echo "ssh: $1 git-upload-pack '$2'"
 +              esac
 +      } >"$TRASH_DIRECTORY/ssh-expect" &&
 +      (cd "$TRASH_DIRECTORY" && test_cmp ssh-expect ssh-output)
 +}
 +
 +test_expect_success 'cloning myhost:src uses ssh' '
 +      clear_ssh &&
 +      git clone myhost:src ssh-clone &&
 +      expect_ssh myhost src
 +'
 +
  test_expect_success NOT_MINGW,NOT_CYGWIN 'clone local path foo:bar' '
 +      clear_ssh &&
        cp -R src "foo:bar" &&
 -      git clone "./foo:bar" foobar
 +      git clone "./foo:bar" foobar &&
 +      expect_ssh none
 +'
 +
 +test_expect_success 'bracketed hostnames are still ssh' '
 +      clear_ssh &&
 +      git clone "[myhost:123]:src" ssh-bracket-clone &&
 +      expect_ssh myhost:123 src
  '
  
+ test_expect_success 'clone from a repository with two identical branches' '
+       (
+               cd src &&
+               git checkout -b another master
+       ) &&
+       git clone src target-11 &&
+       test "z$( cd target-11 && git symbolic-ref HEAD )" = zrefs/heads/another
+ '
  test_done
diff --cc upload-pack.c
Simple merge