~ubuntu-branches/ubuntu/karmic/git-core/karmic

« back to all changes in this revision

Viewing changes to builtin-fetch.c

  • Committer: Package Import Robot
  • Author(s): Kees Cook
  • Date: 2008-11-13 15:11:17 UTC
  • mfrom: (1.1.30) (18.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20081113151117-1z51cdgqzhun6e6x
Tags: 1:1.6.0.4-1ubuntu1
* Merge from debian experimental, remaining changes:
  - debian/control:
    - Drop recently introduced cvsps build dependency; it's only necessary
      or some self tests, but is in universe (Ubuntu specific).
    - Added libauthen-sasl-perl on Recommends and libnet-smtp-ssl-perl on
      Depends for git-email (debian bug 505636).

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
#include "refs.h"
6
6
#include "commit.h"
7
7
#include "builtin.h"
8
 
#include "path-list.h"
 
8
#include "string-list.h"
9
9
#include "remote.h"
10
10
#include "transport.h"
11
11
#include "run-command.h"
12
12
#include "parse-options.h"
13
13
 
14
14
static const char * const builtin_fetch_usage[] = {
15
 
        "git-fetch [options] [<repository> <refspec>...]",
 
15
        "git fetch [options] [<repository> <refspec>...]",
16
16
        NULL
17
17
};
18
18
 
86
86
                /*
87
87
                 * Not fetched to a tracking branch?  We need to fetch
88
88
                 * it anyway to allow this branch's "branch.$name.merge"
89
 
                 * to be honored by git-pull, but we do not have to
 
89
                 * to be honored by 'git pull', but we do not have to
90
90
                 * fail if branch.$name.merge is misconfigured to point
91
91
                 * at a nonexisting branch.  If we were indeed called by
92
 
                 * git-pull, it will notice the misconfiguration because
 
92
                 * 'git pull', it will notice the misconfiguration because
93
93
                 * there is no entry in the resulting FETCH_HEAD marked
94
94
                 * for merging.
95
95
                 */
396
396
 * The refs we are going to fetch are in to_fetch (nr_heads in
397
397
 * total).  If running
398
398
 *
399
 
 *  $ git-rev-list --objects to_fetch[0] to_fetch[1] ... --not --all
 
399
 *  $ git rev-list --objects to_fetch[0] to_fetch[1] ... --not --all
400
400
 *
401
401
 * does not error out, that means everything reachable from the
402
402
 * refs we are going to fetch exists and is connected to some of
465
465
static int add_existing(const char *refname, const unsigned char *sha1,
466
466
                        int flag, void *cbdata)
467
467
{
468
 
        struct path_list *list = (struct path_list *)cbdata;
469
 
        path_list_insert(refname, list);
 
468
        struct string_list *list = (struct string_list *)cbdata;
 
469
        string_list_insert(refname, list);
470
470
        return 0;
471
471
}
472
472
 
485
485
                        struct ref **head,
486
486
                        struct ref ***tail)
487
487
{
488
 
        struct path_list existing_refs = { NULL, 0, 0, 0 };
489
 
        struct path_list new_refs = { NULL, 0, 0, 1 };
 
488
        struct string_list existing_refs = { NULL, 0, 0, 0 };
 
489
        struct string_list new_refs = { NULL, 0, 0, 1 };
490
490
        char *ref_name;
491
491
        int ref_name_len;
492
492
        const unsigned char *ref_sha1;
515
515
                        }
516
516
                }
517
517
 
518
 
                if (!path_list_has_path(&existing_refs, ref_name) &&
519
 
                    !path_list_has_path(&new_refs, ref_name) &&
 
518
                if (!string_list_has_string(&existing_refs, ref_name) &&
 
519
                    !string_list_has_string(&new_refs, ref_name) &&
520
520
                    (has_sha1_file(ref->old_sha1) ||
521
521
                     will_fetch(head, ref->old_sha1))) {
522
 
                        path_list_insert(ref_name, &new_refs);
 
522
                        string_list_insert(ref_name, &new_refs);
523
523
 
524
524
                        rm = alloc_ref_from_str(ref_name);
525
525
                        rm->peer_ref = alloc_ref_from_str(ref_name);
530
530
                }
531
531
                free(ref_name);
532
532
        }
533
 
        path_list_clear(&existing_refs, 0);
534
 
        path_list_clear(&new_refs, 0);
 
533
        string_list_clear(&existing_refs, 0);
 
534
        string_list_clear(&new_refs, 0);
 
535
}
 
536
 
 
537
static void check_not_current_branch(struct ref *ref_map)
 
538
{
 
539
        struct branch *current_branch = branch_get(NULL);
 
540
 
 
541
        if (is_bare_repository() || !current_branch)
 
542
                return;
 
543
 
 
544
        for (; ref_map; ref_map = ref_map->next)
 
545
                if (ref_map->peer_ref && !strcmp(current_branch->refname,
 
546
                                        ref_map->peer_ref->name))
 
547
                        die("Refusing to fetch into current branch");
535
548
}
536
549
 
537
550
static int do_fetch(struct transport *transport,
558
571
        }
559
572
 
560
573
        ref_map = get_ref_map(transport, refs, ref_count, tags, &autotags);
 
574
        if (!update_head_ok)
 
575
                check_not_current_branch(ref_map);
561
576
 
562
577
        for (rm = ref_map; rm; rm = rm->next) {
563
578
                if (rm->peer_ref)