~ubuntu-branches/debian/sid/git/sid

« back to all changes in this revision

Viewing changes to transport-helper.c

  • Committer: Package Import Robot
  • Author(s): Jonathan Nieder
  • Date: 2013-07-30 19:11:14 UTC
  • mfrom: (1.2.21)
  • Revision ID: package-import@ubuntu.com-20130730191114-f07bzymte4v26irn
Tags: 1:1.8.4~rc0-1
* new upstream release candidate.
* use /var/lib/git instead of /var/cache/git as default git
  project root to comply with the Filesystem Hierarchy Standard
  (thx Julian Gilbey; closes: #483788):
  * git-daemon.default, git-daemon.in, git-daemon/run: use
    base path of /var/lib and projectroot of /var/lib/git.
  * gitweb.conf: $projectroot = "/var/lib/git".
  * rules: package git: install empty /var/lib/git directory
    instead of /var/cache/git.
  * git.README.Debian, git-daemon-run.README.Debian,
    git-daemon-sysvinit.README.Debian, gitweb.README.Debian:
    update for the new project root.
  * git.preinst: install symlinks /var/lib/git/* ->
    ../../cache/git/*.
  * git.NEWS.Debian: advertise the change and explain how to
    adapt to it.
* update debian/copyright.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
#include "thread-utils.h"
12
12
#include "sigchain.h"
13
13
#include "argv-array.h"
 
14
#include "refs.h"
14
15
 
15
16
static int debug;
16
17
 
47
48
                die_errno("Full write to remote helper failed");
48
49
}
49
50
 
50
 
static int recvline_fh(FILE *helper, struct strbuf *buffer)
 
51
static int recvline_fh(FILE *helper, struct strbuf *buffer, const char *name)
51
52
{
52
53
        strbuf_reset(buffer);
53
54
        if (debug)
65
66
 
66
67
static int recvline(struct helper_data *helper, struct strbuf *buffer)
67
68
{
68
 
        return recvline_fh(helper->out, buffer);
 
69
        return recvline_fh(helper->out, buffer, helper->name);
69
70
}
70
71
 
71
72
static void xchgline(struct helper_data *helper, struct strbuf *buffer)
217
218
                for (i = 0; i < refspec_nr; i++)
218
219
                        free((char *)refspecs[i]);
219
220
                free(refspecs);
 
221
        } else if (data->import || data->bidi_import || data->export) {
 
222
                warning("This remote helper should implement refspec capability.");
220
223
        }
221
224
        strbuf_release(&buf);
222
225
        if (debug)
473
476
         * were fetching.
474
477
         *
475
478
         * (If no "refspec" capability was specified, for historical
476
 
         * reasons we default to *:*.)
 
479
         * reasons we default to the equivalent of *:*.)
477
480
         *
478
481
         * Store the result in to_fetch[i].old_sha1.  Callers such
479
482
         * as "git fetch" can use the value to write feedback to the
540
543
                goto exit;
541
544
 
542
545
        sendline(data, &cmdbuf);
543
 
        recvline_fh(input, &cmdbuf);
 
546
        recvline_fh(input, &cmdbuf, name);
544
547
        if (!strcmp(cmdbuf.buf, "")) {
545
548
                data->no_disconnect_req = 1;
546
549
                if (debug)
622
625
        return -1;
623
626
}
624
627
 
625
 
static void push_update_ref_status(struct strbuf *buf,
 
628
static int push_update_ref_status(struct strbuf *buf,
626
629
                                   struct ref **ref,
627
630
                                   struct ref *remote_refs)
628
631
{
688
691
                *ref = find_ref_by_name(remote_refs, refname);
689
692
        if (!*ref) {
690
693
                warning("helper reported unexpected status of %s", refname);
691
 
                return;
 
694
                return 1;
692
695
        }
693
696
 
694
697
        if ((*ref)->status != REF_STATUS_NONE) {
697
700
                 * status reported by the remote helper if the latter is 'no match'.
698
701
                 */
699
702
                if (status == REF_STATUS_NONE)
700
 
                        return;
 
703
                        return 1;
701
704
        }
702
705
 
703
706
        (*ref)->status = status;
704
707
        (*ref)->remote_status = msg;
 
708
        return !(status == REF_STATUS_OK);
705
709
}
706
710
 
707
711
static void push_update_refs_status(struct helper_data *data,
710
714
        struct strbuf buf = STRBUF_INIT;
711
715
        struct ref *ref = remote_refs;
712
716
        for (;;) {
 
717
                char *private;
 
718
 
713
719
                recvline(data, &buf);
714
720
                if (!buf.len)
715
721
                        break;
716
722
 
717
 
                push_update_ref_status(&buf, &ref, remote_refs);
 
723
                if (push_update_ref_status(&buf, &ref, remote_refs))
 
724
                        continue;
 
725
 
 
726
                if (!data->refspecs)
 
727
                        continue;
 
728
 
 
729
                /* propagate back the update to the remote namespace */
 
730
                private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);
 
731
                if (!private)
 
732
                        continue;
 
733
                update_ref("update by helper", private, ref->new_sha1, NULL, 0, 0);
 
734
                free(private);
718
735
        }
719
736
        strbuf_release(&buf);
720
737
}
789
806
        struct string_list revlist_args = STRING_LIST_INIT_NODUP;
790
807
        struct strbuf buf = STRBUF_INIT;
791
808
 
 
809
        if (!data->refspecs)
 
810
                die("remote-helper doesn't support push; refspec needed");
 
811
 
 
812
        if (flags & TRANSPORT_PUSH_DRY_RUN) {
 
813
                if (set_helper_option(transport, "dry-run", "true") != 0)
 
814
                        die("helper %s does not support dry-run", data->name);
 
815
        }
 
816
 
792
817
        helper = get_helper(transport);
793
818
 
794
819
        write_constant(helper->in, "export\n");
799
824
                char *private;
800
825
                unsigned char sha1[20];
801
826
 
802
 
                if (!data->refspecs)
803
 
                        continue;
 
827
                if (ref->deletion)
 
828
                        die("remote-helpers do not support ref deletion");
 
829
 
804
830
                private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);
805
831
                if (private && !get_sha1(private, sha1)) {
806
832
                        strbuf_addf(&buf, "^%s", private);
809
835
                }
810
836
                free(private);
811
837
 
812
 
                if (ref->deletion) {
 
838
                if (ref->deletion)
813
839
                        die("remote-helpers do not support ref deletion");
814
 
                }
815
840
 
816
 
                if (ref->peer_ref)
 
841
                if (ref->peer_ref) {
 
842
                        if (strcmp(ref->peer_ref->name, ref->name))
 
843
                                die("remote-helpers do not support old:new syntax");
817
844
                        string_list_append(&revlist_args, ref->peer_ref->name);
818
 
 
 
845
                }
819
846
        }
820
847
 
821
848
        if (get_exporter(transport, &exporter, &revlist_args))
955
982
#define PBUFFERSIZE 8192
956
983
 
957
984
/* Print bidirectional transfer loop debug message. */
 
985
__attribute__((format (printf, 1, 2)))
958
986
static void transfer_debug(const char *fmt, ...)
959
987
{
960
988
        va_list args;
1040
1068
                return -1;
1041
1069
        } else if (bytes == 0) {
1042
1070
                transfer_debug("%s EOF (with %i bytes in buffer)",
1043
 
                        t->src_name, t->bufuse);
 
1071
                        t->src_name, (int)t->bufuse);
1044
1072
                t->state = SSTATE_FLUSHING;
1045
1073
        } else if (bytes > 0) {
1046
1074
                t->bufuse += bytes;